@sckyzo/cosmos-theme 0.1.0 → 0.2.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,16 @@ 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.2.0](https://github.com/SckyzO/cosmos/compare/@sckyzo/cosmos-theme@0.1.0...@sckyzo/cosmos-theme@0.2.0) (2026-10-21)
9
+
10
+
11
+ ### Features
12
+
13
+ * **theme:** add a data-font setting with five more fonts ([6135b66](https://github.com/SckyzO/cosmos/commit/6135b6681f669bdcd178b113fb7b0cbf82aef5d0)), closes [#157](https://github.com/SckyzO/cosmos/issues/157)
14
+ * **theme:** add a data-text-size setting ([cd6ed5c](https://github.com/SckyzO/cosmos/commit/cd6ed5c07b15a9df12b56a3638ff0ca477cf1392)), closes [#157](https://github.com/SckyzO/cosmos/issues/157)
15
+ * **theme:** add syntax highlighting tokens ([8589ef1](https://github.com/SckyzO/cosmos/commit/8589ef1434fafdd20e7ae042372ff89a534a30f3))
16
+ * **theme:** add the text-2xs and text-3xs sizes ([57decb3](https://github.com/SckyzO/cosmos/commit/57decb3bc301ec65ce9966c84b8412cd9791b32a)), closes [#157](https://github.com/SckyzO/cosmos/issues/157)
17
+
8
18
  ## [0.1.0](https://github.com/SckyzO/cosmos/compare/@sckyzo/cosmos-theme@0.0.2...@sckyzo/cosmos-theme@0.1.0) (2026-10-20)
9
19
 
10
20
 
package/README.md CHANGED
@@ -4,13 +4,14 @@
4
4
 
5
5
  Cosmos design tokens — CSS only.
6
6
 
7
- Provides three CSS files consumable by any framework:
7
+ Provides CSS files consumable by any framework:
8
8
 
9
- | Import | Purpose |
10
- | ------------------------------- | ------------------------------------------------------------------------------ |
11
- | `@sckyzo/cosmos-theme/tailwind` | Tailwind 4 `@theme` block (palette, fonts, shadows, brand colors) |
12
- | `@sckyzo/cosmos-theme/vars` | Universal CSS custom properties (bg, text, border, accent), themes and accents |
13
- | `@sckyzo/cosmos-theme/fonts` | `@fontsource` font imports (Outfit + JetBrains Mono) |
9
+ | Import | Purpose |
10
+ | ----------------------------------- | ------------------------------------------------------------------------------ |
11
+ | `@sckyzo/cosmos-theme/tailwind` | Tailwind 4 `@theme` block (palette, fonts, shadows, brand colors) |
12
+ | `@sckyzo/cosmos-theme/vars` | Universal CSS custom properties (bg, text, border, accent), themes and accents |
13
+ | `@sckyzo/cosmos-theme/fonts` | `@fontsource` font imports (Outfit + JetBrains Mono) |
14
+ | `@sckyzo/cosmos-theme/fonts/<name>` | One variable font for `data-font`: `inter`, `plex`, `montserrat`, `open-sans` |
14
15
 
15
16
  ## Usage
16
17
 
@@ -71,6 +72,33 @@ Every theme × accent pair meets WCAG AA for body text, links and white text on
71
72
  the accent. `pnpm --filter @sckyzo/cosmos-theme test` runs the contrast check
72
73
  (`scripts/check-contrast.mjs`) against the CSS files.
73
74
 
75
+ ## Fonts & text size
76
+
77
+ Two more settings on `<html>`, both optional:
78
+
79
+ - **Font**: a `data-font` attribute that swaps `--font-sans`. Leave it off for
80
+ Outfit. The others are `inter`, `plex` (IBM Plex Sans), `montserrat`,
81
+ `open-sans`, and `system`, the platform's UI font. Each one loads from its own
82
+ subpath, so import only the fonts you offer; `system` loads nothing. The mono
83
+ font stays JetBrains Mono.
84
+
85
+ ```css
86
+ @import '@sckyzo/cosmos-theme/fonts'; /* Outfit + JetBrains Mono */
87
+ @import '@sckyzo/cosmos-theme/fonts/inter';
88
+ ```
89
+
90
+ - **Text size**: a `data-text-size` attribute, `sm`, `lg` or `xl`, that scales
91
+ every `text-*` size to 93.75%, 112.5% or 125%. Leave it off for 100%. Only the
92
+ text grows: spacing keeps its `rem` values, so layouts keep their density.
93
+ Sizes written in pixels, such as `text-[13px]`, don't scale; the `text-*`
94
+ scale includes `text-2xs` (11px) and `text-3xs` (10px) for small labels.
95
+
96
+ ```html
97
+ <html class="sand" data-accent="teal" data-font="inter" data-text-size="lg"></html>
98
+ ```
99
+
100
+ Both attributes also work on an element below `<html>`, for one part of a page.
101
+
74
102
  ## Tokens
75
103
 
76
104
  See [`css/tailwind-tokens.css`](css/tailwind-tokens.css) for the full source.
@@ -80,9 +108,10 @@ Categories:
80
108
  - **Brand palette** : `--color-brand-25` to `--color-brand-950`
81
109
  - **Semantic colors** : `--color-success-*`, `--color-error-*`, `--color-warning-*`
82
110
  - **Status** : `--color-status-{ok,warn,crit,unknown}`
83
- - **Typography** : `--font-sans` (Outfit), `--font-mono` (JetBrains Mono)
111
+ - **Typography** : `--font-sans` (Outfit), `--font-mono` (JetBrains Mono), `--text-2xs` (11px), `--text-3xs` (10px)
84
112
  - **Shadows** : `--shadow-card`, `--shadow-card-hover`
85
113
  - **Layout vars** (theme-aware): `--color-bg-{base,panel,elevated}`, `--color-text-{base,primary,secondary,muted}`, `--color-border`, `--color-accent`
114
+ - **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`).
86
115
 
87
116
  ## License
88
117
 
package/css/css-vars.css CHANGED
@@ -9,8 +9,10 @@
9
9
  * dark .dark — neutral black/gray dark theme
10
10
  * deep-blue .deep-blue — navy dark theme
11
11
  * accent → data-accent="indigo" etc. — no attribute means blue
12
+ * font → data-font="inter" etc. — no attribute means Outfit
13
+ * text → data-text-size="sm" | "lg" | "xl" — no attribute means normal
12
14
  *
13
- * <html class="sand" data-accent="teal">
15
+ * <html class="sand" data-accent="teal" data-font="inter" data-text-size="lg">
14
16
  *
15
17
  * Themes and accents redefine Tailwind's palette variables (--color-white,
16
18
  * --color-gray-*, --color-brand-*), so components styled with bg-white /
@@ -37,6 +39,23 @@
37
39
  --color-text-secondary: #667085;
38
40
  --color-text-muted: #98a2b3;
39
41
 
42
+ /* ── Code ──────────────────────────────────────────────────────────────── */
43
+ /* Syntax highlighting on CodeBlock (gray-50 / gray-900), read by Shiki's
44
+ * CSS variables theme with variablePrefix '--color-code-'. */
45
+ --color-code-foreground: oklch(27.8% 0.033 256.848);
46
+ --color-code-token-keyword: #6d28d9;
47
+ --color-code-token-string: #15803d;
48
+ --color-code-token-comment: #5b6472;
49
+ --color-code-token-constant: #b45309;
50
+ --color-code-token-function: #1d4ed8;
51
+ --color-code-token-parameter: #c2410c;
52
+ --color-code-token-string-expression: #0f766e;
53
+ --color-code-token-punctuation: #4b5563;
54
+ --color-code-token-link: #1d4ed8;
55
+ --color-code-token-inserted: #15803d;
56
+ --color-code-token-deleted: #b91c1c;
57
+ --color-code-token-changed: #b45309;
58
+
40
59
  /* ── Accent ────────────────────────────────────────────────────────────── */
41
60
  --color-accent: var(--color-brand-500);
42
61
  }
@@ -55,6 +74,13 @@
55
74
  --color-text-secondary: #746656;
56
75
  --color-text-muted: #a39684;
57
76
 
77
+ /* ── Code ──────────────────────────────────────────────────────────────── */
78
+ /* Syntax highlighting on CodeBlock (gray-50 / gray-900), read by Shiki's
79
+ * CSS variables theme with variablePrefix '--color-code-'. */
80
+ --color-code-foreground: oklch(27.5% 0.02 60);
81
+ --color-code-token-comment: #6e5f4f;
82
+ --color-code-token-punctuation: #57493c;
83
+
58
84
  /* Warm gray scale — same lightness steps as Tailwind gray, beige hue. */
59
85
  --color-white: oklch(99.3% 0.008 85);
60
86
  --color-gray-50: oklch(97% 0.014 85);
@@ -84,6 +110,23 @@
84
110
  --color-text-secondary: #a3a3a3;
85
111
  --color-text-muted: #8f8f8f;
86
112
 
113
+ /* ── Code ──────────────────────────────────────────────────────────────── */
114
+ /* Syntax highlighting on CodeBlock (gray-50 / gray-900), read by Shiki's
115
+ * CSS variables theme with variablePrefix '--color-code-'. */
116
+ --color-code-foreground: #e5e5e5;
117
+ --color-code-token-comment: #8f8f8f;
118
+ --color-code-token-punctuation: #a3a3a3;
119
+ --color-code-token-keyword: #c4b5fd;
120
+ --color-code-token-string: #86efac;
121
+ --color-code-token-constant: #fcd34d;
122
+ --color-code-token-function: #93c5fd;
123
+ --color-code-token-parameter: #fdba74;
124
+ --color-code-token-string-expression: #5eead4;
125
+ --color-code-token-link: #93c5fd;
126
+ --color-code-token-inserted: #86efac;
127
+ --color-code-token-deleted: #fca5a5;
128
+ --color-code-token-changed: #fcd34d;
129
+
87
130
  /* Neutral gray scale, softened near-black (no pure #000). */
88
131
  --color-gray-50: #fafafa;
89
132
  --color-gray-100: #f5f5f5;
@@ -113,6 +156,23 @@
113
156
  --color-text-primary: #fff;
114
157
  --color-text-secondary: #98a2b3;
115
158
  --color-text-muted: #667085;
159
+
160
+ /* ── Code ──────────────────────────────────────────────────────────────── */
161
+ /* Syntax highlighting on CodeBlock (gray-50 / gray-900), read by Shiki's
162
+ * CSS variables theme with variablePrefix '--color-code-'. */
163
+ --color-code-foreground: oklch(92.8% 0.006 264.531);
164
+ --color-code-token-comment: #98a2b3;
165
+ --color-code-token-punctuation: #b8c0cc;
166
+ --color-code-token-keyword: #c4b5fd;
167
+ --color-code-token-string: #86efac;
168
+ --color-code-token-constant: #fcd34d;
169
+ --color-code-token-function: #93c5fd;
170
+ --color-code-token-parameter: #fdba74;
171
+ --color-code-token-string-expression: #5eead4;
172
+ --color-code-token-link: #93c5fd;
173
+ --color-code-token-inserted: #86efac;
174
+ --color-code-token-deleted: #fca5a5;
175
+ --color-code-token-changed: #fcd34d;
116
176
  }
117
177
 
118
178
  /* ── Accents ───────────────────────────────────────────────────────────────
@@ -284,6 +344,93 @@
284
344
  --color-brand-950: #00280d;
285
345
  }
286
346
 
347
+ /* ── Fonts ─────────────────────────────────────────────────────────────────
348
+ * data-font swaps the sans-serif family; no attribute keeps Outfit. Each
349
+ * font loads from its own subpath (@sckyzo/cosmos-theme/fonts/inter, …), so
350
+ * an app only ships the ones it offers; `system` uses the platform's UI font
351
+ * and loads nothing. The mono font stays JetBrains Mono.
352
+ *
353
+ * font-family is set here too: plain text inherits the family <html>
354
+ * computed, so an element below <html> with data-font needs its own
355
+ * font-family to switch. In the base layer, so font-mono on the same element
356
+ * still wins. */
357
+ @layer base {
358
+ [data-font] {
359
+ font-family: var(--font-sans);
360
+ }
361
+ }
362
+
363
+ [data-font='inter'] {
364
+ --font-sans: 'Inter Variable', system-ui, sans-serif;
365
+ }
366
+
367
+ [data-font='plex'] {
368
+ --font-sans: 'IBM Plex Sans Variable', system-ui, sans-serif;
369
+ }
370
+
371
+ [data-font='montserrat'] {
372
+ --font-sans: 'Montserrat Variable', system-ui, sans-serif;
373
+ }
374
+
375
+ [data-font='open-sans'] {
376
+ --font-sans: 'Open Sans Variable', system-ui, sans-serif;
377
+ }
378
+
379
+ [data-font='system'] {
380
+ --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
381
+ }
382
+
383
+ /* ── Text size ─────────────────────────────────────────────────────────────
384
+ * data-text-size scales every text-* size: sm 93.75%, lg 112.5%, xl 125%;
385
+ * no attribute keeps 100%. Spacing stays the same, so layouts keep their
386
+ * density, and line heights follow (they are ratios). Sizes written in
387
+ * pixels, such as text-[9px], don't scale.
388
+ *
389
+ * The sizes are declared again here, not scaled in the @theme block: a
390
+ * custom property resolves var() on the element that declares it, so a
391
+ * --text-sm declared on :root would ignore an attribute set below <html>.
392
+ * Same values as Tailwind's, plus text-2xs and text-3xs. */
393
+ [data-text-size] {
394
+ --text-3xs: calc(0.625rem * var(--cosmos-text-scale, 1));
395
+ --text-2xs: calc(0.6875rem * var(--cosmos-text-scale, 1));
396
+ --text-xs: calc(0.75rem * var(--cosmos-text-scale, 1));
397
+ --text-sm: calc(0.875rem * var(--cosmos-text-scale, 1));
398
+ --text-base: calc(1rem * var(--cosmos-text-scale, 1));
399
+ --text-lg: calc(1.125rem * var(--cosmos-text-scale, 1));
400
+ --text-xl: calc(1.25rem * var(--cosmos-text-scale, 1));
401
+ --text-2xl: calc(1.5rem * var(--cosmos-text-scale, 1));
402
+ --text-3xl: calc(1.875rem * var(--cosmos-text-scale, 1));
403
+ --text-4xl: calc(2.25rem * var(--cosmos-text-scale, 1));
404
+ --text-5xl: calc(3rem * var(--cosmos-text-scale, 1));
405
+ --text-6xl: calc(3.75rem * var(--cosmos-text-scale, 1));
406
+ --text-7xl: calc(4.5rem * var(--cosmos-text-scale, 1));
407
+ --text-8xl: calc(6rem * var(--cosmos-text-scale, 1));
408
+ --text-9xl: calc(8rem * var(--cosmos-text-scale, 1));
409
+ }
410
+
411
+ [data-text-size='sm'] {
412
+ --cosmos-text-scale: 0.9375;
413
+ }
414
+
415
+ [data-text-size='lg'] {
416
+ --cosmos-text-scale: 1.125;
417
+ }
418
+
419
+ [data-text-size='xl'] {
420
+ --cosmos-text-scale: 1.25;
421
+ }
422
+
423
+ /* Text without a text-* class: body under <html data-text-size>, or the
424
+ element carrying the attribute below <html>. Not <html> itself, whose
425
+ font size sets rem and would scale the spacing too. In the base layer, so
426
+ a text-* class on the same element still wins. */
427
+ @layer base {
428
+ [data-text-size] body,
429
+ [data-text-size]:not(:root) {
430
+ font-size: var(--text-base);
431
+ }
432
+ }
433
+
287
434
  /* Smooth theme switching transition — opt-in via .cosmos-bg-transition class
288
435
  on the app shell (not body, to avoid transitioning every DOM element). */
289
436
  .cosmos-bg-transition {
@@ -0,0 +1,2 @@
1
+ /* Font for data-font='inter': one variable file, weights 100–900. */
2
+ @import '@fontsource-variable/inter/wght.css';
@@ -0,0 +1,2 @@
1
+ /* Font for data-font='montserrat': one variable file, weights 100–900. */
2
+ @import '@fontsource-variable/montserrat/wght.css';
@@ -0,0 +1,2 @@
1
+ /* Font for data-font='open-sans': one variable file, weights 300–800. */
2
+ @import '@fontsource-variable/open-sans/wght.css';
@@ -0,0 +1,2 @@
1
+ /* Font for data-font='plex': one variable file, weights 100–700. */
2
+ @import '@fontsource-variable/ibm-plex-sans/wght.css';
package/css/fonts.css CHANGED
@@ -1,5 +1,6 @@
1
- /* Cosmos fonts — self-hosted via @fontsource (no internet required at runtime).
2
- Consumers must install @fontsource/outfit and @fontsource/jetbrains-mono as deps. */
1
+ /* Cosmos default fonts, Outfit and JetBrains Mono, self-hosted via @fontsource
2
+ (no network needed at runtime). The @fontsource packages are dependencies of
3
+ this package. The other data-font choices load from fonts/<name>.css. */
3
4
 
4
5
  @import '@fontsource/outfit/300.css';
5
6
  @import '@fontsource/outfit/400.css';
@@ -18,6 +18,12 @@
18
18
  --font-sans: 'Outfit', system-ui, sans-serif;
19
19
  --font-mono: 'JetBrains Mono', monospace;
20
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;
26
+
21
27
  /* ── Status colors — health indicators, badges, alerts ─────────────────── */
22
28
  --color-status-ok: #10b981;
23
29
  --color-status-warn: #f59e0b;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sckyzo/cosmos-theme",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Tailwind 4 theme and design tokens for the Cosmos design system — palette, typography, radii and light/dark CSS variables.",
5
5
  "license": "MIT",
6
6
  "author": "SckyzO",
@@ -18,6 +18,10 @@
18
18
  "./tailwind": "./css/tailwind-tokens.css",
19
19
  "./vars": "./css/css-vars.css",
20
20
  "./fonts": "./css/fonts.css",
21
+ "./fonts/inter": "./css/fonts/inter.css",
22
+ "./fonts/plex": "./css/fonts/plex.css",
23
+ "./fonts/montserrat": "./css/fonts/montserrat.css",
24
+ "./fonts/open-sans": "./css/fonts/open-sans.css",
21
25
  "./package.json": "./package.json"
22
26
  },
23
27
  "files": [
@@ -34,6 +38,10 @@
34
38
  "build": "echo 'CSS-only package, no build step needed'"
35
39
  },
36
40
  "dependencies": {
41
+ "@fontsource-variable/ibm-plex-sans": "^5.3.0",
42
+ "@fontsource-variable/inter": "^5.3.0",
43
+ "@fontsource-variable/montserrat": "^5.3.0",
44
+ "@fontsource-variable/open-sans": "^5.3.0",
37
45
  "@fontsource/jetbrains-mono": "^5.3.0",
38
46
  "@fontsource/outfit": "^5.3.0"
39
47
  },