SPB Git

Repository Public License

Tokens.swift 9.3 KB 229 lines swift

1// =============================================================================2//                  SP BOUCHER | SOFTWARE & RESEARCH3//             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project          : ORIX Camera9// File             : Packages/ORIXCameraKit/Sources/ORIXDesign/Tokens.swift10// Description      : ORIX design tokens: colour roles (light and dark),11//                    spacing, radii, typography, motion. Shared by every ORIX12//                    app.13// Module           : ORIXDesign14// Repository       : https://git.spboucher.ai/orix-camera15// Project Website  : https://www.orixlab.dev16// Created          : 2026-11-2117// Last Modified    : 2026-11-2118//19// =============================================================================20// AUTHOR & PROFESSIONAL AFFILIATION21// =============================================================================22//23// Author           : Simon-Pierre Boucher24// Position         : Professor of Finance25// Institution      : Université du Québec en Outaouais (UQO)26// Department       : Département des sciences administratives27// Organization     : SP Boucher28//29// Website          : https://spboucher.ai30// Git              : https://git.spboucher.ai31//32// =============================================================================33// OFFICIAL CONTACT DIRECTORY34// =============================================================================35//36// General          : info@spboucher.ai37// Professional     : contact@spboucher.ai38// Direct           : simon@spboucher.ai39// Research         : research@spboucher.ai40// Development      : dev@spboucher.ai41// Support          : support@spboucher.ai42// Security/Admin   : admin@spboucher.ai43// Notifications    : notifications@spboucher.ai44//45// Preferred Contact: support@spboucher.ai46//47// =============================================================================48// COPYRIGHT & INTELLECTUAL PROPERTY49// =============================================================================50//51// Copyright (c) 202652// Simon-Pierre Boucher53//54// All rights reserved where applicable.55//56// This file is governed by the applicable project license,57// copyright notices, institutional agreements and relevant law.58//59// Unless expressly authorized by the applicable license or60// rights holder, copying, redistribution, sublicensing,61// publication and commercial exploitation are not permitted.62//63// Existing third-party rights and notices remain unaffected.64//65// =============================================================================66// CONFIDENTIALITY & SECURITY67// =============================================================================68//69// Classification   : Public70// Distribution     : Public repository; use is governed by the project license71// Security Contact : admin@spboucher.ai72//73// Access to this source does not independently grant permission74// to redistribute or disclose confidential materials.75//76// Do not embed credentials, private keys, access tokens,77// certificates or confidential personal information.78//79// =============================================================================80// LICENSE & MAINTENANCE81// =============================================================================82//83// License          : Proprietary, all rights reserved (see license file)84// License File     : LICENSE85// Maintainer       : Simon-Pierre Boucher86// Technical Contact: dev@spboucher.ai87//88// =============================================================================89// END OF SP BOUCHER SOURCE HEADER90// =============================================================================9192import SwiftUI9394#if canImport(UIKit)95import UIKit96#elseif canImport(AppKit)97import AppKit98#endif99100public extension Color {101    /// A colour with distinct light and dark values (sRGB hex).102    init(light: UInt32, dark: UInt32) {103        #if canImport(UIKit)104        self.init(uiColor: UIColor { $0.userInterfaceStyle == .dark ? UIColor(hex: dark) : UIColor(hex: light) })105        #else106        self.init(nsColor: NSColor(name: nil) { $0.bestMatch(from: [.darkAqua, .aqua]) == .darkAqua ? NSColor(hex: dark) : NSColor(hex: light) })107        #endif108    }109110    init(hex: UInt32, opacity: Double = 1) {111        self.init(.sRGB, red: Double((hex >> 16) & 0xFF) / 255, green: Double((hex >> 8) & 0xFF) / 255, blue: Double(hex & 0xFF) / 255, opacity: opacity)112    }113}114115#if canImport(UIKit)116extension UIColor {117    convenience init(hex: UInt32) {118        self.init(red: CGFloat((hex >> 16) & 0xFF) / 255, green: CGFloat((hex >> 8) & 0xFF) / 255, blue: CGFloat(hex & 0xFF) / 255, alpha: 1)119    }120}121#else122extension NSColor {123    convenience init(hex: UInt32) {124        self.init(srgbRed: CGFloat((hex >> 16) & 0xFF) / 255, green: CGFloat((hex >> 8) & 0xFF) / 255, blue: CGFloat(hex & 0xFF) / 255, alpha: 1)125    }126}127#endif128129/// The accent pair of one ORIX app. The family shares every other token; each app brings its own pair.130public struct ORIXAccent: Sendable, Equatable {131    public var primary: Color132    public var secondary: Color133    public init(primary: Color, secondary: Color) {134        self.primary = primary135        self.secondary = secondary136    }137138    /// ORIX Camera: violet with the amber "exposure" highlight.139    public static let camera = ORIXAccent(primary: Color(light: 0x7C3AED, dark: 0xA78BFA), secondary: Color(light: 0xD97706, dark: 0xFBBF24))140141    /// ORIX Scan: indigo with the cyan "optical beam".142    public static let scan = ORIXAccent(primary: Color(light: 0x5B5BF0, dark: 0x8484FF), secondary: Color(light: 0x0FB5CF, dark: 0x22D3EE))143144    public var gradient: LinearGradient {145        LinearGradient(colors: [Color(hex: 0xA78BFA), Color(hex: 0x7C3AED), Color(hex: 0x5B21B6)], startPoint: .topLeading, endPoint: .bottomTrailing)146    }147148    public var beam: LinearGradient {149        LinearGradient(colors: [secondary.opacity(0), secondary, secondary.opacity(0)], startPoint: .leading, endPoint: .trailing)150    }151}152153public enum ORIX {154    public enum Palette {155        /// App background behind grouped content.156        public static let canvas = Color(light: 0xF4F5FA, dark: 0x0A0D18)157        /// Cards and rows.158        public static let surface = Color(light: 0xFFFFFF, dark: 0x141828)159        /// Raised or nested surfaces (fields inside cards, chips).160        public static let surfaceRaised = Color(light: 0xEEF0F7, dark: 0x1D2236)161        /// The neutral backdrop documents sit on (never pure white, so page edges stay visible).162        public static let desk = Color(light: 0xE4E7F0, dark: 0x05070E)163        public static let hairline = Color(light: 0xDDE0EA, dark: 0x262C42)164        public static let textPrimary = Color(light: 0x0E1222, dark: 0xF2F4FB)165        public static let textSecondary = Color(light: 0x596078, dark: 0xA3AAC2)166        public static let textTertiary = Color(light: 0x8A90A6, dark: 0x6F7690)167        public static let success = Color(light: 0x12925A, dark: 0x34D399)168        public static let warning = Color(light: 0xB86A00, dark: 0xFBBF24)169        public static let danger = Color(light: 0xD4313F, dark: 0xFF6B76)170        public static let onAccent = Color.white171    }172173    /// 4-point spacing scale.174    public enum Space {175        public static let xxs: CGFloat = 4176        public static let xs: CGFloat = 8177        public static let sm: CGFloat = 12178        public static let md: CGFloat = 16179        public static let lg: CGFloat = 20180        public static let xl: CGFloat = 28181        public static let xxl: CGFloat = 40182    }183184    /// Continuous-corner radii.185    public enum Radius {186        public static let chip: CGFloat = 10187        public static let control: CGFloat = 14188        public static let card: CGFloat = 20189        public static let hero: CGFloat = 28190        /// Paper has almost square corners.191        public static let page: CGFloat = 5192    }193194    public enum Motion {195        /// State changes of controls.196        public static let quick = Animation.snappy(duration: 0.22)197        /// Layout changes, sheets of content moving.198        public static let standard = Animation.smooth(duration: 0.35)199        /// Emphasis (the scan beam, success marks).200        public static let expressive = Animation.spring(response: 0.5, dampingFraction: 0.72)201    }202203    /// Minimum touch target (Apple Human Interface Guidelines).204    public static let minimumTarget: CGFloat = 44205}206207/// Text styles. All of them are built on Dynamic Type styles, so they scale with the user's text size.208public extension Font {209    static let orixDisplay = Font.system(.largeTitle, design: .rounded, weight: .bold)210    static let orixTitle = Font.system(.title2, design: .rounded, weight: .semibold)211    static let orixHeadline = Font.system(.headline, design: .default, weight: .semibold)212    static let orixBody = Font.system(.body)213    static let orixCallout = Font.system(.callout)214    static let orixCaption = Font.system(.caption, weight: .medium)215    static let orixOverline = Font.system(.caption2, weight: .semibold)216    static let orixMono = Font.system(.footnote, design: .monospaced)217}218219private struct ORIXAccentKey: EnvironmentKey {220    static let defaultValue = ORIXAccent.camera221}222223public extension EnvironmentValues {224    var orixAccent: ORIXAccent {225        get { self[ORIXAccentKey.self] }226        set { self[ORIXAccentKey.self] = newValue }227    }228}229
Files main
Menu

Theme