@tenphi/tasty 0.0.0-snapshot.047dfbb → 0.0.0-snapshot.04fb534

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.
Files changed (134) hide show
  1. package/README.md +452 -370
  2. package/dist/babel-types-Dc5zghyE.d.ts +18 -0
  3. package/dist/chunks/async-storage-f9j9JRtq.js +37 -0
  4. package/dist/chunks/async-storage-f9j9JRtq.js.map +1 -0
  5. package/dist/chunks/build-config--0qoqt_P.js +60 -0
  6. package/dist/chunks/build-config--0qoqt_P.js.map +1 -0
  7. package/dist/{collector-J6LwZR0N.js → chunks/collector-zp5BrLF0.js} +68 -101
  8. package/dist/chunks/collector-zp5BrLF0.js.map +1 -0
  9. package/dist/chunks/config-engine-BaLq8HrX.js +272 -0
  10. package/dist/chunks/config-engine-BaLq8HrX.js.map +1 -0
  11. package/dist/chunks/config-file-DlZXJMj8.js +25 -0
  12. package/dist/chunks/config-file-DlZXJMj8.js.map +1 -0
  13. package/dist/chunks/css-definitions-CfXZ3tU9.js +910 -0
  14. package/dist/chunks/css-definitions-CfXZ3tU9.js.map +1 -0
  15. package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
  16. package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
  17. package/dist/chunks/debug--OC-WA-Q.js +502 -0
  18. package/dist/chunks/debug--OC-WA-Q.js.map +1 -0
  19. package/dist/chunks/dsl-CsFl9LGn.js +1458 -0
  20. package/dist/chunks/dsl-CsFl9LGn.js.map +1 -0
  21. package/dist/chunks/hydration-TRcz5vnk.js +41 -0
  22. package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
  23. package/dist/chunks/react-runtime-DnZ6M1Iv.js +691 -0
  24. package/dist/chunks/react-runtime-DnZ6M1Iv.js.map +1 -0
  25. package/dist/chunks/runtime-engine-J9X_h-Pw.js +2435 -0
  26. package/dist/chunks/runtime-engine-J9X_h-Pw.js.map +1 -0
  27. package/dist/chunks/runtime-state-o_v3Bj7b.js +152 -0
  28. package/dist/chunks/runtime-state-o_v3Bj7b.js.map +1 -0
  29. package/dist/{merge-styles-CAdKaHxh.js → chunks/shared-utils-y-HjvPN4.js} +60 -55
  30. package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
  31. package/dist/chunks/style-engine-D6lC3O3G.js +5626 -0
  32. package/dist/chunks/style-engine-D6lC3O3G.js.map +1 -0
  33. package/dist/{css-writer-IC7tdnIf.js → chunks/zero-engine-BnjoV04F.js} +95 -136
  34. package/dist/chunks/zero-engine-BnjoV04F.js.map +1 -0
  35. package/dist/{collector-CddJZDOr.d.ts → collector-D2OT6I2G.d.ts} +64 -8
  36. package/dist/{config-C3SKYuxY.d.ts → config-C4ftFxgI.d.ts} +514 -92
  37. package/dist/core/index.d.ts +5 -5
  38. package/dist/core/index.js +9 -6
  39. package/dist/hydrate-CRyjjAyl.d.ts +22 -0
  40. package/dist/{index-ByBYTH9l.d.ts → index-DxQNRj50.d.ts} +586 -400
  41. package/dist/index.d.ts +5 -5
  42. package/dist/index.js +11 -732
  43. package/dist/{merge-styles-CvUi7SOD.d.ts → merge-styles-D39qBtox.d.ts} +2 -3
  44. package/dist/ssr/astro-client.d.ts +1 -1
  45. package/dist/ssr/astro-client.js +1 -14
  46. package/dist/ssr/astro-client.js.map +1 -1
  47. package/dist/ssr/astro-middleware-extract-static.d.ts +10 -0
  48. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  49. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  50. package/dist/ssr/astro-middleware-extract.d.ts +10 -0
  51. package/dist/ssr/astro-middleware-extract.js +9 -0
  52. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  53. package/dist/ssr/astro-middleware-static.d.ts +17 -0
  54. package/dist/ssr/astro-middleware-static.js +7 -0
  55. package/dist/ssr/astro-middleware-static.js.map +1 -0
  56. package/dist/ssr/astro-middleware.d.ts +11 -8
  57. package/dist/ssr/astro-middleware.js +2 -14
  58. package/dist/ssr/astro-middleware.js.map +1 -1
  59. package/dist/ssr/astro.d.ts +40 -10
  60. package/dist/ssr/astro.js +160 -86
  61. package/dist/ssr/astro.js.map +1 -1
  62. package/dist/ssr/client.d.ts +2 -0
  63. package/dist/ssr/client.js +2 -0
  64. package/dist/ssr/index.d.ts +5 -32
  65. package/dist/ssr/index.js +6 -6
  66. package/dist/ssr/index.js.map +1 -1
  67. package/dist/ssr/next-config.d.ts +64 -0
  68. package/dist/ssr/next-config.js +123 -0
  69. package/dist/ssr/next-config.js.map +1 -0
  70. package/dist/ssr/next.d.ts +9 -8
  71. package/dist/ssr/next.js +29 -44
  72. package/dist/ssr/next.js.map +1 -1
  73. package/dist/static/index.d.ts +8 -9
  74. package/dist/static/index.js +4 -22
  75. package/dist/static/index.js.map +1 -1
  76. package/dist/static/inject.d.ts +1 -2
  77. package/dist/{index-C5owZ15q.d.ts → types-CYQIhUg1.d.ts} +874 -598
  78. package/dist/zero/babel.d.ts +12 -19
  79. package/dist/zero/babel.js +97 -156
  80. package/dist/zero/babel.js.map +1 -1
  81. package/dist/zero/index.d.ts +76 -7
  82. package/dist/zero/index.js +25 -2
  83. package/dist/zero/index.js.map +1 -0
  84. package/dist/zero/next.d.ts +4 -5
  85. package/dist/zero/next.js +3 -38
  86. package/dist/zero/next.js.map +1 -1
  87. package/docs/README.md +20 -9
  88. package/docs/adoption.md +69 -36
  89. package/docs/ai-agents.md +259 -0
  90. package/docs/comparison.md +77 -47
  91. package/docs/configuration.md +617 -98
  92. package/docs/debug.md +28 -15
  93. package/docs/design-system.md +166 -33
  94. package/docs/dsl.md +637 -205
  95. package/docs/getting-started.md +130 -50
  96. package/docs/injector.md +160 -69
  97. package/docs/llms.txt +31 -0
  98. package/docs/methodology.md +82 -51
  99. package/docs/migration-v3.md +285 -0
  100. package/docs/pipeline.md +57 -33
  101. package/docs/plugins.md +333 -0
  102. package/docs/react-api.md +215 -50
  103. package/docs/runtime-benchmarks.md +388 -0
  104. package/docs/ssr.md +310 -118
  105. package/docs/styles.md +209 -41
  106. package/docs/tasty-static.md +289 -136
  107. package/harness/dev.harnesspm/rules/usage.md +12 -0
  108. package/harness/dev.harnesspm/scripts/render.mjs +441 -0
  109. package/harness/dev.harnesspm/scripts/styles.mjs +412 -0
  110. package/harness/plugin.json +20 -0
  111. package/package.json +148 -49
  112. package/tasty.config.ts +5 -0
  113. package/dist/async-storage-DKK-wTD4.js +0 -44
  114. package/dist/async-storage-DKK-wTD4.js.map +0 -1
  115. package/dist/collector-J6LwZR0N.js.map +0 -1
  116. package/dist/config-C3F4Ogo1.js +0 -10993
  117. package/dist/config-C3F4Ogo1.js.map +0 -1
  118. package/dist/context-CA8YKeMn.js +0 -24
  119. package/dist/context-CA8YKeMn.js.map +0 -1
  120. package/dist/core-DxHmF6S9.js +0 -1598
  121. package/dist/core-DxHmF6S9.js.map +0 -1
  122. package/dist/css-writer-IC7tdnIf.js.map +0 -1
  123. package/dist/format-global-rules-DklyaXv-.js +0 -22
  124. package/dist/format-global-rules-DklyaXv-.js.map +0 -1
  125. package/dist/format-rules-DTLY39Hm.js +0 -143
  126. package/dist/format-rules-DTLY39Hm.js.map +0 -1
  127. package/dist/hydrate-8Zglgy_C.js +0 -45
  128. package/dist/hydrate-8Zglgy_C.js.map +0 -1
  129. package/dist/index.js.map +0 -1
  130. package/dist/keyframes-DgGkipNK.js +0 -595
  131. package/dist/keyframes-DgGkipNK.js.map +0 -1
  132. package/dist/merge-styles-CAdKaHxh.js.map +0 -1
  133. package/dist/resolve-recipes-BQNdunBd.js +0 -144
  134. package/dist/resolve-recipes-BQNdunBd.js.map +0 -1
package/docs/debug.md CHANGED
@@ -6,9 +6,7 @@ Runtime CSS inspection and diagnostics for the Tasty styling system. Inspect inj
6
6
 
7
7
  ## Overview
8
8
 
9
- `tastyDebug` is a diagnostic object that exposes Tasty's runtime CSS state. It is designed for development use but can be manually installed in production for debugging.
10
-
11
- In development mode (`isDevEnv()` returns `true`), `tastyDebug` is automatically installed on `window.tastyDebug`. In production, install it manually when needed.
9
+ `tastyDebug` is a diagnostic object that exposes Tasty's runtime CSS state. It is designed for development use and can be installed on `window` explicitly when needed.
12
10
 
13
11
  All methods **log to the console by default**. Pass `{ raw: true }` to suppress logging and only return data.
14
12
 
@@ -19,7 +17,6 @@ All methods **log to the console by default**. Pass `{ raw: true }` to suppress
19
17
  ## Quick Start
20
18
 
21
19
  ```typescript
22
- // Auto-installed in dev mode. Otherwise:
23
20
  import { tastyDebug } from '@tenphi/tasty';
24
21
  tastyDebug.install();
25
22
 
@@ -54,6 +51,19 @@ interface DebugOptions {
54
51
 
55
52
  When `raw` is `false` (the default), results are logged to the console **and** returned. When `raw` is `true`, results are returned silently.
56
53
 
54
+ ### Environments Without a DOM
55
+
56
+ `tastyDebug` reads the document, so on a server — SSR, a Node REPL, a test
57
+ runner in the `node` environment — there is nothing for it to read. Every
58
+ method returns its empty result (`''`, an empty `InspectResult`, a summary of
59
+ zeroes, `metrics: null`) instead of throwing, and explains itself once with a
60
+ console warning. `{ raw: true }` suppresses that warning along with the rest of
61
+ the logging.
62
+
63
+ To see the styles a server render produced, read the `ServerStyleCollector`
64
+ instead — `collector.getCSS()` and `collector.getRenderedClassNames()`. See
65
+ [SSR](./ssr.md).
66
+
57
67
  ---
58
68
 
59
69
  ## API Reference
@@ -68,7 +78,7 @@ Retrieves CSS text for a given target. Logs the result with rule count and size.
68
78
  |---|---|
69
79
  | `'all'` | All tasty CSS (component + global + raw) |
70
80
  | `'active'` | CSS for classes currently in the DOM |
71
- | `'unused'` | CSS with refCount = 0 (cached but not used) |
81
+ | `'unused'` | CSS for classes `gc({ force: true })` would delete now — not rendered, not pinned, past the `gc.grace` window |
72
82
  | `'global'` | Only global CSS (from `injectGlobal`) |
73
83
  | `'page'` | All CSS on the page (including non-tasty) |
74
84
  | `'t3a5f'` | CSS for a specific tasty class (class names are `t` + base36 hash) |
@@ -79,7 +89,7 @@ Retrieves CSS text for a given target. Logs the result with rule count and size.
79
89
  **Extra options:**
80
90
 
81
91
  ```typescript
82
- interface CssOptions extends DebugOptions {
92
+ interface CSSOptions extends DebugOptions {
83
93
  prettify?: boolean; // Format output (default: true)
84
94
  source?: boolean; // Read original CSS instead of live CSSOM (default: false, dev-mode only)
85
95
  }
@@ -111,14 +121,14 @@ Inspects a DOM element and returns detailed information about its tasty styles,
111
121
  ```typescript
112
122
  interface InspectResult {
113
123
  element?: Element | null;
114
- classes: string[]; // Tasty classes on the element
115
- chunks: ChunkInfo[]; // Chunk assignment per class
116
- css: string; // Prettified CSS
117
- size: number; // CSS size in characters
118
- rules: number; // Number of CSS rule blocks
124
+ classes: string[]; // Tasty classes on the element
125
+ chunks: DebugChunkInfo[]; // Chunk assignment per class
126
+ css: string; // Prettified CSS
127
+ size: number; // CSS size in characters
128
+ rules: number; // Number of CSS rule blocks
119
129
  }
120
130
 
121
- interface ChunkInfo {
131
+ interface DebugChunkInfo {
122
132
  className: string;
123
133
  chunkName: string | null; // e.g., 'appearance', 'font', 'dimension'
124
134
  }
@@ -144,7 +154,8 @@ One-shot overview of the entire Tasty CSS state. Logs a compact report.
144
154
  ```typescript
145
155
  interface Summary {
146
156
  activeClasses: string[];
147
- unusedClasses: string[];
157
+ unusedClasses: string[]; // classes gc({ force: true }) would delete now
158
+ hotClasses: string[]; // not rendered, but pinned or inside gc.grace — not yet collectable
148
159
  totalStyledClasses: string[];
149
160
 
150
161
  activeCSSSize: number;
@@ -241,7 +252,9 @@ tastyDebug.cache();
241
252
 
242
253
  ### `cleanup(opts?): void`
243
254
 
244
- Forces immediate cleanup of all unused styles (those with `refCount = 0`).
255
+ Removes every injected style that is neither carried by an element nor pinned by
256
+ an outstanding `inject()` handle — the same set `summary()` reports as unused.
257
+ Equivalent to `gc({ force: true })`.
245
258
 
246
259
  ```typescript
247
260
  tastyDebug.cleanup();
@@ -262,7 +275,7 @@ tastyDebug.help();
262
275
 
263
276
  ### `install(): void`
264
277
 
265
- Attaches `tastyDebug` to `window.tastyDebug`. Called automatically in development mode.
278
+ Attaches `tastyDebug` to `window.tastyDebug`.
266
279
 
267
280
  ```typescript
268
281
  import { tastyDebug } from '@tenphi/tasty';
@@ -1,8 +1,8 @@
1
1
  # Building a Design System
2
2
 
3
- This guide walks through building a design-system styling layer on top of Tasty — defining tokens, state aliases, recipes, primitive components, and compound components with sub-elements.
3
+ This guide shows how to build shared React components whose styles stay predictable as states, variants, themes, and responsive rules accumulate. You will define tokens, state aliases, recipes, primitive APIs, and compound components with sub-elements.
4
4
 
5
- It assumes you have already decided to adopt Tasty. The goal is not just to centralize tokens, but to define a styling language whose component states resolve deterministically across variants, responsive rules, and sub-elements. For evaluation criteria, audience fit, and incremental adoption phases, see the [Adoption Guide](adoption.md). For the recommended component patterns and mental model, see [Methodology](methodology.md).
5
+ It assumes you have already decided to adopt Tasty. The goal is not only to centralize values, but to give your design system one state model and a governed component-facing styling API. For evaluation criteria and incremental rollout, see the [Adoption Guide](adoption.md). For the recommended component architecture, see [Methodology](methodology.md).
6
6
 
7
7
  ---
8
8
 
@@ -42,15 +42,25 @@ configure({
42
42
  // Borders
43
43
  '#border': '#e0e0e0',
44
44
 
45
- // Unit values
46
- '$gap': '8px',
47
- '$radius': '4px',
45
+ // Spacing and shape scale
46
+ $gap: '8px',
47
+ $radius: '4px',
48
48
  '$border-width': '1px',
49
49
  '$outline-width': '2px',
50
50
  },
51
+ // Built-in units compile to fixed values by default. Pointing them at the
52
+ // tokens above lets a theme or density mode change the scale at runtime.
53
+ units: {
54
+ x: 'var(--gap)', // 2x → calc(2 * var(--gap))
55
+ r: 'var(--radius)',
56
+ bw: 'var(--border-width)',
57
+ ow: 'var(--outline-width)',
58
+ },
51
59
  });
52
60
  ```
53
61
 
62
+ Leave out the `units` block to keep the built-in fixed scale (`x` = `8px`, `r` = `6px`, `bw` = `1px`, `ow` = `3px`), or set fixed values there instead (`units: { x: '8px', r: '4px' }`). Define the token a unit points at; until you do, `--gap`, `--radius`, `--border-width`, and `--outline-width` start at the built-in unit values. Boolean shorthands follow the same scale: `radius: true` is `1r`, `border: true` is `1bw`, and `outline: true` is `1ow`. See [Built-in Units](dsl.md#built-in-units).
63
+
54
64
  Tokens are injected as CSS custom properties on `:root` when the first style is rendered. They support state maps for theme-aware values:
55
65
 
56
66
  ```tsx
@@ -66,7 +76,7 @@ configure({
66
76
 
67
77
  The `#on-*` convention names the text color that sits on top of a fill — `#on-primary` is the text color on a `#primary` background. This makes state maps self-documenting: `fill: '#primary'` and `color: '#on-primary'` clearly belong together.
68
78
 
69
- For OKHSL-based palette generation with automatic WCAG contrast solving, see [Glaze](https://github.com/tenphi/glaze).
79
+ To generate the whole palette instead of hand-picking values, use [Glaze](https://github.com/tenphi/glaze): it builds light, dark, and high-contrast variants from one hue in the OKHST color space, solves WCAG and APCA contrast, and exports Tasty tokens you can pass straight to `configure({ tokens: theme.tasty() })`.
70
80
 
71
81
  ### Replace tokens for value aliases
72
82
 
@@ -91,8 +101,18 @@ import { configure } from '@tenphi/tasty';
91
101
 
92
102
  configure({
93
103
  presets: {
94
- h1: { fontSize: '2rem', lineHeight: '1.2', letterSpacing: '-0.02em', fontWeight: 700 },
95
- t2: { fontSize: '0.875rem', lineHeight: '1.5', letterSpacing: 'normal', fontWeight: 400 },
104
+ h1: {
105
+ fontSize: '2rem',
106
+ lineHeight: '1.2',
107
+ letterSpacing: '-0.02em',
108
+ fontWeight: 700,
109
+ },
110
+ t2: {
111
+ fontSize: '0.875rem',
112
+ lineHeight: '1.5',
113
+ letterSpacing: 'normal',
114
+ fontWeight: 400,
115
+ },
96
116
  },
97
117
  });
98
118
  ```
@@ -117,14 +137,22 @@ Then use `preset: 'h1'` or `preset: 't2'` in any component's styles.
117
137
 
118
138
  ### Registering brand fonts
119
139
 
120
- Register your design system's custom fonts via `configure({ fontFace })` so every component can reference them:
140
+ Register your design system's custom fonts via `configure({ fontFaces })` so every component can reference them:
121
141
 
122
142
  ```ts
123
143
  configure({
124
- fontFace: {
144
+ fontFaces: {
125
145
  'Brand Sans': [
126
- { src: 'url("/fonts/brand-regular.woff2") format("woff2")', fontWeight: 400, fontDisplay: 'swap' },
127
- { src: 'url("/fonts/brand-bold.woff2") format("woff2")', fontWeight: 700, fontDisplay: 'swap' },
146
+ {
147
+ src: 'url("/fonts/brand-regular.woff2") format("woff2")',
148
+ fontWeight: 400,
149
+ fontDisplay: 'swap',
150
+ },
151
+ {
152
+ src: 'url("/fonts/brand-bold.woff2") format("woff2")',
153
+ fontWeight: 700,
154
+ fontDisplay: 'swap',
155
+ },
128
156
  ],
129
157
  },
130
158
  });
@@ -144,7 +172,8 @@ configure({
144
172
  '@mobile': '@media(w < 768px)',
145
173
  '@tablet': '@media(768px <= w < 1024px)',
146
174
  '@desktop': '@media(w >= 1024px)',
147
- '@dark': '@root(schema=dark) | (!@root(schema) & @media(prefers-color-scheme: dark))',
175
+ '@dark':
176
+ '@root(schema=dark) | (!@root(schema) & @media(prefers-color-scheme: dark))',
148
177
  '@reduced-motion': '@media(prefers-reduced-motion: reduce)',
149
178
  },
150
179
  });
@@ -157,11 +186,25 @@ const Card = tasty({
157
186
  styles: {
158
187
  padding: { '': '4x', '@mobile': '2x' },
159
188
  flow: { '': 'row', '@mobile': 'column' },
160
- fill: { '': '#surface', '@dark': '#surface-dark' },
189
+ radius: { '': '1r', '@mobile': '0' },
161
190
  },
162
191
  });
163
192
  ```
164
193
 
194
+ Aliases can build on each other, so a composite state is defined once too:
195
+
196
+ ```tsx
197
+ configure({
198
+ states: {
199
+ '@mobile': '@media(w < 768px)',
200
+ '@tablet': '@media(768px <= w < 1024px)',
201
+ '@touch': '@mobile | @tablet',
202
+ },
203
+ });
204
+ ```
205
+
206
+ Theme switching belongs in tokens (`'#surface': { '': '#fff', '@dark': '#1c1c1e' }`) rather than in component state maps, so components stay theme-agnostic.
207
+
165
208
  Without aliases, the same component would need the full media query expression inlined in every state map — across every property, in every component. Aliases eliminate that duplication.
166
209
 
167
210
  ---
@@ -185,7 +228,7 @@ configure({
185
228
  'input-reset': {
186
229
  border: 'none',
187
230
  outline: 'none',
188
- fill: 'transparent',
231
+ fill: '#clear',
189
232
  font: true,
190
233
  preset: 't3',
191
234
  },
@@ -211,7 +254,7 @@ const ProfileCard = tasty({
211
254
  });
212
255
  ```
213
256
 
214
- Use the `/` separator when a recipe should be applied *after* local styles (post-merge), so recipe states take priority:
257
+ Use the `/` separator when a recipe should be applied _after_ local styles (post-merge), so recipe states take priority:
215
258
 
216
259
  ```tsx
217
260
  const Input = tasty({
@@ -260,7 +303,7 @@ const Grid = tasty({
260
303
  display: 'grid',
261
304
  gap: '1x',
262
305
  },
263
- styleProps: [...FLOW_STYLES, 'gridColumns', 'gridRows', 'gridAreas'],
306
+ styleProps: FLOW_STYLES, // includes gridColumns, gridRows, gridAreas
264
307
  });
265
308
  ```
266
309
 
@@ -279,18 +322,54 @@ Product engineers use these to compose layouts without writing CSS:
279
322
  </Grid>
280
323
  ```
281
324
 
325
+ ### Interactive components with variants
326
+
327
+ Variants are named looks that replace each other. Combine them with `modProps` for states that stack, such as size or loading:
328
+
329
+ ```tsx
330
+ const Button = tasty({
331
+ as: 'button',
332
+ modProps: { size: ['sm', 'md', 'lg'] as const },
333
+ styles: {
334
+ recipe: 'interactive',
335
+ padding: { '': '1.5x 3x', 'size=sm': '1x 2x', 'size=lg': '2x 4x' },
336
+ radius: '1r',
337
+ },
338
+ variants: {
339
+ default: {
340
+ fill: {
341
+ '': '#primary',
342
+ ':hover': '#primary-hover',
343
+ disabled: '#surface',
344
+ },
345
+ color: '#on-primary',
346
+ },
347
+ danger: {
348
+ fill: { '': '#danger', ':hover': '#danger-hover', disabled: '#surface' },
349
+ color: '#on-danger',
350
+ },
351
+ },
352
+ });
353
+
354
+ <Button variant="danger" size="lg">
355
+ Delete
356
+ </Button>;
357
+ ```
358
+
359
+ `variant` is typed from the keys, the `default` variant applies when no `variant` prop is passed (or the variant the `variant` option names, such as `variant: 'danger'`), and only the variants that actually render emit CSS. See [React API — Variants](react-api.md#variants).
360
+
282
361
  ### Which styleProps to expose
283
362
 
284
363
  Match the prop set to the component's role:
285
364
 
286
- | Component category | Recommended styleProps |
287
- |--------------------|----------------------|
288
- | Layout containers (`Space`, `Box`, `Grid`) | `FLOW_STYLES` — flow, gap, align, justify, padding, fill |
289
- | Positioned elements (`Button`, `Badge`) | `POSITION_STYLES` — placeSelf, gridArea, order |
290
- | Text elements | `['preset', 'color']` or a custom subset |
291
- | Compound components | Typically none — styling happens via sub-elements and wrapping |
365
+ | Component category | Recommended styleProps |
366
+ | ------------------------------------------ | --------------------------------------------------------------------------------------------------- |
367
+ | Layout containers (`Space`, `Box`, `Grid`) | `FLOW_STYLES` — flow, gap, align/justify/place, grid templates (add `padding` or `fill` explicitly) |
368
+ | Positioned elements (`Button`, `Badge`) | `POSITION_STYLES` — placeSelf, gridArea, order |
369
+ | Text elements | `['color', ...TEXT_STYLES]` (`preset` is always available) |
370
+ | Compound components | Typically none — styling happens via sub-elements and wrapping |
292
371
 
293
- Exposing too many props weakens the design system's constraints. See [Methodology — styleProps as the public API](methodology.md#styleprops-as-the-public-api) for the rationale.
372
+ `BASE_STYLES` (`display`, `font`, `preset`, `hide`, `whiteSpace`, `opacity`, `transition`) are accepted as props on every component without being listed. Exposing too many props weakens the design system's constraints. See [Methodology — styleProps as the public API](methodology.md#styleprops-as-the-public-api) for the rationale.
294
373
 
295
374
  ---
296
375
 
@@ -335,9 +414,7 @@ Usage:
335
414
  ```tsx
336
415
  <Card>
337
416
  <Card.Title>Monthly Revenue</Card.Title>
338
- <Card.Content>
339
- $1.2M — up 12% from last month.
340
- </Card.Content>
417
+ <Card.Content>$1.2M — up 12% from last month.</Card.Content>
341
418
  <Card.Footer>
342
419
  <Button>Details</Button>
343
420
  </Card.Footer>
@@ -352,26 +429,28 @@ For sub-element syntax details (selector affix `$`, `@own()`, `elements` config)
352
429
 
353
430
  ## Defining the override contract
354
431
 
355
- A design system works best when the rules for customization are explicit. Tasty provides three levels of control:
432
+ A design system works best when the rules for customization are explicit. Tasty gives product engineers four sanctioned ways to customize a component, and a few to discourage:
356
433
 
357
434
  ### What product engineers can do
358
435
 
359
436
  1. **Use styleProps** — adjust layout, spacing, positioning through the props the component exposes:
360
437
 
361
438
  ```tsx
362
- <Space flow="row" gap="3x" padding="2x">
439
+ <Space flow="row" gap="3x" placeItems="center">
363
440
  ```
364
441
 
365
442
  2. **Use modProps** — control component states through typed props instead of `mods`:
366
443
 
367
444
  ```tsx
368
- <Button isLoading size="large">Submit</Button>
445
+ <Button isLoading size="large">
446
+ Submit
447
+ </Button>
369
448
  ```
370
449
 
371
450
  3. **Pass tokens** — inject runtime values through the `tokens` prop for per-instance customization:
372
451
 
373
452
  ```tsx
374
- <ProgressBar tokens={{ '$progress': `${percent}%` }} />
453
+ <ProgressBar tokens={{ $progress: `${percent}%` }} />
375
454
  ```
376
455
 
377
456
  4. **Create styled wrappers** — extend a component's styles with `tasty(Base, { styles })`:
@@ -379,7 +458,12 @@ A design system works best when the rules for customization are explicit. Tasty
379
458
  ```tsx
380
459
  const DangerButton = tasty(Button, {
381
460
  styles: {
382
- fill: { '': '#danger', ':hover': '#danger-hover' },
461
+ fill: {
462
+ '': '#danger',
463
+ ':hover': '#danger-hover',
464
+ ':active': '#danger-pressed',
465
+ disabled: '@inherit', // a map with '' replaces the parent's; keep its disabled branch
466
+ },
383
467
  color: '#on-danger',
384
468
  },
385
469
  });
@@ -395,6 +479,53 @@ See [Methodology — styles prop vs style prop](methodology.md#styles-prop-vs-st
395
479
 
396
480
  ---
397
481
 
482
+ ## Guardrails: linting and types
483
+
484
+ A vocabulary only holds if mistakes surface early. Register the same names you pass to `configure()` with the ESLint plugin and with TypeScript:
485
+
486
+ ```ts
487
+ // tasty.config.ts — read by @tenphi/eslint-plugin-tasty
488
+ export default {
489
+ tokens: ['#surface', '#text', '#primary', '#danger', '$gap', '$radius'],
490
+ states: ['@mobile', '@tablet', '@desktop', '@dark', '@reduced-motion'],
491
+ presets: ['h1', 'h2', 'h3', 't2', 't3'],
492
+ recipes: ['card', 'elevated', 'input-reset', 'interactive'],
493
+ importSources: ['@my-org/ds'], // where product code imports tasty() from
494
+ };
495
+ ```
496
+
497
+ ```js
498
+ // eslint.config.js
499
+ import tasty from '@tenphi/eslint-plugin-tasty';
500
+
501
+ export default [tasty.configs.recommended]; // or tasty.configs.strict
502
+ ```
503
+
504
+ ```ts
505
+ // tasty.d.ts
506
+ import '@tenphi/tasty';
507
+
508
+ declare module '@tenphi/tasty' {
509
+ interface TastyNamedColors {
510
+ surface: true;
511
+ text: true;
512
+ primary: true;
513
+ danger: true;
514
+ }
515
+ interface TastyPresetNames {
516
+ h1: true;
517
+ h2: true;
518
+ h3: true;
519
+ t2: true;
520
+ t3: true;
521
+ }
522
+ }
523
+ ```
524
+
525
+ Unknown colors, presets, and recipes then fail lint (`valid-color-token`, `valid-preset`, `valid-recipe`), and `strict` adds checks for unknown `$` tokens and state aliases (`valid-custom-property`, `no-unknown-state-alias`). The same names autocomplete in editors. Deriving both lists from the same token and recipe modules that `config.ts` imports keeps all three in sync.
526
+
527
+ ---
528
+
398
529
  ## Project structure
399
530
 
400
531
  A recommended structure for a design system built on Tasty:
@@ -402,6 +533,8 @@ A recommended structure for a design system built on Tasty:
402
533
  ```
403
534
  ds/
404
535
  config.ts # configure() — tokens, units, states, recipes
536
+ tasty.config.ts # Names the ESLint plugin validates against
537
+ tasty.d.ts # TypeScript augmentation for autocomplete
405
538
  primitives/
406
539
  Space.tsx # Layout: flex container with FLOW_STYLES
407
540
  Box.tsx # Generic container
@@ -417,7 +550,7 @@ ds/
417
550
  tokens/
418
551
  colors.ts # Color token definitions
419
552
  typography.ts # Typography presets for configure({ presets })
420
- spacing.ts # Spacing token definitions
553
+ units.ts # Spacing and shape scale for configure({ units })
421
554
  index.ts # Public API: re-exports components + configure
422
555
  ```
423
556