feat: generate Swift design tokens from tokens.json and add SstUI base
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import AppKit
|
||||
import SwiftUI
|
||||
|
||||
extension NSColor {
|
||||
convenience init(hex: UInt32) {
|
||||
self.init(
|
||||
srgbRed: CGFloat((hex >> 16) & 0xFF) / 255,
|
||||
green: CGFloat((hex >> 8) & 0xFF) / 255,
|
||||
blue: CGFloat(hex & 0xFF) / 255,
|
||||
alpha: 1)
|
||||
}
|
||||
}
|
||||
|
||||
extension Color {
|
||||
/// A colour that switches between the Aluminium (light) and Graphite (dark) value with the appearance.
|
||||
static func dynamic(light: UInt32, dark: UInt32) -> Color {
|
||||
Color(nsColor: NSColor(name: nil) { appearance in
|
||||
appearance.bestMatch(from: [.darkAqua, .aqua]) == .darkAqua ? NSColor(hex: dark) : NSColor(hex: light)
|
||||
})
|
||||
}
|
||||
|
||||
/// The same colour in both finishes (shadow bases).
|
||||
static func fixed(hex: UInt32) -> Color {
|
||||
Color(nsColor: NSColor(hex: hex))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user