SPB Git

Repository Public

AuraTokens.swift 9.7 KB 202 lines swift

1// =============================================================================2//                  SP BOUCHER | SOFTWARE & RESEARCH3//             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project          : SP Browser9// File             : SPBrowser/Shared/Aura/AuraTokens.swift10// Module           : SPBrowser11// Repository       : https://git.spboucher.ai/sp-browser12// Created          : 2026-11-1913// Last Modified    : 2026-11-1914//15// =============================================================================16// AUTHOR & PROFESSIONAL AFFILIATION17// =============================================================================18//19// Author           : Simon-Pierre Boucher20// Position         : Professor of Finance21// Institution      : Université du Québec en Outaouais (UQO)22// Department       : Département des sciences administratives23// Organization     : SP Boucher24//25// Website          : https://spboucher.ai26// Git              : https://git.spboucher.ai27//28// =============================================================================29// OFFICIAL CONTACT DIRECTORY30// =============================================================================31//32// General          : info@spboucher.ai33// Professional     : contact@spboucher.ai34// Direct           : simon@spboucher.ai35// Research         : research@spboucher.ai36// Development      : dev@spboucher.ai37// Support          : support@spboucher.ai38// Security/Admin   : admin@spboucher.ai39// Notifications    : notifications@spboucher.ai40//41// Preferred Contact: support@spboucher.ai42//43// =============================================================================44// COPYRIGHT & INTELLECTUAL PROPERTY45// =============================================================================46//47// Copyright (c) 202648// Simon-Pierre Boucher49//50// All rights reserved where applicable.51//52// This file is governed by the applicable project license,53// copyright notices, institutional agreements and relevant law.54//55// Unless expressly authorized by the applicable license or56// rights holder, copying, redistribution, sublicensing,57// publication and commercial exploitation are not permitted.58//59// Existing third-party rights and notices remain unaffected.60//61// =============================================================================62// CONFIDENTIALITY & SECURITY63// =============================================================================64//65// Classification   : Public66// Distribution     : Public repository; use is governed by the project license67// Security Contact : admin@spboucher.ai68//69// Access to this source does not independently grant permission70// to redistribute or disclose confidential materials.71//72// Do not embed credentials, private keys, access tokens,73// certificates or confidential personal information.74//75// =============================================================================76// LICENSE & MAINTENANCE77// =============================================================================78//79// License          : None specified (no license file in this repository)80// Maintainer       : Simon-Pierre Boucher81// Technical Contact: dev@spboucher.ai82//83// =============================================================================84// END OF SP BOUCHER SOURCE HEADER85// =============================================================================8687import SwiftUI88#if canImport(AppKit)89import AppKit90#else91import UIKit92#endif9394/// AURA UI — the design system of SP Browser 3. One set of tokens for the Mac, iPhone and iPad apps.95/// Rationale and usage rules: docs/AURA_DESIGN_SYSTEM.md.96enum Aura {97    // MARK: Colour9899    enum Palette {100        static let obsidian = Color(red: 0.027, green: 0.031, blue: 0.047)101        static let graphite = Color(red: 0.078, green: 0.086, blue: 0.110)102        static let deepSpace = Color(red: 0.043, green: 0.082, blue: 0.188)103        static let violet = Color(red: 0.486, green: 0.361, blue: 1.0)104        static let cyan = Color(red: 0.133, green: 0.827, blue: 0.933)105        static let electricBlue = Color(red: 0.184, green: 0.420, blue: 1.0)106        static let accent = Color("AccentColor")107108        static func adaptive(light: PlatformColor, dark: PlatformColor) -> Color {109            #if canImport(AppKit)110            Color(nsColor: NSColor(name: nil) { $0.bestMatch(from: [.darkAqua, .aqua]) == .darkAqua ? dark : light })111            #else112            Color(uiColor: UIColor { $0.userInterfaceStyle == .dark ? dark : light })113            #endif114        }115116        /// Window chrome: obsidian-graphite in dark mode, cool frosted grey in light mode.117        static let chrome = adaptive(light: PlatformColor(red: 0.933, green: 0.941, blue: 0.961, alpha: 1), dark: PlatformColor(red: 0.055, green: 0.063, blue: 0.086, alpha: 1))118        /// Page-level surface (start page, reader, native search results).119        static let surface = adaptive(light: .white, dark: PlatformColor(red: 0.078, green: 0.086, blue: 0.110, alpha: 1))120        static let field = adaptive(light: PlatformColor(white: 1, alpha: 0.86), dark: PlatformColor(white: 1, alpha: 0.07))121        static let card = adaptive(light: PlatformColor(white: 0.965, alpha: 1), dark: PlatformColor(white: 1, alpha: 0.055))122        static let hairline = adaptive(light: PlatformColor(white: 0, alpha: 0.10), dark: PlatformColor(white: 1, alpha: 0.09))123        static let hover = adaptive(light: PlatformColor(white: 0, alpha: 0.06), dark: PlatformColor(white: 1, alpha: 0.08))124        static let selected = adaptive(light: .white, dark: PlatformColor(white: 1, alpha: 0.13))125        /// Tint laid over materials so glass keeps the AURA hue instead of going neutral grey.126        static let glassTint = adaptive(light: PlatformColor(red: 0.95, green: 0.96, blue: 1.0, alpha: 0.55), dark: PlatformColor(red: 0.06, green: 0.07, blue: 0.11, alpha: 0.55))127        /// Top edge of a glass surface: the "luminous border".128        static let rimLight = adaptive(light: PlatformColor(white: 1, alpha: 0.90), dark: PlatformColor(white: 1, alpha: 0.22))129        static let rimShade = adaptive(light: PlatformColor(white: 0, alpha: 0.10), dark: PlatformColor(white: 1, alpha: 0.04))130        static let highlight = adaptive(light: PlatformColor(red: 1.0, green: 0.86, blue: 0.30, alpha: 0.45), dark: PlatformColor(red: 1.0, green: 0.80, blue: 0.25, alpha: 0.28))131        static let link = adaptive(light: PlatformColor(red: 0.10, green: 0.27, blue: 0.80, alpha: 1), dark: PlatformColor(red: 0.55, green: 0.72, blue: 1.0, alpha: 1))132133        /// Identity colours for workspaces, tab groups, profiles, canvas notes and constellations.134        static let identity: [Color] = [electricBlue, cyan, violet, Color(red: 0.20, green: 0.78, blue: 0.47),135                                        Color(red: 1.0, green: 0.62, blue: 0.20), Color(red: 1.0, green: 0.37, blue: 0.55)]136        static func identity(_ index: Int) -> Color { identity[((index % identity.count) + identity.count) % identity.count] }137    }138139    /// The signature gradient: violet → electric blue → cyan. Used sparingly (brand mark, progress, focus trail, selection glow).140    static let gradient = LinearGradient(colors: [Palette.violet, Palette.electricBlue, Palette.cyan], startPoint: .topLeading, endPoint: .bottomTrailing)141    static let horizontalGradient = LinearGradient(colors: [Palette.violet, Palette.electricBlue, Palette.cyan], startPoint: .leading, endPoint: .trailing)142143    // MARK: Shape and space144145    enum Radius {146        static let s: CGFloat = 6, m: CGFloat = 10, l: CGFloat = 14, xl: CGFloat = 20, xxl: CGFloat = 28147    }148149    enum Space {150        static let xs: CGFloat = 4, s: CGFloat = 8, m: CGFloat = 12, l: CGFloat = 16, xl: CGFloat = 24, xxl: CGFloat = 36151    }152153    // MARK: Depth154155    /// Visual elevation of a surface. Shadows grow and soften with height; nothing else changes.156    enum Elevation: Sendable {157        /// Part of the window chrome: no shadow.158        case flat159        /// Cards and fields resting on a page.160        case raised161        /// Panels and bars floating over content.162        case floating163        /// Palettes, peeks and modals above everything.164        case overlay165166        var shadow: (opacity: Double, radius: CGFloat, y: CGFloat) {167            switch self {168            case .flat: return (0, 0, 0)169            case .raised: return (0.08, 6, 2)170            case .floating: return (0.18, 16, 7)171            case .overlay: return (0.32, 36, 16)172            }173        }174    }175176    /// How much room controls take. The Mac toolbar compacts when the window is narrow; iPhone is always compact.177    enum Density: Sendable {178        case compact, regular179        var controlSize: CGFloat { self == .compact ? 26 : 28 }180        var spacing: CGFloat { self == .compact ? 2 : 4 }181    }182}183184/// Tokens used by the views shared between the Mac and iOS apps. Since 3.0 they are the AURA tokens.185enum SPTheme {186    static let radiusS = Aura.Radius.s, radiusM = Aura.Radius.m, radiusL = Aura.Radius.l, radiusXL = Aura.Radius.xl187    static let accent = Aura.Palette.accent188    static let electricBlue = Aura.Palette.electricBlue189    static let cyan = Aura.Palette.cyan190    static let violet = Aura.Palette.violet191    static let brandGradient = Aura.gradient192    static func adaptive(light: PlatformColor, dark: PlatformColor) -> Color { Aura.Palette.adaptive(light: light, dark: dark) }193    static let surface = Aura.Palette.surface194    static let chrome = Aura.Palette.chrome195    static let field = Aura.Palette.field196    static let card = Aura.Palette.card197    static let hairline = Aura.Palette.hairline198    static let hover = Aura.Palette.hover199    static let highlight = Aura.Palette.highlight200    static let link = Aura.Palette.link201}202
Files main
Menu

Theme