Branchwell

Jobley / app · jobley.ai / Sources / JobleyUI / Theme.swift

1import SwiftUI
2import JobleyKit
3
4/// The "Noticeboard" direction from jobley.ai: paper cream, forest green, a marigold seal.
5/// The values are the site's `:root` tokens in assets/site.css, light and dark.
6public enum Theme {
7 public static let background = Color(light: 0xfaf6ee, dark: 0x0d1511)
8 public static let surface = Color(light: 0xfffdf8, dark: 0x16221c)
9 public static let surface2 = Color(light: 0xf7f2e7, dark: 0x1b2922)
10 public static let line = Color(light: 0xe4dccb, dark: 0x25352c)
11 public static let ink = Color(light: 0x15241c, dark: 0xf3efe4)
12 public static let ink2 = Color(light: 0x3c4a42, dark: 0xc5cdc4)
13 public static let muted = Color(light: 0x677268, dark: 0x8f9c93)
14 /// Text and icons in the accent colour.
15 public static let accent = Color(light: 0x17603f, dark: 0x7fd6a6)
16 /// Filled buttons.
17 public static let fill = Color(light: 0x17603f, dark: 0x23784f)
18 public static let seal = Color(hex: 0xf5b83d)
19 public static let sealText = Color(light: 0x8a5a00, dark: 0xf5b83d)
20 public static let danger = Color(light: 0xb3391f, dark: 0xf08a6f)
21
22 /// Fraunces on the site; the system serif is the closest built-in face.
23 public static func display(_ size: CGFloat, weight: Font.Weight = .semibold) -> Font {
24 .system(size: size, weight: weight, design: .serif)
25 }
26 public static func mono(_ size: CGFloat) -> Font { .system(size: size, design: .monospaced) }
27}
28
29public extension Color {
30 init(hex: UInt32) {
31 self.init(red: Double((hex >> 16) & 0xff) / 255, green: Double((hex >> 8) & 0xff) / 255, blue: Double(hex & 0xff) / 255)
32 }
33
34 init(light: UInt32, dark: UInt32) {
35 #if os(macOS)
36 self.init(nsColor: NSColor(name: nil) { appearance in
37 let isDark = appearance.bestMatch(from: [.darkAqua, .aqua]) == .darkAqua
38 return NSColor(Color(hex: isDark ? dark : light))
39 })
40 #else
41 self.init(uiColor: UIColor { traits in UIColor(Color(hex: traits.userInterfaceStyle == .dark ? dark : light)) })
42 #endif
43 }
44}
45
46/// The app mark: a job card with an approval seal (jobley-site/mark.svg), drawn natively.
47public struct JobleyMark: View {
48 var size: CGFloat
49 public init(size: CGFloat = 28) { self.size = size }
50 public var body: some View {
51 ZStack {
52 RoundedRectangle(cornerRadius: size * 0.24, style: .continuous).fill(Theme.fill)
53 VStack(alignment: .leading, spacing: size * 0.09) {
54 Capsule().fill(.white).frame(width: size * 0.42, height: size * 0.09)
55 Capsule().fill(.white.opacity(0.75)).frame(width: size * 0.3, height: size * 0.07)
56 Capsule().fill(.white.opacity(0.75)).frame(width: size * 0.36, height: size * 0.07)
57 }
58 .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
59 .padding(size * 0.2)
60 Circle().fill(Theme.seal).frame(width: size * 0.34)
61 .overlay(Image(systemName: "checkmark").font(.system(size: size * 0.17, weight: .heavy)).foregroundStyle(Color(hex: 0x3a2a05)))
62 .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottomTrailing)
63 .padding(size * 0.12)
64 }
65 .frame(width: size, height: size)
66 .accessibilityHidden(true)
67 }
68}