// GENERATED by `cotton-gen` from `cotton-core — design/palette.rs` — do not edit by hand. // Run `pnpm gen:design`; `gen:design:check` guards drift in CI. // // THE ONE PLACE A COLOUR MAY BE WRITTEN. Every other Swift source reads a role // off `CottonColors` (or off a `CottonPalette` handed to it); `PaletteGuardTests` // reads the sources and fails on a hex, a `Color(red:`, or a bare asset name // spelled anywhere else. // // ONE palette — `paper` — plus the status colours and the Mac sidebar's. **The app is light-only**: // there is no theme choice, no dark mode and no system-appearance switch, so a // colorset carries one colour and nothing the operating system decides can // repaint a screen. // // `graphite` is the BRAND's fixed charcoal and is not an appearance: it is read // as authored VALUES by the surfaces that are charcoal whatever the app is // doing — the app-icon tile and the ground the logo is set on. Nothing // resolves to it. // // `sidebar` is the Mac window's charcoal column — five opaque values read by // `Boot/HomeSidebar.swift` alone. Chrome, not an appearance: the content beside // it is still paper. // // The COLOUR RULE the app is bound by lives above this file and cannot be // expressed in it: monochrome plus ONE accent, colour never names a kind, and // no user-chosen colour renders anywhere. Twenty-four roles is the whole surface; // there is no twenty-fifth and no per-record tint. import SwiftUI #if canImport(UIKit) import UIKit #elseif canImport(AppKit) import AppKit #endif /// One colour, as the record wrote it: `#RRGGBB` or `#RRGGBBAA`. /// /// The value type exists beside the asset catalogue so a test can assert the /// NUMBERS without loading a bundle, and so a caller that needs a colour where /// no trait collection is resolvable (a snapshot, a computed blend) has one. public struct CottonColor: Equatable, Sendable { public let hex: String public init(_ hex: String) { self.hex = hex } /// The four channels, 0…1. public var components: (red: Double, green: Double, blue: Double, alpha: Double) { let digits = Array(hex.dropFirst()) func channel(_ at: Int) -> Double { guard digits.count >= (at + 1) * 2 else { return 1 } let pair = String(digits[at * 2 ... at * 2 + 1]) return Double(UInt8(pair, radix: 16) ?? 0) / 255 } return (channel(0), channel(1), channel(2), digits.count >= 8 ? channel(3) : 1) } public var color: Color { let parts = components return Color( .sRGB, red: parts.red, green: parts.green, blue: parts.blue, opacity: parts.alpha ) } #if canImport(UIKit) public var uiColor: UIColor { let parts = components return UIColor( red: parts.red, green: parts.green, blue: parts.blue, alpha: parts.alpha ) } #elseif canImport(AppKit) public var nsColor: NSColor { let parts = components return NSColor( srgbRed: parts.red, green: parts.green, blue: parts.blue, alpha: parts.alpha ) } #endif } /// The status colours. public struct CottonStatus: Equatable, Sendable { public let success: CottonColor public let successLight: CottonColor public let error: CottonColor public let errorLight: CottonColor public let warning: CottonColor public let warningLight: CottonColor } /// The Mac sidebar's charcoal, opaque. public struct CottonSidebar: Equatable, Sendable { public let ground: CottonColor public let ink: CottonColor public let inkMuted: CottonColor public let selection: CottonColor public let hairline: CottonColor } /// One palette: every role a surface can paint with. public struct CottonPalette: Equatable, Sendable { /// The stable registry id. public let name: String public let ground: CottonColor public let groundMuted: CottonColor public let groundElevated: CottonColor public let ink: CottonColor public let inkBody: CottonColor public let inkSecondary: CottonColor public let inkTertiary: CottonColor public let hairline: CottonColor public let accent: CottonColor public let accentContrast: CottonColor public let chipGround: CottonColor public let highlight: CottonColor public let selection: CottonColor public let status: CottonStatus } /// Every colorset in `Palette.xcassets`, by name — so no call site spells one. public enum ColorSlot: String, CaseIterable, Sendable { case ground case groundMuted case groundElevated case ink case inkBody case inkSecondary case inkTertiary case hairline case accent case accentContrast case chipGround case highlight case selection case statusSuccess case statusSuccessLight case statusError case statusErrorLight case statusWarning case statusWarningLight case sidebarGround case sidebarInk case sidebarInkMuted case sidebarSelection case sidebarHairline /// The asset name, which IS the case name. Total by construction. public var assetName: String { rawValue } #if canImport(UIKit) /// The colorset's colour. One value per colorset — the trait collection /// has nothing to choose between, which is what light-only means. public var color: Color { Color(assetName, bundle: .module) } public var uiColor: UIColor { // A missing colorset is a build that shipped without its resources — // louder here than a silently black screen. guard let found = UIColor(named: assetName, in: .module, compatibleWith: nil) else { preconditionFailure("Palette.xcassets has no colorset named \(assetName)") } return found } #elseif canImport(AppKit) /// The Mac's, from the authored hex — NEVER the colorset. `Bundle.module` /// on an INSTALLED copy is a `fatalError`: the accessor looks beside the /// executable and in the build directory, and a packaged app has neither. /// And whether the catalogue is even compiled is the toolchain's choice — /// SwiftPM's Swift Build system runs actool and writes an `Assets.car`, /// the older native build system copies `Palette.xcassets` RAW, and under /// that one a colour reached by name had nothing to resolve against and /// drew as nothing (measured 2026-09-12, the phone's screens white with /// invisible ink in the Mac's window). Pictures are read through whichever /// layout the build wrote (`CottonPaper/Resources.swift`); a COLOUR needs no /// bundle at all, so the Mac reads the hex this file already carries — /// one declaration, two renderers. It is a STATIC colour: the Mac app /// pins `NSAppearance(named: .aqua)` at boot, so there is no appearance /// for a dynamic provider to answer. public var color: Color { Color(nsColor: nsColor) } public var nsColor: NSColor { authored.nsColor } #endif /// The authored hex for this role. public var authored: CottonColor { Palettes.authored(self) } } /// The typed accessors — `CottonColors.accent`, never `Color("accent")`. public enum CottonColors { /// The `ground` colorset — one colour, because the app is light-only. public static var ground: Color { ColorSlot.ground.color } /// The `groundMuted` colorset — one colour, because the app is light-only. public static var groundMuted: Color { ColorSlot.groundMuted.color } /// The `groundElevated` colorset — one colour, because the app is light-only. public static var groundElevated: Color { ColorSlot.groundElevated.color } /// The `ink` colorset — one colour, because the app is light-only. public static var ink: Color { ColorSlot.ink.color } /// The `inkBody` colorset — one colour, because the app is light-only. public static var inkBody: Color { ColorSlot.inkBody.color } /// The `inkSecondary` colorset — one colour, because the app is light-only. public static var inkSecondary: Color { ColorSlot.inkSecondary.color } /// The `inkTertiary` colorset — one colour, because the app is light-only. public static var inkTertiary: Color { ColorSlot.inkTertiary.color } /// The `hairline` colorset — one colour, because the app is light-only. public static var hairline: Color { ColorSlot.hairline.color } /// The `accent` colorset — one colour, because the app is light-only. public static var accent: Color { ColorSlot.accent.color } /// The `accentContrast` colorset — one colour, because the app is light-only. public static var accentContrast: Color { ColorSlot.accentContrast.color } /// The `chipGround` colorset — one colour, because the app is light-only. public static var chipGround: Color { ColorSlot.chipGround.color } /// The `highlight` colorset — one colour, because the app is light-only. public static var highlight: Color { ColorSlot.highlight.color } /// The `selection` colorset — one colour, because the app is light-only. public static var selection: Color { ColorSlot.selection.color } /// The `statusSuccess` colorset — one colour, because the app is light-only. public static var statusSuccess: Color { ColorSlot.statusSuccess.color } /// The `statusSuccessLight` colorset — one colour, because the app is light-only. public static var statusSuccessLight: Color { ColorSlot.statusSuccessLight.color } /// The `statusError` colorset — one colour, because the app is light-only. public static var statusError: Color { ColorSlot.statusError.color } /// The `statusErrorLight` colorset — one colour, because the app is light-only. public static var statusErrorLight: Color { ColorSlot.statusErrorLight.color } /// The `statusWarning` colorset — one colour, because the app is light-only. public static var statusWarning: Color { ColorSlot.statusWarning.color } /// The `statusWarningLight` colorset — one colour, because the app is light-only. public static var statusWarningLight: Color { ColorSlot.statusWarningLight.color } /// The `sidebarGround` colorset — one colour, because the app is light-only. public static var sidebarGround: Color { ColorSlot.sidebarGround.color } /// The `sidebarInk` colorset — one colour, because the app is light-only. public static var sidebarInk: Color { ColorSlot.sidebarInk.color } /// The `sidebarInkMuted` colorset — one colour, because the app is light-only. public static var sidebarInkMuted: Color { ColorSlot.sidebarInkMuted.color } /// The `sidebarSelection` colorset — one colour, because the app is light-only. public static var sidebarSelection: Color { ColorSlot.sidebarSelection.color } /// The `sidebarHairline` colorset — one colour, because the app is light-only. public static var sidebarHairline: Color { ColorSlot.sidebarHairline.color } } /// The same twenty-four as `UIColor`, for the UIKit seams (a text view's tint) /// that cannot take a SwiftUI `Color`. UIKit's only: /// since H2 this file compiles for macOS too, where the palette is `Color`. #if canImport(UIKit) public enum CottonUIColors { public static var ground: UIColor { ColorSlot.ground.uiColor } public static var groundMuted: UIColor { ColorSlot.groundMuted.uiColor } public static var groundElevated: UIColor { ColorSlot.groundElevated.uiColor } public static var ink: UIColor { ColorSlot.ink.uiColor } public static var inkBody: UIColor { ColorSlot.inkBody.uiColor } public static var inkSecondary: UIColor { ColorSlot.inkSecondary.uiColor } public static var inkTertiary: UIColor { ColorSlot.inkTertiary.uiColor } public static var hairline: UIColor { ColorSlot.hairline.uiColor } public static var accent: UIColor { ColorSlot.accent.uiColor } public static var accentContrast: UIColor { ColorSlot.accentContrast.uiColor } public static var chipGround: UIColor { ColorSlot.chipGround.uiColor } public static var highlight: UIColor { ColorSlot.highlight.uiColor } public static var selection: UIColor { ColorSlot.selection.uiColor } public static var statusSuccess: UIColor { ColorSlot.statusSuccess.uiColor } public static var statusSuccessLight: UIColor { ColorSlot.statusSuccessLight.uiColor } public static var statusError: UIColor { ColorSlot.statusError.uiColor } public static var statusErrorLight: UIColor { ColorSlot.statusErrorLight.uiColor } public static var statusWarning: UIColor { ColorSlot.statusWarning.uiColor } public static var statusWarningLight: UIColor { ColorSlot.statusWarningLight.uiColor } public static var sidebarGround: UIColor { ColorSlot.sidebarGround.uiColor } public static var sidebarInk: UIColor { ColorSlot.sidebarInk.uiColor } public static var sidebarInkMuted: UIColor { ColorSlot.sidebarInkMuted.uiColor } public static var sidebarSelection: UIColor { ColorSlot.sidebarSelection.uiColor } public static var sidebarHairline: UIColor { ColorSlot.sidebarHairline.uiColor } } #endif public enum Palettes { /// **The app's palette, and the only one it wears.** Every colorset is /// this palette's value. public static let paper = CottonPalette( name: "cotton", ground: CottonColor("#FFFFFF"), groundMuted: CottonColor("#EEE3D6"), groundElevated: CottonColor("#FFFFFF"), ink: CottonColor("#444444"), inkBody: CottonColor("#444444"), inkSecondary: CottonColor("#888888"), inkTertiary: CottonColor("#ABABAB"), hairline: CottonColor("#E2E2E2"), accent: CottonColor("#C6534B"), accentContrast: CottonColor("#FFFFFF"), chipGround: CottonColor("#F2F2F2"), highlight: CottonColor("#D9F7A6"), selection: CottonColor("#C6534B2E"), status: status ) /// **The brand's fixed charcoal — not an appearance and not a choice.** /// /// Nothing resolves to this. It is read as VALUES by the surfaces that are /// charcoal whatever the app is doing: the app-icon tile and the ground /// the logo is set on. public static let graphite = CottonPalette( name: "cotton-graphite", ground: CottonColor("#1D1E1E"), groundMuted: CottonColor("#232425"), groundElevated: CottonColor("#2E2F30"), ink: CottonColor("#CFDAE4"), inkBody: CottonColor("#DFE0E0"), inkSecondary: CottonColor("#A2A3A4"), inkTertiary: CottonColor("#7A7B7C"), hairline: CottonColor("#3E3F40"), accent: CottonColor("#5FA1DF"), accentContrast: CottonColor("#FFFFFF"), chipGround: CottonColor("#2A2B2C"), highlight: CottonColor("#2E4053"), selection: CottonColor("#5FA1DF2E"), status: status ) public static let status = CottonStatus( success: CottonColor("#4F7D5C"), successLight: CottonColor("#E8F1EB"), error: CottonColor("#B0453D"), errorLight: CottonColor("#F8EAE8"), warning: CottonColor("#A06C1C"), warningLight: CottonColor("#F7EFDC") ) /// The Mac window's sidebar: charcoal chrome beside the paper. public static let sidebar = CottonSidebar( ground: CottonColor("#1D1E1E"), ink: CottonColor("#D7CDC2"), inkMuted: CottonColor("#918B84"), selection: CottonColor("#363634"), hairline: CottonColor("#111212") ) /// The authored hex behind a colorset. Total over `ColorSlot`, which is /// what makes the catalogue and the value type unable to drift: both are /// generated from the same record, and this switch names every case. public static func authored(_ slot: ColorSlot) -> CottonColor { switch slot { case .ground: return paper.ground case .groundMuted: return paper.groundMuted case .groundElevated: return paper.groundElevated case .ink: return paper.ink case .inkBody: return paper.inkBody case .inkSecondary: return paper.inkSecondary case .inkTertiary: return paper.inkTertiary case .hairline: return paper.hairline case .accent: return paper.accent case .accentContrast: return paper.accentContrast case .chipGround: return paper.chipGround case .highlight: return paper.highlight case .selection: return paper.selection case .statusSuccess: return status.success case .statusSuccessLight: return status.successLight case .statusError: return status.error case .statusErrorLight: return status.errorLight case .statusWarning: return status.warning case .statusWarningLight: return status.warningLight case .sidebarGround: return sidebar.ground case .sidebarInk: return sidebar.ink case .sidebarInkMuted: return sidebar.inkMuted case .sidebarSelection: return sidebar.selection case .sidebarHairline: return sidebar.hairline } } }