@tenphi/tasty 0.0.0-snapshot.6da0da7 → 0.0.0-snapshot.6ea31ec
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 +211 -248
- package/dist/_virtual/_rolldown/runtime.js +1 -2
- package/dist/chunks/cacheKey.d.ts +1 -0
- package/dist/chunks/cacheKey.js +1 -2
- package/dist/chunks/cacheKey.js.map +1 -1
- package/dist/chunks/definitions.d.ts +1 -1
- package/dist/chunks/definitions.js +2 -3
- package/dist/chunks/definitions.js.map +1 -1
- package/dist/chunks/index.d.ts +1 -0
- package/dist/chunks/renderChunk.d.ts +1 -0
- package/dist/chunks/renderChunk.js +1 -2
- package/dist/chunks/renderChunk.js.map +1 -1
- package/dist/config.d.ts +58 -3
- package/dist/config.js +66 -24
- package/dist/config.js.map +1 -1
- package/dist/core/index.d.ts +8 -7
- package/dist/core/index.js +6 -6
- package/dist/counter-style/index.js +51 -0
- package/dist/counter-style/index.js.map +1 -0
- package/dist/debug.d.ts +26 -141
- package/dist/debug.js +357 -637
- package/dist/debug.js.map +1 -1
- package/dist/font-face/index.js +63 -0
- package/dist/font-face/index.js.map +1 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/resolve-ssr-collector.js +14 -0
- package/dist/hooks/resolve-ssr-collector.js.map +1 -0
- package/dist/hooks/useCounterStyle.d.ts +50 -0
- package/dist/hooks/useCounterStyle.js +46 -0
- package/dist/hooks/useCounterStyle.js.map +1 -0
- package/dist/hooks/useFontFace.d.ts +43 -0
- package/dist/hooks/useFontFace.js +70 -0
- package/dist/hooks/useFontFace.js.map +1 -0
- package/dist/hooks/useGlobalStyles.js +2 -7
- package/dist/hooks/useGlobalStyles.js.map +1 -1
- package/dist/hooks/useKeyframes.js +2 -7
- package/dist/hooks/useKeyframes.js.map +1 -1
- package/dist/hooks/useProperty.js +2 -7
- package/dist/hooks/useProperty.js.map +1 -1
- package/dist/hooks/useRawCSS.js +2 -7
- package/dist/hooks/useRawCSS.js.map +1 -1
- package/dist/hooks/useStyles.js +36 -48
- package/dist/hooks/useStyles.js.map +1 -1
- package/dist/index.d.ts +11 -8
- package/dist/index.js +8 -6
- package/dist/injector/index.d.ts +20 -2
- package/dist/injector/index.js +21 -4
- package/dist/injector/index.js.map +1 -1
- package/dist/injector/injector.d.ts +19 -1
- package/dist/injector/injector.js +36 -2
- package/dist/injector/injector.js.map +1 -1
- package/dist/injector/sheet-manager.js +8 -4
- package/dist/injector/sheet-manager.js.map +1 -1
- package/dist/injector/types.d.ts +61 -1
- package/dist/keyframes/index.js +1 -1
- package/dist/parser/classify.js +6 -6
- package/dist/parser/classify.js.map +1 -1
- package/dist/parser/const.js +30 -3
- package/dist/parser/const.js.map +1 -1
- package/dist/parser/lru.js +1 -1
- package/dist/parser/lru.js.map +1 -1
- package/dist/parser/parser.js +2 -3
- package/dist/parser/parser.js.map +1 -1
- package/dist/parser/tokenizer.js +1 -1
- package/dist/parser/tokenizer.js.map +1 -1
- package/dist/parser/types.js +1 -1
- package/dist/parser/types.js.map +1 -1
- package/dist/pipeline/conditions.js +1 -1
- package/dist/pipeline/conditions.js.map +1 -1
- package/dist/pipeline/exclusive.js +1 -2
- package/dist/pipeline/exclusive.js.map +1 -1
- package/dist/pipeline/index.d.ts +2 -0
- package/dist/pipeline/index.js +58 -20
- package/dist/pipeline/index.js.map +1 -1
- package/dist/pipeline/materialize.js +1 -3
- package/dist/pipeline/materialize.js.map +1 -1
- package/dist/pipeline/parseStateKey.js +1 -2
- package/dist/pipeline/parseStateKey.js.map +1 -1
- package/dist/pipeline/simplify.js +1 -2
- package/dist/pipeline/simplify.js.map +1 -1
- package/dist/pipeline/warnings.js +1 -1
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/okhsl-plugin.js +3 -277
- package/dist/plugins/okhsl-plugin.js.map +1 -1
- package/dist/plugins/types.d.ts +1 -1
- package/dist/properties/index.js +3 -17
- package/dist/properties/index.js.map +1 -1
- package/dist/properties/property-type-resolver.js +1 -2
- package/dist/properties/property-type-resolver.js.map +1 -1
- package/dist/ssr/astro.js +1 -2
- package/dist/ssr/astro.js.map +1 -1
- package/dist/ssr/async-storage.js +1 -2
- package/dist/ssr/async-storage.js.map +1 -1
- package/dist/ssr/collect-auto-properties.js +1 -2
- package/dist/ssr/collect-auto-properties.js.map +1 -1
- package/dist/ssr/collector.d.ts +17 -0
- package/dist/ssr/collector.js +51 -8
- package/dist/ssr/collector.js.map +1 -1
- package/dist/ssr/context.d.ts +2 -2
- package/dist/ssr/context.js +1 -2
- package/dist/ssr/context.js.map +1 -1
- package/dist/ssr/format-global-rules.js +1 -1
- package/dist/ssr/format-keyframes.js +1 -2
- package/dist/ssr/format-keyframes.js.map +1 -1
- package/dist/ssr/format-property.js +10 -9
- package/dist/ssr/format-property.js.map +1 -1
- package/dist/ssr/format-rules.js +8 -5
- package/dist/ssr/format-rules.js.map +1 -1
- package/dist/ssr/hydrate.js +1 -2
- package/dist/ssr/hydrate.js.map +1 -1
- package/dist/ssr/index.js +2 -3
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/next.d.ts +2 -2
- package/dist/ssr/next.js +2 -4
- package/dist/ssr/next.js.map +1 -1
- package/dist/ssr/ssr-collector-ref.js +1 -1
- package/dist/states/index.js +3 -2
- package/dist/states/index.js.map +1 -1
- package/dist/static/index.js +1 -2
- package/dist/static/inject.d.ts +5 -0
- package/dist/static/inject.js +17 -0
- package/dist/static/inject.js.map +1 -0
- package/dist/static/tastyStatic.js +1 -2
- package/dist/static/tastyStatic.js.map +1 -1
- package/dist/static/types.js +1 -1
- package/dist/styles/border.d.ts +1 -1
- package/dist/styles/border.js +10 -19
- package/dist/styles/border.js.map +1 -1
- package/dist/styles/color.d.ts +1 -1
- package/dist/styles/color.js +11 -8
- package/dist/styles/color.js.map +1 -1
- package/dist/styles/const.js +17 -0
- package/dist/styles/const.js.map +1 -0
- package/dist/styles/createStyle.js +28 -26
- package/dist/styles/createStyle.js.map +1 -1
- package/dist/styles/dimension.js +15 -3
- package/dist/styles/dimension.js.map +1 -1
- package/dist/styles/directional.js +125 -0
- package/dist/styles/directional.js.map +1 -0
- package/dist/styles/display.d.ts +3 -10
- package/dist/styles/display.js +45 -39
- package/dist/styles/display.js.map +1 -1
- package/dist/styles/fade.d.ts +1 -1
- package/dist/styles/fade.js +9 -5
- package/dist/styles/fade.js.map +1 -1
- package/dist/styles/fill.d.ts +2 -2
- package/dist/styles/fill.js +3 -4
- package/dist/styles/fill.js.map +1 -1
- package/dist/styles/flow.js +1 -1
- package/dist/styles/gap.d.ts +1 -1
- package/dist/styles/gap.js +4 -3
- package/dist/styles/gap.js.map +1 -1
- package/dist/styles/height.d.ts +1 -1
- package/dist/styles/height.js +1 -2
- package/dist/styles/height.js.map +1 -1
- package/dist/styles/index.d.ts +0 -1
- package/dist/styles/index.js +3 -4
- package/dist/styles/index.js.map +1 -1
- package/dist/styles/inset.d.ts +1 -29
- package/dist/styles/inset.js +19 -135
- package/dist/styles/inset.js.map +1 -1
- package/dist/styles/list.d.ts +5 -5
- package/dist/styles/list.js +4 -2
- package/dist/styles/list.js.map +1 -1
- package/dist/styles/margin.d.ts +1 -1
- package/dist/styles/margin.js +17 -89
- package/dist/styles/margin.js.map +1 -1
- package/dist/styles/outline.d.ts +1 -1
- package/dist/styles/outline.js +6 -16
- package/dist/styles/outline.js.map +1 -1
- package/dist/styles/padding.d.ts +1 -1
- package/dist/styles/padding.js +17 -89
- package/dist/styles/padding.js.map +1 -1
- package/dist/styles/placement.d.ts +37 -0
- package/dist/styles/placement.js +74 -0
- package/dist/styles/placement.js.map +1 -0
- package/dist/styles/predefined.d.ts +4 -4
- package/dist/styles/predefined.js +9 -10
- package/dist/styles/predefined.js.map +1 -1
- package/dist/styles/preset.d.ts +6 -1
- package/dist/styles/preset.js +54 -53
- package/dist/styles/preset.js.map +1 -1
- package/dist/styles/radius.d.ts +1 -3
- package/dist/styles/radius.js +28 -6
- package/dist/styles/radius.js.map +1 -1
- package/dist/styles/scrollMargin.d.ts +24 -0
- package/dist/styles/scrollMargin.js +32 -0
- package/dist/styles/scrollMargin.js.map +1 -0
- package/dist/styles/scrollbar.d.ts +1 -1
- package/dist/styles/scrollbar.js +8 -5
- package/dist/styles/scrollbar.js.map +1 -1
- package/dist/styles/shadow.d.ts +1 -1
- package/dist/styles/shadow.js +4 -3
- package/dist/styles/shadow.js.map +1 -1
- package/dist/styles/shared.js +17 -0
- package/dist/styles/shared.js.map +1 -0
- package/dist/styles/transition.d.ts +1 -1
- package/dist/styles/transition.js +5 -4
- package/dist/styles/transition.js.map +1 -1
- package/dist/styles/types.d.ts +71 -15
- package/dist/styles/width.d.ts +1 -1
- package/dist/styles/width.js +1 -2
- package/dist/styles/width.js.map +1 -1
- package/dist/tasty.d.ts +31 -893
- package/dist/tasty.js +22 -10
- package/dist/tasty.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils/cache-wrapper.js +1 -2
- package/dist/utils/cache-wrapper.js.map +1 -1
- package/dist/utils/case-converter.js +1 -1
- package/dist/utils/color-math.d.ts +46 -0
- package/dist/utils/color-math.js +749 -0
- package/dist/utils/color-math.js.map +1 -0
- package/dist/utils/color-space.d.ts +5 -0
- package/dist/utils/color-space.js +228 -0
- package/dist/utils/color-space.js.map +1 -0
- package/dist/utils/colors.js +3 -2
- package/dist/utils/colors.js.map +1 -1
- package/dist/utils/dotize.js +1 -1
- package/dist/utils/dotize.js.map +1 -1
- package/dist/utils/filter-base-props.js +1 -1
- package/dist/utils/get-display-name.js +1 -1
- package/dist/utils/has-keys.js +1 -1
- package/dist/utils/is-dev-env.js +1 -1
- package/dist/utils/is-dev-env.js.map +1 -1
- package/dist/utils/is-valid-element-type.js +1 -1
- package/dist/utils/merge-styles.js +1 -2
- package/dist/utils/merge-styles.js.map +1 -1
- package/dist/utils/mod-attrs.d.ts +0 -2
- package/dist/utils/mod-attrs.js +2 -3
- package/dist/utils/mod-attrs.js.map +1 -1
- package/dist/utils/process-tokens.d.ts +3 -13
- package/dist/utils/process-tokens.js +19 -100
- package/dist/utils/process-tokens.js.map +1 -1
- package/dist/utils/resolve-recipes.js +1 -2
- package/dist/utils/resolve-recipes.js.map +1 -1
- package/dist/utils/selector-transform.js +1 -1
- package/dist/utils/string.js +1 -1
- package/dist/utils/styles.d.ts +3 -18
- package/dist/utils/styles.js +23 -221
- package/dist/utils/styles.js.map +1 -1
- package/dist/utils/typography.js +9 -1
- package/dist/utils/typography.js.map +1 -1
- package/dist/utils/warnings.js +1 -1
- package/dist/zero/babel.d.ts +31 -4
- package/dist/zero/babel.js +140 -48
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/css-writer.js +1 -2
- package/dist/zero/css-writer.js.map +1 -1
- package/dist/zero/extractor.js +54 -3
- package/dist/zero/extractor.js.map +1 -1
- package/dist/zero/index.js +1 -2
- package/dist/zero/next.d.ts +12 -0
- package/dist/zero/next.js +5 -4
- package/dist/zero/next.js.map +1 -1
- package/docs/PIPELINE.md +519 -0
- package/docs/README.md +31 -0
- package/docs/adoption.md +16 -6
- package/docs/comparison.md +16 -9
- package/docs/configuration.md +87 -3
- package/docs/debug.md +152 -339
- package/docs/design-system.md +26 -3
- package/docs/dsl.md +136 -3
- package/docs/getting-started.md +29 -13
- package/docs/injector.md +2 -2
- package/docs/methodology.md +71 -5
- package/docs/runtime.md +228 -34
- package/docs/ssr.md +5 -3
- package/docs/styles.md +32 -24
- package/docs/tasty-static.md +102 -2
- package/package.json +12 -6
- package/dist/styles/align.d.ts +0 -15
- package/dist/styles/align.js +0 -14
- package/dist/styles/align.js.map +0 -1
- package/dist/styles/justify.d.ts +0 -15
- package/dist/styles/justify.js +0 -14
- package/dist/styles/justify.js.map +0 -1
- package/dist/utils/hsl-to-rgb.js +0 -38
- package/dist/utils/hsl-to-rgb.js.map +0 -1
- package/dist/utils/okhsl-to-rgb.js +0 -296
- package/dist/utils/okhsl-to-rgb.js.map +0 -1
package/docs/design-system.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
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.
|
|
4
4
|
|
|
5
|
-
It assumes you have already decided to adopt Tasty. 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 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).
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -103,6 +103,23 @@ configure({
|
|
|
103
103
|
|
|
104
104
|
Then use `preset: 'h1'` or `preset: 't2'` in any component's styles.
|
|
105
105
|
|
|
106
|
+
### Registering brand fonts
|
|
107
|
+
|
|
108
|
+
Register your design system's custom fonts via `configure({ fontFace })` so every component can reference them:
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
configure({
|
|
112
|
+
fontFace: {
|
|
113
|
+
'Brand Sans': [
|
|
114
|
+
{ src: 'url("/fonts/brand-regular.woff2") format("woff2")', fontWeight: 400, fontDisplay: 'swap' },
|
|
115
|
+
{ src: 'url("/fonts/brand-bold.woff2") format("woff2")', fontWeight: 700, fontDisplay: 'swap' },
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
See [Font Face](configuration.md#font-face) for the full configuration reference.
|
|
122
|
+
|
|
106
123
|
---
|
|
107
124
|
|
|
108
125
|
## Defining state aliases
|
|
@@ -333,13 +350,19 @@ A design system works best when the rules for customization are explicit. Tasty
|
|
|
333
350
|
<Space flow="row" gap="3x" padding="2x">
|
|
334
351
|
```
|
|
335
352
|
|
|
336
|
-
2. **
|
|
353
|
+
2. **Use modProps** — control component states through typed props instead of `mods`:
|
|
354
|
+
|
|
355
|
+
```tsx
|
|
356
|
+
<Button isLoading size="large">Submit</Button>
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
3. **Pass tokens** — inject runtime values through the `tokens` prop for per-instance customization:
|
|
337
360
|
|
|
338
361
|
```tsx
|
|
339
362
|
<ProgressBar tokens={{ '$progress': `${percent}%` }} />
|
|
340
363
|
```
|
|
341
364
|
|
|
342
|
-
|
|
365
|
+
4. **Create styled wrappers** — extend a component's styles with `tasty(Base, { styles })`:
|
|
343
366
|
|
|
344
367
|
```tsx
|
|
345
368
|
const DangerButton = tasty(Button, {
|
package/docs/dsl.md
CHANGED
|
@@ -36,6 +36,46 @@ styles: { Title: { preset: 'h3' } }
|
|
|
36
36
|
// Targets: <div data-element="Title">
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
+
#### Selector Affix (`$`)
|
|
40
|
+
|
|
41
|
+
Control how a sub-element selector attaches to the root selector using the `$` property inside the sub-element's styles:
|
|
42
|
+
|
|
43
|
+
| Pattern | Result | Description |
|
|
44
|
+
|---------|--------|-------------|
|
|
45
|
+
| *(none)* | ` [el]` | Descendant (default) |
|
|
46
|
+
| `>` | `> [el]` | Direct child |
|
|
47
|
+
| `>Body>Row>` | `> [Body] > [Row] > [el]` | Chained elements |
|
|
48
|
+
| `h1` | ` h1` | Tag selector (no key injection) |
|
|
49
|
+
| `h1 >` | ` h1 > [el]` | Key is direct child of tag |
|
|
50
|
+
| `h1 *` | ` h1 *` | Any descendant of tag |
|
|
51
|
+
| `*` | ` *` | All descendants |
|
|
52
|
+
| `::before` | `::before` | Root pseudo (no key) |
|
|
53
|
+
| `@::before` | `[el]::before` | Pseudo on the sub-element |
|
|
54
|
+
| `>@:hover` | `> [el]:hover` | Pseudo-class on the sub-element |
|
|
55
|
+
| `>@.active` | `> [el].active` | Class on the sub-element |
|
|
56
|
+
|
|
57
|
+
Rules for key injection (`[data-element="..."]`):
|
|
58
|
+
|
|
59
|
+
- **Trailing combinator** (`>`, `+`, `~`) — key is injected after it
|
|
60
|
+
- **Uppercase element name** (`Body`, `Row`) — key is injected as descendant
|
|
61
|
+
- **HTML tag** (`h1`, `a`, `span`) — no key injection; the tag IS the selector
|
|
62
|
+
- **Universal selector** (`*`) — no key injection
|
|
63
|
+
- **Pseudo / class / attribute** — no key injection
|
|
64
|
+
|
|
65
|
+
The `@` placeholder marks exactly where `[data-element="..."]` is injected, allowing you to attach pseudo-classes, pseudo-elements, or class selectors directly to the sub-element instead of the root:
|
|
66
|
+
|
|
67
|
+
```jsx
|
|
68
|
+
const List = tasty({
|
|
69
|
+
styles: {
|
|
70
|
+
Item: {
|
|
71
|
+
$: '>@:last-child',
|
|
72
|
+
border: 'none',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
// → .t0 > [data-element="Item"]:last-child { border: none }
|
|
77
|
+
```
|
|
78
|
+
|
|
39
79
|
### Color Token
|
|
40
80
|
|
|
41
81
|
Named color prefixed with `#` that maps to CSS custom properties. Supports opacity with `.N` suffix:
|
|
@@ -53,6 +93,8 @@ mods={{ hovered: true, theme: 'danger' }}
|
|
|
53
93
|
// → data-hovered="" data-theme="danger"
|
|
54
94
|
```
|
|
55
95
|
|
|
96
|
+
Modifiers can also be exposed as top-level component props via `modProps` — see [Runtime — Mod Props](runtime.md#mod-props).
|
|
97
|
+
|
|
56
98
|
---
|
|
57
99
|
|
|
58
100
|
## Color Tokens & Opacity
|
|
@@ -77,8 +119,6 @@ color: '(#primary, #secondary)', // Fallback syntax
|
|
|
77
119
|
| `cr` | Card border radius | `1cr` | `var(--card-radius)` |
|
|
78
120
|
| `bw` | Border width | `2bw` | `calc(var(--border-width) * 2)` |
|
|
79
121
|
| `ow` | Outline width | `1ow` | `var(--outline-width)` |
|
|
80
|
-
| `fs` | Font size | `1fs` | `var(--font-size)` |
|
|
81
|
-
| `lh` | Line height | `1lh` | `var(--line-height)` |
|
|
82
122
|
| `sf` | Stable fraction | `1sf` | `minmax(0, 1fr)` |
|
|
83
123
|
|
|
84
124
|
You can register additional custom units via [`configure()`](configuration.md#options).
|
|
@@ -228,7 +268,7 @@ const SimpleButton = tasty(Button, {
|
|
|
228
268
|
| `@media` | Media queries | `@media(w < 768px)` |
|
|
229
269
|
| `@(...)` | Container queries | `@(panel, w >= 300px)` |
|
|
230
270
|
| `@supports` | Feature/selector support | `@supports(display: grid)` |
|
|
231
|
-
| `@root` | Root element states | `@root(
|
|
271
|
+
| `@root` | Root element states | `@root(schema=dark)` |
|
|
232
272
|
| `@parent` | Parent/ancestor element states | `@parent(hovered)` |
|
|
233
273
|
| `@own` | Sub-element's own state | `@own(hovered)` |
|
|
234
274
|
| `@starting` | Entry animation | `@starting` |
|
|
@@ -322,6 +362,8 @@ display: {
|
|
|
322
362
|
|
|
323
363
|
Root states generate selectors on the `:root` element. They are useful for theme modes, feature flags, and other page-level conditions:
|
|
324
364
|
|
|
365
|
+
These docs use `data-schema` in examples. If your app standardizes on a different root attribute, keep the same pattern and swap the attribute name consistently in your aliases and selectors.
|
|
366
|
+
|
|
325
367
|
```jsx
|
|
326
368
|
color: {
|
|
327
369
|
'': '#text',
|
|
@@ -525,6 +567,97 @@ Use explicit `@properties` when you need non-default settings like `inherits: fa
|
|
|
525
567
|
|
|
526
568
|
---
|
|
527
569
|
|
|
570
|
+
## Font Face (`@fontFace`)
|
|
571
|
+
|
|
572
|
+
Register custom fonts directly inside a `styles` object. Keys are font-family names, values are descriptor objects (or arrays of them for multiple weights/styles).
|
|
573
|
+
|
|
574
|
+
```ts
|
|
575
|
+
const Heading = tasty({
|
|
576
|
+
styles: {
|
|
577
|
+
'@fontFace': {
|
|
578
|
+
'Brand Sans': {
|
|
579
|
+
src: 'url("/fonts/brand-sans.woff2") format("woff2")',
|
|
580
|
+
fontDisplay: 'swap',
|
|
581
|
+
},
|
|
582
|
+
},
|
|
583
|
+
fontFamily: '"Brand Sans", sans-serif',
|
|
584
|
+
},
|
|
585
|
+
});
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
### Multiple weights
|
|
589
|
+
|
|
590
|
+
Supply an array to register several variants of the same family:
|
|
591
|
+
|
|
592
|
+
```ts
|
|
593
|
+
'@fontFace': {
|
|
594
|
+
'Brand Sans': [
|
|
595
|
+
{ src: 'url("/fonts/brand-regular.woff2") format("woff2")', fontWeight: 400, fontDisplay: 'swap' },
|
|
596
|
+
{ src: 'url("/fonts/brand-bold.woff2") format("woff2")', fontWeight: 700, fontDisplay: 'swap' },
|
|
597
|
+
],
|
|
598
|
+
}
|
|
599
|
+
```
|
|
600
|
+
|
|
601
|
+
### Supported descriptors
|
|
602
|
+
|
|
603
|
+
| Descriptor | CSS property | Type |
|
|
604
|
+
|---|---|---|
|
|
605
|
+
| `src` (required) | `src` | `string` |
|
|
606
|
+
| `fontWeight` | `font-weight` | `string \| number` |
|
|
607
|
+
| `fontStyle` | `font-style` | `string` |
|
|
608
|
+
| `fontStretch` | `font-stretch` | `string` |
|
|
609
|
+
| `fontDisplay` | `font-display` | `'auto' \| 'block' \| 'swap' \| 'fallback' \| 'optional'` |
|
|
610
|
+
| `unicodeRange` | `unicode-range` | `string` |
|
|
611
|
+
| `ascentOverride` | `ascent-override` | `string` |
|
|
612
|
+
| `descentOverride` | `descent-override` | `string` |
|
|
613
|
+
| `lineGapOverride` | `line-gap-override` | `string` |
|
|
614
|
+
| `sizeAdjust` | `size-adjust` | `string` |
|
|
615
|
+
| `fontFeatureSettings` | `font-feature-settings` | `string` |
|
|
616
|
+
| `fontVariationSettings` | `font-variation-settings` | `string` |
|
|
617
|
+
|
|
618
|
+
> Font-face rules are permanent — they are injected once and never cleaned up, matching how browsers handle `@font-face`.
|
|
619
|
+
|
|
620
|
+
---
|
|
621
|
+
|
|
622
|
+
## Counter Style (`@counterStyle`)
|
|
623
|
+
|
|
624
|
+
Define custom list markers via the CSS `@counter-style` at-rule. Keys are counter-style names, values are descriptor objects.
|
|
625
|
+
|
|
626
|
+
```ts
|
|
627
|
+
const EmojiList = tasty({
|
|
628
|
+
tag: 'ol',
|
|
629
|
+
styles: {
|
|
630
|
+
'@counterStyle': {
|
|
631
|
+
thumbs: {
|
|
632
|
+
system: 'cyclic',
|
|
633
|
+
symbols: '"👍"',
|
|
634
|
+
suffix: '" "',
|
|
635
|
+
},
|
|
636
|
+
},
|
|
637
|
+
listStyleType: 'thumbs',
|
|
638
|
+
},
|
|
639
|
+
});
|
|
640
|
+
```
|
|
641
|
+
|
|
642
|
+
### Supported descriptors
|
|
643
|
+
|
|
644
|
+
| Descriptor | CSS property | Type |
|
|
645
|
+
|---|---|---|
|
|
646
|
+
| `system` (required) | `system` | `'cyclic' \| 'numeric' \| 'alphabetic' \| 'symbolic' \| 'additive' \| 'fixed' \| string` |
|
|
647
|
+
| `symbols` | `symbols` | `string` |
|
|
648
|
+
| `additiveSymbols` | `additive-symbols` | `string` |
|
|
649
|
+
| `prefix` | `prefix` | `string` |
|
|
650
|
+
| `suffix` | `suffix` | `string` |
|
|
651
|
+
| `negative` | `negative` | `string` |
|
|
652
|
+
| `range` | `range` | `string` |
|
|
653
|
+
| `pad` | `pad` | `string` |
|
|
654
|
+
| `fallback` | `fallback` | `string` |
|
|
655
|
+
| `speakAs` | `speak-as` | `string` |
|
|
656
|
+
|
|
657
|
+
> Counter-style rules are permanent — they are injected once and never cleaned up, matching how browsers handle `@counter-style`.
|
|
658
|
+
|
|
659
|
+
---
|
|
660
|
+
|
|
528
661
|
## Style Properties
|
|
529
662
|
|
|
530
663
|
For a complete reference of all enhanced style properties — syntax, values, modifiers, and recommendations — see **[Style Properties Reference](styles.md)**.
|
package/docs/getting-started.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Getting Started
|
|
2
2
|
|
|
3
|
-
This guide walks you from zero to a working Tasty
|
|
3
|
+
This guide walks you from zero to a working Tasty component, then through the optional shared configuration and tooling layers. It is the right starting point when you already want to try Tasty in code. If you are still deciding whether Tasty fits your team, start with [Comparison](comparison.md) and [Adoption Guide](adoption.md) first. For a feature overview, see the [README](../README.md). For the full style language reference, see the [Style DSL](dsl.md). For the React API, see the [Runtime API](runtime.md). For the rest of the docs by role or task, see the [Docs Hub](README.md).
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -10,6 +10,8 @@ This guide walks you from zero to a working Tasty setup with tooling. For a feat
|
|
|
10
10
|
- **React** >= 18 (peer dependency)
|
|
11
11
|
- **Package manager**: pnpm, npm, or yarn
|
|
12
12
|
|
|
13
|
+
Tasty can be used immediately in a React app, but it is most compelling for teams building reusable components with intersecting states, variants, tokens, and design-system conventions.
|
|
14
|
+
|
|
13
15
|
---
|
|
14
16
|
|
|
15
17
|
## Install
|
|
@@ -47,9 +49,9 @@ export default function App() {
|
|
|
47
49
|
|
|
48
50
|
---
|
|
49
51
|
|
|
50
|
-
##
|
|
52
|
+
## Optional: add shared configuration
|
|
51
53
|
|
|
52
|
-
|
|
54
|
+
Use `configure()` once, before your app renders, when your app or design system needs shared state aliases, tokens, recipes, or parser extensions:
|
|
53
55
|
|
|
54
56
|
```tsx
|
|
55
57
|
// src/tasty-config.ts
|
|
@@ -63,6 +65,8 @@ configure({
|
|
|
63
65
|
});
|
|
64
66
|
```
|
|
65
67
|
|
|
68
|
+
These examples use `data-schema="dark"` as the root-state convention. If your app already uses a different attribute such as `data-theme="dark"`, keep the pattern and swap the attribute name consistently across your config and components.
|
|
69
|
+
|
|
66
70
|
Import this file at the top of your app entry point so it runs before any component renders:
|
|
67
71
|
|
|
68
72
|
```tsx
|
|
@@ -74,9 +78,9 @@ import App from './App';
|
|
|
74
78
|
createRoot(document.getElementById('root')!).render(<App />);
|
|
75
79
|
```
|
|
76
80
|
|
|
77
|
-
### Define
|
|
81
|
+
### Define shared tokens and override default unit values
|
|
78
82
|
|
|
79
|
-
Color tokens like `#primary` resolve to CSS custom properties at runtime (e.g. `var(--primary-color)`). Built-in units like `x`, `r`, and `bw`
|
|
83
|
+
Color tokens like `#primary` resolve to CSS custom properties at runtime (e.g. `var(--primary-color)`). Built-in units like `x`, `r`, and `bw` already work without setup and multiply CSS custom properties by default. Use `configure({ tokens })` when you want to define shared token values or override the defaults your app uses:
|
|
80
84
|
|
|
81
85
|
```tsx
|
|
82
86
|
// src/tasty-config.ts
|
|
@@ -108,7 +112,7 @@ configure({
|
|
|
108
112
|
});
|
|
109
113
|
```
|
|
110
114
|
|
|
111
|
-
Every component using `#primary`, `2x`, or `1r` adjusts automatically. Tokens are injected as `:root` CSS custom properties when the first style is rendered.
|
|
115
|
+
Every component using `#primary`, `2x`, or `1r` adjusts automatically. Tokens are injected as `:root` CSS custom properties when the first style is rendered. You can also use standard CSS color values such as `rgb(...)`, `hsl(...)`, and named colors directly; `okhsl(...)` is the recommended choice when you want authored colors that stay aligned with Tasty's design-system-oriented workflow.
|
|
112
116
|
|
|
113
117
|
> **Note:** `configure({ replaceTokens })` is a separate mechanism — it replaces tokens with literal values at parse time (baked into CSS). Use it for value aliases like `$card-padding: '4x'` that should be resolved during style generation, not for defining color or unit values. See [Configuration — Replace Tokens](configuration.md#replace-tokens-parse-time-substitution) for details.
|
|
114
118
|
|
|
@@ -142,7 +146,7 @@ export default [
|
|
|
142
146
|
|
|
143
147
|
### What `recommended` catches
|
|
144
148
|
|
|
145
|
-
The recommended config enables 18 rules
|
|
149
|
+
The `recommended` config enables 18 of the plugin's 27 total rules. It covers the most common issues without turning on the stricter governance rules:
|
|
146
150
|
|
|
147
151
|
| Category | Rules | Examples |
|
|
148
152
|
|----------|-------|---------|
|
|
@@ -175,27 +179,39 @@ export default [
|
|
|
175
179
|
|
|
176
180
|
## Choosing a rendering mode
|
|
177
181
|
|
|
178
|
-
Tasty
|
|
182
|
+
Tasty has two styling approaches. Pick the one that fits your use case, then decide whether your runtime setup also needs server rendering support:
|
|
179
183
|
|
|
180
|
-
|
|
|
184
|
+
| Approach | Entry point | Best for | Trade-off |
|
|
181
185
|
|------|-------------|----------|-----------|
|
|
182
|
-
| **Runtime** | `tasty()` from `@tenphi/tasty` | Interactive apps, design systems | CSS generated at runtime; full feature set (styleProps, sub-elements, variants) |
|
|
186
|
+
| **Runtime** | `tasty()` from `@tenphi/tasty` | Interactive apps with reusable stateful components, design systems | CSS generated at runtime; full feature set (styleProps, sub-elements, variants) |
|
|
183
187
|
| **Zero-runtime** | `tastyStatic()` from `@tenphi/tasty/static` | Static sites, landing pages, SSG | Zero JS overhead; requires Babel plugin; no dynamic props |
|
|
184
|
-
| **SSR** | `@tenphi/tasty/ssr/next` or `@tenphi/tasty/ssr/astro` | Next.js, Astro, streaming SSR | Runtime `tasty()` with server-rendered CSS and zero-cost hydration |
|
|
185
188
|
|
|
186
|
-
|
|
189
|
+
Both share the same DSL, tokens, units, and state mappings.
|
|
187
190
|
|
|
188
191
|
- Runtime is the default and requires no extra setup beyond `@tenphi/tasty`.
|
|
192
|
+
- If your framework can execute runtime code during server rendering, add SSR support on top of runtime with `@tenphi/tasty/ssr/next`, `@tenphi/tasty/ssr/astro`, or the core SSR API. This still uses `tasty()`; it just collects CSS on the server and hydrates the cache on the client.
|
|
189
193
|
- Zero-runtime requires the Babel plugin and additional peer dependencies. See [Zero Runtime (tastyStatic)](tasty-static.md).
|
|
190
|
-
- SSR works with existing `tasty()` components — wrap your app with a registry or
|
|
194
|
+
- SSR works with existing `tasty()` components — wrap your app with a registry, middleware, or collector. See [Server-Side Rendering](ssr.md).
|
|
191
195
|
|
|
192
196
|
---
|
|
193
197
|
|
|
194
198
|
## Next steps
|
|
195
199
|
|
|
200
|
+
- **[Docs Hub](README.md)** — Pick the next guide by role, styling approach, or task
|
|
196
201
|
- **[Methodology](methodology.md)** — The recommended patterns for structuring Tasty components: sub-elements, styleProps, tokens, extension
|
|
197
202
|
- **[Style DSL](dsl.md)** — State maps, tokens, units, extending semantics, keyframes, @property
|
|
198
203
|
- **[Runtime API](runtime.md)** — `tasty()` factory, component props, variants, sub-elements, hooks
|
|
199
204
|
- **[Building a Design System](design-system.md)** — Practical guide to building a DS layer with Tasty: tokens, recipes, primitives, compound components
|
|
205
|
+
- **[Adoption Guide](adoption.md)** — Roll out Tasty inside an existing design system or platform team
|
|
206
|
+
- **[Comparison](comparison.md)** — Evaluate Tasty against other styling systems
|
|
200
207
|
- **[Configuration](configuration.md)** — Full `configure()` API: tokens, recipes, custom units, style handlers, TypeScript extensions
|
|
201
208
|
- **[Style Properties](styles.md)** — Complete reference for all enhanced style properties
|
|
209
|
+
- **[Debug Utilities](debug.md)** — Inspect generated CSS and debug runtime behavior when styles do not look right
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## Common issues
|
|
214
|
+
|
|
215
|
+
- Styles are missing on first render: make sure the file that calls `configure()` is imported before any `tasty()` component renders.
|
|
216
|
+
- Token or unit values are not what you expect: check your `configure({ tokens, units })` setup, then inspect the generated CSS variables with [Debug Utilities](debug.md).
|
|
217
|
+
- You need build-time extraction or server-rendered CSS delivery: use [Zero Runtime (tastyStatic)](tasty-static.md) for extraction, or add [Server-Side Rendering](ssr.md) on top of runtime `tasty()` when your framework renders on the server.
|
package/docs/injector.md
CHANGED
|
@@ -199,7 +199,7 @@ slideIn.dispose(); // Immediate keyframes deletion from DOM
|
|
|
199
199
|
|
|
200
200
|
### `configure(config): void`
|
|
201
201
|
|
|
202
|
-
Configures the Tasty style system.
|
|
202
|
+
Configures the Tasty style system. `configure()` is optional, but if you use it, it must be called **before** any styles are generated (before first render).
|
|
203
203
|
|
|
204
204
|
```typescript
|
|
205
205
|
import { configure } from '@tenphi/tasty';
|
|
@@ -216,7 +216,7 @@ configure({
|
|
|
216
216
|
nonce: 'csp-nonce', // CSP nonce for security
|
|
217
217
|
states: { // Global predefined states for advanced state mapping
|
|
218
218
|
'@mobile': '@media(w < 768px)',
|
|
219
|
-
'@dark': '@root(
|
|
219
|
+
'@dark': '@root(schema=dark)',
|
|
220
220
|
},
|
|
221
221
|
});
|
|
222
222
|
```
|
package/docs/methodology.md
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
# Methodology
|
|
2
2
|
|
|
3
|
-
Tasty has opinions about how components should be structured. The patterns described here are not mandatory — Tasty works without them — but following them gets the most out of the engine:
|
|
3
|
+
Tasty has opinions about how components should be structured. The patterns described here are not mandatory — Tasty works without them — but following them gets the most out of the engine: deterministic state resolution, cleaner component APIs, simpler overrides, and fewer surprises as the system grows.
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
## Component architecture: root + sub-elements
|
|
8
8
|
|
|
9
|
+
This model matters most for design-system authors and platform teams building reusable, stateful components. It turns Tasty's selector guarantees into a component architecture that stays predictable as states, variants, and compound parts accumulate.
|
|
10
|
+
|
|
9
11
|
### The model
|
|
10
12
|
|
|
11
13
|
Every Tasty component has a **root element** and zero or more **sub-elements**. The root owns the state context. Sub-elements participate in the same context by default.
|
|
@@ -161,6 +163,61 @@ Exposing every CSS property as a prop defeats the purpose of a design system. Th
|
|
|
161
163
|
|
|
162
164
|
---
|
|
163
165
|
|
|
166
|
+
## modProps and mods
|
|
167
|
+
|
|
168
|
+
`modProps` expose modifier keys as top-level component props — the modifier equivalent of `styleProps`. Use them when a component has a fixed set of known state modifiers.
|
|
169
|
+
|
|
170
|
+
```tsx
|
|
171
|
+
const Card = tasty({
|
|
172
|
+
modProps: {
|
|
173
|
+
isLoading: Boolean,
|
|
174
|
+
isSelected: Boolean,
|
|
175
|
+
},
|
|
176
|
+
styles: {
|
|
177
|
+
fill: { '': '#surface', isLoading: '#surface.5' },
|
|
178
|
+
border: { '': '1bw solid #outline', isSelected: '2bw solid #primary' },
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// Clean prop API — no mods object needed
|
|
183
|
+
<Card isLoading isSelected>Content</Card>
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### When to use which
|
|
187
|
+
|
|
188
|
+
| Pattern | Use when |
|
|
189
|
+
|---|---|
|
|
190
|
+
| `modProps` | The component has a fixed set of known boolean/string states that drive styles. Provides TypeScript autocomplete and a cleaner JSX API. |
|
|
191
|
+
| `mods` prop | The component needs arbitrary or dynamic modifiers that aren't known at definition time. |
|
|
192
|
+
| Both | Combine `modProps` for the known states and `mods` for ad-hoc overrides. Mod props take precedence. |
|
|
193
|
+
| `styleProps` | Exposing CSS properties (layout, sizing) for customization — different from modifiers. |
|
|
194
|
+
|
|
195
|
+
### Typed modProps vs array form
|
|
196
|
+
|
|
197
|
+
The object form gives precise TypeScript types using JS constructors (`Boolean`, `String`, `Number`) or enum arrays:
|
|
198
|
+
|
|
199
|
+
```tsx
|
|
200
|
+
const Button = tasty({
|
|
201
|
+
modProps: {
|
|
202
|
+
isLoading: Boolean,
|
|
203
|
+
size: ['small', 'medium', 'large'] as const,
|
|
204
|
+
},
|
|
205
|
+
// ...
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
// TypeScript knows: isLoading?: boolean, size?: 'small' | 'medium' | 'large'
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
The array form is simpler but types all values as `ModValue`:
|
|
212
|
+
|
|
213
|
+
```tsx
|
|
214
|
+
modProps: ['isLoading', 'isSelected'] as const,
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
For the full API reference, see [Runtime — Mod Props](runtime.md#mod-props).
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
164
221
|
## tokens prop for dynamic values
|
|
165
222
|
|
|
166
223
|
Every Tasty component accepts a `tokens` prop that renders as inline CSS custom properties on the element. This is the mechanism for per-instance dynamic values.
|
|
@@ -400,8 +457,9 @@ See [Configuration](configuration.md) for the full `configure()` API.
|
|
|
400
457
|
- **Use semantic transition names** (`transition: 'theme 0.3s'`) instead of listing CSS properties
|
|
401
458
|
- **Use `elements` prop** to declare typed sub-components for compound components
|
|
402
459
|
- **Use `styleProps`** to define what product engineers can customize
|
|
460
|
+
- **Use `modProps`** to expose known modifier states as clean component props
|
|
403
461
|
- **Use `tokens` prop** for per-instance dynamic values (progress, user color)
|
|
404
|
-
- **Use modifiers** (`mods`) for state-driven style changes instead of runtime `styles` prop changes
|
|
462
|
+
- **Use modifiers** (`mods` or `modProps`) for state-driven style changes instead of runtime `styles` prop changes
|
|
405
463
|
|
|
406
464
|
### Avoid
|
|
407
465
|
|
|
@@ -439,11 +497,19 @@ Tasty's enhanced properties provide concise syntax, better composability, and si
|
|
|
439
497
|
// Bad: styles object changes every render
|
|
440
498
|
<Card styles={{ padding: isCompact ? '2x' : '4x' }} />
|
|
441
499
|
|
|
442
|
-
// Good: use modifiers
|
|
443
|
-
<Card
|
|
500
|
+
// Good: use modifiers via modProps
|
|
501
|
+
<Card isCompact={isCompact} />
|
|
502
|
+
|
|
503
|
+
// Or via mods object
|
|
504
|
+
<Card mods={{ isCompact }} />
|
|
444
505
|
|
|
445
506
|
// In the component definition:
|
|
446
|
-
|
|
507
|
+
const Card = tasty({
|
|
508
|
+
modProps: ['isCompact'] as const,
|
|
509
|
+
styles: {
|
|
510
|
+
padding: { '': '4x', isCompact: '2x' },
|
|
511
|
+
},
|
|
512
|
+
});
|
|
447
513
|
```
|
|
448
514
|
|
|
449
515
|
Modifiers are compiled into exclusive selectors once. Changing `styles` at runtime forces Tasty to regenerate and re-inject CSS.
|