Skip to content

Commit 3e732f7

Browse files
committed
Simplify examples in README
1 parent ad7eaa5 commit 3e732f7

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

README.md

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ A versatile alternative to `NSColorWell` for Cocoa and `ColorPicker` for SwiftUI
1313
<img src="Sources/ColorWellKit/Documentation.docc/Resources/color-well-with-popover-light.png" style="width:37%">
1414
</div>
1515

16-
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. However, in practice, there are very few notable differences:
16+
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:
1717

1818
<div align="center">
1919
<img src="Sources/ColorWellKit/Documentation.docc/Resources/design-comparison-dark.png" style="width:49%">
@@ -41,42 +41,40 @@ import SwiftUI
4141
import ColorWellKit
4242

4343
struct ContentView: View {
44-
@Binding var fontColor: Color
44+
@Binding var textColor: Color
4545

4646
var body: some View {
4747
VStack {
48-
ColorWellView("Font Color", selection: $fontColor)
48+
ColorWellView("Text Color", selection: $textColor)
4949
.colorWellStyle(.expanded)
5050

51-
MyCustomTextEditor(fontColor: fontColor)
51+
MyCustomTextEditor(textColor: $textColor)
5252
}
5353
}
5454
}
5555
```
5656

5757
### Cocoa
5858

59-
Create a `ColorWell` using one of the available initializers. Respond to color changes using your preferred design pattern.
59+
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.
6060

6161
```swift
6262
import Cocoa
6363
import ColorWellKit
6464

65-
class ContentViewController: NSViewController {
66-
@IBOutlet var textControls: NSStackView!
67-
@IBOutlet var textEditor: MyCustomNSTextEditor!
68-
69-
private var colorObservation: NSKeyValueObservation?
65+
class ViewController: NSViewController {
66+
@IBOutlet var colorWell: ColorWell!
67+
@IBOutlet var textEditor: NSTextView!
7068

7169
override func viewDidLoad() {
72-
let colorWell = ColorWell(style: .expanded)
73-
colorWell.color = textEditor.fontColor
74-
75-
colorObservation = colorWell.observe(\.color) { colorWell, _ in
76-
textEditor.fontColor = colorWell.color
70+
colorWell.style = .expanded
71+
if let textColor = textEditor.textColor {
72+
colorWell.color = textColor
7773
}
74+
}
7875

79-
textControls.addArrangedSubview(colorWell)
76+
@IBAction func updateTextColor(sender: ColorWell) {
77+
textEditor.textColor = sender.color
8078
}
8179
}
8280
```

0 commit comments

Comments
 (0)