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/Tokens.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 SwiftUI89#if canImport(AppKit) && !targetEnvironment(macCatalyst)90import AppKit91#elseif canImport(UIKit)92import UIKit93#endif9495/// Spacing scale (points). Use these instead of literals so both apps share one rhythm.96public enum CRSpacing {97 public static let xxs: CGFloat = 298 public static let xs: CGFloat = 499 public static let sm: CGFloat = 8100 public static let md: CGFloat = 12101 public static let lg: CGFloat = 16102 public static let xl: CGFloat = 24103 public static let xxl: CGFloat = 32104 public static let xxxl: CGFloat = 48105}106107/// Corner radii, same values as the web design tokens (`--radius-sm|md|lg`).108public enum CRRadius {109 public static let xs: CGFloat = 6110 public static let sm: CGFloat = 10111 public static let md: CGFloat = 16112 public static let lg: CGFloat = 22113 /// Fully rounded (pills, chips).114 public static let pill: CGFloat = 999115}116117/// A drop shadow recipe (the web's `--shadow-card|float|pop`, simplified to one layer).118public struct CRShadow: Hashable, Sendable {119 public var radius: CGFloat120 public var y: CGFloat121 public var opacity: Double122123 public static let card = CRShadow(radius: 7, y: 3, opacity: 0.08)124 public static let float = CRShadow(radius: 16, y: 8, opacity: 0.16)125 public static let pop = CRShadow(radius: 28, y: 16, opacity: 0.26)126}127128extension View {129 /// Applies a `CRShadow`.130 public func crShadow(_ shadow: CRShadow) -> some View {131 self.shadow(color: Color.black.opacity(shadow.opacity), radius: shadow.radius, x: 0, y: shadow.y)132 }133}134135/// Typography: system text styles (Dynamic Type friendly) and the terminal font choice.136public enum CRTypography {137 public static let largeTitle = Font.largeTitle.weight(.bold)138 public static let title = Font.title2.weight(.semibold)139 public static let headline = Font.headline140 public static let body = Font.body141 public static let callout = Font.callout142 public static let caption = Font.caption143 public static let footnote = Font.footnote144 /// Section labels above cards (small caps look).145 public static let overline = Font.caption.weight(.semibold)146 /// Big numbers in stat tiles: rounded, monospaced digits.147 public static let metric = Font.system(.title, design: .rounded).weight(.semibold).monospacedDigit()148 /// Inline code, ids, paths.149 public static let mono = Font.system(.callout, design: .monospaced)150 public static let monoSmall = Font.system(.caption, design: .monospaced)151152 /// Default terminal font of the web application (`UserSettings.terminalFont`).153 public static let defaultTerminalFontName = "JetBrains Mono"154 /// Font names tried in order when resolving the terminal font; the system monospaced font is the final fallback.155 public static let terminalFontCandidates = ["JetBrains Mono", "JetBrainsMono-Regular", "JetBrains Mono NL", "SF Mono", "Menlo"]156157 /// Whether a font family / PostScript name is installed.158 public static func isFontAvailable(_ name: String) -> Bool {159 guard !name.isEmpty else { return false }160 #if canImport(AppKit) && !targetEnvironment(macCatalyst)161 return NSFont(name: name, size: 12) != nil162 #elseif canImport(UIKit)163 return UIFont(name: name, size: 12) != nil164 #else165 return false166 #endif167 }168169 /// First installed name among `preferred` and `terminalFontCandidates`; nil = use the system monospaced font.170 public static func resolvedTerminalFontName(preferred: String? = nil) -> String? {171 ([preferred].compactMap { $0 } + terminalFontCandidates).first(where: isFontAvailable)172 }173174 /// SwiftUI terminal font (fixed size on purpose: the user picks it in settings).175 public static func terminalFont(size: CGFloat, preferred: String? = nil) -> Font {176 if let name = resolvedTerminalFontName(preferred: preferred) { return Font.custom(name, fixedSize: size) }177 return Font.system(size: size, design: .monospaced)178 }179180 #if canImport(AppKit) && !targetEnvironment(macCatalyst)181 /// AppKit terminal font for the terminal view.182 public static func terminalPlatformFont(size: CGFloat, preferred: String? = nil) -> NSFont {183 resolvedTerminalFontName(preferred: preferred).flatMap { NSFont(name: $0, size: size) }184 ?? NSFont.monospacedSystemFont(ofSize: size, weight: .regular)185 }186 #elseif canImport(UIKit)187 /// UIKit terminal font for the terminal view.188 public static func terminalPlatformFont(size: CGFloat, preferred: String? = nil) -> UIFont {189 resolvedTerminalFontName(preferred: preferred).flatMap { UIFont(name: $0, size: size) }190 ?? UIFont.monospacedSystemFont(ofSize: size, weight: .regular)191 }192 #endif193}194195/// Motion tokens. Every helper returns `nil` (no animation) when Reduce Motion is on.196public enum CRMotion {197 public enum Kind: Sendable, CaseIterable {198 /// Small state changes (hover, toggles).199 case quick200 /// Default transitions.201 case standard202 /// Larger layout moves.203 case emphasized204 /// Springy feedback (the web's `--ease-spring`).205 case spring206 }207208 public static let quickDuration: Double = 0.12209 public static let standardDuration: Double = 0.2210 public static let emphasizedDuration: Double = 0.32211212 /// The animation for a kind, or nil when Reduce Motion is enabled.213 public static func animation(_ kind: Kind = .standard, reduceMotion: Bool) -> Animation? {214 guard !reduceMotion else { return nil }215 switch kind {216 case .quick: return .timingCurve(0.2, 0.7, 0.2, 1, duration: quickDuration)217 case .standard: return .timingCurve(0.2, 0.7, 0.2, 1, duration: standardDuration)218 case .emphasized: return .timingCurve(0.2, 0.7, 0.2, 1, duration: emphasizedDuration)219 case .spring: return .spring(response: 0.32, dampingFraction: 0.72)220 }221 }222}223224extension Animation {225 /// Standard animation, nil under Reduce Motion.226 public static func crStandard(reduceMotion: Bool) -> Animation? { CRMotion.animation(.standard, reduceMotion: reduceMotion) }227 /// Quick animation, nil under Reduce Motion.228 public static func crQuick(reduceMotion: Bool) -> Animation? { CRMotion.animation(.quick, reduceMotion: reduceMotion) }229 /// Spring animation, nil under Reduce Motion.230 public static func crSpring(reduceMotion: Bool) -> Animation? { CRMotion.animation(.spring, reduceMotion: reduceMotion) }231}232233private struct CRAnimationModifier<V: Equatable>: ViewModifier {234 @Environment(\.accessibilityReduceMotion) private var reduceMotion235 let kind: CRMotion.Kind236 let value: V237 func body(content: Content) -> some View {238 content.animation(CRMotion.animation(kind, reduceMotion: reduceMotion), value: value)239 }240}241242extension View {243 /// `animation(_:value:)` that honours Reduce Motion. Never apply it to a container holding a terminal view.244 public func crAnimation<V: Equatable>(_ kind: CRMotion.Kind = .standard, value: V) -> some View {245 modifier(CRAnimationModifier(kind: kind, value: value))246 }247}248