You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Musubi/design/Theme.swift

50 lines
2.1 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import SwiftUI
/// Musubi design tokens. Source of truth: design/tokens.json and docs/03-design.md.
enum Theme {
enum Color {
static let sumi = adaptive(dark: 0x14151B, light: 0xF4F4F6) // background
static let kasumi = adaptive(dark: 0x1E2029, light: 0xFFFFFF) // surface
static let usuzumi = adaptive(dark: 0x2B2E3A, light: 0xDADBE2) // lines
static let washi = adaptive(dark: 0xECE9E2, light: 0x16171D) // text
static let nezumi = adaptive(dark: 0x8E8C96, light: 0x6A6974) // muted text
static let ai = adaptive(dark: 0x8A99F2, light: 0x4F63D9) // the one brand accent
// Status colours – only for states, never decoration.
static let shu = SwiftUI.Color(hex: 0xE5484D) // tally PGM, talk active
static let moegi = SwiftUI.Color(hex: 0x3DBE7A) // tally preview, connection ok
static let kohaku = SwiftUI.Color(hex: 0xE8A23A) // warning
}
enum Radius { static let card: CGFloat = 12, button: CGFloat = 8, chip: CGFloat = 6 }
enum Space { static let unit: CGFloat = 8, card: CGFloat = 16 }
enum Stroke { static let line: CGFloat = 1, cord: CGFloat = 2, knot: CGFloat = 6 }
enum Font {
static let title = SwiftUI.Font.system(.title3, weight: .semibold)
static let body = SwiftUI.Font.system(.body)
static let caption = SwiftUI.Font.system(.caption)
static let number = SwiftUI.Font.system(.body, design: .monospaced).monospacedDigit()
}
private static func adaptive(dark: UInt32, light: UInt32) -> SwiftUI.Color {
SwiftUI.Color(nsColor: NSColor(name: nil) { appearance in
appearance.bestMatch(from: [.darkAqua, .aqua]) == .darkAqua
? NSColor(hex: dark) : NSColor(hex: light)
})
}
}
extension SwiftUI.Color {
init(hex: UInt32) { self.init(nsColor: NSColor(hex: hex)) }
}
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)
}
}

Powered by TurnKey Linux.