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

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