SPB Git

Repository Public MIT

GlassBuiltInThemes.swift 10.3 KB 163 lines swift

1// =============================================================================2//                  SP BOUCHER | SOFTWARE & RESEARCH3//             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project          : SP GlassKit7// File             : Sources/SPGlassThemes/GlassBuiltInThemes.swift8// Module           : SPGlassThemes9// Repository       : https://git.spboucher.ai/sp-glasskit10// Project Website  : https://glass.spboucher.ai11// Created          : 2026-12-0212// Last Modified    : 2026-12-0213//14// Author           : Simon-Pierre Boucher15// Position         : Professor of Finance16// Institution      : Université du Québec en Outaouais (UQO)17// Organization     : SP Boucher18// Website          : https://spboucher.ai19// Git              : https://git.spboucher.ai20//21// Preferred Contact: contact@spboucher.ai22// Development      : dev@spboucher.ai23// Support          : support@spboucher.ai24// Security/Admin   : admin@spboucher.ai25//26// Copyright (c) 202627// Simon-Pierre Boucher28// All rights reserved where applicable. This file is governed by the29// applicable project license, copyright notices and relevant law.30// Existing third-party rights and notices remain unaffected.31//32// License          : MIT33//34// Do not embed credentials, private keys, access tokens,35// certificates or confidential personal information.36//37// =============================================================================38// END OF SP BOUCHER SOURCE HEADER39// =============================================================================4041import Foundation4243extension GlassTheme {44    /// Follows the system: every colour role resolves to the matching system colour.45    public static let system = GlassTheme(46        id: "system", name: "System",47        summary: "System colours and accent. The safest choice inside an existing app."48    )4950    public static let crystal = GlassTheme(51        id: "crystal", name: "Crystal", summary: "Minimal, neutral and quiet.",52        light: palette(primary: 0x18181B, secondary: 0x64748B, accent: 0x475569, destructive: 0xB91C1C, success: 0x15803D, warning: 0xB45309,53                       background: 0xFFFFFF, surface: 0xF3F4F6, textPrimary: 0x18181B, textSecondary: 0x52525B, separator: 0xE5E7EB, focusRing: 0x64748B),54        dark: palette(primary: 0xE5E7EB, secondary: 0xAAB9CC, accent: 0xAAB9CC, destructive: 0xF87171, success: 0x4ADE80, warning: 0xFBBF24,55                      background: 0x0F1115, surface: 0x1B1E24, textPrimary: 0xF4F4F5, textSecondary: 0xAAB9CC, separator: 0x2E333B, focusRing: 0xAAB9CC)56    )5758    public static let obsidian = GlassTheme(59        id: "obsidian", name: "Obsidian", summary: "Deep neutral blacks with a restrained highlight.",60        light: palette(primary: 0x18181B, secondary: 0x52525B, accent: 0x27272A, destructive: 0xB91C1C, success: 0x166534, warning: 0x92400E,61                       background: 0xFAFAFA, surface: 0xEFEFF1, textPrimary: 0x09090B, textSecondary: 0x52525B, separator: 0xD4D4D8, focusRing: 0x52525B),62        dark: palette(primary: 0xD4D4D8, secondary: 0xA1A1AA, accent: 0xD4D4D8, destructive: 0xF87171, success: 0x4ADE80, warning: 0xFBBF24,63                      background: 0x09090B, surface: 0x18181B, textPrimary: 0xFAFAFA, textSecondary: 0xA1A1AA, separator: 0x27272A, focusRing: 0xD4D4D8),64        radii: GlassRadii(small: 6, medium: 12, large: 18, extraLarge: 26)65    )6667    public static let aurora = GlassTheme(68        id: "aurora", name: "Aurora", summary: "Indigo, violet and cyan for forward-looking interfaces.",69        light: palette(primary: 0x4F46E5, secondary: 0x7C3AED, accent: 0xDB2777, destructive: 0xDC2626, success: 0x047857, warning: 0xB45309,70                       background: 0xFAFAFF, surface: 0xF0EFFE, textPrimary: 0x1E1B4B, textSecondary: 0x4C4A73, separator: 0xDDD9FB, focusRing: 0x6366F1),71        dark: palette(primary: 0x818CF8, secondary: 0xA78BFA, accent: 0x22D3EE, destructive: 0xFB7185, success: 0x34D399, warning: 0xFBBF24,72                      background: 0x0E0B1F, surface: 0x1A1633, textPrimary: 0xF5F3FF, textSecondary: 0xC4B5FD, separator: 0x2E2A52, focusRing: 0x22D3EE),73        typography: GlassTypography(design: .rounded),74        motion: GlassMotion(style: .snappy),75        glass: GlassMaterialTokens(variant: .regular, tint: .primary)76    )7778    public static let emerald = GlassTheme(79        id: "emerald", name: "Emerald", summary: "Greens drawn from foliage, calm and legible.",80        light: palette(primary: 0x065F46, secondary: 0x047857, accent: 0x059669, destructive: 0xB91C1C, success: 0x047857, warning: 0x92400E,81                       background: 0xECFDF5, surface: 0xD5F5E6, textPrimary: 0x064E3B, textSecondary: 0x065F46, separator: 0xA7E8CB, focusRing: 0x059669),82        dark: palette(primary: 0x10B981, secondary: 0x6EE7B7, accent: 0x6EE7B7, destructive: 0xFCA5A5, success: 0x6EE7B7, warning: 0xFCD34D,83                      background: 0x03261D, surface: 0x064E3B, textPrimary: 0xECFDF5, textSecondary: 0xA7F3D0, separator: 0x065F46, focusRing: 0x6EE7B7),84        density: .comfortable85    )8687    public static let solar = GlassTheme(88        id: "solar", name: "Solar", summary: "Warm ambers and burnt orange.",89        light: palette(primary: 0xC2410C, secondary: 0xB45309, accent: 0xD97706, destructive: 0xB91C1C, success: 0x3F6212, warning: 0xB45309,90                       background: 0xFFFBEB, surface: 0xFEF3C7, textPrimary: 0x7C2D12, textSecondary: 0x9A3412, separator: 0xFDE68A, focusRing: 0xEA580C),91        dark: palette(primary: 0xF59E0B, secondary: 0xFCD34D, accent: 0xFB923C, destructive: 0xFCA5A5, success: 0xBEF264, warning: 0xFCD34D,92                      background: 0x1C0F07, surface: 0x2E1709, textPrimary: 0xFFFBEB, textSecondary: 0xFCD34D, separator: 0x7C2D12, focusRing: 0xFCD34D),93        typography: GlassTypography(design: .serif)94    )9596    public static let ocean = GlassTheme(97        id: "ocean", name: "Ocean", summary: "Maritime blues from shallow to deep water.",98        light: palette(primary: 0x0369A1, secondary: 0x0284C7, accent: 0x0284C7, destructive: 0xB91C1C, success: 0x047857, warning: 0xB45309,99                       background: 0xF0F9FF, surface: 0xE0F2FE, textPrimary: 0x082F49, textSecondary: 0x075985, separator: 0xBAE6FD, focusRing: 0x0369A1),100        dark: palette(primary: 0x0EA5E9, secondary: 0x7DD3FC, accent: 0x7DD3FC, destructive: 0xFCA5A5, success: 0x6EE7B7, warning: 0xFCD34D,101                      background: 0x051D2E, surface: 0x082F49, textPrimary: 0xF0F9FF, textSecondary: 0x7DD3FC, separator: 0x0C4A6E, focusRing: 0x7DD3FC),102        glass: GlassMaterialTokens(variant: .regular, tint: .accent)103    )104105    public static let neon = GlassTheme(106        id: "neon", name: "Neon", summary: "High-energy violet, magenta and cyan for games.",107        light: palette(primary: 0x9333EA, secondary: 0xA21CAF, accent: 0xDB0070, destructive: 0xBE123C, success: 0x4D7C0F, warning: 0xA16207,108                       background: 0xFAF5FF, surface: 0xF3E8FF, textPrimary: 0x090014, textSecondary: 0x581C87, separator: 0xE9D5FF, focusRing: 0x9333EA),109        dark: palette(primary: 0xA855F7, secondary: 0x00FFFF, accent: 0xFF0080, destructive: 0xFF6B8B, success: 0xBEF264, warning: 0xFDE047,110                      background: 0x090014, surface: 0x170B2B, textPrimary: 0xFAF5FF, textSecondary: 0xD8B4FE, separator: 0x3B1D63, focusRing: 0x00FFFF),111        typography: GlassTypography(design: .rounded, headingWeight: .bold),112        motion: GlassMotion(style: .bouncy),113        glass: GlassMaterialTokens(variant: .regular, tint: .primary)114    )115116    /// The System theme followed by the seven designed themes.117    public static let builtIn: [GlassTheme] = [.system, .crystal, .obsidian, .aurora, .emerald, .solar, .ocean, .neon]118119    /// Illustrative themes named after SP Boucher products.120    ///121    /// They show how a product theme is declared: only the brand roles are set and every other role follows122    /// the system. The colours are examples chosen for this package; they are not the palettes of those123    /// products and nothing here is used by them.124    public static let examples: [GlassTheme] = [125        example(id: "example-lou-ka", name: "Lou-Ka (example)", light: (0x0F766E, 0xB45309), dark: (0x2DD4BF, 0xFBBF24)),126        example(id: "example-immoka", name: "IMMOKA (example)", light: (0x1E3A8A, 0xB91C1C), dark: (0x93C5FD, 0xFCA5A5)),127        example(id: "example-vrai-prix", name: "Vrai Prix (example)", light: (0x15803D, 0xC2410C), dark: (0x4ADE80, 0xFB923C)),128        example(id: "example-maclustr", name: "MacLustr (example)", light: (0x334155, 0x0369A1), dark: (0xCBD5E1, 0x38BDF8)),129        example(id: "example-orix", name: "ORIX (example)", light: (0x6D28D9, 0x0E7490), dark: (0xC4B5FD, 0x67E8F9)),130    ]131132    /// Looks a theme up among the built-in and example themes.133    public static func named(_ id: GlassThemeID) -> GlassTheme? {134        (builtIn + examples).first { $0.id == id }135    }136137    private static func example(id: GlassThemeID, name: String, light: (UInt32, UInt32), dark: (UInt32, UInt32)) -> GlassTheme {138        func brand(_ pair: (UInt32, UInt32)) -> GlassPalette {139            GlassPalette([140                .primary: GlassRGBA(rgb: pair.0), .accent: GlassRGBA(rgb: pair.1), .focusRing: GlassRGBA(rgb: pair.0),141            ])142        }143        return GlassTheme(144            id: id, name: name,145            summary: "Illustrative palette for documentation. Not the product's actual brand colours.",146            light: brand(light), dark: brand(dark)147        )148    }149150    private static func palette(151        primary: UInt32, secondary: UInt32, accent: UInt32, destructive: UInt32, success: UInt32, warning: UInt32,152        background: UInt32, surface: UInt32, textPrimary: UInt32, textSecondary: UInt32, separator: UInt32, focusRing: UInt32153    ) -> GlassPalette {154        GlassPalette([155            .primary: GlassRGBA(rgb: primary), .secondary: GlassRGBA(rgb: secondary), .accent: GlassRGBA(rgb: accent),156            .destructive: GlassRGBA(rgb: destructive), .success: GlassRGBA(rgb: success), .warning: GlassRGBA(rgb: warning),157            .background: GlassRGBA(rgb: background), .surface: GlassRGBA(rgb: surface),158            .textPrimary: GlassRGBA(rgb: textPrimary), .textSecondary: GlassRGBA(rgb: textSecondary),159            .separator: GlassRGBA(rgb: separator), .focusRing: GlassRGBA(rgb: focusRing),160        ])161    }162}163
Files main
Menu

Theme