@sckyzo/cosmos-theme 0.3.0 → 0.4.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,19 @@ 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.4.0](https://github.com/SckyzO/cosmos/compare/@sckyzo/cosmos-theme@0.3.0...@sckyzo/cosmos-theme@0.4.0) (2026-10-30)
9
+
10
+
11
+ ### Features
12
+
13
+ * **react:** add density to appearance settings and a compact DataTable ([000d1c2](https://github.com/SckyzO/cosmos/commit/000d1c211c4a4bfffd22e1b119558d0e0cb57235))
14
+ * **theme:** add 20px and 24px row padding tokens ([e4acd79](https://github.com/SckyzO/cosmos/commit/e4acd79ac1cc8e47551e1b2d82efe032c7ed95fa))
15
+ * **theme:** add a 4px row padding token ([4886cf3](https://github.com/SckyzO/cosmos/commit/4886cf3c65edbdef99ee88a4f9dc822ae8ea3000))
16
+ * **theme:** add a 5px row token that stops at 4px ([842804d](https://github.com/SckyzO/cosmos/commit/842804d10ab958a7c3f083ebd842597ffb16bd78))
17
+ * **theme:** add data-density and its spacing tokens ([070f74a](https://github.com/SckyzO/cosmos/commit/070f74a8135fe3564b4609a8a53755fc9e12d002))
18
+ * **theme:** follow the nearest dir attribute in the rtl variant ([6e25a80](https://github.com/SckyzO/cosmos/commit/6e25a800d64c3c3208c1d0eea940fe60980842d3))
19
+ * **theme:** rescale every corner with data-radius ([2bdea86](https://github.com/SckyzO/cosmos/commit/2bdea865a341d3052e9a1fe10a1c7875f6793f9f))
20
+
8
21
  ## [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
22
 
10
23
 
package/README.md CHANGED
@@ -55,6 +55,11 @@ Two independent settings, both on the `<html>` element:
55
55
 
56
56
  `.dark` and `.deep-blue` both enable Tailwind's `dark:` variant.
57
57
 
58
+ - **Direction**: the native `dir` attribute, on `<html>` or any ancestor. Tailwind's `rtl:` variant is
59
+ redefined to follow the nearest `dir` attribute, so a `dir="ltr"` island inside a right-to-left
60
+ page is not flipped. It does not follow `dir="auto"`, nor a `dir="rtl"` nested inside such an
61
+ island.
62
+
58
63
  - **Accent**: a `data-accent` attribute that swaps the whole `--color-brand-*`
59
64
  scale (and with it `--color-accent` and the focus ring). Leave it off for
60
65
  `blue`. The others are `indigo`, `violet`, `purple`, `rose`, `teal`, `cyan`,
@@ -130,6 +135,62 @@ Two more settings on `<html>`, both optional:
130
135
 
131
136
  Both attributes also work on an element below `<html>`, for one part of a page.
132
137
 
138
+ ## Density
139
+
140
+ A `data-density` attribute on `<html>` tightens or loosens the vertical rhythm of
141
+ every control and row at once: `compact`, none for the default, or `comfortable`.
142
+ Only the heights and the vertical padding of rows move; panel padding, gaps and
143
+ horizontal padding stay. It applies on touch screens too: the user's choice wins.
144
+
145
+ | Token | Default | `compact` | `comfortable` | Used by |
146
+ | ------------------------------ | ---------- | --------- | ------------- | --------------------------- |
147
+ | `h-ctrl-28` … `h-ctrl-48` | 28–48px | 4px less | 4px more | buttons, fields, segments |
148
+ | `py-row-4` … `py-row-24` | 4–24px | 2px less | 2px more | list rows, menu items, tabs |
149
+ | `py-cell-head`, `py-cell-body` | 12px, 14px | 8px, 10px | 16px, 20px | table cells |
150
+
151
+ The token is named by its default size: `h-ctrl-36` is today's `h-9`. The smallest
152
+ control, 28px, stays at 24px in `compact`, the WCAG 2.5.8 floor, and `py-row-5`
153
+ stops at 4px for the same reason. They are `--spacing-ctrl-*`, `--spacing-row-*` and
154
+ `--spacing-cell-*` theme variables, so any utility of the spacing scale takes
155
+ them (`h-ctrl-36`, `min-h-ctrl-36`, `size-ctrl-32`, `py-row-8`). Use them for a
156
+ control or a row of your own and it follows the page.
157
+
158
+ ```html
159
+ <html class="sand" data-density="compact"></html>
160
+ ```
161
+
162
+ The attribute also works on an element below `<html>`; `data-density="default"`
163
+ opts a part of a compact or comfortable page out (a `DataTable` with its own
164
+ `density` does this).
165
+
166
+ ## Radius
167
+
168
+ A `data-radius` attribute on `<html>` rescales every corner at once: `none`,
169
+ `sm`, none for the default, or `lg`. It rebuilds Tailwind's own `--radius-*`
170
+ variables, the ones `rounded-sm` to `rounded-4xl` read, so a component needs
171
+ nothing more than those utilities.
172
+
173
+ | Step | `--radius-*` | `rounded-lg` (8px by default) |
174
+ | --------- | ------------------------------- | ----------------------------- |
175
+ | `none` | 2px, every one | 2px |
176
+ | `sm` | half of Tailwind's | 4px |
177
+ | (default) | Tailwind's, nothing moves | 8px |
178
+ | `lg` | one and a half times Tailwind's | 12px |
179
+
180
+ `rounded-full` and `rounded-none` are literals and never change: avatars,
181
+ status dots, switches, badges and pill buttons stay round at every step. A
182
+ corner that must follow the page goes through the scale. A bare `rounded` is a
183
+ fixed `0.25rem` in Tailwind 4, so write `rounded-sm` (the same value, through
184
+ the variable); an arbitrary `rounded-[10px]` is fixed too, and
185
+ `rounded-[calc(var(--radius-lg)*1.25)]` is not.
186
+
187
+ ```html
188
+ <html class="sand" data-radius="lg"></html>
189
+ ```
190
+
191
+ The attribute also works on an element below `<html>`; `data-radius="default"`
192
+ opts a part of the page out of its parent's radius.
193
+
133
194
  ## Tokens
134
195
 
135
196
  See [`css/tailwind-tokens.css`](css/tailwind-tokens.css) for the full source.
package/css/css-vars.css CHANGED
@@ -500,6 +500,111 @@
500
500
  }
501
501
  }
502
502
 
503
+ /* ── Density ───────────────────────────────────────────────────────────────
504
+ * data-density moves the vertical rhythm only: the height of controls
505
+ * (--spacing-ctrl-*), the vertical padding of rows (--spacing-row-*) and of
506
+ * table cells (--spacing-cell-*). Panel padding, gaps and the horizontal
507
+ * padding stay. compact takes 4px off a control (the smallest, 28px, stays at
508
+ * 24px, the WCAG 2.5.8 floor) and 2px off each side of a row; comfortable adds
509
+ * as much. No attribute keeps today's values; 'default' is the same, spelled
510
+ * out so a part of the page (a DataTable) can opt out of its parent's density.
511
+ *
512
+ * Declared again here for the same reason as the text sizes: a custom property
513
+ * resolves var() on the element that declares it, so the tokens are rebuilt
514
+ * on every element that carries the attribute. */
515
+ [data-density] {
516
+ --spacing-ctrl-28: calc(1.75rem + var(--cosmos-density-control, 0rem));
517
+ --spacing-ctrl-32: calc(2rem + var(--cosmos-density-control, 0rem));
518
+ --spacing-ctrl-36: calc(2.25rem + var(--cosmos-density-control, 0rem));
519
+ --spacing-ctrl-40: calc(2.5rem + var(--cosmos-density-control, 0rem));
520
+ --spacing-ctrl-44: calc(2.75rem + var(--cosmos-density-control, 0rem));
521
+ --spacing-ctrl-48: calc(3rem + var(--cosmos-density-control, 0rem));
522
+ --spacing-row-4: calc(0.25rem + var(--cosmos-density-row, 0rem));
523
+ /* 5px rows are 26px sidebar rows of 16px text: compact stops at 4px, the 24px floor. */
524
+ --spacing-row-5: max(0.25rem, calc(0.3125rem + var(--cosmos-density-row, 0rem)));
525
+ --spacing-row-6: calc(0.375rem + var(--cosmos-density-row, 0rem));
526
+ --spacing-row-8: calc(0.5rem + var(--cosmos-density-row, 0rem));
527
+ --spacing-row-10: calc(0.625rem + var(--cosmos-density-row, 0rem));
528
+ --spacing-row-12: calc(0.75rem + var(--cosmos-density-row, 0rem));
529
+ --spacing-row-14: calc(0.875rem + var(--cosmos-density-row, 0rem));
530
+ --spacing-row-16: calc(1rem + var(--cosmos-density-row, 0rem));
531
+ --spacing-row-20: calc(1.25rem + var(--cosmos-density-row, 0rem));
532
+ --spacing-row-24: calc(1.5rem + var(--cosmos-density-row, 0rem));
533
+ --spacing-cell-head: calc(0.75rem + var(--cosmos-density-cell-head, 0rem));
534
+ --spacing-cell-body: calc(0.875rem + var(--cosmos-density-cell-body, 0rem));
535
+ }
536
+
537
+ [data-density='default'] {
538
+ --cosmos-density-control: 0rem;
539
+ --cosmos-density-row: 0rem;
540
+ --cosmos-density-cell-head: 0rem;
541
+ --cosmos-density-cell-body: 0rem;
542
+ --cosmos-density-virtual-cell: calc(48em / 14);
543
+ }
544
+
545
+ [data-density='compact'] {
546
+ --cosmos-density-control: -0.25rem;
547
+ --cosmos-density-row: -0.125rem;
548
+ --cosmos-density-cell-head: -0.25rem;
549
+ --cosmos-density-cell-body: -0.25rem;
550
+ --cosmos-density-virtual-cell: calc(40em / 14);
551
+ }
552
+
553
+ [data-density='comfortable'] {
554
+ --cosmos-density-control: 0.25rem;
555
+ --cosmos-density-row: 0.125rem;
556
+ --cosmos-density-cell-head: 0.25rem;
557
+ --cosmos-density-cell-body: 0.375rem;
558
+ --cosmos-density-virtual-cell: calc(60em / 14);
559
+ }
560
+
561
+ /* ── Radius ────────────────────────────────────────────────────────────────
562
+ * data-radius rescales Tailwind's own --radius-* tokens, the ones rounded-sm
563
+ * to rounded-4xl read, so every corner of a component follows. none squares
564
+ * them all to 2px (a scale cannot get there from 4px to 32px), sm halves
565
+ * them, lg takes them one and a half times. No attribute keeps today's
566
+ * values; 'default' is the same, spelled out so a part of the page can opt
567
+ * out of its parent's radius. rounded-full and rounded-none are literals and
568
+ * never move: avatars, dots, switches, badges and pill buttons stay round.
569
+ *
570
+ * Declared again here for the same reason as the text sizes and the density:
571
+ * a custom property resolves var() on the element that declares it, so the
572
+ * tokens are rebuilt on every element that carries the attribute. The values
573
+ * are Tailwind's (theme.css); check-contrast.mjs fails if one goes missing. */
574
+ [data-radius] {
575
+ --radius-xs: calc(0.125rem * var(--cosmos-radius-scale, 1));
576
+ --radius-sm: calc(0.25rem * var(--cosmos-radius-scale, 1));
577
+ --radius-md: calc(0.375rem * var(--cosmos-radius-scale, 1));
578
+ --radius-lg: calc(0.5rem * var(--cosmos-radius-scale, 1));
579
+ --radius-xl: calc(0.75rem * var(--cosmos-radius-scale, 1));
580
+ --radius-2xl: calc(1rem * var(--cosmos-radius-scale, 1));
581
+ --radius-3xl: calc(1.5rem * var(--cosmos-radius-scale, 1));
582
+ --radius-4xl: calc(2rem * var(--cosmos-radius-scale, 1));
583
+ }
584
+
585
+ [data-radius='default'] {
586
+ --cosmos-radius-scale: 1;
587
+ }
588
+
589
+ [data-radius='sm'] {
590
+ --cosmos-radius-scale: 0.5;
591
+ }
592
+
593
+ [data-radius='lg'] {
594
+ --cosmos-radius-scale: 1.5;
595
+ }
596
+
597
+ [data-radius='none'] {
598
+ --radius-xs: 2px;
599
+ --radius-sm: 2px;
600
+ --radius-md: 2px;
601
+ --radius-lg: 2px;
602
+ --radius-xl: 2px;
603
+ --radius-2xl: 2px;
604
+ --radius-3xl: 2px;
605
+ --radius-4xl: 2px;
606
+ }
607
+
503
608
  /* Smooth theme switching transition — opt-in via .cosmos-bg-transition class
504
609
  on the app shell (not body, to avoid transitioning every DOM element). */
505
610
  .cosmos-bg-transition {
@@ -16,6 +16,15 @@
16
16
  `focus:border-brand-500`, so form controls lost their focus border in the dark themes. */
17
17
  @custom-variant dark (&:where(.dark, .dark *, .deep-blue, .deep-blue *));
18
18
 
19
+ /* Tailwind rtl variant: the nearest `dir` attribute. Not `:dir(rtl)`: Tailwind's build lowers
20
+ it to a list of `:lang()` for its browser targets, which a page that only sets `dir` never
21
+ matches (the dev server skips that step, so only a build shows it). Tailwind's default adds
22
+ `[dir="rtl"] *`, which also holds in a `dir="ltr"` island inside a right-to-left page (a code
23
+ sample, a phone number field) and would flip its icons: the `:not()` leaves the island out.
24
+ Not followed: `dir="auto"`, and a `dir="rtl"` nested in such an island.
25
+ `tests/e2e/specs/rtl-variant.spec.ts` checks it in the static build. */
26
+ @custom-variant rtl (&:where([dir="rtl"], [dir="rtl"] *):not(:where([dir="rtl"] [dir="ltr"], [dir="rtl"] [dir="ltr"] *)));
27
+
19
28
  /* The colors the charts read as plain CSS variables (var(--color-brand-500),
20
29
  * var(--color-status-warn)…), with no utility behind them. Tailwind only emits
21
30
  * a theme variable that a utility uses, so these are `static`: always in the
@@ -72,6 +81,32 @@
72
81
  --text-2xs: 0.6875rem;
73
82
  --text-3xs: 0.625rem;
74
83
 
84
+ /* ── Density ────────────────────────────────────────────────────────────── */
85
+ /* The vertical rhythm that data-density moves (css-vars.css redefines these
86
+ under the attribute): the height of a control, named by its default
87
+ height in px (h-ctrl-36 is h-9), and the vertical padding of a row, named
88
+ the same way (py-row-8 is py-2). A table cell has its own two. The
89
+ horizontal padding and the gaps stay where they are. Without the
90
+ attribute these are the values the components always had. */
91
+ --spacing-ctrl-28: 1.75rem;
92
+ --spacing-ctrl-32: 2rem;
93
+ --spacing-ctrl-36: 2.25rem;
94
+ --spacing-ctrl-40: 2.5rem;
95
+ --spacing-ctrl-44: 2.75rem;
96
+ --spacing-ctrl-48: 3rem;
97
+ --spacing-row-4: 0.25rem;
98
+ --spacing-row-5: 0.3125rem;
99
+ --spacing-row-6: 0.375rem;
100
+ --spacing-row-8: 0.5rem;
101
+ --spacing-row-10: 0.625rem;
102
+ --spacing-row-12: 0.75rem;
103
+ --spacing-row-14: 0.875rem;
104
+ --spacing-row-16: 1rem;
105
+ --spacing-row-20: 1.25rem;
106
+ --spacing-row-24: 1.5rem;
107
+ --spacing-cell-head: 0.75rem;
108
+ --spacing-cell-body: 0.875rem;
109
+
75
110
  /* ── Card shadows — work on both light and dark backgrounds ────────────── */
76
111
  --shadow-card: 0 1px 3px rgb(0 0 0 / 40%), 0 1px 2px rgb(0 0 0 / 30%);
77
112
  --shadow-card-hover: 0 10px 25px rgb(0 0 0 / 50%), 0 4px 6px rgb(0 0 0 / 20%);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sckyzo/cosmos-theme",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
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",