oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1// Ported from the r7 mockups (native-mockups-r4, native/mockups/Shared/Theme.swift).
2import SwiftUI
3#if os(macOS)
4import AppKit
5#else
6import UIKit
7#endif
8
9// Colours transcribed from the web day theme (internal/equipo/static/theme.css).
10enum Palette {
11 static let text = Color(light: 0x18181B, dark: 0xEDEDF0)
12 static let secondary = Color(light: 0x52525C, dark: 0xA1A1AA)
13 static let faint = Color(light: 0x6B6B75, dark: 0x8C8C96)
14 static let background = Color(light: 0xFBFBFC, dark: 0x0C0D0F)
15 static let surface = Color(light: 0xFFFFFF, dark: 0x141518)
16 static let surface2 = Color(light: 0xF3F3F5, dark: 0x18191D)
17 static let border = Color(light: 0xE6E6EA, dark: 0x26282E)
18 static let accent = Color(light: 0x1F56D6, dark: 0x7AA2FF)
19 static let soft = Color(light: 0xECF1FF, dark: 0x16234A)
20 static let softBorder = Color(light: 0xC9D7FA, dark: 0x27397A)
21 static let controlFace = Color(light: 0xFFFFFF, dark: 0x141518)
22 static let controlFaceHover = Color(light: 0xF7F8FA, dark: 0x1B1D22)
23 static let controlFacePressed = Color(light: 0xE6E9EE, dark: 0x202329)
24 /// --rst-line-strong: hollow track dots.
25 static let lineStrong = Color(light: 0x868691, dark: 0x71737C)
26 /// --rst-light-rim: the edge of a raised card, accent mixed into the line.
27 static let lightRim = Color(light: 0xB8C5E5, dark: 0x5D6986)
28 static let controlText = Color(light: 0x18181B, dark: 0xEDEDF0)
29 static let controlBorder = Color(light: 0xD0D4DC, dark: 0x343843)
30 static let placeholder = Color(light: 0x6B6B75, dark: 0x8C8C96)
31 static let primaryFill = Color(light: 0x2257DF, dark: 0x2F61E8)
32 static let primaryFillHover = Color(light: 0x1D4DC8, dark: 0x2956D0)
33 static let primaryEdge = Color(light: 0x153CA0, dark: 0x1F43A6)
34 static let positive = Color(light: 0x166534, dark: 0x6EE7A8)
35 static let positiveBackground = Color(light: 0xDCFCE7, dark: 0x10281C)
36 static let warning = Color(light: 0x854D0E, dark: 0xF0C46A)
37 /// Paused work's calm indigo (equipo.css --equipo-tone-paused-*).
38 static let paused = Color(light: 0x4B44B3, dark: 0xB4ADF6)
39 static let pausedBackground = Color(light: 0xEEEDFB, dark: 0x201E3B)
40 static let warningBackground = Color(light: 0xFEF3C7, dark: 0x2C2110)
41 static let negative = Color(light: 0xB91C1C, dark: 0xF79AA0)
42 static let negativeBackground = Color(light: 0xFEE2E2, dark: 0x331819)
43 static let neutral = Color(light: 0x374151, dark: 0xC3C9D1)
44 static let neutralBackground = Color(light: 0xEEF0F2, dark: 0x262C34)
45 static let contactShadow = Color(light: 0x101828, dark: 0x000000)
46}
47extension Color {
48 init(light: UInt32, dark: UInt32) {
49 #if os(macOS)
50 self.init(nsColor: NSColor(name: nil) { appearance in
51 let hex = appearance.bestMatch(from: [.aqua, .darkAqua]) == .darkAqua ? dark : light
52 return NSColor(srgbRed: Double((hex >> 16) & 255) / 255, green: Double((hex >> 8) & 255) / 255, blue: Double(hex & 255) / 255, alpha: 1)
53 })
54 #else
55 self.init(uiColor: UIColor { traits in
56 let hex = traits.userInterfaceStyle == .dark ? dark : light
57 return UIColor(red: Double((hex >> 16) & 255) / 255, green: Double((hex >> 8) & 255) / 255, blue: Double(hex & 255) / 255, alpha: 1)
58 })
59 #endif
60 }
61}
62
63// One scale per platform: text styles on iPhone so Dynamic Type works,
64// fixed AppKit-sized type on the Mac.
65enum Typo {
66 #if os(iOS)
67 static let screenTitle = Font.title2.weight(.bold)
68 static let question = Font.title3.weight(.semibold)
69 static let cardTitle = Font.headline
70 static let body = Font.body
71 static let secondary = Font.subheadline
72 static let secondaryStrong = Font.subheadline.weight(.semibold)
73 static let caption = Font.footnote
74 static let captionStrong = Font.footnote.weight(.semibold)
75 static let button = Font.body.weight(.medium)
76 static let stat = Font.system(.title2, design: .rounded).weight(.semibold)
77 static let bylineName = Font.headline
78 static let bylineVerb = Font.subheadline
79 static let time = Font.footnote.monospacedDigit()
80 static let eyebrow = Font.footnote.weight(.semibold)
81 static let reportTitle = Font.title3.weight(.semibold)
82 static let compactTitle = Font.body.weight(.semibold)
83 static let cardLine = Font.body
84 static let factLabel = Font.footnote
85 static let factValue = Font.subheadline.weight(.semibold)
86 static let code = Font.system(.footnote, design: .monospaced).weight(.semibold)
87 static let thread = Font.subheadline
88 static let threadWho = Font.caption.weight(.semibold)
89 static let chip = Font.caption.weight(.bold)
90 static let message = Font.body
91 #else
92 static let screenTitle = Font.system(size: 20, weight: .bold)
93 static let question = Font.system(size: 15, weight: .semibold)
94 static let cardTitle = Font.system(size: 13, weight: .semibold)
95 static let body = Font.system(size: 13)
96 static let secondary = Font.system(size: 12)
97 static let secondaryStrong = Font.system(size: 12, weight: .semibold)
98 static let caption = Font.system(size: 11)
99 static let captionStrong = Font.system(size: 11, weight: .semibold)
100 static let button = Font.system(size: 13, weight: .medium)
101 static let stat = Font.system(size: 20, weight: .semibold, design: .rounded)
102 static let bylineName = Font.system(size: 13, weight: .bold)
103 static let bylineVerb = Font.system(size: 12)
104 static let time = Font.system(size: 11).monospacedDigit()
105 static let eyebrow = Font.system(size: 11, weight: .semibold)
106 static let reportTitle = Font.system(size: 15, weight: .semibold)
107 static let compactTitle = Font.system(size: 13, weight: .semibold)
108 static let cardLine = Font.system(size: 14)
109 static let factLabel = Font.system(size: 11)
110 static let factValue = Font.system(size: 12, weight: .semibold)
111 static let code = Font.system(size: 11, weight: .semibold, design: .monospaced)
112 static let thread = Font.system(size: 13)
113 static let threadWho = Font.system(size: 11, weight: .semibold)
114 static let chip = Font.system(size: 10, weight: .bold)
115 static let message = Font.system(size: 14)
116 #endif
117}
118enum Metric {
119 #if os(iOS)
120 static let card: CGFloat = 14
121 static let control: CGFloat = 10
122 static let buttonHeight: CGFloat = 48
123 static let cardPadding: CGFloat = 16
124 static let target: CGFloat = 44
125 static let raised: CGFloat = 18
126 static let raisedPadding: CGFloat = 14
127 static let tile: CGFloat = 30
128 /// Where a report's content starts: past the byline tile.
129 static let indent: CGFloat = 40
130 static let gap: CGFloat = 12
131 #else
132 static let card: CGFloat = 10
133 static let control: CGFloat = 6
134 static let buttonHeight: CGFloat = 32
135 static let cardPadding: CGFloat = 14
136 static let target: CGFloat = 32
137 static let raised: CGFloat = 14
138 static let raisedPadding: CGFloat = 16
139 static let tile: CGFloat = 30
140 static let indent: CGFloat = 48
141 static let gap: CGFloat = 12
142 #endif
143}
144
145enum Tone {
146 case neutral, accent, positive, warning, negative
147 var foreground: Color {
148 switch self {
149 case .neutral: return Palette.neutral
150 case .accent: return Palette.accent
151 case .positive: return Palette.positive
152 case .warning: return Palette.warning
153 case .negative: return Palette.negative
154 }
155 }
156 var background: Color {
157 switch self {
158 case .neutral: return Palette.neutralBackground
159 case .accent: return Palette.soft
160 case .positive: return Palette.positiveBackground
161 case .warning: return Palette.warningBackground
162 case .negative: return Palette.negativeBackground
163 }
164 }
165}
166
167/// A card: surface, full hairline border, and an optional tint. Never a coloured edge.
168struct Panel<Content: View>: View {
169 var tinted = false
170 var tone: Tone = .accent
171 var padding: CGFloat = Metric.cardPadding
172 var spacing: CGFloat = 12
173 @ViewBuilder var content: Content
174 var body: some View {
175 let shape = RoundedRectangle(cornerRadius: Metric.card, style: .continuous)
176 VStack(alignment: .leading, spacing: spacing) { content }
177 .frame(maxWidth: .infinity, alignment: .leading)
178 .padding(padding)
179 .background(shape.fill(tinted ? tone.background : Palette.surface))
180 .overlay(shape.strokeBorder(tinted ? (tone == .accent ? Palette.softBorder : tone.foreground.opacity(0.25)) : Palette.border, lineWidth: 1))
181 }
182}
183struct QuietLabel: View {
184 let text: String
185 var body: some View { Text(text).font(Typo.caption).foregroundStyle(Palette.secondary).fixedSize(horizontal: false, vertical: true) }
186}
187struct SectionTitle: View {
188 let text: String
189 var body: some View {
190 Text(text).font(Typo.captionStrong).textCase(.uppercase).kerning(0.4)
191 .foregroundStyle(Palette.secondary).accessibilityAddTraits(.isHeader)
192 }
193}
194struct StatusPill: View {
195 let text: String
196 var tone: Tone = .neutral
197 var icon: String?
198 var body: some View {
199 HStack(spacing: 4) {
200 if let icon { Image(systemName: icon).imageScale(.small) }
201 Text(text)
202 }
203 .font(Typo.captionStrong)
204 .foregroundStyle(tone.foreground)
205 .padding(.horizontal, 8).padding(.vertical, 3)
206 .background(tone.background, in: Capsule())
207 }
208}
209struct CountBadge: View {
210 let count: Int
211 var body: some View {
212 Text(count.formatted()).font(Typo.captionStrong).monospacedDigit()
213 .foregroundStyle(Palette.warning)
214 .padding(.horizontal, 7).frame(minWidth: 22, minHeight: 20)
215 .background(Palette.warningBackground, in: Capsule())
216 .accessibilityLabel(Text(String(localized: "needs.count_spoken \(count)", bundle: .module)))
217 }
218}
219/// A specialist is always an icon beside its name. No lettered squares.
220struct SpecialistLabel: View {
221 let category: String
222 var tone: Color = Palette.text
223 var body: some View {
224 HStack(spacing: 6) {
225 let who = Specialist(category: category)
226 Image(systemName: who.symbol).foregroundStyle(Palette.secondary)
227 Text(who.name).foregroundStyle(tone)
228 }.font(Typo.secondaryStrong)
229 }
230}
231struct Meter: View {
232 let value: Double
233 var tone: Tone = .accent
234 var body: some View {
235 GeometryReader { proxy in
236 ZStack(alignment: .leading) {
237 Capsule().fill(Palette.neutralBackground)
238 Capsule().fill(tone == .accent ? Palette.primaryFill : tone.foreground)
239 .frame(width: max(6, proxy.size.width * min(1, max(0, value))))
240 }
241 }.frame(height: 6).accessibilityElement().accessibilityValue("\(Int(value * 100)) percent")
242 }
243}
244func specialistIcon(_ category: String) -> String { Specialist(category: category).symbol }
245func compact(_ value: Int64) -> String {
246 Int(value).formatted(.number.notation(.compactName).precision(.fractionLength(0...1)))
247}
248