forge
Explore
Log in

Don't you dare go Hollow

forge

Clone
★ 0

0 watching0 forksRustAGPL-3.07.1 MiB490f099Tahinli7 hours ago322 commits

accent_palette.rs481 lines, 13.8 KiBHistoryRawDownload
1//! Accent palettes: the one place where the accent colours are defined. Nothing else holds
2//! these values. `build.rs` reads this file to generate the accent stylesheet, and the app
3//! reads it to resolve a stored id and to list the settings picker. Keep it pure data: no `use`,
4//! no crate items, no external crates.
5
6/// The colour tokens one palette sets in one theme. The values are CSS colours; `TOKEN_VARS`
7/// names the custom property each field becomes.
8pub struct Tokens {
9 pub accent: &'static str,
10 pub accent_ink: &'static str,
11 pub accent_soft: &'static str,
12 pub accent_text: &'static str,
13 pub focus: &'static str,
14 pub public_bg: &'static str,
15 pub public_text: &'static str,
16 pub note: &'static str,
17 pub hunk_bg: &'static str,
18 pub hunk_text: &'static str,
19}
20
21/// One accent colour: its id (the stored value and the `data-accent` attribute), and the tokens
22/// used in light and dark themes.
23pub struct Palette {
24 pub id: &'static str,
25 pub light: Tokens,
26 pub dark: Tokens,
27}
28
29/// The palette used when none is stored, and for anonymous visitors. It must be `PALETTES[0]`.
30pub const DEFAULT: &str = "sage";
31
32/// One token: the custom property it becomes and the field of `Tokens` that holds its value.
33pub struct TokenVar {
34 pub name: &'static str,
35 pub value: fn(&Tokens) -> &'static str,
36}
37
38/// Every token a palette sets.
39pub const TOKEN_VARS: &[TokenVar] = &[
40 TokenVar {
41 name: "--accent",
42 value: |t| t.accent,
43 },
44 TokenVar {
45 name: "--accent-ink",
46 value: |t| t.accent_ink,
47 },
48 TokenVar {
49 name: "--accent-soft",
50 value: |t| t.accent_soft,
51 },
52 TokenVar {
53 name: "--accent-text",
54 value: |t| t.accent_text,
55 },
56 TokenVar {
57 name: "--focus",
58 value: |t| t.focus,
59 },
60 TokenVar {
61 name: "--public-bg",
62 value: |t| t.public_bg,
63 },
64 TokenVar {
65 name: "--public-text",
66 value: |t| t.public_text,
67 },
68 TokenVar {
69 name: "--note",
70 value: |t| t.note,
71 },
72 TokenVar {
73 name: "--hunk-bg",
74 value: |t| t.hunk_bg,
75 },
76 TokenVar {
77 name: "--hunk-text",
78 value: |t| t.hunk_text,
79 },
80];
81
82/// Every accent colour on offer, in the order the picker lists them. The heatmap levels are not
83/// here: style/_heatmap.scss mixes them from `--accent`/`--accent-ink` and the base's surface,
84/// so they follow every accent and base.
85pub const PALETTES: &[Palette] = &[
86 // Sage: the original forge colour.
87 Palette {
88 id: "sage",
89 light: Tokens {
90 accent: "#5E7D63",
91 accent_ink: "#4A6750",
92 accent_soft: "#E4ECE3",
93 accent_text: "#FFFFFF",
94 focus: "#4A6750",
95 public_bg: "#E4ECE3",
96 public_text: "#4A6750",
97 note: "#4A6750",
98 hunk_bg: "#EDF1EB",
99 hunk_text: "#3F5F46",
100 },
101 // Dark is matcha: a yellow-green fill with dark text, which reads cleaner on slate than
102 // the grey-green sage did.
103 dark: Tokens {
104 accent: "#93A663",
105 accent_ink: "#BCCB8F",
106 accent_soft: "#283020",
107 accent_text: "#151A0B",
108 focus: "#BCCB8F",
109 public_bg: "#283020",
110 public_text: "#D3DDB4",
111 note: "#BCCB8F",
112 hunk_bg: "#1D2219",
113 hunk_text: "#B3C385",
114 },
115 },
116 // Ember: iron at working heat, a soft red-orange; copper in light.
117 Palette {
118 id: "ember",
119 light: Tokens {
120 accent: "#B44D1A",
121 accent_ink: "#8F3A12",
122 accent_soft: "#F8E9DF",
123 accent_text: "#FFFFFF",
124 focus: "#8F3A12",
125 public_bg: "#F9E4D6",
126 public_text: "#8F3A12",
127 note: "#8F3A12",
128 hunk_bg: "#FBF0E8",
129 hunk_text: "#883611",
130 },
131 dark: Tokens {
132 accent: "#E8894A",
133 accent_ink: "#FFB27A",
134 accent_soft: "#3A2518",
135 accent_text: "#1A0E06",
136 focus: "#FFB27A",
137 public_bg: "#3A2416",
138 public_text: "#FFC69A",
139 note: "#FFB27A",
140 hunk_bg: "#24180F",
141 hunk_text: "#F0A066",
142 },
143 },
144 // Blue, clear and cool.
145 Palette {
146 id: "ocean",
147 light: Tokens {
148 accent: "#467799",
149 accent_ink: "#336180",
150 accent_soft: "#DEECF6",
151 accent_text: "#FFFFFF",
152 focus: "#336180",
153 public_bg: "#DEECF6",
154 public_text: "#336180",
155 note: "#336180",
156 hunk_bg: "#E9F1F7",
157 hunk_text: "#2B5977",
158 },
159 dark: Tokens {
160 accent: "#86B9DD",
161 accent_ink: "#9FCBEA",
162 accent_soft: "#1C2F3C",
163 accent_text: "#061118",
164 focus: "#86B9DD",
165 public_bg: "#1C2F3C",
166 public_text: "#9FCBEA",
167 note: "#9FCBEA",
168 hunk_bg: "#1A252E",
169 hunk_text: "#86B9DD",
170 },
171 },
172 // Violet with a soft, muted edge.
173 Palette {
174 id: "plum",
175 light: Tokens {
176 accent: "#7B699C",
177 accent_ink: "#645482",
178 accent_soft: "#EBE7F5",
179 accent_text: "#FFFFFF",
180 focus: "#645482",
181 public_bg: "#EBE7F5",
182 public_text: "#645482",
183 note: "#645482",
184 hunk_bg: "#F0EEF7",
185 hunk_text: "#5C4B79",
186 },
187 dark: Tokens {
188 accent: "#BBA9E0",
189 accent_ink: "#CBBCEB",
190 accent_soft: "#2F283C",
191 accent_text: "#110D18",
192 focus: "#BBA9E0",
193 public_bg: "#2F283C",
194 public_text: "#CBBCEB",
195 note: "#CBBCEB",
196 hunk_bg: "#25212E",
197 hunk_text: "#BBA9E0",
198 },
199 },
200 // Dusty pink, warm and quiet.
201 Palette {
202 id: "rose",
203 light: Tokens {
204 accent: "#A25E6F",
205 accent_ink: "#864958",
206 accent_soft: "#F6E4E8",
207 accent_text: "#FFFFFF",
208 focus: "#864958",
209 public_bg: "#F6E4E8",
210 public_text: "#864958",
211 note: "#864958",
212 hunk_bg: "#F7ECEE",
213 hunk_text: "#7D4050",
214 },
215 dark: Tokens {
216 accent: "#E79DAD",
217 accent_ink: "#F3B2C0",
218 accent_soft: "#3E242A",
219 accent_text: "#190A0E",
220 focus: "#E79DAD",
221 public_bg: "#3E242A",
222 public_text: "#F3B2C0",
223 note: "#F3B2C0",
224 hunk_bg: "#2F1E22",
225 hunk_text: "#E79DAD",
226 },
227 },
228];
229
230/// The neutral colour tokens one base sets in one theme. The values are CSS colours;
231/// `BASE_TOKEN_VARS` names the custom property each field becomes.
232pub struct BaseTokens {
233 pub bg: &'static str,
234 pub surface: &'static str,
235 pub surface_2: &'static str,
236 pub text: &'static str,
237 pub text_2: &'static str,
238 pub muted: &'static str,
239 pub border: &'static str,
240 pub border_strong: &'static str,
241 pub code_bg: &'static str,
242 pub private_bg: &'static str,
243 pub private_text: &'static str,
244 pub ln_text: &'static str,
245}
246
247/// One base: the neutral backgrounds, surfaces and text. Its id is the stored value and the
248/// attribute value, and the tokens are used in light and dark themes.
249pub struct Base {
250 pub id: &'static str,
251 pub light: BaseTokens,
252 pub dark: BaseTokens,
253}
254
255/// The base used when none is stored, and for anonymous visitors. It must be `BASES[0]`.
256pub const BASE_DEFAULT: &str = "ink";
257
258/// One base token: the custom property it becomes and the field of `BaseTokens` that holds its
259/// value.
260pub struct BaseTokenVar {
261 pub name: &'static str,
262 pub value: fn(&BaseTokens) -> &'static str,
263}
264
265/// Every neutral token a base sets. The stylesheet keeps no copy of these.
266pub const BASE_TOKEN_VARS: &[BaseTokenVar] = &[
267 BaseTokenVar {
268 name: "--bg",
269 value: |t| t.bg,
270 },
271 BaseTokenVar {
272 name: "--surface",
273 value: |t| t.surface,
274 },
275 BaseTokenVar {
276 name: "--surface-2",
277 value: |t| t.surface_2,
278 },
279 BaseTokenVar {
280 name: "--text",
281 value: |t| t.text,
282 },
283 BaseTokenVar {
284 name: "--text-2",
285 value: |t| t.text_2,
286 },
287 BaseTokenVar {
288 name: "--muted",
289 value: |t| t.muted,
290 },
291 BaseTokenVar {
292 name: "--border",
293 value: |t| t.border,
294 },
295 BaseTokenVar {
296 name: "--border-strong",
297 value: |t| t.border_strong,
298 },
299 BaseTokenVar {
300 name: "--code-bg",
301 value: |t| t.code_bg,
302 },
303 BaseTokenVar {
304 name: "--private-bg",
305 value: |t| t.private_bg,
306 },
307 BaseTokenVar {
308 name: "--private-text",
309 value: |t| t.private_text,
310 },
311 BaseTokenVar {
312 name: "--ln-text",
313 value: |t| t.ln_text,
314 },
315];
316
317/// Every base on offer, in the order the picker lists them: the default first, then each in the
318/// column of the accent of its hue (Anvil under Ember, Dusk under Ocean, Heather under Plum, Blush
319/// under Rose). Ink's faint olive tint sits with Sage.
320pub const BASES: &[Base] = &[
321 // Ink: crisp white in light, near-black in dark.
322 Base {
323 id: "ink",
324 light: BaseTokens {
325 bg: "#FCFCFB",
326 surface: "#FFFFFF",
327 surface_2: "#F2F2F0",
328 text: "#111111",
329 text_2: "#333333",
330 muted: "#5F5F5C",
331 border: "#E3E3E0",
332 border_strong: "#C9C9C5",
333 code_bg: "#F2F2F0",
334 private_bg: "#F2F2F0",
335 private_text: "#333333",
336 ln_text: "#5F5F5C",
337 },
338 dark: BaseTokens {
339 bg: "#000000",
340 surface: "#0B0B0B",
341 surface_2: "#141414",
342 text: "#F2F2F0",
343 text_2: "#CFCFCC",
344 muted: "#9C9C98",
345 border: "#242424",
346 border_strong: "#353535",
347 code_bg: "#141414",
348 private_bg: "#141414",
349 private_text: "#CFCFCC",
350 ln_text: "#9C9C98",
351 },
352 },
353 // Anvil: warm soot and cooled steel in dark, ash in light.
354 Base {
355 id: "anvil",
356 light: BaseTokens {
357 bg: "#F6F5F3",
358 surface: "#FFFFFF",
359 surface_2: "#EFEEEB",
360 text: "#191816",
361 text_2: "#3F3C37",
362 muted: "#5F5C56",
363 border: "#E3E1DD",
364 border_strong: "#C9C6BF",
365 code_bg: "#EFEEEB",
366 private_bg: "#EFEEEB",
367 private_text: "#3F3C37",
368 ln_text: "#5F5C56",
369 },
370 dark: BaseTokens {
371 bg: "#141312",
372 surface: "#1D1C1A",
373 surface_2: "#292724",
374 text: "#F2F0EB",
375 text_2: "#D6D2CA",
376 muted: "#AAA69D",
377 border: "#2F2D2A",
378 border_strong: "#55524C",
379 code_bg: "#292724",
380 private_bg: "#292724",
381 private_text: "#D6D2CA",
382 ln_text: "#AAA69D",
383 },
384 },
385 // Dusk: cool blue-grey, a deeper blue-tinted neutral.
386 Base {
387 id: "dusk",
388 light: BaseTokens {
389 bg: "#E9EEF5",
390 surface: "#F8FAFD",
391 surface_2: "#DCE3EE",
392 text: "#161F2D",
393 text_2: "#303D52",
394 muted: "#56637A",
395 border: "#CBD5E3",
396 border_strong: "#AEBBCE",
397 code_bg: "#DCE3EE",
398 private_bg: "#DCE3EE",
399 private_text: "#303D52",
400 ln_text: "#505D73",
401 },
402 dark: BaseTokens {
403 bg: "#0B1019",
404 surface: "#121927",
405 surface_2: "#1A2332",
406 text: "#E0E7F1",
407 text_2: "#BFC9D9",
408 muted: "#8F9BB0",
409 border: "#222D3E",
410 border_strong: "#303D51",
411 code_bg: "#1A2332",
412 private_bg: "#1A2332",
413 private_text: "#BFC9D9",
414 ln_text: "#8F9BB0",
415 },
416 },
417 // Heather: violet-grey, Dusk turned to the hue of Plum.
418 Base {
419 id: "heather",
420 light: BaseTokens {
421 bg: "#EEECF4",
422 surface: "#FAF9FD",
423 surface_2: "#E4E0EC",
424 text: "#211B2B",
425 text_2: "#40384F",
426 muted: "#665E77",
427 border: "#D6D1E1",
428 border_strong: "#BDB6CB",
429 code_bg: "#E4E0EC",
430 private_bg: "#E4E0EC",
431 private_text: "#40384F",
432 ln_text: "#605870",
433 },
434 dark: BaseTokens {
435 bg: "#110E18",
436 surface: "#1B1625",
437 surface_2: "#251F30",
438 text: "#E8E4F0",
439 text_2: "#CAC5D7",
440 muted: "#9D96AD",
441 border: "#2F293B",
442 border_strong: "#3F384E",
443 code_bg: "#251F30",
444 private_bg: "#251F30",
445 private_text: "#CAC5D7",
446 ln_text: "#9D96AD",
447 },
448 },
449 // Blush: rose-grey, Dusk turned to the hue of Rose.
450 Base {
451 id: "blush",
452 light: BaseTokens {
453 bg: "#F5EBEC",
454 surface: "#FDF9F9",
455 surface_2: "#EDDEE0",
456 text: "#2B191C",
457 text_2: "#4F3438",
458 muted: "#77595E",
459 border: "#E2CED1",
460 border_strong: "#CCB2B6",
461 code_bg: "#EDDEE0",
462 private_bg: "#EDDEE0",
463 private_text: "#4F3438",
464 ln_text: "#715358",
465 },
466 dark: BaseTokens {
467 bg: "#180C0E",
468 surface: "#251316",
469 surface_2: "#301C20",
470 text: "#F0E2E4",
471 text_2: "#D8C2C5",
472 muted: "#AE9296",
473 border: "#3C2529",
474 border_strong: "#4E3438",
475 code_bg: "#301C20",
476 private_bg: "#301C20",
477 private_text: "#D8C2C5",
478 ln_text: "#AE9296",
479 },
480 },
481];