@tenphi/tasty 0.0.0-snapshot.a85ade8 → 0.0.0-snapshot.a8a2a5d
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 +418 -381
- package/dist/babel-types-BOABQvEI.d.ts +16 -0
- package/dist/chunks/async-storage-CzSKAyrI.js +36 -0
- package/dist/chunks/async-storage-CzSKAyrI.js.map +1 -0
- package/dist/chunks/build-config-DQkT3Wru.js +59 -0
- package/dist/chunks/build-config-DQkT3Wru.js.map +1 -0
- package/dist/{collector-C6TtL8HJ.js → chunks/collector-Df9zcabl.js} +11 -129
- package/dist/chunks/collector-Df9zcabl.js.map +1 -0
- package/dist/chunks/config-engine-C7OUmM1J.js +269 -0
- package/dist/chunks/config-engine-C7OUmM1J.js.map +1 -0
- package/dist/chunks/config-file-BX3F_61U.js +24 -0
- package/dist/chunks/config-file-BX3F_61U.js.map +1 -0
- package/dist/chunks/css-definitions-BkdTqT7G.js +896 -0
- package/dist/chunks/css-definitions-BkdTqT7G.js.map +1 -0
- package/dist/chunks/css-resources-C0zT36nQ.js +141 -0
- package/dist/chunks/css-resources-C0zT36nQ.js.map +1 -0
- package/dist/chunks/debug-CwGMB2RI.js +501 -0
- package/dist/chunks/debug-CwGMB2RI.js.map +1 -0
- package/dist/chunks/dsl-BAwiOznp.js +1442 -0
- package/dist/chunks/dsl-BAwiOznp.js.map +1 -0
- package/dist/chunks/hydration-DEmoq1sQ.js +39 -0
- package/dist/chunks/hydration-DEmoq1sQ.js.map +1 -0
- package/dist/chunks/react-runtime-B8YqpFx7.js +678 -0
- package/dist/chunks/react-runtime-B8YqpFx7.js.map +1 -0
- package/dist/chunks/runtime-engine-CHNH2nGy.js +2418 -0
- package/dist/chunks/runtime-engine-CHNH2nGy.js.map +1 -0
- package/dist/chunks/runtime-state-BxLKsQzs.js +150 -0
- package/dist/chunks/runtime-state-BxLKsQzs.js.map +1 -0
- package/dist/{merge-styles-DuoZEsm9.js → chunks/shared-utils-CYgOs2mp.js} +58 -57
- package/dist/chunks/shared-utils-CYgOs2mp.js.map +1 -0
- package/dist/chunks/style-engine-DkKH-TqL.js +5573 -0
- package/dist/chunks/style-engine-DkKH-TqL.js.map +1 -0
- package/dist/{css-writer-Bgowobbx.js → chunks/zero-engine-C-0ar_PT.js} +67 -149
- package/dist/chunks/zero-engine-C-0ar_PT.js.map +1 -0
- package/dist/{collector-BTVXj2hS.d.ts → collector-BN6hCWIx.d.ts} +3 -6
- package/dist/{config-LfIDmVHx.d.ts → config-Chmu-PnP.d.ts} +49 -63
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.js +9 -6
- package/dist/hydrate-CTh8SGd9.d.ts +20 -0
- package/dist/{index-Bm9ltvdH.d.ts → index-szujmf6W.d.ts} +263 -348
- package/dist/index.d.ts +5 -5
- package/dist/index.js +11 -922
- package/dist/merge-styles-Cx25bpax.d.ts +4 -0
- package/dist/ssr/astro-client.d.ts +1 -1
- package/dist/ssr/astro-client.js +2 -16
- package/dist/ssr/astro-client.js.map +1 -1
- package/dist/ssr/astro-middleware-extract-static.d.ts +1 -4
- package/dist/ssr/astro-middleware-extract-static.js +1 -2
- package/dist/ssr/astro-middleware-extract.d.ts +1 -4
- package/dist/ssr/astro-middleware-extract.js +1 -2
- package/dist/ssr/astro-middleware-static.d.ts +1 -4
- package/dist/ssr/astro-middleware-static.js +2 -14
- package/dist/ssr/astro-middleware-static.js.map +1 -1
- package/dist/ssr/astro-middleware.d.ts +1 -4
- package/dist/ssr/astro-middleware.js +2 -15
- package/dist/ssr/astro-middleware.js.map +1 -1
- package/dist/ssr/astro.d.ts +17 -19
- package/dist/ssr/astro.js +218 -1
- package/dist/ssr/astro.js.map +1 -0
- package/dist/ssr/client.d.ts +2 -0
- package/dist/ssr/client.js +1 -0
- package/dist/ssr/index.d.ts +5 -27
- package/dist/ssr/index.js +6 -7
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/next-config.d.ts +63 -0
- package/dist/ssr/next-config.js +122 -0
- package/dist/ssr/next-config.js.map +1 -0
- package/dist/ssr/next.d.ts +9 -10
- package/dist/ssr/next.js +30 -45
- package/dist/ssr/next.js.map +1 -1
- package/dist/static/index.d.ts +8 -13
- package/dist/static/index.js +6 -26
- package/dist/static/index.js.map +1 -1
- package/dist/static/inject.d.ts +1 -4
- package/dist/static/inject.js +1 -2
- package/dist/{index-BmogEzTo.d.ts → types-DbMN-Yyn.d.ts} +1013 -1043
- package/dist/zero/babel.d.ts +71 -2
- package/dist/zero/babel.js +84 -150
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.d.ts +61 -12
- package/dist/zero/index.js +24 -2
- package/dist/zero/index.js.map +1 -0
- package/dist/zero/next.d.ts +5 -7
- package/dist/zero/next.js +4 -40
- package/dist/zero/next.js.map +1 -1
- package/docs/README.md +4 -1
- package/docs/adoption.md +25 -17
- package/docs/ai-agents.md +69 -34
- package/docs/comparison.md +9 -8
- package/docs/configuration.md +204 -70
- package/docs/debug.md +18 -7
- package/docs/design-system.md +129 -15
- package/docs/dsl.md +327 -117
- package/docs/getting-started.md +81 -22
- package/docs/injector.md +41 -40
- package/docs/llms.txt +31 -0
- package/docs/methodology.md +48 -23
- package/docs/migration-v3.md +3 -3
- package/docs/pipeline.md +55 -28
- package/docs/plugins.md +22 -42
- package/docs/react-api.md +76 -11
- package/docs/runtime-benchmarks.md +257 -47
- package/docs/ssr.md +226 -80
- package/docs/styles.md +169 -33
- package/docs/tasty-static.md +176 -58
- package/harness/dev.harnesspm/rules/usage.md +12 -0
- package/harness/dev.harnesspm/scripts/render.mjs +320 -0
- package/harness/dev.harnesspm/scripts/styles.mjs +299 -0
- package/harness/plugin.json +20 -0
- package/package.json +116 -48
- package/tasty.config.ts +1 -0
- package/dist/astro-ib7E7V4Y.js +0 -307
- package/dist/astro-ib7E7V4Y.js.map +0 -1
- package/dist/async-storage-DKK-wTD4.js +0 -44
- package/dist/async-storage-DKK-wTD4.js.map +0 -1
- package/dist/babel-DWCsafYw.d.ts +0 -83
- package/dist/collector-C6TtL8HJ.js.map +0 -1
- package/dist/config-B3gPdCqd.js +0 -12421
- package/dist/config-B3gPdCqd.js.map +0 -1
- package/dist/context-CA8YKeMn.js +0 -24
- package/dist/context-CA8YKeMn.js.map +0 -1
- package/dist/core-Bq7w2kti.js +0 -1686
- package/dist/core-Bq7w2kti.js.map +0 -1
- package/dist/css-writer-Bgowobbx.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-rCZ37rqY.js +0 -130
- package/dist/format-rules-rCZ37rqY.js.map +0 -1
- package/dist/hydrate-CNOmZprz.js +0 -37
- package/dist/hydrate-CNOmZprz.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/keyframes-DE-OE76F.js +0 -535
- package/dist/keyframes-DE-OE76F.js.map +0 -1
- package/dist/merge-styles-BcLl1u_d.d.ts +0 -7
- package/dist/merge-styles-DuoZEsm9.js.map +0 -1
- package/dist/resolve-recipes-H9NqOQuP.js +0 -144
- package/dist/resolve-recipes-H9NqOQuP.js.map +0 -1
package/docs/design-system.md
CHANGED
|
@@ -42,15 +42,25 @@ configure({
|
|
|
42
42
|
// Borders
|
|
43
43
|
'#border': '#e0e0e0',
|
|
44
44
|
|
|
45
|
-
//
|
|
45
|
+
// Spacing and shape scale
|
|
46
46
|
$gap: '8px',
|
|
47
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
|
|
|
@@ -176,11 +186,25 @@ const Card = tasty({
|
|
|
176
186
|
styles: {
|
|
177
187
|
padding: { '': '4x', '@mobile': '2x' },
|
|
178
188
|
flow: { '': 'row', '@mobile': 'column' },
|
|
179
|
-
|
|
189
|
+
radius: { '': '1r', '@mobile': '0' },
|
|
180
190
|
},
|
|
181
191
|
});
|
|
182
192
|
```
|
|
183
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
|
+
|
|
184
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.
|
|
185
209
|
|
|
186
210
|
---
|
|
@@ -279,7 +303,7 @@ const Grid = tasty({
|
|
|
279
303
|
display: 'grid',
|
|
280
304
|
gap: '1x',
|
|
281
305
|
},
|
|
282
|
-
styleProps:
|
|
306
|
+
styleProps: FLOW_STYLES, // includes gridColumns, gridRows, gridAreas
|
|
283
307
|
});
|
|
284
308
|
```
|
|
285
309
|
|
|
@@ -298,18 +322,54 @@ Product engineers use these to compose layouts without writing CSS:
|
|
|
298
322
|
</Grid>
|
|
299
323
|
```
|
|
300
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
|
+
|
|
301
361
|
### Which styleProps to expose
|
|
302
362
|
|
|
303
363
|
Match the prop set to the component's role:
|
|
304
364
|
|
|
305
|
-
| Component category | Recommended styleProps
|
|
306
|
-
| ------------------------------------------ |
|
|
307
|
-
| Layout containers (`Space`, `Box`, `Grid`) | `FLOW_STYLES` — flow, gap, align
|
|
308
|
-
| Positioned elements (`Button`, `Badge`) | `POSITION_STYLES` — placeSelf, gridArea, order
|
|
309
|
-
| Text elements | `['
|
|
310
|
-
| 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 |
|
|
311
371
|
|
|
312
|
-
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.
|
|
313
373
|
|
|
314
374
|
---
|
|
315
375
|
|
|
@@ -369,14 +429,14 @@ For sub-element syntax details (selector affix `$`, `@own()`, `elements` config)
|
|
|
369
429
|
|
|
370
430
|
## Defining the override contract
|
|
371
431
|
|
|
372
|
-
A design system works best when the rules for customization are explicit. Tasty
|
|
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:
|
|
373
433
|
|
|
374
434
|
### What product engineers can do
|
|
375
435
|
|
|
376
436
|
1. **Use styleProps** — adjust layout, spacing, positioning through the props the component exposes:
|
|
377
437
|
|
|
378
438
|
```tsx
|
|
379
|
-
<Space flow="row" gap="3x"
|
|
439
|
+
<Space flow="row" gap="3x" placeItems="center">
|
|
380
440
|
```
|
|
381
441
|
|
|
382
442
|
2. **Use modProps** — control component states through typed props instead of `mods`:
|
|
@@ -398,7 +458,12 @@ A design system works best when the rules for customization are explicit. Tasty
|
|
|
398
458
|
```tsx
|
|
399
459
|
const DangerButton = tasty(Button, {
|
|
400
460
|
styles: {
|
|
401
|
-
fill: {
|
|
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
|
+
},
|
|
402
467
|
color: '#on-danger',
|
|
403
468
|
},
|
|
404
469
|
});
|
|
@@ -414,6 +479,53 @@ See [Methodology — styles prop vs style prop](methodology.md#styles-prop-vs-st
|
|
|
414
479
|
|
|
415
480
|
---
|
|
416
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
|
+
|
|
417
529
|
## Project structure
|
|
418
530
|
|
|
419
531
|
A recommended structure for a design system built on Tasty:
|
|
@@ -421,6 +533,8 @@ A recommended structure for a design system built on Tasty:
|
|
|
421
533
|
```
|
|
422
534
|
ds/
|
|
423
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
|
|
424
538
|
primitives/
|
|
425
539
|
Space.tsx # Layout: flex container with FLOW_STYLES
|
|
426
540
|
Box.tsx # Generic container
|
|
@@ -436,7 +550,7 @@ ds/
|
|
|
436
550
|
tokens/
|
|
437
551
|
colors.ts # Color token definitions
|
|
438
552
|
typography.ts # Typography presets for configure({ presets })
|
|
439
|
-
|
|
553
|
+
units.ts # Spacing and shape scale for configure({ units })
|
|
440
554
|
index.ts # Public API: re-exports components + configure
|
|
441
555
|
```
|
|
442
556
|
|