GithubHelp home page GithubHelp logo

ynie / colorwellkit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jordanbaird/colorwellkit

0.0 0.0 0.0 1.38 MB

A versatile alternative to NSColorWell for Cocoa and ColorPicker for SwiftUI

License: MIT License

Swift 100.00%

colorwellkit's Introduction

ColorWellKit

Continuous Integration Release Swift Versions Docs License

A versatile alternative to NSColorWell for Cocoa and ColorPicker for SwiftUI.

ColorWellKit is designed to mimic the appearance and behavior of the color well designs introduced in macOS 13 Ventura, ideal for use in apps that are unable to target the latest SDK. While a central goal of ColorWellKit is to maintain a similar look and behave in a similar way to Apple's design, it is not intended to be an exact clone. There are a number of subtle design differences ranging from the way system colors are handled to the size of the drop shadow. In practice, there are very few notable differences:

Install

Add the following dependency to your Package.swift file:

.package(url: "https://github.com/jordanbaird/ColorWellKit", from: "0.2.0")

Usage

Read the full documentation here

SwiftUI

Create a ColorWellView and add it to your view hierarchy. There are a wide range of initializers and modifiers to choose from, allowing you to set the color well's color, label, and style.

import SwiftUI
import ColorWellKit

struct ContentView: View {
    @Binding var textColor: Color

    var body: some View {
        VStack {
            ColorWellView("Text Color", selection: $textColor)
                .colorWellStyle(.expanded)

            MyCustomTextEditor(textColor: $textColor)
        }
    }
}

Cocoa

Create a ColorWell using one of the available initializers, or use an IBOutlet to create a connection to a Storyboard or NIB file. Respond to color changes using your preferred design pattern.

import Cocoa
import ColorWellKit

class ViewController: NSViewController {
    @IBOutlet var colorWell: ColorWell!
    @IBOutlet var textEditor: NSTextView!

    override func viewDidLoad() {
        colorWell.style = .expanded
        if let textColor = textEditor.textColor {
            colorWell.color = textColor
        }
    }

    @IBAction func updateTextColor(sender: ColorWell) {
        textEditor.textColor = sender.color
    }
}

License

ColorWellKit is available under the MIT license.

colorwellkit's People

Contributors

jordanbaird avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.