@sckyzo/cosmos-theme 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,13 @@ All notable changes to `@sckyzo/cosmos-theme` are documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.3.0](https://github.com/SckyzO/cosmos/compare/@sckyzo/cosmos-theme@0.2.0...@sckyzo/cosmos-theme@0.3.0) (2026-10-27)
9
+
10
+
11
+ ### Features
12
+
13
+ * **theme:** always emit the colors the charts read ([38fed2a](https://github.com/SckyzO/cosmos/commit/38fed2a70a6f9729b856f8911cdcd104d360867f))
14
+
8
15
  ## [0.2.0](https://github.com/SckyzO/cosmos/compare/@sckyzo/cosmos-theme@0.1.0...@sckyzo/cosmos-theme@0.2.0) (2026-10-21)
9
16
 
10
17
 
package/README.md CHANGED
@@ -72,6 +72,37 @@ Every theme × accent pair meets WCAG AA for body text, links and white text on
72
72
  the accent. `pnpm --filter @sckyzo/cosmos-theme test` runs the contrast check
73
73
  (`scripts/check-contrast.mjs`) against the CSS files.
74
74
 
75
+ ## Focus indicator
76
+
77
+ Four Tailwind utilities, shipped with `@sckyzo/cosmos-theme/tailwind`, give
78
+ every control the same keyboard focus look: a **solid accent indicator** plus
79
+ the `--shadow-focus-ring` halo (12% of the accent). The halo alone is too faint
80
+ to count: the solid part is what reaches 3:1 against the surface (WCAG 1.4.11;
81
+ `brand-500` is checked on every theme × accent pair by `pnpm test`).
82
+
83
+ | Utility | Paints | For |
84
+ | --------------------------- | --------------------------- | --------------------------------------------------------------------- |
85
+ | `focus-indicator` | 2px `brand-500` ring + halo | buttons, links, toggles, tabs, menu items, cards… |
86
+ | `field-focus` | `brand-500` border + halo | text inputs, textarea, select and their wrappers |
87
+ | `field-focus-error` | `red-500` border + red halo | the same fields in error (`--shadow-focus-ring-error`) |
88
+ | `focus-indicator-on-accent` | 2px white ring, no halo | a control filled with `brand-500`, where the accent ring would vanish |
89
+
90
+ They hold no state: put the variant that fits in front of them.
91
+
92
+ ```html
93
+ <button class="focus-visible:focus-indicator">Save</button>
94
+ <input class="focus:field-focus border border-gray-200" />
95
+ <div class="focus-within:field-focus border border-gray-200"><input /></div>
96
+ <!-- a control drawn by a sibling of a visually hidden input -->
97
+ <input type="checkbox" class="peer sr-only" />
98
+ <span class="peer-focus-visible:focus-indicator"></span>
99
+ ```
100
+
101
+ There is no ring offset. Add `ring-inset` where an ancestor clips with
102
+ `overflow-hidden`, or a neighbour covers the outer ring. The utilities use
103
+ `outline-hidden`, so the indicator survives forced-colors mode, where box
104
+ shadows are not painted.
105
+
75
106
  ## Fonts & text size
76
107
 
77
108
  Two more settings on `<html>`, both optional:
@@ -103,13 +134,17 @@ Both attributes also work on an element below `<html>`, for one part of a page.
103
134
 
104
135
  See [`css/tailwind-tokens.css`](css/tailwind-tokens.css) for the full source.
105
136
 
137
+ The brand palette, the status colors and the semantic colors are always in the CSS (`@theme static`): Tailwind
138
+ only emits a theme variable that a utility uses, and the charts read these as plain `var(--color-…)`.
139
+
106
140
  Categories:
107
141
 
108
142
  - **Brand palette** : `--color-brand-25` to `--color-brand-950`
143
+ - **Chart series** : `--color-chart-2` to `--color-chart-8`, the series colors after the accent (the first series is `--color-brand-500`). Each accent lists its own seven, skipping the hues that look like it
109
144
  - **Semantic colors** : `--color-success-*`, `--color-error-*`, `--color-warning-*`
110
145
  - **Status** : `--color-status-{ok,warn,crit,unknown}`
111
146
  - **Typography** : `--font-sans` (Outfit), `--font-mono` (JetBrains Mono), `--text-2xs` (11px), `--text-3xs` (10px)
112
- - **Shadows** : `--shadow-card`, `--shadow-card-hover`
147
+ - **Shadows** : `--shadow-card`, `--shadow-card-hover`, `--shadow-focus-ring` and `--shadow-focus-ring-error` (the focus halos)
113
148
  - **Layout vars** (theme-aware): `--color-bg-{base,panel,elevated}`, `--color-text-{base,primary,secondary,muted}`, `--color-border`, `--color-accent`
114
149
  - **Code highlighting** (theme-aware): `--color-code-foreground` and `--color-code-token-*` (keyword, string, comment, constant, function, parameter, string-expression, punctuation, link, inserted, deleted, changed). The names match Shiki's CSS variables theme with `variablePrefix: '--color-code-'`. Each one keeps 4.5:1 on CodeBlock's background in all four themes (checked by `pnpm test`).
115
150
 
package/css/css-vars.css CHANGED
@@ -37,7 +37,7 @@
37
37
  --color-text-base: #101828;
38
38
  --color-text-primary: #101828;
39
39
  --color-text-secondary: #667085;
40
- --color-text-muted: #98a2b3;
40
+ --color-text-muted: #677185;
41
41
 
42
42
  /* ── Code ──────────────────────────────────────────────────────────────── */
43
43
  /* Syntax highlighting on CodeBlock (gray-50 / gray-900), read by Shiki's
@@ -58,6 +58,19 @@
58
58
 
59
59
  /* ── Accent ────────────────────────────────────────────────────────────── */
60
60
  --color-accent: var(--color-brand-500);
61
+
62
+ /* ── Chart series ──────────────────────────────────────────────────────── */
63
+ /* Series 2 to 8 of the charts, after the accent (series 1 is
64
+ * --color-brand-500, which the accents redefine). Each accent below lists its
65
+ * own seven: the hues that look like it are skipped and a reserve takes
66
+ * their place, so no series is mistaken for the accent. */
67
+ --color-chart-2: #06b6d4;
68
+ --color-chart-3: #8b5cf6;
69
+ --color-chart-4: #ec4899;
70
+ --color-chart-5: #64748b;
71
+ --color-chart-6: #f97316;
72
+ --color-chart-7: #14b8a6;
73
+ --color-chart-8: #84cc16;
61
74
  }
62
75
 
63
76
  /* ── Themes ────────────────────────────────────────────────────────────── */
@@ -72,7 +85,7 @@
72
85
  --color-text-base: #1e1711;
73
86
  --color-text-primary: #1e1711;
74
87
  --color-text-secondary: #746656;
75
- --color-text-muted: #a39684;
88
+ --color-text-muted: #7a6c5b;
76
89
 
77
90
  /* ── Code ──────────────────────────────────────────────────────────────── */
78
91
  /* Syntax highlighting on CodeBlock (gray-50 / gray-900), read by Shiki's
@@ -155,7 +168,7 @@
155
168
  --color-text-base: #e4e7ec;
156
169
  --color-text-primary: #fff;
157
170
  --color-text-secondary: #98a2b3;
158
- --color-text-muted: #667085;
171
+ --color-text-muted: #8792a5;
159
172
 
160
173
  /* ── Code ──────────────────────────────────────────────────────────────── */
161
174
  /* Syntax highlighting on CodeBlock (gray-50 / gray-900), read by Shiki's
@@ -192,6 +205,13 @@
192
205
  --color-brand-800: #2f25ab;
193
206
  --color-brand-900: #24257a;
194
207
  --color-brand-950: #160b63;
208
+ --color-chart-2: #06b6d4;
209
+ --color-chart-3: #ec4899;
210
+ --color-chart-4: #64748b;
211
+ --color-chart-5: #f97316;
212
+ --color-chart-6: #14b8a6;
213
+ --color-chart-7: #84cc16;
214
+ --color-chart-8: #d946ef;
195
215
  }
196
216
 
197
217
  [data-accent='violet'] {
@@ -201,12 +221,19 @@
201
221
  --color-brand-200: #d8ceff;
202
222
  --color-brand-300: #c0abff;
203
223
  --color-brand-400: #a57eff;
204
- --color-brand-500: #8745f1;
224
+ --color-brand-500: #8a49f5;
205
225
  --color-brand-600: #752cdb;
206
226
  --color-brand-700: #6508c6;
207
227
  --color-brand-800: #5200a4;
208
228
  --color-brand-900: #3f097e;
209
229
  --color-brand-950: #2b005b;
230
+ --color-chart-2: #06b6d4;
231
+ --color-chart-3: #ec4899;
232
+ --color-chart-4: #64748b;
233
+ --color-chart-5: #f97316;
234
+ --color-chart-6: #14b8a6;
235
+ --color-chart-7: #84cc16;
236
+ --color-chart-8: #3b82f6;
210
237
  }
211
238
 
212
239
  [data-accent='purple'] {
@@ -216,7 +243,7 @@
216
243
  --color-brand-200: #f0c2ff;
217
244
  --color-brand-300: #e696ff;
218
245
  --color-brand-400: #d55bf8;
219
- --color-brand-500: #ad2ecf;
246
+ --color-brand-500: #b234d4;
220
247
  --color-brand-600: #990aba;
221
248
  --color-brand-700: #81019e;
222
249
  --color-brand-800: #690181;
@@ -231,12 +258,19 @@
231
258
  --color-brand-200: #ffc3d2;
232
259
  --color-brand-300: #ff96b4;
233
260
  --color-brand-400: #ff4e90;
234
- --color-brand-500: #d4166d;
261
+ --color-brand-500: #d81e70;
235
262
  --color-brand-600: #b8005c;
236
263
  --color-brand-700: #9b004c;
237
264
  --color-brand-800: #7f013d;
238
265
  --color-brand-900: #64002f;
239
266
  --color-brand-950: #45001e;
267
+ --color-chart-2: #06b6d4;
268
+ --color-chart-3: #8b5cf6;
269
+ --color-chart-4: #64748b;
270
+ --color-chart-5: #f97316;
271
+ --color-chart-6: #14b8a6;
272
+ --color-chart-7: #84cc16;
273
+ --color-chart-8: #3b82f6;
240
274
  }
241
275
 
242
276
  [data-accent='teal'] {
@@ -252,6 +286,13 @@
252
286
  --color-brand-800: #024a43;
253
287
  --color-brand-900: #003833;
254
288
  --color-brand-950: #002723;
289
+ --color-chart-2: #8b5cf6;
290
+ --color-chart-3: #ec4899;
291
+ --color-chart-4: #64748b;
292
+ --color-chart-5: #f97316;
293
+ --color-chart-6: #84cc16;
294
+ --color-chart-7: #3b82f6;
295
+ --color-chart-8: #d946ef;
255
296
  }
256
297
 
257
298
  [data-accent='cyan'] {
@@ -267,6 +308,13 @@
267
308
  --color-brand-800: #014759;
268
309
  --color-brand-900: #003645;
269
310
  --color-brand-950: #002631;
311
+ --color-chart-2: #8b5cf6;
312
+ --color-chart-3: #ec4899;
313
+ --color-chart-4: #64748b;
314
+ --color-chart-5: #f97316;
315
+ --color-chart-6: #84cc16;
316
+ --color-chart-7: #3b82f6;
317
+ --color-chart-8: #d946ef;
270
318
  }
271
319
 
272
320
  [data-accent='graphite'] {
@@ -282,6 +330,13 @@
282
330
  --color-brand-800: #3c414b;
283
331
  --color-brand-900: #2e3138;
284
332
  --color-brand-950: #1f2228;
333
+ --color-chart-2: #06b6d4;
334
+ --color-chart-3: #8b5cf6;
335
+ --color-chart-4: #ec4899;
336
+ --color-chart-5: #f97316;
337
+ --color-chart-6: #14b8a6;
338
+ --color-chart-7: #84cc16;
339
+ --color-chart-8: #3b82f6;
285
340
  }
286
341
 
287
342
  [data-accent='red'] {
@@ -291,7 +346,7 @@
291
346
  --color-brand-200: #ffc6c0;
292
347
  --color-brand-300: #ff9b94;
293
348
  --color-brand-400: #ff5a57;
294
- --color-brand-500: #db192a;
349
+ --color-brand-500: #de1f2d;
295
350
  --color-brand-600: #be021e;
296
351
  --color-brand-700: #a00118;
297
352
  --color-brand-800: #830011;
@@ -312,6 +367,13 @@
312
367
  --color-brand-800: #712b00;
313
368
  --color-brand-900: #592000;
314
369
  --color-brand-950: #3d1300;
370
+ --color-chart-2: #06b6d4;
371
+ --color-chart-3: #8b5cf6;
372
+ --color-chart-4: #ec4899;
373
+ --color-chart-5: #64748b;
374
+ --color-chart-6: #14b8a6;
375
+ --color-chart-7: #84cc16;
376
+ --color-chart-8: #3b82f6;
315
377
  }
316
378
 
317
379
  [data-accent='amber'] {
@@ -327,6 +389,13 @@
327
389
  --color-brand-800: #5d3900;
328
390
  --color-brand-900: #482b00;
329
391
  --color-brand-950: #321c00;
392
+ --color-chart-2: #06b6d4;
393
+ --color-chart-3: #8b5cf6;
394
+ --color-chart-4: #ec4899;
395
+ --color-chart-5: #64748b;
396
+ --color-chart-6: #14b8a6;
397
+ --color-chart-7: #84cc16;
398
+ --color-chart-8: #3b82f6;
330
399
  }
331
400
 
332
401
  [data-accent='green'] {
@@ -10,38 +10,23 @@
10
10
  */
11
11
 
12
12
  /* Tailwind dark variant: respond to the .dark / .deep-blue class set by the consumer's
13
- ThemeContext, instead of (or in addition to) prefers-color-scheme. */
14
- @custom-variant dark (&:is(.dark, .dark *, .deep-blue, .deep-blue *));
15
-
16
- @theme {
17
- /* ── Typography ─────────────────────────────────────────────────────────── */
18
- --font-sans: 'Outfit', system-ui, sans-serif;
19
- --font-mono: 'JetBrains Mono', monospace;
20
-
21
- /* Sizes under text-xs (12px) for dense labels: 11px and 10px. Without a
22
- --line-height they set only font-size, like text-[11px] would, and the
23
- text size setting in css-vars.css can scale them. */
24
- --text-2xs: 0.6875rem;
25
- --text-3xs: 0.625rem;
13
+ ThemeContext, instead of (or in addition to) prefers-color-scheme.
14
+ `:where()` keeps the variant at zero specificity, as Tailwind documents it: with `:is()` it
15
+ weighed as much as `focus:` or `hover:` and, emitted later, `dark:border-gray-700` beat
16
+ `focus:border-brand-500`, so form controls lost their focus border in the dark themes. */
17
+ @custom-variant dark (&:where(.dark, .dark *, .deep-blue, .deep-blue *));
26
18
 
19
+ /* The colors the charts read as plain CSS variables (var(--color-brand-500),
20
+ * var(--color-status-warn)…), with no utility behind them. Tailwind only emits
21
+ * a theme variable that a utility uses, so these are `static`: always in the
22
+ * CSS, whatever the app's classes are. */
23
+ @theme static {
27
24
  /* ── Status colors — health indicators, badges, alerts ─────────────────── */
28
25
  --color-status-ok: #10b981;
29
26
  --color-status-warn: #f59e0b;
30
27
  --color-status-crit: #ef4444;
31
28
  --color-status-unknown: #6b7280;
32
29
 
33
- /* ── Card shadows — work on both light and dark backgrounds ────────────── */
34
- --shadow-card: 0 1px 3px rgb(0 0 0 / 40%), 0 1px 2px rgb(0 0 0 / 30%);
35
- --shadow-card-hover: 0 10px 25px rgb(0 0 0 / 50%), 0 4px 6px rgb(0 0 0 / 20%);
36
-
37
- /* ── TailAdmin elevation shadows (theme.shadow-{xs,sm,md,lg,xl}) ───────── */
38
- --shadow-theme-xs: 0px 1px 2px 0px rgb(16 24 40 / 5%);
39
- --shadow-theme-sm: 0px 1px 3px 0px rgb(16 24 40 / 10%), 0px 1px 2px 0px rgb(16 24 40 / 6%);
40
- --shadow-theme-md: 0px 4px 8px -2px rgb(16 24 40 / 10%), 0px 2px 4px -2px rgb(16 24 40 / 6%);
41
- --shadow-theme-lg: 0px 12px 16px -4px rgb(16 24 40 / 8%), 0px 4px 6px -2px rgb(16 24 40 / 3%);
42
- --shadow-theme-xl: 0px 20px 24px -4px rgb(16 24 40 / 8%), 0px 8px 8px -4px rgb(16 24 40 / 3%);
43
- --shadow-focus-ring: 0px 0px 0px 4px color-mix(in srgb, var(--color-brand-500) 12%, transparent);
44
-
45
30
  /* ── Brand palette (TailAdmin blue) — [data-accent] in css-vars.css swaps it ── */
46
31
  --color-brand-25: #f2f7ff;
47
32
  --color-brand-50: #ecf3ff;
@@ -56,9 +41,6 @@
56
41
  --color-brand-900: #262e89;
57
42
  --color-brand-950: #161950;
58
43
 
59
- /* Dark gray aligned with Tailwind gray-900 — keeps SectionCard bg matching body bg */
60
- --color-gray-dark: #111827;
61
-
62
44
  /* ── Semantic colors ───────────────────────────────────────────────────── */
63
45
  --color-success-25: #f6fef9;
64
46
  --color-success-50: #ecfdf3;
@@ -77,8 +59,79 @@
77
59
  --color-warning-100: #fef0c7;
78
60
  --color-warning-500: #f79009;
79
61
  --color-warning-600: #dc6803;
62
+ }
63
+
64
+ @theme {
65
+ /* ── Typography ─────────────────────────────────────────────────────────── */
66
+ --font-sans: 'Outfit', system-ui, sans-serif;
67
+ --font-mono: 'JetBrains Mono', monospace;
68
+
69
+ /* Sizes under text-xs (12px) for dense labels: 11px and 10px. Without a
70
+ --line-height they set only font-size, like text-[11px] would, and the
71
+ text size setting in css-vars.css can scale them. */
72
+ --text-2xs: 0.6875rem;
73
+ --text-3xs: 0.625rem;
74
+
75
+ /* ── Card shadows — work on both light and dark backgrounds ────────────── */
76
+ --shadow-card: 0 1px 3px rgb(0 0 0 / 40%), 0 1px 2px rgb(0 0 0 / 30%);
77
+ --shadow-card-hover: 0 10px 25px rgb(0 0 0 / 50%), 0 4px 6px rgb(0 0 0 / 20%);
78
+
79
+ /* ── TailAdmin elevation shadows (theme.shadow-{xs,sm,md,lg,xl}) ───────── */
80
+ --shadow-theme-xs: 0px 1px 2px 0px rgb(16 24 40 / 5%);
81
+ --shadow-theme-sm: 0px 1px 3px 0px rgb(16 24 40 / 10%), 0px 1px 2px 0px rgb(16 24 40 / 6%);
82
+ --shadow-theme-md: 0px 4px 8px -2px rgb(16 24 40 / 10%), 0px 2px 4px -2px rgb(16 24 40 / 6%);
83
+ --shadow-theme-lg: 0px 12px 16px -4px rgb(16 24 40 / 8%), 0px 4px 6px -2px rgb(16 24 40 / 3%);
84
+ --shadow-theme-xl: 0px 20px 24px -4px rgb(16 24 40 / 8%), 0px 8px 8px -4px rgb(16 24 40 / 3%);
85
+ --shadow-focus-ring: 0px 0px 0px 4px color-mix(in srgb, var(--color-brand-500) 12%, transparent);
86
+ --shadow-focus-ring-error: 0 0 0 4px color-mix(in srgb, var(--color-red-500) 12%, transparent);
87
+
88
+ /* Dark gray aligned with Tailwind gray-900 — keeps SectionCard bg matching body bg */
89
+ --color-gray-dark: #111827;
80
90
 
81
91
  /* ── Bridges: aliases that pull values from CSS vars (defined in css-vars.css)
82
92
  so utilities like bg-accent-primary stay in sync with theme switcher. */
83
93
  --color-accent-primary: var(--color-accent);
84
94
  }
95
+
96
+ /* ── Focus indicator ───────────────────────────────────────────────────────
97
+ * One focus look for every control: a solid accent indicator plus the
98
+ * --shadow-focus-ring halo. The halo is 12% of the accent, too faint to be the
99
+ * only cue, so the solid part is what carries WCAG 1.4.11 (brand-500 reaches
100
+ * 3:1 on the surfaces of the four themes, see scripts/check-contrast.mjs).
101
+ *
102
+ * The utilities hold no state: put the variant that fits in front of them.
103
+ *
104
+ * focus-visible:focus-indicator a button, link, toggle, tab, menu item…:
105
+ * 2px accent ring + halo, keyboard focus only
106
+ * peer-focus-visible:…, group-focus-visible:…, focus-within:…
107
+ * the same, for a control drawn by a sibling
108
+ * or a wrapper (checkbox, radio, card)
109
+ * focus:field-focus a text field: accent border + halo
110
+ * focus-within:field-focus the same on a wrapper of the field
111
+ * focus:field-focus-error the field in error: red border + red halo
112
+ * focus-visible:focus-indicator-on-accent
113
+ * a control filled with brand-500 (the active
114
+ * segment, the selected day), where a brand
115
+ * ring would vanish: a 2px white ring, no halo
116
+ * (white on brand-500 is checked at 4.5:1)
117
+ *
118
+ * No ring offset. Add ring-inset where an ancestor clips (overflow-hidden) or a
119
+ * neighbour hides the outer ring.
120
+ *
121
+ * outline-hidden hides the browser outline but keeps it in forced-colors mode,
122
+ * where box-shadow is not painted: the indicator never disappears there. */
123
+ @utility focus-indicator {
124
+ @apply ring-brand-500 shadow-focus-ring ring-2 outline-hidden;
125
+ }
126
+
127
+ @utility field-focus {
128
+ @apply border-brand-500 shadow-focus-ring outline-hidden;
129
+ }
130
+
131
+ @utility field-focus-error {
132
+ @apply shadow-focus-ring-error border-red-500 outline-hidden;
133
+ }
134
+
135
+ @utility focus-indicator-on-accent {
136
+ @apply ring-2 ring-white outline-hidden;
137
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sckyzo/cosmos-theme",
3
- "version": "0.2.0",
4
- "description": "Tailwind 4 theme and design tokens for the Cosmos design system — palette, typography, radii and light/dark CSS variables.",
3
+ "version": "0.3.0",
4
+ "description": "Tailwind 4 theme and design tokens for the Cosmos design system — palette, typography, radii and CSS variables for its light, sand, dark and deep-blue themes.",
5
5
  "license": "MIT",
6
6
  "author": "SckyzO",
7
7
  "homepage": "https://github.com/SckyzO/cosmos/tree/main/packages/theme",