@rowkit/tokens 0.4.0 → 1.0.0-beta.1

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/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # @rowkit/tokens
2
2
 
3
- [![npm](https://img.shields.io/npm/v/@rowkit/tokens?color=3b5bdb)](https://www.npmjs.com/package/@rowkit/tokens)
3
+ [![npm](https://img.shields.io/npm/v/@rowkit/tokens/beta?color=D63A1F)](https://www.npmjs.com/package/@rowkit/tokens)
4
4
  [![license](https://img.shields.io/npm/l/@rowkit/tokens)](https://github.com/NikolaiKushner/rowkit/blob/main/LICENSE)
5
5
 
6
- The design tokens behind [rowkit](https://www.npmjs.com/package/rowkit) — colour, spacing, typography, radii, shadows, layers and motion.
6
+ The design tokens behind [rowkit](https://www.npmjs.com/package/rowkit) — colour, shadows, sizes, corners, type, layers and motion for its two themes: **Windows 98**, the default, and **modern**, in light and dark. Plus `defineTheme()`, to make a theme of your own (with rowkit installed, import it from `rowkit/theme` — the same function, matched to the components).
7
7
 
8
8
  Usable on its own. Nothing here depends on Vue, so a chart library, a design tool or an email template can read the same values the components use.
9
9
 
@@ -12,14 +12,14 @@ Usable on its own. Nothing here depends on Vue, so a chart library, a design too
12
12
  ## Install
13
13
 
14
14
  ```bash
15
- npm i @rowkit/tokens
15
+ npm i @rowkit/tokens@beta
16
16
  ```
17
17
 
18
18
  ## Two layers
19
19
 
20
- **Primitives** are the raw ramps: `--color-primary-600` is one specific blue and means nothing on its own. **Semantic** tokens name a role — `--color-card`, `--color-muted-foreground`, `--color-border` — and point at a primitive through `var()`.
20
+ **Primitives** are the raw palette — the VGA colours and Windows 98's system colours: `--color-vga-navy` is one specific blue and means nothing on its own. **Semantic** tokens name a role — `--color-card`, `--color-muted-foreground`, `--color-border` — and point at a primitive through `var()`.
21
21
 
22
- Only the semantic layer changes under `.dark`, which is what makes dark mode a matter of repointing references rather than hunting hex codes.
22
+ Rebranding is a matter of repointing semantic references rather than hunting hex codes. The modern theme has a palette of its own (`--color-modern-*`) and points the same semantic names at it, once for light and once for dark.
23
23
 
24
24
  ## Use
25
25
 
@@ -30,7 +30,13 @@ As a Tailwind v4 theme:
30
30
  @import '@rowkit/tokens/css';
31
31
  ```
32
32
 
33
- Every token becomes a theme value, so `bg-card`, `text-muted-foreground`, `p-4`, `rounded-md` and `shadow-lg` resolve to the scales above.
33
+ Every token becomes a theme value, so `bg-card`, `text-ui`, `p-4` and `shadow-raised` resolve to the scales above. The stylesheet also carries both themes. Pick one with an attribute on any element; themes nest:
34
+
35
+ ```html
36
+ <html data-theme="modern" data-color-scheme="dark"></html>
37
+ ```
38
+
39
+ Without `data-theme` a page is Windows 98. Without `data-color-scheme` the modern theme follows the system's light or dark setting.
34
40
 
35
41
  As CSS custom properties, for anything Tailwind does not cover:
36
42
 
@@ -46,18 +52,74 @@ Or in TypeScript, fully typed, when a value has to reach JavaScript:
46
52
  ```ts
47
53
  import { tokens } from '@rowkit/tokens'
48
54
 
49
- tokens.color.primary[800] // 'oklch(0.32 0.09 255)' — ink blue
55
+ tokens.color.vga.silver // '#c0c0c0' — the face of every window
56
+
57
+ const series = [tokens.color.vga.navy, tokens.color.vga.green, tokens.color.vga.maroon]
58
+ ```
59
+
60
+ `tokens` is grouped by scale rather than flattened, so `tokens.color.vga.navy` narrows to its literal type and autocompletes at every level. The scales are Windows 98's values.
61
+
62
+ ## Themes as data
63
+
64
+ `tokens.themes` has each theme as the CSS variables it declares — every value a theme may set, by name:
65
+
66
+ ```ts
67
+ import { tokens } from '@rowkit/tokens'
68
+
69
+ tokens.themes.win98['--spacing-control-md'] // '28px'
70
+ tokens.themes.modern.light['--spacing-control-md'] // '32px'
71
+ tokens.themes.modern.dark // only what the dark scheme changes
72
+ ```
73
+
74
+ ## A theme of your own
50
75
 
51
- const series = [tokens.color.primary[500], tokens.color.success[500]]
76
+ `defineTheme()` starts from `modern` (the default) or `win98`, lays your values over it and returns the stylesheet — every variable declared, and for a theme with a dark scheme, the dark rules too, following the system unless `data-color-scheme` fixes it. A token name rowkit does not have throws, so a typo fails the build.
77
+
78
+ ```ts
79
+ import { defineTheme } from '@rowkit/tokens'
80
+
81
+ export const acme = defineTheme({
82
+ name: 'acme', // <html data-theme="acme">
83
+ extends: 'modern',
84
+ light: { '--color-control-primary': '#5b3df5', '--radius-md': '10px' },
85
+ dark: { '--color-control-primary': '#7c66ff' },
86
+ })
52
87
  ```
53
88
 
54
- `tokens` is grouped by scale rather than flattened, so `tokens.color.primary[600]` narrows to its literal type and autocompletes at every level.
89
+ Write the string to a file imported after `rowkit/styles`, or into a `<style>` element at start-up. `themeRule(selector, scheme, values)` writes one rule, if you would rather assemble the stylesheet yourself:
90
+
91
+ ```ts
92
+ import { themeRule, tokens } from '@rowkit/tokens'
93
+
94
+ themeRule('.print', 'light', { ...tokens.themes.win98, '--color-background': '#ffffff' })
95
+ ```
96
+
97
+ The whole guide, with a live builder: [Themes](https://rowkit.dev/foundations/themes).
98
+
99
+ ## Reference
100
+
101
+ `@rowkit/tokens/reference` describes every token a theme sets: what it is for, which components read it, and its value in Windows 98 and in modern light and dark. A separate entry point, so the main one stays small.
102
+
103
+ ```ts
104
+ import { tokenReference } from '@rowkit/tokens/reference'
105
+
106
+ tokenReference.find((t) => t.name === '--color-control-primary')
107
+ // { name, group: 'color', description: '…', components: ['Button'], values: { win98, modernLight, modernDark } }
108
+ ```
55
109
 
56
110
  ## Notes on the values
57
111
 
58
- **Colour is OKLCH, clamped to sRGB.** Every chromatic family shares one lightness ramp, so `primary-600`, `danger-600` and `success-600` carry the same perceptual weight. Chroma is clamped to the sRGB gamut on purpose: OKLCH can express colours outside it, and browsers gamut-map those by their own rules — which makes a token render differently on a P3 laptop than on an sRGB monitor.
112
+ **Windows 98's colour is the exact Windows 98 palette.** Primitives are `#rrggbb` values from the VGA palette and the default Windows 98 scheme, named as in the design's Figma variables. The modern palette follows the designer's Figma file.
113
+
114
+ **Depth: bevels in Windows 98, soft shadows in modern.** In Windows 98, `shadow-raised`, `shadow-sunken`, `shadow-window` and the rest are hard inset lines in the four `bevel-*` colours. The modern theme sets the same names to soft shadows outside the box and hairline edges.
115
+
116
+ **Corners: square in Windows 98, rounded in modern.** In Windows 98 the radius scale multiplies `--radius`, which is `0rem` until you set it. The modern theme sets each step as a length: 7px for a button or a field, 12px for a window.
117
+
118
+ **Type: PT Sans and VT323 in Windows 98, the system's faces in modern.** Both set the interface at 13px (`text-ui`) — in Windows 98, its 8pt at Large Fonts. Windows 98 has two weights, regular and bold; modern's emphasis (`--font-weight-strong`) is semibold. The font files are not shipped: for Windows 98, load `@fontsource/pt-sans` and `@fontsource/vt323` in the app. The modern theme loads nothing.
119
+
120
+ **Motion: next to none in Windows 98, short in modern.** Windows 98 changes state at once; the modern theme uses transitions of 120–160ms.
59
121
 
60
- **Contrast is asserted, not claimed.** Every semantic pairing is checked against WCAG AA in the package's own tests, in both themes.
122
+ **Contrast is asserted, not claimed.** Every semantic text pairing is checked against WCAG AA, and every control boundary and focus ring against 3:1, in every theme and scheme, in the package's own tests.
61
123
 
62
124
  **Spacing keys are multiples of 4px.** `4` is 1rem, `2` is 8px — the convention most Vue and Tailwind developers already carry.
63
125
 
@@ -67,4 +129,4 @@ const series = [tokens.color.primary[500], tokens.color.success[500]]
67
129
 
68
130
  MIT © Nikolai Kushner
69
131
 
70
- Design language based on [shadcn/ui](https://ui.shadcn.com) by shadcn, adapted for Vue. shadcn/ui is MIT licensed; rowkit adopts its token values and class recipes, not its code.
132
+ The Windows 98 theme is a tribute to Windows 98. rowkit is not affiliated with or endorsed by Microsoft.