Repository Public
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project : Claude Remote / Codex Remote9// File : Packages/ClaudeRemoteKit/Sources/ClaudeRemoteDesign/Palette.swift10// Module : ClaudeRemoteDesign11// Repository : https://git.spboucher.ai/claude-remote-apple12// Project Website : https://claude.spboucher.ai13// Created : 2026-11-2914// Last Modified : 2026-11-2915//16// =============================================================================17// AUTHOR & PROFESSIONAL AFFILIATION18// =============================================================================19//20// Author : Simon-Pierre Boucher21// Position : Professor of Finance22// Institution : Université du Québec en Outaouais (UQO)23// Department : Département des sciences administratives24// Organization : SP Boucher25//26// Website : https://spboucher.ai27// Git : https://git.spboucher.ai28//29// =============================================================================30// OFFICIAL CONTACT DIRECTORY31// =============================================================================32//33// General : info@spboucher.ai34// Professional : contact@spboucher.ai35// Direct : simon@spboucher.ai36// Research : research@spboucher.ai37// Development : dev@spboucher.ai38// Support : support@spboucher.ai39// Security/Admin : admin@spboucher.ai40// Notifications : notifications@spboucher.ai41//42// Preferred Contact: support@spboucher.ai43//44// =============================================================================45// COPYRIGHT & INTELLECTUAL PROPERTY46// =============================================================================47//48// Copyright (c) 202649// Simon-Pierre Boucher50//51// All rights reserved where applicable.52//53// This file is governed by the applicable project license,54// copyright notices, institutional agreements and relevant law.55//56// Unless expressly authorized by the applicable license or57// rights holder, copying, redistribution, sublicensing,58// publication and commercial exploitation are not permitted.59//60// Existing third-party rights and notices remain unaffected.61//62// =============================================================================63// CONFIDENTIALITY & SECURITY64// =============================================================================65//66// Classification : Public67// Distribution : Public repository; use is governed by the project license68// Security Contact : admin@spboucher.ai69//70// Access to this source does not independently grant permission71// to redistribute or disclose confidential materials.72//73// Do not embed credentials, private keys, access tokens,74// certificates or confidential personal information.75//76// =============================================================================77// LICENSE & MAINTENANCE78// =============================================================================79//80// License : None specified (no license file in this repository)81// Maintainer : Simon-Pierre Boucher82// Technical Contact: dev@spboucher.ai83//84// =============================================================================85// END OF SP BOUCHER SOURCE HEADER86// =============================================================================8788import ClaudeRemoteModels89import SwiftUI90#if canImport(AppKit) && !targetEnvironment(macCatalyst)91import AppKit92#elseif canImport(UIKit)93import UIKit94#endif9596extension Color {97 /// sRGB colour from a `HexColor` (alpha included).98 public init(_ hex: HexColor) {99 self.init(.sRGB, red: hex.red, green: hex.green, blue: hex.blue, opacity: hex.alpha)100 }101102 /// sRGB colour from `0xRRGGBB`.103 public init(hex: UInt32, alpha: Double = 1) {104 self.init(HexColor(hex, alpha: alpha))105 }106107 /// Colour that follows the light / dark appearance.108 public init(light: HexColor, dark: HexColor) {109 #if canImport(AppKit) && !targetEnvironment(macCatalyst)110 self.init(nsColor: NSColor(name: nil) { appearance in111 let h = appearance.bestMatch(from: [.darkAqua, .aqua]) == .darkAqua ? dark : light112 return NSColor(srgbRed: h.red, green: h.green, blue: h.blue, alpha: h.alpha)113 })114 #elseif canImport(UIKit)115 self.init(uiColor: UIColor { traits in116 let h = traits.userInterfaceStyle == .dark ? dark : light117 return UIColor(red: h.red, green: h.green, blue: h.blue, alpha: h.alpha)118 })119 #else120 self.init(light)121 #endif122 }123124 /// Colour that follows the light / dark appearance.125 public init(_ adaptive: AdaptiveHex) {126 self.init(light: adaptive.light, dark: adaptive.dark)127 }128}129130/// A semantic colour: its raw light / dark values (for contrast checks) and the dynamic `Color`.131public struct CRColorToken: Hashable, Sendable {132 public var light: HexColor133 public var dark: HexColor134135 public init(light: HexColor, dark: HexColor) {136 self.light = light137 self.dark = dark138 }139 public init(light: UInt32, dark: UInt32) {140 self.init(light: HexColor(light), dark: HexColor(dark))141 }142 public init(_ adaptive: AdaptiveHex) {143 self.init(light: adaptive.light, dark: adaptive.dark)144 }145146 /// Dynamic colour following the appearance.147 public var color: Color { Color(light: light, dark: dark) }148 /// Raw value for a colour scheme.149 public func hex(_ scheme: ColorScheme) -> HexColor { scheme == .dark ? dark : light }150 public func color(_ scheme: ColorScheme) -> Color { Color(hex(scheme)) }151}152153/// Neutral and status colours shared by both products: the web application's design tokens154/// (`apps/web/src/app/globals.css`). Text-capable tokens meet WCAG AA on `bg` / `surface`;155/// the `*Vivid` tokens are for fills (dots, bars, rings), never for text.156public enum CRPalette {157 public static let bg = CRColorToken(light: 0xF7F6F3, dark: 0x080B10)158 public static let surface = CRColorToken(light: 0xFFFFFF, dark: 0x10151D)159 public static let surface2 = CRColorToken(light: 0xF2F1ED, dark: 0x161D27)160 public static let elevated = CRColorToken(light: 0xFFFFFF, dark: 0x1D2632)161 public static let text = CRColorToken(light: 0x17181C, dark: 0xF4F7FB)162 public static let text2 = CRColorToken(light: 0x555B69, dark: 0xA1ADBD)163 public static let muted = CRColorToken(light: 0x626876, dark: 0x8492A6)164 /// Decorative only (placeholders, disabled glyphs): below AA for body text.165 public static let faint = CRColorToken(light: 0x8E94A3, dark: 0x5D6A7D)166 public static let success = CRColorToken(light: 0x0C7049, dark: 0x42C995)167 public static let warning = CRColorToken(light: 0x805800, dark: 0xE7B86B)168 public static let error = CRColorToken(light: 0xBF2C34, dark: 0xF08080)169 /// Informational text (links, "starting"): GitHub-like blue, AA in both themes.170 public static let info = CRColorToken(light: 0x0860C7, dark: 0x729FFF)171 public static let successVivid = CRColorToken(light: 0x1FA971, dark: 0x42C995)172 public static let warningVivid = CRColorToken(light: 0xE0A100, dark: 0xE7B86B)173 public static let errorVivid = CRColorToken(light: 0xE5484D, dark: 0xED7777)174 public static let infoVivid = CRColorToken(light: 0x3B82F6, dark: 0x729FFF)175 public static let neutralVivid = CRColorToken(light: 0x8E94A3, dark: 0x5D6A7D)176 public static let line = CRColorToken(light: HexColor(0x000000, alpha: 0.06), dark: HexColor(0xFFFFFF, alpha: 0.06))177 public static let line2 = CRColorToken(light: HexColor(0x000000, alpha: 0.09), dark: HexColor(0xFFFFFF, alpha: 0.09))178 public static let line3 = CRColorToken(light: HexColor(0x000000, alpha: 0.18), dark: HexColor(0xFFFFFF, alpha: 0.17))179 public static let cardLine = CRColorToken(light: HexColor(0x000000, alpha: 0.04), dark: HexColor(0xFFFFFF, alpha: 0.08))180 public static let hover = CRColorToken(light: HexColor(0x000000, alpha: 0.04), dark: HexColor(0xFFFFFF, alpha: 0.07))181 public static let scrim = CRColorToken(light: HexColor(0x171820, alpha: 0.35), dark: HexColor(0x000000, alpha: 0.6))182 /// Background behind a terminal (matches the web terminal themes).183 public static let terminalBackground = CRColorToken(light: 0xFCFCFA, dark: 0x080B10)184 /// Deep ink behind hero banners of the Claude product (white text on it in both themes).185 public static let ink = CRColorToken(light: 0x11122B, dark: 0x11122B)186}187188/// Per-product colours: the neutral palette plus the accent family of an `AgentProfile`.189/// Inject it once at the root with `.crTheme(profile)`; read it with `@Environment(\.crTheme)`.190public struct CRTheme: Hashable, Sendable {191 public var agent: AgentID192 public var productName: String193 public var symbolName: String194 /// Interactive accent, text-capable.195 public var accent: CRColorToken196 public var accentSecondary: CRColorToken197 /// Text / glyph colour on an accent fill.198 public var onAccent: CRColorToken199 /// Warm companion fill and its text-capable ink.200 public var warm: CRColorToken201 public var warmInk: CRColorToken202 /// Brand gradient stops.203 public var gradientStops: [HexColor]204 /// Deep ink behind hero banners.205 public var ink: HexColor206207 public init(profile: AgentProfile) {208 agent = profile.id209 productName = profile.productName210 symbolName = profile.symbolName211 accent = CRColorToken(profile.accent.primary)212 accentSecondary = CRColorToken(profile.accent.secondary)213 onAccent = CRColorToken(profile.accent.onPrimary)214 warm = CRColorToken(profile.accent.warm)215 warmInk = CRColorToken(profile.accent.warmInk)216 gradientStops = profile.accent.gradient217 ink = profile.accent.ink218 }219220 public static let claude = CRTheme(profile: .claude)221 public static let codex = CRTheme(profile: .codex)222223 /// Brand gradient (mark, hero, primary call to action).224 public var gradient: LinearGradient {225 LinearGradient(colors: gradientStops.map { Color($0) }, startPoint: .topLeading, endPoint: .bottomTrailing)226 }227 public var inkColor: Color { Color(ink) }228}229230extension EnvironmentValues {231 /// The product theme (defaults to Claude).232 @Entry public var crTheme: CRTheme = .claude233}234235extension View {236 /// Injects the theme of a product and tints controls with its accent.237 public func crTheme(_ profile: AgentProfile) -> some View { crTheme(custom: CRTheme(profile: profile)) }238239 /// Injects a hand-built theme and tints controls with its accent.240 public func crTheme(custom theme: CRTheme) -> some View {241 environment(\.crTheme, theme).tint(theme.accent.color)242 }243}244245/// Background materials of the workstation chrome.246public enum CRMaterial {247 /// Sidebars and inspectors.248 public static let sidebar: Material = .regular249 /// Toolbars, key rows and floating bars over content.250 public static let bar: Material = .bar251 /// Popovers and HUDs.252 public static let overlay: Material = .thick253 /// Subtle glass over imagery.254 public static let glass: Material = .ultraThin255}256257private struct CRCardModifier: ViewModifier {258 let padding: CGFloat259 let radius: CGFloat260 let elevated: Bool261 func body(content: Content) -> some View {262 let shape = RoundedRectangle(cornerRadius: radius, style: .continuous)263 content264 .padding(padding)265 .background((elevated ? CRPalette.elevated : CRPalette.surface).color, in: shape)266 .overlay(shape.strokeBorder(CRPalette.line2.color, lineWidth: 1))267 .crShadow(elevated ? .float : .card)268 }269}270271extension View {272 /// Card chrome: surface fill, hairline border, soft shadow.273 public func crCard(padding: CGFloat = CRSpacing.lg, radius: CGFloat = CRRadius.md, elevated: Bool = false) -> some View {274 modifier(CRCardModifier(padding: padding, radius: radius, elevated: elevated))275 }276277 /// Panel chrome over a material (floating bars, inspectors).278 public func crPanel(_ material: Material = CRMaterial.bar, radius: CGFloat = CRRadius.md, padding: CGFloat = CRSpacing.md) -> some View {279 let shape = RoundedRectangle(cornerRadius: radius, style: .continuous)280 return self.padding(padding)281 .background(material, in: shape)282 .overlay(shape.strokeBorder(CRPalette.line2.color, lineWidth: 1))283 }284285 /// App window / screen background.286 public func crScreenBackground() -> some View {287 background(CRPalette.bg.color.ignoresSafeArea())288 }289}290