@tenphi/tasty 0.0.0-snapshot.b49e579 → 0.0.0-snapshot.b4e384c
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 +436 -394
- package/dist/babel-types-Dc5zghyE.d.ts +18 -0
- package/dist/chunks/async-storage-f9j9JRtq.js +37 -0
- package/dist/chunks/async-storage-f9j9JRtq.js.map +1 -0
- package/dist/chunks/build-config-D9Iq8QQm.js +60 -0
- package/dist/chunks/build-config-D9Iq8QQm.js.map +1 -0
- package/dist/{collector-D6fpuCdp.js → chunks/collector-Cb8ah2JF.js} +25 -119
- package/dist/chunks/collector-Cb8ah2JF.js.map +1 -0
- package/dist/chunks/config-engine-CMYFZYQh.js +272 -0
- package/dist/chunks/config-engine-CMYFZYQh.js.map +1 -0
- package/dist/chunks/config-file-DlZXJMj8.js +25 -0
- package/dist/chunks/config-file-DlZXJMj8.js.map +1 -0
- package/dist/chunks/css-definitions-B4aWBkH3.js +910 -0
- package/dist/chunks/css-definitions-B4aWBkH3.js.map +1 -0
- package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
- package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
- package/dist/chunks/debug-D2Pu7Xhy.js +502 -0
- package/dist/chunks/debug-D2Pu7Xhy.js.map +1 -0
- package/dist/chunks/dsl-CsFl9LGn.js +1458 -0
- package/dist/chunks/dsl-CsFl9LGn.js.map +1 -0
- package/dist/chunks/hydration-TRcz5vnk.js +41 -0
- package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
- package/dist/chunks/react-runtime-DHiopXCu.js +691 -0
- package/dist/chunks/react-runtime-DHiopXCu.js.map +1 -0
- package/dist/chunks/runtime-engine-NGCofNXy.js +2435 -0
- package/dist/chunks/runtime-engine-NGCofNXy.js.map +1 -0
- package/dist/chunks/runtime-state-lZjMbvwV.js +152 -0
- package/dist/chunks/runtime-state-lZjMbvwV.js.map +1 -0
- package/dist/{merge-styles-biRwSixM.js → chunks/shared-utils-y-HjvPN4.js} +60 -55
- package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
- package/dist/chunks/style-engine-DnkV_4Jg.js +5602 -0
- package/dist/chunks/style-engine-DnkV_4Jg.js.map +1 -0
- package/dist/{css-writer-DB4ZVUYy.js → chunks/zero-engine-DcwaCvFs.js} +65 -145
- package/dist/chunks/zero-engine-DcwaCvFs.js.map +1 -0
- package/dist/{collector-D8o4Wdq-.d.ts → collector-D2OT6I2G.d.ts} +23 -4
- package/dist/{config-De8L9NWM.d.ts → config-C4ftFxgI.d.ts} +273 -78
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.js +9 -6
- package/dist/hydrate-CRyjjAyl.d.ts +22 -0
- package/dist/{index-DzGxoeyN.d.ts → index-DxQNRj50.d.ts} +369 -258
- package/dist/index.d.ts +5 -5
- package/dist/index.js +11 -867
- package/dist/{merge-styles-DLm4wdnb.d.ts → merge-styles-D39qBtox.d.ts} +2 -3
- package/dist/ssr/astro-client.d.ts +1 -1
- package/dist/ssr/astro-client.js +1 -14
- package/dist/ssr/astro-client.js.map +1 -1
- package/dist/ssr/astro-middleware-extract-static.d.ts +10 -0
- package/dist/ssr/astro-middleware-extract-static.js +9 -0
- package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
- package/dist/ssr/astro-middleware-extract.d.ts +10 -0
- package/dist/ssr/astro-middleware-extract.js +9 -0
- package/dist/ssr/astro-middleware-extract.js.map +1 -0
- package/dist/ssr/astro-middleware-static.d.ts +3 -2
- package/dist/ssr/astro-middleware-static.js +0 -11
- package/dist/ssr/astro-middleware-static.js.map +1 -1
- package/dist/ssr/astro-middleware.d.ts +3 -2
- package/dist/ssr/astro-middleware.js +0 -12
- package/dist/ssr/astro-middleware.js.map +1 -1
- package/dist/ssr/astro.d.ts +40 -6
- package/dist/ssr/astro.js +157 -93
- package/dist/ssr/astro.js.map +1 -1
- package/dist/ssr/client.d.ts +2 -0
- package/dist/ssr/client.js +2 -0
- package/dist/ssr/index.d.ts +5 -25
- package/dist/ssr/index.js +5 -5
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/next-config.d.ts +64 -0
- package/dist/ssr/next-config.js +123 -0
- package/dist/ssr/next-config.js.map +1 -0
- package/dist/ssr/next.d.ts +9 -8
- package/dist/ssr/next.js +29 -43
- package/dist/ssr/next.js.map +1 -1
- package/dist/static/index.d.ts +8 -9
- package/dist/static/index.js +4 -22
- package/dist/static/index.js.map +1 -1
- package/dist/static/inject.d.ts +1 -2
- package/dist/{index-KUYya3x7.d.ts → types-CYQIhUg1.d.ts} +745 -592
- package/dist/zero/babel.d.ts +73 -2
- package/dist/zero/babel.js +81 -144
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.d.ts +63 -8
- package/dist/zero/index.js +25 -2
- package/dist/zero/index.js.map +1 -0
- package/dist/zero/next.d.ts +4 -5
- package/dist/zero/next.js +3 -38
- package/dist/zero/next.js.map +1 -1
- package/docs/README.md +16 -8
- package/docs/adoption.md +69 -36
- package/docs/ai-agents.md +122 -86
- package/docs/comparison.md +77 -47
- package/docs/configuration.md +434 -110
- package/docs/debug.md +21 -8
- package/docs/design-system.md +152 -31
- package/docs/dsl.md +503 -222
- package/docs/getting-started.md +130 -50
- package/docs/injector.md +117 -68
- package/docs/methodology.md +81 -50
- package/docs/migration-v3.md +52 -52
- package/docs/pipeline.md +55 -31
- package/docs/plugins.md +59 -75
- package/docs/react-api.md +141 -55
- package/docs/runtime-benchmarks.md +388 -0
- package/docs/ssr.md +285 -101
- package/docs/styles.md +178 -35
- package/docs/tasty-static.md +286 -135
- package/package.json +125 -41
- package/dist/async-storage-DKK-wTD4.js +0 -44
- package/dist/async-storage-DKK-wTD4.js.map +0 -1
- package/dist/babel-R2qT7yLN.d.ts +0 -83
- package/dist/collector-D6fpuCdp.js.map +0 -1
- package/dist/config-Bxme0Moq.js +0 -12442
- package/dist/config-Bxme0Moq.js.map +0 -1
- package/dist/context-CA8YKeMn.js +0 -24
- package/dist/context-CA8YKeMn.js.map +0 -1
- package/dist/core-BR4waa0Q.js +0 -1552
- package/dist/core-BR4waa0Q.js.map +0 -1
- package/dist/css-writer-DB4ZVUYy.js.map +0 -1
- package/dist/format-global-rules-DklyaXv-.js +0 -22
- package/dist/format-global-rules-DklyaXv-.js.map +0 -1
- package/dist/format-rules-BXSRL8KZ.js +0 -145
- package/dist/format-rules-BXSRL8KZ.js.map +0 -1
- package/dist/hydrate-D_EWjD6z.js +0 -37
- package/dist/hydrate-D_EWjD6z.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/keyframes-DrUITLCz.js +0 -424
- package/dist/keyframes-DrUITLCz.js.map +0 -1
- package/dist/merge-styles-biRwSixM.js.map +0 -1
- package/dist/resolve-recipes-CBVdPz67.js +0 -144
- package/dist/resolve-recipes-CBVdPz67.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
|
|
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
|
|
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) |
|
|
@@ -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
|
-
|
|
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`.
|
|
278
|
+
Attaches `tastyDebug` to `window.tastyDebug`.
|
|
266
279
|
|
|
267
280
|
```typescript
|
|
268
281
|
import { tastyDebug } from '@tenphi/tasty';
|
package/docs/design-system.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Building a Design System
|
|
2
2
|
|
|
3
|
-
This guide
|
|
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
|
|
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
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
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: {
|
|
95
|
-
|
|
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
|
```
|
|
@@ -123,8 +143,16 @@ Register your design system's custom fonts via `configure({ fontFaces })` so eve
|
|
|
123
143
|
configure({
|
|
124
144
|
fontFaces: {
|
|
125
145
|
'Brand Sans': [
|
|
126
|
-
{
|
|
127
|
-
|
|
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':
|
|
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,13 @@ const Card = tasty({
|
|
|
157
186
|
styles: {
|
|
158
187
|
padding: { '': '4x', '@mobile': '2x' },
|
|
159
188
|
flow: { '': 'row', '@mobile': 'column' },
|
|
160
|
-
|
|
189
|
+
radius: { '': '1r', '@mobile': '0' },
|
|
161
190
|
},
|
|
162
191
|
});
|
|
163
192
|
```
|
|
164
193
|
|
|
194
|
+
Theme switching belongs in tokens (`'#surface': { '': '#fff', '@dark': '#1c1c1e' }`) rather than in component state maps, so components stay theme-agnostic.
|
|
195
|
+
|
|
165
196
|
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
197
|
|
|
167
198
|
---
|
|
@@ -185,7 +216,7 @@ configure({
|
|
|
185
216
|
'input-reset': {
|
|
186
217
|
border: 'none',
|
|
187
218
|
outline: 'none',
|
|
188
|
-
fill: '
|
|
219
|
+
fill: '#clear',
|
|
189
220
|
font: true,
|
|
190
221
|
preset: 't3',
|
|
191
222
|
},
|
|
@@ -211,7 +242,7 @@ const ProfileCard = tasty({
|
|
|
211
242
|
});
|
|
212
243
|
```
|
|
213
244
|
|
|
214
|
-
Use the `/` separator when a recipe should be applied
|
|
245
|
+
Use the `/` separator when a recipe should be applied _after_ local styles (post-merge), so recipe states take priority:
|
|
215
246
|
|
|
216
247
|
```tsx
|
|
217
248
|
const Input = tasty({
|
|
@@ -260,7 +291,7 @@ const Grid = tasty({
|
|
|
260
291
|
display: 'grid',
|
|
261
292
|
gap: '1x',
|
|
262
293
|
},
|
|
263
|
-
styleProps:
|
|
294
|
+
styleProps: FLOW_STYLES, // includes gridColumns, gridRows, gridAreas
|
|
264
295
|
});
|
|
265
296
|
```
|
|
266
297
|
|
|
@@ -279,18 +310,54 @@ Product engineers use these to compose layouts without writing CSS:
|
|
|
279
310
|
</Grid>
|
|
280
311
|
```
|
|
281
312
|
|
|
313
|
+
### Interactive components with variants
|
|
314
|
+
|
|
315
|
+
Variants are named looks that replace each other. Combine them with `modProps` for states that stack, such as size or loading:
|
|
316
|
+
|
|
317
|
+
```tsx
|
|
318
|
+
const Button = tasty({
|
|
319
|
+
as: 'button',
|
|
320
|
+
modProps: { size: ['sm', 'md', 'lg'] as const },
|
|
321
|
+
styles: {
|
|
322
|
+
recipe: 'interactive',
|
|
323
|
+
padding: { '': '1.5x 3x', 'size=sm': '1x 2x', 'size=lg': '2x 4x' },
|
|
324
|
+
radius: '1r',
|
|
325
|
+
},
|
|
326
|
+
variants: {
|
|
327
|
+
default: {
|
|
328
|
+
fill: {
|
|
329
|
+
'': '#primary',
|
|
330
|
+
':hover': '#primary-hover',
|
|
331
|
+
disabled: '#surface',
|
|
332
|
+
},
|
|
333
|
+
color: '#on-primary',
|
|
334
|
+
},
|
|
335
|
+
danger: {
|
|
336
|
+
fill: { '': '#danger', ':hover': '#danger-hover', disabled: '#surface' },
|
|
337
|
+
color: '#on-danger',
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
<Button variant="danger" size="lg">
|
|
343
|
+
Delete
|
|
344
|
+
</Button>;
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
`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).
|
|
348
|
+
|
|
282
349
|
### Which styleProps to expose
|
|
283
350
|
|
|
284
351
|
Match the prop set to the component's role:
|
|
285
352
|
|
|
286
|
-
| Component category
|
|
287
|
-
|
|
288
|
-
| Layout containers (`Space`, `Box`, `Grid`) | `FLOW_STYLES` — flow, gap, align
|
|
289
|
-
| Positioned elements (`Button`, `Badge`)
|
|
290
|
-
| Text elements
|
|
291
|
-
| Compound components
|
|
353
|
+
| Component category | Recommended styleProps |
|
|
354
|
+
| ------------------------------------------ | --------------------------------------------------------------------------------------------------- |
|
|
355
|
+
| Layout containers (`Space`, `Box`, `Grid`) | `FLOW_STYLES` — flow, gap, align/justify/place, grid templates (add `padding` or `fill` explicitly) |
|
|
356
|
+
| Positioned elements (`Button`, `Badge`) | `POSITION_STYLES` — placeSelf, gridArea, order |
|
|
357
|
+
| Text elements | `['color', ...TEXT_STYLES]` (`preset` is always available) |
|
|
358
|
+
| Compound components | Typically none — styling happens via sub-elements and wrapping |
|
|
292
359
|
|
|
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.
|
|
360
|
+
`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
361
|
|
|
295
362
|
---
|
|
296
363
|
|
|
@@ -335,9 +402,7 @@ Usage:
|
|
|
335
402
|
```tsx
|
|
336
403
|
<Card>
|
|
337
404
|
<Card.Title>Monthly Revenue</Card.Title>
|
|
338
|
-
<Card.Content>
|
|
339
|
-
$1.2M — up 12% from last month.
|
|
340
|
-
</Card.Content>
|
|
405
|
+
<Card.Content>$1.2M — up 12% from last month.</Card.Content>
|
|
341
406
|
<Card.Footer>
|
|
342
407
|
<Button>Details</Button>
|
|
343
408
|
</Card.Footer>
|
|
@@ -352,26 +417,28 @@ For sub-element syntax details (selector affix `$`, `@own()`, `elements` config)
|
|
|
352
417
|
|
|
353
418
|
## Defining the override contract
|
|
354
419
|
|
|
355
|
-
A design system works best when the rules for customization are explicit. Tasty
|
|
420
|
+
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
421
|
|
|
357
422
|
### What product engineers can do
|
|
358
423
|
|
|
359
424
|
1. **Use styleProps** — adjust layout, spacing, positioning through the props the component exposes:
|
|
360
425
|
|
|
361
426
|
```tsx
|
|
362
|
-
<Space flow="row" gap="3x"
|
|
427
|
+
<Space flow="row" gap="3x" placeItems="center">
|
|
363
428
|
```
|
|
364
429
|
|
|
365
430
|
2. **Use modProps** — control component states through typed props instead of `mods`:
|
|
366
431
|
|
|
367
432
|
```tsx
|
|
368
|
-
<Button isLoading size="large">
|
|
433
|
+
<Button isLoading size="large">
|
|
434
|
+
Submit
|
|
435
|
+
</Button>
|
|
369
436
|
```
|
|
370
437
|
|
|
371
438
|
3. **Pass tokens** — inject runtime values through the `tokens` prop for per-instance customization:
|
|
372
439
|
|
|
373
440
|
```tsx
|
|
374
|
-
<ProgressBar tokens={{
|
|
441
|
+
<ProgressBar tokens={{ $progress: `${percent}%` }} />
|
|
375
442
|
```
|
|
376
443
|
|
|
377
444
|
4. **Create styled wrappers** — extend a component's styles with `tasty(Base, { styles })`:
|
|
@@ -379,7 +446,12 @@ A design system works best when the rules for customization are explicit. Tasty
|
|
|
379
446
|
```tsx
|
|
380
447
|
const DangerButton = tasty(Button, {
|
|
381
448
|
styles: {
|
|
382
|
-
fill: {
|
|
449
|
+
fill: {
|
|
450
|
+
'': '#danger',
|
|
451
|
+
':hover': '#danger-hover',
|
|
452
|
+
':active': '#danger-pressed',
|
|
453
|
+
disabled: '@inherit', // a map with '' replaces the parent's; keep its disabled branch
|
|
454
|
+
},
|
|
383
455
|
color: '#on-danger',
|
|
384
456
|
},
|
|
385
457
|
});
|
|
@@ -395,6 +467,53 @@ See [Methodology — styles prop vs style prop](methodology.md#styles-prop-vs-st
|
|
|
395
467
|
|
|
396
468
|
---
|
|
397
469
|
|
|
470
|
+
## Guardrails: linting and types
|
|
471
|
+
|
|
472
|
+
A vocabulary only holds if mistakes surface early. Register the same names you pass to `configure()` with the ESLint plugin and with TypeScript:
|
|
473
|
+
|
|
474
|
+
```ts
|
|
475
|
+
// tasty.config.ts — read by @tenphi/eslint-plugin-tasty
|
|
476
|
+
export default {
|
|
477
|
+
tokens: ['#surface', '#text', '#primary', '#danger', '$gap', '$radius'],
|
|
478
|
+
states: ['@mobile', '@tablet', '@desktop', '@dark', '@reduced-motion'],
|
|
479
|
+
presets: ['h1', 'h2', 'h3', 't2', 't3'],
|
|
480
|
+
recipes: ['card', 'elevated', 'input-reset', 'interactive'],
|
|
481
|
+
importSources: ['@my-org/ds'], // where product code imports tasty() from
|
|
482
|
+
};
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
```js
|
|
486
|
+
// eslint.config.js
|
|
487
|
+
import tasty from '@tenphi/eslint-plugin-tasty';
|
|
488
|
+
|
|
489
|
+
export default [tasty.configs.recommended]; // or tasty.configs.strict
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
```ts
|
|
493
|
+
// tasty.d.ts
|
|
494
|
+
import '@tenphi/tasty';
|
|
495
|
+
|
|
496
|
+
declare module '@tenphi/tasty' {
|
|
497
|
+
interface TastyNamedColors {
|
|
498
|
+
surface: true;
|
|
499
|
+
text: true;
|
|
500
|
+
primary: true;
|
|
501
|
+
danger: true;
|
|
502
|
+
}
|
|
503
|
+
interface TastyPresetNames {
|
|
504
|
+
h1: true;
|
|
505
|
+
h2: true;
|
|
506
|
+
h3: true;
|
|
507
|
+
t2: true;
|
|
508
|
+
t3: true;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
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.
|
|
514
|
+
|
|
515
|
+
---
|
|
516
|
+
|
|
398
517
|
## Project structure
|
|
399
518
|
|
|
400
519
|
A recommended structure for a design system built on Tasty:
|
|
@@ -402,6 +521,8 @@ A recommended structure for a design system built on Tasty:
|
|
|
402
521
|
```
|
|
403
522
|
ds/
|
|
404
523
|
config.ts # configure() — tokens, units, states, recipes
|
|
524
|
+
tasty.config.ts # Names the ESLint plugin validates against
|
|
525
|
+
tasty.d.ts # TypeScript augmentation for autocomplete
|
|
405
526
|
primitives/
|
|
406
527
|
Space.tsx # Layout: flex container with FLOW_STYLES
|
|
407
528
|
Box.tsx # Generic container
|
|
@@ -417,7 +538,7 @@ ds/
|
|
|
417
538
|
tokens/
|
|
418
539
|
colors.ts # Color token definitions
|
|
419
540
|
typography.ts # Typography presets for configure({ presets })
|
|
420
|
-
|
|
541
|
+
units.ts # Spacing and shape scale for configure({ units })
|
|
421
542
|
index.ts # Public API: re-exports components + configure
|
|
422
543
|
```
|
|
423
544
|
|