steid

@jamesgill /

steid/styles.css
CSS15.4 KBCode·Blame·History·Raw
1/* Steid's theme.
2 Started from Topcoat's `neutral` theme and retuned; see plans/ui.md.
3
4 The theme is a small set of design tokens. Components refer to tokens only,
5 never to raw colors, so the whole product restyles by editing `:root` and
6 `.dark` below. A component that hardcodes a color is a bug — it will not
7 follow a palette change and it will not adapt to the color scheme.
8
9 --background the page background
10 --surface raised panels: cards, menus, flash messages
11 --foreground text and iconography on the background
12 --muted-foreground secondary text: captions, descriptions, placeholders
13 --primary the emphasis color: primary actions, selection, links
14 --primary-foreground text on a primary-filled surface
15 --success confirmations, and git additions
16 --success-foreground text on a success-filled surface
17 --warning caution, and git modifications
18 --warning-foreground text on a warning-filled surface
19 --destructive destructive actions, errors, and git deletions
20 --destructive-foreground text on a destructive-filled surface
21 --merged a pull request that landed
22 --merged-foreground text on a merged-filled surface
23 --border hairline borders and dividers
24 --ring the focus ring
25 --shadow-xs a subtle shadow for controls: buttons, inputs
26 --shadow-sm a shadow for raised surfaces: cards, menus
27
28 Syntax highlighting adds a --syntax-* family, derived from the same palette and
29 mapped onto the highlighter's classes at the bottom of this file.
30
31 Interactive states (hover, press) have no tokens of their own: components
32 derive them by applying the fill or foreground color at reduced opacity,
33 which adapts to both color schemes automatically.
34
35 Steid is dark-first — the layout sets `class="dark"` on <html>. Light mode
36 is supported and secondary. */
37
38@import "tailwindcss";
39
40/* Scan the project's Rust sources for the Tailwind classes they use. This
41 file is installed at the project root, so `./src` is the crate's source. */
42@source "./src/**/*.rs";
43
44/* Dark mode is opted into by putting the `dark` class on an ancestor,
45 typically <html>. */
46@custom-variant dark (&:is(.dark *));
47
48/* Expose the tokens as Tailwind utilities (`bg-background`, `text-primary`,
49 `border-border`, ...). The indirection through plain variables on `:root`
50 and `.dark` is what lets the values swap when the color scheme changes. */
51@theme inline {
52 --font-sans: "Geist", ui-sans-serif, system-ui, sans-serif;
53 /* Paths, commit hashes, branch names, and code. */
54 --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", monospace;
55 --color-background: var(--background);
56 --color-surface: var(--surface);
57 --color-foreground: var(--foreground);
58 --color-muted-foreground: var(--muted-foreground);
59 --color-primary: var(--primary);
60 --color-primary-foreground: var(--primary-foreground);
61 --color-success: var(--success);
62 --color-success-foreground: var(--success-foreground);
63 --color-warning: var(--warning);
64 --color-warning-foreground: var(--warning-foreground);
65 --color-destructive: var(--destructive);
66 --color-destructive-foreground: var(--destructive-foreground);
67 --color-merged: var(--merged);
68 --color-merged-foreground: var(--merged-foreground);
69 --color-border: var(--border);
70 --color-ring: var(--ring);
71 --shadow-xs: var(--shadow-xs);
72 --shadow-sm: var(--shadow-sm);
73}
74
75/* Light mode. Secondary, but it should not look like an afterthought. */
76:root {
77 --background: oklch(0.99 0.003 260);
78 --surface: oklch(1 0 0);
79 --foreground: oklch(0.24 0.012 260);
80 --muted-foreground: oklch(0.51 0.014 260);
81 --primary: oklch(0.5 0.18 250);
82 --primary-foreground: oklch(0.99 0.003 260);
83 --success: oklch(0.52 0.15 145);
84 --success-foreground: oklch(0.99 0.01 145);
85 --warning: oklch(0.62 0.14 85);
86 --warning-foreground: oklch(0.99 0.01 85);
87 --destructive: oklch(0.55 0.2 27);
88 --destructive-foreground: oklch(0.99 0.012 27);
89 /* A pull request that landed. The sixth semantic colour, and the one state the
90 theme's five could not say: "merged" and "closed" are opposite outcomes, and a
91 single muted grey for both would report a branch as rejected when it shipped.
92 Purple is git's own convention for it, and it is far enough from `--primary`
93 that a merged badge cannot read as an action. Kept in step with
94 `--label-purple`, which is the same hue at label chroma. */
95 --merged: oklch(0.5 0.19 300);
96 --merged-foreground: oklch(0.99 0.012 300);
97 --border: oklch(0.9 0.008 260);
98 --ring: oklch(0.5 0.18 250);
99 --shadow-xs: 0 1px 2px oklch(0.24 0.02 260 / 12%);
100 --shadow-sm:
101 0 1px 2px oklch(0.24 0.02 260 / 10%),
102 0 2px 8px -2px oklch(0.24 0.02 260 / 9%);
103
104 --syntax-comment: oklch(0.55 0.015 260);
105 --syntax-punctuation: oklch(0.46 0.015 260);
106 --syntax-variable: oklch(0.3 0.014 260);
107 --syntax-type: oklch(0.45 0.09 195);
108 --syntax-function: oklch(0.48 0.15 250);
109 --syntax-constant: oklch(0.5 0.12 62);
110 --syntax-string: oklch(0.45 0.12 150);
111 --syntax-keyword: oklch(0.45 0.17 300);
112 --syntax-heading: oklch(0.42 0.16 250);
113}
114
115/* Dark mode. The primary surface for this product. */
116.dark {
117 --background: oklch(0.16 0.02 260);
118 --surface: oklch(0.2 0.02 260);
119 --foreground: oklch(0.9 0.01 260);
120 --muted-foreground: oklch(0.66 0.014 260);
121 --primary: oklch(0.65 0.15 250);
122 --primary-foreground: oklch(0.16 0.02 260);
123 --success: oklch(0.7 0.17 145);
124 --success-foreground: oklch(0.16 0.02 145);
125 --warning: oklch(0.8 0.15 85);
126 --warning-foreground: oklch(0.16 0.02 85);
127 --destructive: oklch(0.65 0.2 25);
128 --destructive-foreground: oklch(0.14 0.02 25);
129 --merged: oklch(0.68 0.17 300);
130 --merged-foreground: oklch(0.15 0.02 300);
131 --border: oklch(0.3 0.012 260);
132 --ring: oklch(0.65 0.15 250);
133 /* Light-mode shadows disappear on a dark background, so these are deeper. */
134 --shadow-xs: 0 1px 2px oklch(0 0 0 / 35%);
135 --shadow-sm: 0 1px 2px oklch(0 0 0 / 35%), 0 2px 8px -2px oklch(0 0 0 / 30%);
136
137 --syntax-comment: oklch(0.6 0.014 260);
138 --syntax-punctuation: oklch(0.72 0.014 260);
139 --syntax-variable: oklch(0.86 0.02 260);
140 --syntax-type: oklch(0.82 0.08 195);
141 --syntax-function: oklch(0.78 0.11 240);
142 --syntax-constant: oklch(0.82 0.11 70);
143 --syntax-string: oklch(0.78 0.12 150);
144 --syntax-keyword: oklch(0.75 0.12 300);
145 --syntax-heading: oklch(0.75 0.13 250);
146}
147
148@layer base {
149 body {
150 @apply bg-background font-sans text-foreground;
151 }
152}
153
154/* Syntax highlighting.
155 `infrastructure/highlight.rs` emits classes, never inline colors, so the theme
156 lives here with everything else and follows the color scheme. Tailwind never sees
157 these class names — the markup is generated, not written in `src/` — so this is
158 plain CSS against the tokens above, as ui.md requires.
159
160 The classes are the *atoms* of a TextMate scope, flattened and prefixed: the scope
161 `storage.type.function.rust` becomes `class="hl-storage hl-type hl-function hl-rust"`.
162 Atoms are therefore not positional — `hl-function` is on `meta.function`, which
163 wraps a whole function body, as well as on the name itself — so a single-atom
164 selector is only safe for an atom that leads its scope. The rest are spelled out as
165 the compound they really are.
166
167 Order is load-bearing. Spans nest, so an inner span with two matching rules of equal
168 specificity takes the later one; `punctuation.definition.string` carries both
169 `hl-punctuation` and `hl-string`, and a quote should read as its string. Weakest
170 first, strongest last. */
171
172.hl-punctuation,
173.hl-keyword.hl-operator {
174 color: var(--syntax-punctuation);
175}
176
177.hl-variable,
178.hl-entity.hl-other.hl-attribute-name {
179 color: var(--syntax-variable);
180}
181
182.hl-entity.hl-name,
183.hl-support.hl-function {
184 color: var(--syntax-function);
185}
186
187.hl-entity.hl-name.hl-type,
188.hl-entity.hl-name.hl-class,
189.hl-entity.hl-name.hl-struct,
190.hl-entity.hl-name.hl-enum,
191.hl-entity.hl-name.hl-trait,
192.hl-entity.hl-name.hl-namespace,
193.hl-support.hl-type,
194.hl-support.hl-class {
195 color: var(--syntax-type);
196}
197
198.hl-constant,
199.hl-support.hl-constant {
200 color: var(--syntax-constant);
201}
202
203.hl-storage,
204.hl-keyword,
205.hl-entity.hl-name.hl-tag {
206 color: var(--syntax-keyword);
207}
208
209.hl-string {
210 color: var(--syntax-string);
211}
212
213/* Markdown and other markup: the source is read as prose, so structure carries the
214 color and the body stays at foreground. */
215.hl-markup.hl-heading {
216 color: var(--syntax-heading);
217 font-weight: 600;
218}
219
220.hl-markup.hl-raw {
221 color: var(--syntax-string);
222}
223
224.hl-markup.hl-underline.hl-link {
225 color: var(--syntax-function);
226}
227
228.hl-markup.hl-bold {
229 font-weight: 600;
230}
231
232.hl-markup.hl-italic {
233 font-style: italic;
234}
235
236/* Last, so a comment is a comment whatever it contains. */
237.hl-comment {
238 color: var(--syntax-comment);
239}
240
241.hl-invalid {
242 color: var(--destructive);
243}
244
245/* Unified diff rows.
246
247 Plain CSS rather than Tailwind utilities because these are theme tokens at
248 low alpha, and `color-mix` against a custom property is not something a
249 utility class can express. The alpha is the point: a tint has to sit under
250 text that stays readable in both color schemes, which a solid `--success`
251 or `--destructive` would not.
252
253 Never a raw color here — every value is a token mixed with transparency, so
254 the diff follows a palette change like everything else. The gutters take a
255 stronger mix than the line so the numbers stay legible against it. */
256.diff-line-add {
257 background-color: color-mix(in oklab, var(--success) 12%, transparent);
258}
259
260.diff-line-del {
261 background-color: color-mix(in oklab, var(--destructive) 12%, transparent);
262}
263
264.diff-gutter-add {
265 background-color: color-mix(in oklab, var(--success) 20%, transparent);
266}
267
268.diff-gutter-del {
269 background-color: color-mix(in oklab, var(--destructive) 20%, transparent);
270}
271
272/* A hunk header separates two parts of a file, so it reads as a rule rather
273 than as a change: no tint, a hairline above it, and muted text. */
274.diff-line-hunk td {
275 border-top: 1px solid var(--border);
276 padding-top: 0.25rem;
277 padding-bottom: 0.25rem;
278}
279
280.diff-line-hunk:first-child td {
281 border-top: 0;
282}
283
284/* Blame's age tint.
285
286 A hairline down the left of each run of lines, its opacity scaled by how
287 recently that commit touched the file relative to the file's own oldest and
288 newest. Five steps, deliberately faint: it should read as texture telling you
289 which end of a file is moving, not as a heat map with values to read off it.
290
291 Plain CSS rather than Tailwind because the colour is the primary token at a
292 fraction of an alpha, which is not a utility — and `color-mix` keeps it a
293 token, so it follows a palette change and both colour schemes. */
294.blame-age {
295 border-left: 2px solid transparent;
296}
297.blame-age-0 {
298 border-left-color: color-mix(in oklab, var(--primary) 5%, transparent);
299}
300.blame-age-1 {
301 border-left-color: color-mix(in oklab, var(--primary) 9%, transparent);
302}
303.blame-age-2 {
304 border-left-color: color-mix(in oklab, var(--primary) 14%, transparent);
305}
306.blame-age-3 {
307 border-left-color: color-mix(in oklab, var(--primary) 21%, transparent);
308}
309.blame-age-4 {
310 border-left-color: color-mix(in oklab, var(--primary) 30%, transparent);
311}
312
313/* Label pills.
314
315 A label's colour is one of eight palette *names*, never a hex value, so this
316 is where those names become colour — one pair of tokens per name, defined for
317 both colour schemes. A hex column in the database would follow neither a
318 palette change nor the colour scheme, and nothing would stop somebody picking
319 a value that is unreadable in one of them.
320
321 Plain CSS rather than Tailwind for the reason the diff rows are: the class on
322 a pill is built at render time (`label-` plus the colour's name), so Tailwind
323 never sees it in `src/` and would ship none of it. It is also a tint under
324 text that has to stay readable in both schemes, which `color-mix` expresses
325 and a utility class does not.
326
327 Each pair is a background at low chroma and a foreground with enough contrast
328 to read at `text-xs`. Light mode tints toward white and darkens the text; dark
329 mode does the opposite. Gray is the default and is deliberately the quietest:
330 the palette is for telling apart the few labels that matter. */
331:root {
332 --label-gray: oklch(0.55 0.02 260);
333 --label-red: oklch(0.55 0.19 27);
334 --label-orange: oklch(0.6 0.15 55);
335 --label-yellow: oklch(0.62 0.14 90);
336 --label-green: oklch(0.52 0.15 148);
337 --label-blue: oklch(0.52 0.17 250);
338 --label-purple: oklch(0.5 0.19 300);
339 --label-pink: oklch(0.56 0.19 350);
340
341 /* How much of the label colour the pill's background and border take. Split
342 out so the two schemes differ in one place rather than in sixteen rules. */
343 --label-fill: 12%;
344 --label-edge: 30%;
345 --label-ink: 100%;
346}
347
348.dark {
349 --label-gray: oklch(0.72 0.02 260);
350 --label-red: oklch(0.7 0.18 25);
351 --label-orange: oklch(0.76 0.14 60);
352 --label-yellow: oklch(0.83 0.14 92);
353 --label-green: oklch(0.75 0.16 148);
354 --label-blue: oklch(0.7 0.14 250);
355 --label-purple: oklch(0.72 0.15 300);
356 --label-pink: oklch(0.74 0.15 350);
357
358 --label-fill: 16%;
359 --label-edge: 38%;
360 --label-ink: 100%;
361}
362
363.label-pill {
364 display: inline-flex;
365 align-items: center;
366 max-width: 14rem;
367 overflow: hidden;
368 border: 1px solid transparent;
369 border-radius: 9999px;
370 padding: 0.0625rem 0.5rem;
371 font-size: 0.6875rem;
372 line-height: 1.25rem;
373 font-weight: 500;
374 white-space: nowrap;
375 text-overflow: ellipsis;
376 /* A pill is a filter link. It should not also announce itself as one with an
377 underline: the fill already says it is a thing you can press. */
378 text-decoration: none;
379 background-color: color-mix(in oklab, var(--label-tint) var(--label-fill), transparent);
380 border-color: color-mix(in oklab, var(--label-tint) var(--label-edge), transparent);
381 color: color-mix(in oklab, var(--label-tint) var(--label-ink), var(--foreground));
382}
383
384a.label-pill:hover {
385 border-color: color-mix(in oklab, var(--label-tint) 60%, transparent);
386}
387
388.label-gray {
389 --label-tint: var(--label-gray);
390}
391.label-red {
392 --label-tint: var(--label-red);
393}
394.label-orange {
395 --label-tint: var(--label-orange);
396}
397.label-yellow {
398 --label-tint: var(--label-yellow);
399}
400.label-green {
401 --label-tint: var(--label-green);
402}
403.label-blue {
404 --label-tint: var(--label-blue);
405}
406.label-purple {
407 --label-tint: var(--label-purple);
408}
409.label-pink {
410 --label-tint: var(--label-pink);
411}
412
413/* The swatch a colour is chosen with: a radio input drawn as the colour itself.
414
415 The input is hidden rather than removed, so it keeps its keyboard focus and
416 its label association; the ring is what says which one is chosen. Plain CSS
417 again, because `:has()` on a sibling radio is not a utility and because the
418 eight fills are the same generated names as above. */
419.label-swatch {
420 display: inline-flex;
421 cursor: pointer;
422 border-radius: 9999px;
423}
424
425.label-swatch input {
426 position: absolute;
427 width: 1px;
428 height: 1px;
429 opacity: 0;
430}
431
432.label-swatch span {
433 display: block;
434 width: 1.5rem;
435 height: 1.5rem;
436 border-radius: 9999px;
437 border: 1px solid color-mix(in oklab, var(--label-tint) var(--label-edge), transparent);
438 background-color: color-mix(in oklab, var(--label-tint) 55%, transparent);
439}
440
441.label-swatch:has(input:checked) span {
442 box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--label-tint);
443}
444
445.label-swatch:has(input:focus-visible) span {
446 box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--ring);
447}