返回 CodeWhale
roles.rs
1 // Generated from vendor/codewhale-design/tokens.json 5.5.0 by tests/generated.rs.
2 // Do not edit. Regenerate: CODEWHALE_BLESS=1 cargo test --test generated
3
4 /// The design tokens version these roles were generated from.
5 pub const TOKENS_VERSION: &str = "5.5.0";
6
7 /// What a color is for. Components name roles; they never name colors.
8 /// Names follow `tokens.json`, so one vocabulary covers the desktop app,
9 /// the web and the terminal. Hint is derived from the token colors.
10 /// See [`Role::is_derived`].
11 #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
12 pub enum Role {
13 /// The deepest ground: rails and things put away.
14 Sidebar,
15 /// The stage.
16 Background,
17 /// A raised panel.
18 Surface,
19 /// A row under the pointer.
20 Hover,
21 /// The selected row.
22 Selected,
23 /// Body ink.
24 Foreground,
25 /// Calm non-interactive ink for sub-agent and external-agent tags.
26 Subagent,
27 /// Ink that recedes: details, verbs in hints, asides.
28 Muted,
29 /// Quiet lines that separate.
30 Border,
31 /// Edges that identify a control or a decision.
32 BorderStrong,
33 /// The primary action fill.
34 Primary,
35 /// Ink on a `Primary` ground.
36 PrimaryForeground,
37 /// The one quiet blue: links, focus and selection.
38 Accent,
39 /// Work happening now, and work done.
40 Live,
41 /// Crest ink of the live action verb sweep.
42 LivePeak,
43 /// Needs you.
44 Attention,
45 /// Failed or destructive.
46 Danger,
47 /// Ink one step quieter than `Muted`: asides and placeholders. Derived: `muted_foreground` receded toward `background` until it just holds 4.5:1 on every ground.
48 Hint,
49 /// The quietest ink: disabled and decorative words, never the only carrier of meaning.
50 Dim,
51 /// Ground behind an added line, under `Foreground` ink: the `diff_add` token.
52 DiffAddedTint,
53 /// Ground behind a removed line, under `Foreground` ink: the `diff_remove` token.
54 DiffRemovedTint,
55 }
56
57 impl Role {
58 pub const COUNT: usize = 21;
59 pub const ALL: [Role; Self::COUNT] = [
60 Role::Sidebar,
61 Role::Background,
62 Role::Surface,
63 Role::Hover,
64 Role::Selected,
65 Role::Foreground,
66 Role::Subagent,
67 Role::Muted,
68 Role::Border,
69 Role::BorderStrong,
70 Role::Primary,
71 Role::PrimaryForeground,
72 Role::Accent,
73 Role::Live,
74 Role::LivePeak,
75 Role::Attention,
76 Role::Danger,
77 Role::Hint,
78 Role::Dim,
79 Role::DiffAddedTint,
80 Role::DiffRemovedTint,
81 ];
82
83 /// The `tokens.json` key this role reads, or `None` for a role the
84 /// kit derives from other tokens ([`Role::is_derived`]).
85 #[must_use]
86 pub const fn token_name(self) -> Option<&'static str> {
87 match self {
88 Role::Sidebar => Some("sidebar"),
89 Role::Background => Some("background"),
90 Role::Surface => Some("surface"),
91 Role::Hover => Some("hover"),
92 Role::Selected => Some("selected"),
93 Role::Foreground => Some("foreground"),
94 Role::Subagent => Some("subagent"),
95 Role::Muted => Some("muted_foreground"),
96 Role::Border => Some("border"),
97 Role::BorderStrong => Some("border_strong"),
98 Role::Primary => Some("primary"),
99 Role::PrimaryForeground => Some("primary_foreground"),
100 Role::Accent => Some("accent"),
101 Role::Live => Some("live"),
102 Role::LivePeak => Some("live_peak"),
103 Role::Attention => Some("attention"),
104 Role::Danger => Some("danger"),
105 Role::Hint => None,
106 Role::Dim => Some("disabled"),
107 Role::DiffAddedTint => Some("diff_add"),
108 Role::DiffRemovedTint => Some("diff_remove"),
109 }
110 }
111
112 /// Position in [`Role::ALL`] and in the color tables.
113 #[must_use]
114 pub const fn index(self) -> usize {
115 self as usize
116 }
117
118 /// Whether the kit derives this role from other tokens, because
119 /// `tokens.json` does not name it.
120 #[must_use]
121 pub const fn is_derived(self) -> bool {
122 matches!(self, Role::Hint)
123 }
124 }
125
126 /// dark token colors, `0xRRGGBB`, indexed by [`Role::index`].
127 pub(crate) const DARK: [u32; Role::COUNT] = [
128 0x0f131c, // Sidebar
129 0x05070b, // Background
130 0x080b11, // Surface
131 0x202938, // Hover
132 0x18202e, // Selected
133 0xedf1f7, // Foreground
134 0xbccad9, // Subagent
135 0xb2bfcd, // Muted
136 0x263040, // Border
137 0x8a97a8, // BorderStrong
138 0x0b4cc4, // Primary
139 0xffffff, // PrimaryForeground
140 0x94beff, // Accent
141 0x7fdfc8, // Live
142 0xe3fcf4, // LivePeak
143 0xf0be82, // Attention
144 0xf4a8a0, // Danger
145 0x8c97a2, // Hint
146 0x828f9e, // Dim
147 0x1d352a, // DiffAddedTint
148 0x422b2c, // DiffRemovedTint
149 ];
150
151 /// dark xterm 256-color indices (16..=255 only; 0..=15 belong to the
152 /// user's profile). Nearest index, except where contrast needed a move:
153 /// - dark hint: 246 -> 247 (nearest failed its contrast floor)
154 /// - dark border_strong: 103 -> 246 (nearest shared an index with another ink)
155 /// - dark diff_add: 235 -> 23 (the cube has no tint this faint; nearest index that keeps the tint's hue)
156 /// - dark diff_remove: 236 -> 52 (the cube has no tint this faint; nearest index that keeps the tint's hue)
157 pub(crate) const DARK_256: [u8; Role::COUNT] = [
158 233, // Sidebar
159 232, // Background
160 232, // Surface
161 236, // Hover
162 235, // Selected
163 255, // Foreground
164 152, // Subagent
165 146, // Muted
166 236, // Border
167 246, // BorderStrong
168 26, // Primary
169 231, // PrimaryForeground
170 111, // Accent
171 116, // Live
172 195, // LivePeak
173 216, // Attention
174 217, // Danger
175 247, // Hint
176 103, // Dim
177 23, // DiffAddedTint
178 52, // DiffRemovedTint
179 ];
180
181 /// light token colors, `0xRRGGBB`, indexed by [`Role::index`].
182 pub(crate) const LIGHT: [u32; Role::COUNT] = [
183 0xfcfdfe, // Sidebar
184 0xf4f7fc, // Background
185 0xfefeff, // Surface
186 0xe2eaf4, // Hover
187 0xd6e1f0, // Selected
188 0x162230, // Foreground
189 0x374553, // Subagent
190 0x45515f, // Muted
191 0xd5dde8, // Border
192 0x687381, // BorderStrong
193 0x0b4cc4, // Primary
194 0xffffff, // PrimaryForeground
195 0x1552c6, // Accent
196 0x146857, // Live
197 0x0b3f33, // LivePeak
198 0x7b4b06, // Attention
199 0xa42531, // Danger
200 0x586370, // Hint
201 0x68727f, // Dim
202 0xd2ebdd, // DiffAddedTint
203 0xf8e1dd, // DiffRemovedTint
204 ];
205
206 /// light xterm 256-color indices (16..=255 only; 0..=15 belong to the
207 /// user's profile). Nearest index, except where contrast needed a move:
208 /// - light accent: 26 -> 25 (nearest failed its contrast floor)
209 /// - light live_peak: 235 -> 236 (nearest shared an index with another ink)
210 /// - light attention: 94 -> 58 (nearest failed its contrast floor)
211 /// - light hint: 241 -> 59 (nearest failed its contrast floor)
212 /// - light border_strong: 243 -> 242 (nearest shared an index with another ink)
213 /// - light diff_add: 253 -> 158 (the cube has no tint this faint; nearest index that keeps the tint's hue)
214 /// - light diff_remove: 224 -> 224 (the cube has no tint this faint; nearest index that keeps the tint's hue)
215 pub(crate) const LIGHT_256: [u8; Role::COUNT] = [
216 231, // Sidebar
217 231, // Background
218 231, // Surface
219 255, // Hover
220 189, // Selected
221 235, // Foreground
222 238, // Subagent
223 239, // Muted
224 253, // Border
225 242, // BorderStrong
226 26, // Primary
227 231, // PrimaryForeground
228 25, // Accent
229 23, // Live
230 236, // LivePeak
231 58, // Attention
232 125, // Danger
233 59, // Hint
234 243, // Dim
235 158, // DiffAddedTint
236 224, // DiffRemovedTint
237 ];
238
239 /// The blue ombre (`Ground::Ocean`): the dark table with its grounds and
240 /// quiet line tinted 0.5 toward `LOGO_BOTTOM` at their own luminance,
241 /// so every contrast floor holds. The diff tints are re-mixed over its own
242 /// background. Truecolor only; 256 colors use `DARK_256`.
243 pub(crate) const OCEAN: [u32; Role::COUNT] = [
244 0x031131, // Sidebar
245 0x01061a, // Background
246 0x010923, // Surface
247 0x0d2656, // Hover
248 0x071e48, // Selected
249 0xedf1f7, // Foreground
250 0xbccad9, // Subagent
251 0xb2bfcd, // Muted
252 0x112d62, // Border
253 0x8a97a8, // BorderStrong
254 0x0b4cc4, // Primary
255 0xffffff, // PrimaryForeground
256 0x94beff, // Accent
257 0x7fdfc8, // Live
258 0xe3fcf4, // LivePeak
259 0xf0be82, // Attention
260 0xf4a8a0, // Danger
261 0x8c97a2, // Hint
262 0x828f9e, // Dim
263 0x152936, // DiffAddedTint
264 0x28202f, // DiffRemovedTint
265 ];
266
266 lines RUST