Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanbaird committed Dec 29, 2023
1 parent c5baa5c commit 665cc27
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
10 changes: 10 additions & 0 deletions Sources/ColorWellKit/Documentation.docc/ColorWellKit.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,15 @@ class ContentViewController: NSViewController {
}
```

## Topics

### Color Wells in SwiftUI

- ``ColorWell``

### Color Wells in Cocoa

- ``CWColorWell``

[light-mode]: color-well-with-popover-light.png
[dark-mode]: color-well-with-popover-dark.png
10 changes: 8 additions & 2 deletions Sources/ColorWellKit/Documentation.docc/SwiftUI/ColorWell.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

Color wells provide an interface in your app for users to select custom colors. A color well displays the currently selected color, and provides options for selecting new colors. There are a number of styles to choose from, letting you customize the color well's appearance and behavior.

By default, color wells support colors with opacity. To disable opacity support, set the `supportsOpacity` parameter to `false`. In this mode, the color well won't show controls for adjusting the opacity of the selected color, and removes opacity from colors set programmatically or selected using another method, like drag-and-drop.

You create a color well by providing a title string and a `Binding` to a `Color`:

```swift
Expand All @@ -22,6 +20,14 @@ struct TextFormatter: View {

![Two color wells, both displayed in the default style](default-style)

By default, color wells support colors with opacity. To disable opacity support, set the `supportsOpacity` parameter to `false`.

```swift
ColorWell("Foreground", selection: $fgColor, supportsOpacity: false)
```

In this mode, the color well does not show controls for adjusting the opacity of the selected color, and removes opacity from colors set programmatically or selected using another method, like drag-and-drop.

### Styling color wells

You can customize a color well's appearance using one of the available color well styles, like ``ColorWellStyle/expanded``, and apply the style with the ``colorWellStyle(_:)`` modifier:
Expand Down
2 changes: 1 addition & 1 deletion Sources/ColorWellKit/Views/Cocoa/CWColorWell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import AppKit

/// A control that displays a user-selectable color value.
/// A Cocoa control that displays a user-selectable color value.
public class CWColorWell: _CWColorWellBaseControl {

// MARK: Static Properties
Expand Down
2 changes: 1 addition & 1 deletion Sources/ColorWellKit/Views/SwiftUI/ColorWell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#if canImport(SwiftUI)
import SwiftUI

/// A view that displays a user-selectable color value.
/// A SwiftUI view that displays a user-selectable color value.
@available(macOS 10.15, *)
public struct ColorWell<Label: View>: View {
@Binding private var selection: NSColor
Expand Down

0 comments on commit 665cc27

Please sign in to comment.