From 665cc27e6b9334ec5bb8d031ca0c83684af857f5 Mon Sep 17 00:00:00 2001 From: Jordan Baird Date: Fri, 29 Dec 2023 07:20:24 -0700 Subject: [PATCH] Update documentation --- .../ColorWellKit/Documentation.docc/ColorWellKit.md | 10 ++++++++++ .../Documentation.docc/SwiftUI/ColorWell.md | 10 ++++++++-- Sources/ColorWellKit/Views/Cocoa/CWColorWell.swift | 2 +- Sources/ColorWellKit/Views/SwiftUI/ColorWell.swift | 2 +- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Sources/ColorWellKit/Documentation.docc/ColorWellKit.md b/Sources/ColorWellKit/Documentation.docc/ColorWellKit.md index bc4e2bc..8a14e5d 100644 --- a/Sources/ColorWellKit/Documentation.docc/ColorWellKit.md +++ b/Sources/ColorWellKit/Documentation.docc/ColorWellKit.md @@ -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 diff --git a/Sources/ColorWellKit/Documentation.docc/SwiftUI/ColorWell.md b/Sources/ColorWellKit/Documentation.docc/SwiftUI/ColorWell.md index bade57c..7862677 100644 --- a/Sources/ColorWellKit/Documentation.docc/SwiftUI/ColorWell.md +++ b/Sources/ColorWellKit/Documentation.docc/SwiftUI/ColorWell.md @@ -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 @@ -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: diff --git a/Sources/ColorWellKit/Views/Cocoa/CWColorWell.swift b/Sources/ColorWellKit/Views/Cocoa/CWColorWell.swift index 2d804cc..d2dee00 100644 --- a/Sources/ColorWellKit/Views/Cocoa/CWColorWell.swift +++ b/Sources/ColorWellKit/Views/Cocoa/CWColorWell.swift @@ -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 diff --git a/Sources/ColorWellKit/Views/SwiftUI/ColorWell.swift b/Sources/ColorWellKit/Views/SwiftUI/ColorWell.swift index 1c175fa..883fcc4 100644 --- a/Sources/ColorWellKit/Views/SwiftUI/ColorWell.swift +++ b/Sources/ColorWellKit/Views/SwiftUI/ColorWell.swift @@ -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: View { @Binding private var selection: NSColor