@tenphi/tasty 0.0.0-snapshot.275370e → 0.0.0-snapshot.27b6708
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 +175 -109
- package/dist/{ssr/async-storage.js → async-storage-DKK-wTD4.js} +2 -2
- package/dist/async-storage-DKK-wTD4.js.map +1 -0
- package/dist/babel-BUQGeOXA.d.ts +83 -0
- package/dist/{ssr/collector.js → collector-DTahQUiV.js} +97 -28
- package/dist/collector-DTahQUiV.js.map +1 -0
- package/dist/{ssr/collector.d.ts → collector-DUaHCcTS.d.ts} +54 -7
- package/dist/config-B5kHzuNz.js +12269 -0
- package/dist/config-B5kHzuNz.js.map +1 -0
- package/dist/config-YsxGv4tq.d.ts +1263 -0
- package/dist/{ssr/context.js → context-CA8YKeMn.js} +11 -3
- package/dist/context-CA8YKeMn.js.map +1 -0
- package/dist/core/index.d.ts +5 -34
- package/dist/core/index.js +6 -27
- package/dist/core-Dr4u1NVD.js +1566 -0
- package/dist/core-Dr4u1NVD.js.map +1 -0
- package/dist/{zero/extractor.js → css-writer-B-J87ncv.js} +148 -24
- package/dist/css-writer-B-J87ncv.js.map +1 -0
- package/dist/{ssr/format-global-rules.js → format-global-rules-DklyaXv-.js} +2 -2
- package/dist/format-global-rules-DklyaXv-.js.map +1 -0
- package/dist/{ssr/format-rules.js → format-rules-DKOA-6qu.js} +59 -2
- package/dist/format-rules-DKOA-6qu.js.map +1 -0
- package/dist/{ssr/hydrate.js → hydrate-OeMX99We.js} +3 -11
- package/dist/hydrate-OeMX99We.js.map +1 -0
- package/dist/index-Cd45t5NM.d.ts +1521 -0
- package/dist/index-PqN-DIpn.d.ts +1911 -0
- package/dist/index.d.ts +5 -51
- package/dist/index.js +922 -36
- package/dist/index.js.map +1 -0
- package/dist/keyframes-CV8azJf3.js +493 -0
- package/dist/keyframes-CV8azJf3.js.map +1 -0
- package/dist/{utils/merge-styles.d.ts → merge-styles-CU7JbEwg.d.ts} +3 -3
- package/dist/{utils/merge-styles.js → merge-styles-oklji0KB.js} +3 -4
- package/dist/merge-styles-oklji0KB.js.map +1 -0
- package/dist/{utils/resolve-recipes.js → resolve-recipes-DTG81rzl.js} +4 -6
- package/dist/resolve-recipes-DTG81rzl.js.map +1 -0
- package/dist/ssr/astro-client.js +1 -1
- package/dist/ssr/astro-client.js.map +1 -1
- package/dist/ssr/astro-middleware-static.d.ts +16 -0
- package/dist/ssr/astro-middleware-static.js +18 -0
- package/dist/ssr/astro-middleware-static.js.map +1 -0
- package/dist/ssr/astro-middleware.d.ts +8 -6
- package/dist/ssr/astro-middleware.js +10 -10
- package/dist/ssr/astro-middleware.js.map +1 -1
- package/dist/ssr/astro.d.ts +2 -17
- package/dist/ssr/astro.js +29 -21
- package/dist/ssr/astro.js.map +1 -1
- package/dist/ssr/index.d.ts +37 -4
- package/dist/ssr/index.js +5 -5
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/next.d.ts +2 -3
- package/dist/ssr/next.js +7 -8
- package/dist/ssr/next.js.map +1 -1
- package/dist/static/index.d.ts +91 -5
- package/dist/static/index.js +49 -3
- package/dist/static/index.js.map +1 -0
- package/dist/static/inject.js.map +1 -1
- package/dist/zero/babel.d.ts +2 -81
- package/dist/zero/babel.js +45 -29
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.d.ts +81 -3
- package/dist/zero/index.js +2 -3
- package/dist/zero/next.d.ts +1 -1
- package/dist/zero/next.js +1 -1
- package/dist/zero/next.js.map +1 -1
- package/docs/README.md +13 -7
- package/docs/adoption.md +53 -28
- package/docs/ai-agents.md +224 -0
- package/docs/comparison.md +59 -30
- package/docs/configuration.md +498 -69
- package/docs/debug.md +18 -16
- package/docs/design-system.md +43 -24
- package/docs/dsl.md +510 -177
- package/docs/getting-started.md +55 -34
- package/docs/injector.md +60 -7
- package/docs/methodology.md +68 -36
- package/docs/migration-v3.md +285 -0
- package/docs/pipeline.md +741 -0
- package/docs/plugins.md +349 -0
- package/docs/react-api.md +162 -38
- package/docs/ssr.md +45 -35
- package/docs/styles.md +65 -16
- package/docs/tasty-static.md +25 -8
- package/package.json +44 -21
- package/tasty.config.ts +6 -0
- package/dist/_virtual/_rolldown/runtime.js +0 -7
- package/dist/chunks/cacheKey.d.ts +0 -1
- package/dist/chunks/cacheKey.js +0 -77
- package/dist/chunks/cacheKey.js.map +0 -1
- package/dist/chunks/definitions.d.ts +0 -37
- package/dist/chunks/definitions.js +0 -258
- package/dist/chunks/definitions.js.map +0 -1
- package/dist/chunks/index.d.ts +0 -1
- package/dist/chunks/renderChunk.d.ts +0 -1
- package/dist/chunks/renderChunk.js +0 -59
- package/dist/chunks/renderChunk.js.map +0 -1
- package/dist/compute-styles.d.ts +0 -31
- package/dist/compute-styles.js +0 -322
- package/dist/compute-styles.js.map +0 -1
- package/dist/config.d.ts +0 -407
- package/dist/config.js +0 -591
- package/dist/config.js.map +0 -1
- package/dist/counter-style/index.js +0 -51
- package/dist/counter-style/index.js.map +0 -1
- package/dist/debug.d.ts +0 -89
- package/dist/debug.js +0 -453
- package/dist/debug.js.map +0 -1
- package/dist/font-face/index.js +0 -63
- package/dist/font-face/index.js.map +0 -1
- package/dist/hooks/index.d.ts +0 -7
- package/dist/hooks/useCounterStyle.d.ts +0 -36
- package/dist/hooks/useCounterStyle.js +0 -65
- package/dist/hooks/useCounterStyle.js.map +0 -1
- package/dist/hooks/useFontFace.d.ts +0 -45
- package/dist/hooks/useFontFace.js +0 -66
- package/dist/hooks/useFontFace.js.map +0 -1
- package/dist/hooks/useGlobalStyles.d.ts +0 -46
- package/dist/hooks/useGlobalStyles.js +0 -88
- package/dist/hooks/useGlobalStyles.js.map +0 -1
- package/dist/hooks/useKeyframes.d.ts +0 -58
- package/dist/hooks/useKeyframes.js +0 -55
- package/dist/hooks/useKeyframes.js.map +0 -1
- package/dist/hooks/useProperty.d.ts +0 -81
- package/dist/hooks/useProperty.js +0 -96
- package/dist/hooks/useProperty.js.map +0 -1
- package/dist/hooks/useRawCSS.d.ts +0 -22
- package/dist/hooks/useRawCSS.js +0 -103
- package/dist/hooks/useRawCSS.js.map +0 -1
- package/dist/hooks/useStyles.d.ts +0 -40
- package/dist/hooks/useStyles.js +0 -31
- package/dist/hooks/useStyles.js.map +0 -1
- package/dist/injector/index.d.ts +0 -182
- package/dist/injector/index.js +0 -185
- package/dist/injector/index.js.map +0 -1
- package/dist/injector/injector.d.ts +0 -198
- package/dist/injector/injector.js +0 -651
- package/dist/injector/injector.js.map +0 -1
- package/dist/injector/sheet-manager.d.ts +0 -132
- package/dist/injector/sheet-manager.js +0 -699
- package/dist/injector/sheet-manager.js.map +0 -1
- package/dist/injector/types.d.ts +0 -235
- package/dist/keyframes/index.js +0 -206
- package/dist/keyframes/index.js.map +0 -1
- package/dist/parser/classify.js +0 -319
- package/dist/parser/classify.js.map +0 -1
- package/dist/parser/const.js +0 -60
- package/dist/parser/const.js.map +0 -1
- package/dist/parser/lru.js +0 -109
- package/dist/parser/lru.js.map +0 -1
- package/dist/parser/parser.d.ts +0 -25
- package/dist/parser/parser.js +0 -115
- package/dist/parser/parser.js.map +0 -1
- package/dist/parser/tokenizer.js +0 -69
- package/dist/parser/tokenizer.js.map +0 -1
- package/dist/parser/types.d.ts +0 -51
- package/dist/parser/types.js +0 -46
- package/dist/parser/types.js.map +0 -1
- package/dist/pipeline/conditions.d.ts +0 -134
- package/dist/pipeline/conditions.js +0 -406
- package/dist/pipeline/conditions.js.map +0 -1
- package/dist/pipeline/exclusive.js +0 -285
- package/dist/pipeline/exclusive.js.map +0 -1
- package/dist/pipeline/index.d.ts +0 -55
- package/dist/pipeline/index.js +0 -708
- package/dist/pipeline/index.js.map +0 -1
- package/dist/pipeline/materialize.js +0 -1157
- package/dist/pipeline/materialize.js.map +0 -1
- package/dist/pipeline/parseStateKey.d.ts +0 -15
- package/dist/pipeline/parseStateKey.js +0 -446
- package/dist/pipeline/parseStateKey.js.map +0 -1
- package/dist/pipeline/simplify.js +0 -690
- package/dist/pipeline/simplify.js.map +0 -1
- package/dist/pipeline/warnings.js +0 -18
- package/dist/pipeline/warnings.js.map +0 -1
- package/dist/plugins/index.d.ts +0 -2
- package/dist/plugins/okhsl-plugin.d.ts +0 -35
- package/dist/plugins/okhsl-plugin.js +0 -97
- package/dist/plugins/okhsl-plugin.js.map +0 -1
- package/dist/plugins/types.d.ts +0 -87
- package/dist/properties/index.js +0 -222
- package/dist/properties/index.js.map +0 -1
- package/dist/properties/property-type-resolver.d.ts +0 -24
- package/dist/properties/property-type-resolver.js +0 -90
- package/dist/properties/property-type-resolver.js.map +0 -1
- package/dist/rsc-cache.js +0 -79
- package/dist/rsc-cache.js.map +0 -1
- package/dist/ssr/async-storage.d.ts +0 -17
- package/dist/ssr/async-storage.js.map +0 -1
- package/dist/ssr/collect-auto-properties.js +0 -58
- package/dist/ssr/collect-auto-properties.js.map +0 -1
- package/dist/ssr/collector.js.map +0 -1
- package/dist/ssr/context.js.map +0 -1
- package/dist/ssr/format-global-rules.js.map +0 -1
- package/dist/ssr/format-keyframes.js +0 -69
- package/dist/ssr/format-keyframes.js.map +0 -1
- package/dist/ssr/format-property.js +0 -49
- package/dist/ssr/format-property.js.map +0 -1
- package/dist/ssr/format-rules.js.map +0 -1
- package/dist/ssr/hydrate.d.ts +0 -29
- package/dist/ssr/hydrate.js.map +0 -1
- package/dist/ssr/ssr-collector-ref.js +0 -29
- package/dist/ssr/ssr-collector-ref.js.map +0 -1
- package/dist/states/index.d.ts +0 -49
- package/dist/states/index.js +0 -170
- package/dist/states/index.js.map +0 -1
- package/dist/static/tastyStatic.d.ts +0 -46
- package/dist/static/tastyStatic.js +0 -30
- package/dist/static/tastyStatic.js.map +0 -1
- package/dist/static/types.d.ts +0 -49
- package/dist/static/types.js +0 -24
- package/dist/static/types.js.map +0 -1
- package/dist/styles/border.d.ts +0 -25
- package/dist/styles/border.js +0 -120
- package/dist/styles/border.js.map +0 -1
- package/dist/styles/color.d.ts +0 -14
- package/dist/styles/color.js +0 -26
- package/dist/styles/color.js.map +0 -1
- package/dist/styles/const.js +0 -17
- package/dist/styles/const.js.map +0 -1
- package/dist/styles/createStyle.js +0 -79
- package/dist/styles/createStyle.js.map +0 -1
- package/dist/styles/dimension.js +0 -109
- package/dist/styles/dimension.js.map +0 -1
- package/dist/styles/directional.js +0 -133
- package/dist/styles/directional.js.map +0 -1
- package/dist/styles/display.d.ts +0 -30
- package/dist/styles/display.js +0 -73
- package/dist/styles/display.js.map +0 -1
- package/dist/styles/fade.d.ts +0 -15
- package/dist/styles/fade.js +0 -62
- package/dist/styles/fade.js.map +0 -1
- package/dist/styles/fill.d.ts +0 -42
- package/dist/styles/fill.js +0 -51
- package/dist/styles/fill.js.map +0 -1
- package/dist/styles/flow.d.ts +0 -16
- package/dist/styles/flow.js +0 -12
- package/dist/styles/flow.js.map +0 -1
- package/dist/styles/gap.d.ts +0 -31
- package/dist/styles/gap.js +0 -38
- package/dist/styles/gap.js.map +0 -1
- package/dist/styles/height.d.ts +0 -17
- package/dist/styles/height.js +0 -19
- package/dist/styles/height.js.map +0 -1
- package/dist/styles/index.d.ts +0 -1
- package/dist/styles/index.js +0 -8
- package/dist/styles/index.js.map +0 -1
- package/dist/styles/inset.d.ts +0 -24
- package/dist/styles/inset.js +0 -34
- package/dist/styles/inset.js.map +0 -1
- package/dist/styles/list.d.ts +0 -16
- package/dist/styles/list.js +0 -100
- package/dist/styles/list.js.map +0 -1
- package/dist/styles/margin.d.ts +0 -24
- package/dist/styles/margin.js +0 -32
- package/dist/styles/margin.js.map +0 -1
- package/dist/styles/outline.d.ts +0 -29
- package/dist/styles/outline.js +0 -55
- package/dist/styles/outline.js.map +0 -1
- package/dist/styles/padding.d.ts +0 -24
- package/dist/styles/padding.js +0 -32
- package/dist/styles/padding.js.map +0 -1
- package/dist/styles/placement.d.ts +0 -37
- package/dist/styles/placement.js +0 -74
- package/dist/styles/placement.js.map +0 -1
- package/dist/styles/predefined.d.ts +0 -71
- package/dist/styles/predefined.js +0 -237
- package/dist/styles/predefined.js.map +0 -1
- package/dist/styles/preset.d.ts +0 -52
- package/dist/styles/preset.js +0 -127
- package/dist/styles/preset.js.map +0 -1
- package/dist/styles/radius.d.ts +0 -12
- package/dist/styles/radius.js +0 -83
- package/dist/styles/radius.js.map +0 -1
- package/dist/styles/scrollMargin.d.ts +0 -24
- package/dist/styles/scrollMargin.js +0 -32
- package/dist/styles/scrollMargin.js.map +0 -1
- package/dist/styles/scrollbar.d.ts +0 -25
- package/dist/styles/scrollbar.js +0 -51
- package/dist/styles/scrollbar.js.map +0 -1
- package/dist/styles/shadow.d.ts +0 -14
- package/dist/styles/shadow.js +0 -25
- package/dist/styles/shadow.js.map +0 -1
- package/dist/styles/shared.js +0 -17
- package/dist/styles/shared.js.map +0 -1
- package/dist/styles/transition.d.ts +0 -14
- package/dist/styles/transition.js +0 -159
- package/dist/styles/transition.js.map +0 -1
- package/dist/styles/types.d.ts +0 -564
- package/dist/styles/width.d.ts +0 -17
- package/dist/styles/width.js +0 -19
- package/dist/styles/width.js.map +0 -1
- package/dist/tasty.d.ts +0 -134
- package/dist/tasty.js +0 -248
- package/dist/tasty.js.map +0 -1
- package/dist/types.d.ts +0 -184
- package/dist/utils/cache-wrapper.js +0 -21
- package/dist/utils/cache-wrapper.js.map +0 -1
- package/dist/utils/case-converter.js +0 -8
- package/dist/utils/case-converter.js.map +0 -1
- package/dist/utils/color-math.d.ts +0 -46
- package/dist/utils/color-math.js +0 -749
- package/dist/utils/color-math.js.map +0 -1
- package/dist/utils/color-space.d.ts +0 -5
- package/dist/utils/color-space.js +0 -228
- package/dist/utils/color-space.js.map +0 -1
- package/dist/utils/colors.d.ts +0 -5
- package/dist/utils/colors.js +0 -10
- package/dist/utils/colors.js.map +0 -1
- package/dist/utils/css-types.d.ts +0 -7
- package/dist/utils/deps-equal.js +0 -15
- package/dist/utils/deps-equal.js.map +0 -1
- package/dist/utils/dotize.d.ts +0 -26
- package/dist/utils/dotize.js +0 -122
- package/dist/utils/dotize.js.map +0 -1
- package/dist/utils/filter-base-props.d.ts +0 -15
- package/dist/utils/filter-base-props.js +0 -45
- package/dist/utils/filter-base-props.js.map +0 -1
- package/dist/utils/get-display-name.d.ts +0 -7
- package/dist/utils/get-display-name.js +0 -10
- package/dist/utils/get-display-name.js.map +0 -1
- package/dist/utils/has-keys.js +0 -13
- package/dist/utils/has-keys.js.map +0 -1
- package/dist/utils/hash.js +0 -14
- package/dist/utils/hash.js.map +0 -1
- package/dist/utils/is-dev-env.js +0 -19
- package/dist/utils/is-dev-env.js.map +0 -1
- package/dist/utils/is-valid-element-type.js +0 -15
- package/dist/utils/is-valid-element-type.js.map +0 -1
- package/dist/utils/merge-styles.js.map +0 -1
- package/dist/utils/mod-attrs.d.ts +0 -6
- package/dist/utils/mod-attrs.js +0 -20
- package/dist/utils/mod-attrs.js.map +0 -1
- package/dist/utils/process-tokens.d.ts +0 -17
- package/dist/utils/process-tokens.js +0 -83
- package/dist/utils/process-tokens.js.map +0 -1
- package/dist/utils/resolve-recipes.d.ts +0 -17
- package/dist/utils/resolve-recipes.js.map +0 -1
- package/dist/utils/selector-transform.js +0 -32
- package/dist/utils/selector-transform.js.map +0 -1
- package/dist/utils/string.js +0 -8
- package/dist/utils/string.js.map +0 -1
- package/dist/utils/styles.d.ts +0 -99
- package/dist/utils/styles.js +0 -220
- package/dist/utils/styles.js.map +0 -1
- package/dist/utils/typography.d.ts +0 -58
- package/dist/utils/typography.js +0 -51
- package/dist/utils/typography.js.map +0 -1
- package/dist/utils/warnings.d.ts +0 -16
- package/dist/utils/warnings.js +0 -16
- package/dist/utils/warnings.js.map +0 -1
- package/dist/zero/css-writer.d.ts +0 -45
- package/dist/zero/css-writer.js +0 -73
- package/dist/zero/css-writer.js.map +0 -1
- package/dist/zero/extractor.d.ts +0 -24
- package/dist/zero/extractor.js.map +0 -1
- package/docs/PIPELINE.md +0 -519
package/docs/getting-started.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Getting Started
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Build one stateful component first. You will see how Tasty expresses priority as a state map, why overlapping states do not compete, and where shared design-system configuration fits afterward.
|
|
4
|
+
|
|
5
|
+
This is the right starting point when you are ready to try Tasty in code. If you are still evaluating it, read the [Introduction](../README.md), [Comparison](comparison.md), and [Adoption Guide](adoption.md).
|
|
4
6
|
|
|
5
7
|
---
|
|
6
8
|
|
|
@@ -10,7 +12,7 @@ This guide walks you from zero to a working Tasty component, then through the op
|
|
|
10
12
|
- **React** >= 18 (peer dependency)
|
|
11
13
|
- **Package manager**: pnpm, npm, or yarn
|
|
12
14
|
|
|
13
|
-
Tasty
|
|
15
|
+
No Tasty configuration is required for the first component.
|
|
14
16
|
|
|
15
17
|
---
|
|
16
18
|
|
|
@@ -22,36 +24,57 @@ pnpm add @tenphi/tasty
|
|
|
22
24
|
|
|
23
25
|
---
|
|
24
26
|
|
|
25
|
-
##
|
|
27
|
+
## Build a button whose states don’t fight
|
|
26
28
|
|
|
27
29
|
```tsx
|
|
28
30
|
import { tasty } from '@tenphi/tasty';
|
|
29
31
|
|
|
30
|
-
const
|
|
31
|
-
as: '
|
|
32
|
+
const Button = tasty({
|
|
33
|
+
as: 'button',
|
|
32
34
|
styles: {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
padding: '12px 20px',
|
|
36
|
+
radius: '8px',
|
|
37
|
+
border: '0',
|
|
38
|
+
fill: {
|
|
39
|
+
'': 'royalblue',
|
|
40
|
+
':hover': 'blue',
|
|
41
|
+
':active': 'navy',
|
|
42
|
+
disabled: 'lightgray',
|
|
43
|
+
},
|
|
44
|
+
color: {
|
|
45
|
+
'': 'white',
|
|
46
|
+
disabled: 'dimgray',
|
|
47
|
+
},
|
|
48
|
+
cursor: {
|
|
49
|
+
'': 'pointer',
|
|
50
|
+
disabled: 'not-allowed',
|
|
51
|
+
},
|
|
40
52
|
},
|
|
41
53
|
});
|
|
42
54
|
|
|
43
55
|
export default function App() {
|
|
44
|
-
return
|
|
56
|
+
return (
|
|
57
|
+
<>
|
|
58
|
+
<Button>Save changes</Button>
|
|
59
|
+
<Button disabled>Disabled</Button>
|
|
60
|
+
</>
|
|
61
|
+
);
|
|
45
62
|
}
|
|
46
63
|
```
|
|
47
64
|
|
|
48
|
-
`tasty()` returns a normal React component.
|
|
65
|
+
`tasty()` returns a normal React component. The keys in each state map define priority: later branches win over earlier ones. Because `disabled` is last, a disabled button keeps its disabled styles even while the pointer is over it.
|
|
66
|
+
|
|
67
|
+
`disabled` and `checked` are built-in automatic states. Tasty activates them from the corresponding native prop or attribute, so `disabled` is the concise Tasty form of `[disabled]`, and `checked` is the concise form of `[checked]`.
|
|
68
|
+
|
|
69
|
+
Tasty compiles that priority into selectors that exclude one another. The hover, active, and disabled background rules cannot all match and ask the CSS cascade to decide the winner.
|
|
70
|
+
|
|
71
|
+
The example uses ordinary CSS values so it works without setup. A design system will usually replace them with shared tokens, units, and state aliases in the next step. See the [Style DSL](dsl.md) for the complete state-map syntax and [Style Properties](styles.md) for Tasty’s enhanced CSS properties.
|
|
49
72
|
|
|
50
73
|
---
|
|
51
74
|
|
|
52
|
-
##
|
|
75
|
+
## Add your design system’s language
|
|
53
76
|
|
|
54
|
-
Use `configure()` once, before your app renders, when your app or design system
|
|
77
|
+
The first component needs no configuration. Use `configure()` once, before your app renders, when your app or design system is ready to share tokens, state aliases, recipes, units, or parser extensions:
|
|
55
78
|
|
|
56
79
|
```tsx
|
|
57
80
|
// src/tasty-config.ts
|
|
@@ -91,8 +114,8 @@ configure({
|
|
|
91
114
|
'#primary': 'oklch(55% 0.25 265)',
|
|
92
115
|
'#surface': '#fff',
|
|
93
116
|
'#text': '#111',
|
|
94
|
-
|
|
95
|
-
|
|
117
|
+
$gap: '8px',
|
|
118
|
+
$radius: '4px',
|
|
96
119
|
'$border-width': '1px',
|
|
97
120
|
'$outline-width': '2px',
|
|
98
121
|
},
|
|
@@ -148,23 +171,21 @@ export default [
|
|
|
148
171
|
|
|
149
172
|
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:
|
|
150
173
|
|
|
151
|
-
| Category
|
|
152
|
-
|
|
153
|
-
| Property validation | `known-property`, `valid-boolean-property`, `valid-sub-element`
|
|
154
|
-
| Value validation
|
|
155
|
-
| State validation
|
|
156
|
-
| Structure
|
|
157
|
-
| Static mode
|
|
158
|
-
| Style properties
|
|
174
|
+
| Category | Rules | Examples |
|
|
175
|
+
| ------------------- | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------ |
|
|
176
|
+
| Property validation | `known-property`, `valid-boolean-property`, `valid-sub-element` | Flags typos like `pading` or invalid boolean usage |
|
|
177
|
+
| Value validation | `valid-value`, `valid-color-token`, `valid-custom-unit` | Catches `#nonexistent` tokens, bad unit syntax |
|
|
178
|
+
| State validation | `valid-state-key`, `no-nested-state-map`, `require-default-state` | Validates state key syntax, ensures `''` default exists |
|
|
179
|
+
| Structure | `valid-styles-structure`, `no-important`, `no-nested-selector` | Prevents `!important`, invalid nesting |
|
|
180
|
+
| Static mode | `static-no-dynamic-values`, `static-valid-selector` | Enforces build-time constraints in `tastyStatic()` |
|
|
181
|
+
| Style properties | `valid-preset`, `valid-recipe`, `valid-transition`, `valid-directional-modifier`, `valid-radius-shape` | Validates preset names, recipe references, transition syntax |
|
|
159
182
|
|
|
160
183
|
### Strict config
|
|
161
184
|
|
|
162
185
|
For stricter governance, use `tasty.configs.strict`. It adds rules that enforce best practices like preferring shorthand properties, consistent token usage, and flagging direct `styles` prop usage:
|
|
163
186
|
|
|
164
187
|
```js
|
|
165
|
-
export default [
|
|
166
|
-
tasty.configs.strict,
|
|
167
|
-
];
|
|
188
|
+
export default [tasty.configs.strict];
|
|
168
189
|
```
|
|
169
190
|
|
|
170
191
|
---
|
|
@@ -181,11 +202,11 @@ export default [
|
|
|
181
202
|
|
|
182
203
|
`tasty()` is the default for all React apps. All `tasty()` components and style functions are hook-free and work as React Server Components without `'use client'`. In server-only contexts, they produce zero client JavaScript with the full feature set.
|
|
183
204
|
|
|
184
|
-
| Approach
|
|
185
|
-
|
|
186
|
-
| **Runtime (default)**
|
|
187
|
-
| **Runtime + SSR integration** | Add `@tenphi/tasty/ssr/*`
|
|
188
|
-
| **Zero-runtime**
|
|
205
|
+
| Approach | Entry point | Best for | Trade-off |
|
|
206
|
+
| ----------------------------- | ------------------------------------------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
|
|
207
|
+
| **Runtime (default)** | `tasty()` from `@tenphi/tasty` | All React apps — server-rendered by default, zero client JS until you need interactivity | Full feature set (styleProps, sub-elements, variants); CSS computed during rendering |
|
|
208
|
+
| **Runtime + SSR integration** | Add `@tenphi/tasty/ssr/*` | Apps with client-side hydration (Next.js client components, Astro islands) | Adds CSS batching, deduplication, FOUC prevention, and client cache hydration |
|
|
209
|
+
| **Zero-runtime** | `tastyStatic()` from `@tenphi/tasty/static` | Non-React frameworks or build-time extraction without React | Requires Babel plugin; no `styleProps` or runtime-only APIs |
|
|
189
210
|
|
|
190
211
|
Both `tasty()` and `tastyStatic()` share the same DSL, tokens, units, and state mappings.
|
|
191
212
|
|
package/docs/injector.md
CHANGED
|
@@ -11,7 +11,7 @@ The Style Injector is the core engine behind Tasty's styling system, providing:
|
|
|
11
11
|
- **Hash-based deduplication** - Identical CSS gets the same className
|
|
12
12
|
- **Reference counting** - Automatic cleanup when components unmount (refCount = 0)
|
|
13
13
|
- **CSS nesting flattening** - Handles `&`, `.Class`, `SubElement` patterns
|
|
14
|
-
- **
|
|
14
|
+
- **At-rule injection** - First-class `@keyframes`, `@property`, `@font-face`, `@counter-style`, and `@function` support
|
|
15
15
|
- **Smart cleanup** - CSS rules batched cleanup, keyframes disposed immediately
|
|
16
16
|
- **SSR support** - Deterministic class names and CSS extraction
|
|
17
17
|
- **Multiple roots** - Works with Document and ShadowRoot
|
|
@@ -224,7 +224,22 @@ configure({
|
|
|
224
224
|
|
|
225
225
|
**Auto-Detection Features:**
|
|
226
226
|
- `devMode`: Automatically enabled in development environments (detected via `isDevEnv()`)
|
|
227
|
-
- `forceTextInjection`: Automatically enabled in test environments (Jest, Vitest, Mocha, jsdom)
|
|
227
|
+
- `forceTextInjection`: Automatically enabled in test environments (Jest, Vitest, Mocha, happy-dom, jsdom)
|
|
228
|
+
|
|
229
|
+
**Injection Modes:**
|
|
230
|
+
|
|
231
|
+
Each sheet picks its write mode once, when it is created, and keeps it for its
|
|
232
|
+
lifetime:
|
|
233
|
+
|
|
234
|
+
| Mode | How rules are written | How rules are removed |
|
|
235
|
+
|---|---|---|
|
|
236
|
+
| CSSOM (default) | `styleSheet.insertRule(rule, index)` | `styleSheet.deleteRule(index)` |
|
|
237
|
+
| Text (`forceTextInjection`, or when `styleElement.sheet` is unavailable) | appended to `<style>.textContent` | rule texts are tracked per sheet and the element's text is rebuilt without them |
|
|
238
|
+
| Adopted (ShadowRoot with constructable sheets) | `insertRule` on the constructable sheet | `deleteRule` on the constructable sheet |
|
|
239
|
+
|
|
240
|
+
Text mode cannot edit a single rule in place the way CSSOM can, so the sheet
|
|
241
|
+
keeps the inserted rule texts in index order and rewrites the element on delete.
|
|
242
|
+
Dispose, ref-counted cleanup and GC therefore behave identically in every mode.
|
|
228
243
|
|
|
229
244
|
**Configuration Notes:**
|
|
230
245
|
- Most options have sensible defaults and auto-detection
|
|
@@ -235,6 +250,33 @@ configure({
|
|
|
235
250
|
|
|
236
251
|
---
|
|
237
252
|
|
|
253
|
+
### At-rule injection
|
|
254
|
+
|
|
255
|
+
Beyond ordinary rules, the injector has a dedicated entry point per at-rule. All of them deduplicate by name and are **permanent** — there is no ref-counting or dispose, because a rule that other CSS references by name cannot be safely removed while any of it might still apply.
|
|
256
|
+
|
|
257
|
+
| Function | Injects | Notes |
|
|
258
|
+
|---|---|---|
|
|
259
|
+
| `keyframes(steps, nameOrOptions?)` | `@keyframes` | The exception: ref-counted and disposed immediately when unused. Returns the injected name, which may differ from the requested one. |
|
|
260
|
+
| `property(name, options?)` | `@property` | `name` accepts `$name`, `#name`, or `--name`. Usually unnecessary — types are inferred automatically unless `configure({ autoPropertyTypes: false })`. |
|
|
261
|
+
| `fontFace(family, descriptors, options?)` | `@font-face` | Deduplicated by family **and** descriptor content, so several faces of one family coexist. |
|
|
262
|
+
| `counterStyle(name, descriptors, options?)` | `@counter-style` | |
|
|
263
|
+
| `func(name, definition, options?)` | `@function` | `name` accepts `$$name`, `$name`, or `--name`. Abbreviated because `function` is a reserved word. |
|
|
264
|
+
|
|
265
|
+
Every one of these takes an optional `root` (a `Document` or `ShadowRoot`).
|
|
266
|
+
|
|
267
|
+
`func()` also accepts `weak: true`, which registers the rule **without** overriding an existing one of the same name. `configure()` uses it for global `@function` definitions so a component-local definition always wins over the global default, regardless of which is injected first.
|
|
268
|
+
|
|
269
|
+
```ts
|
|
270
|
+
import { counterStyle, fontFace, func, property } from '@tenphi/tasty';
|
|
271
|
+
|
|
272
|
+
property('$card-elevation', { syntax: '<number>', initialValue: '0' });
|
|
273
|
+
fontFace('Inter', { src: 'url(/inter.woff2)', fontWeight: '400 700' });
|
|
274
|
+
counterStyle('dashes', { system: 'cyclic', symbols: '"—"', suffix: ' ' });
|
|
275
|
+
func('$$negative', { args: ['$value'], result: '(-1 * $value)' });
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
238
280
|
## Advanced Features
|
|
239
281
|
|
|
240
282
|
### Style Result Format
|
|
@@ -258,6 +300,17 @@ const styleRule: StyleResult = {
|
|
|
258
300
|
};
|
|
259
301
|
```
|
|
260
302
|
|
|
303
|
+
### Batched Injection
|
|
304
|
+
|
|
305
|
+
`configure({ batchInjection: true })` queues every sheet write — component
|
|
306
|
+
rules, global rules, raw CSS and at-rules — into one FIFO and applies them
|
|
307
|
+
together, so the document is style-invalidated once per flush instead of once per
|
|
308
|
+
component. `<TastyBatchProvider>` flushes in `useInsertionEffect`, before any
|
|
309
|
+
layout effect, so a queued write can never be observed by a measurement. See
|
|
310
|
+
[Batched injection](configuration.md#batched-injection) for the modes and the
|
|
311
|
+
ordering guarantee. `flushStyles()` applies pending writes on demand; every read
|
|
312
|
+
API here calls it for you.
|
|
313
|
+
|
|
261
314
|
### Deduplication & Performance
|
|
262
315
|
|
|
263
316
|
```typescript
|
|
@@ -350,14 +403,14 @@ const shadowAnimation = keyframes({
|
|
|
350
403
|
### Server-Side Rendering
|
|
351
404
|
|
|
352
405
|
```typescript
|
|
353
|
-
import {
|
|
406
|
+
import { getCSSText, getCSSTextForNode } from '@tenphi/tasty';
|
|
354
407
|
|
|
355
408
|
// Extract all CSS for SSR
|
|
356
|
-
const cssText =
|
|
409
|
+
const cssText = getCSSText();
|
|
357
410
|
|
|
358
411
|
// Extract CSS for specific DOM subtree (like jest-styled-components)
|
|
359
412
|
const container = render(<MyComponent />);
|
|
360
|
-
const componentCSS =
|
|
413
|
+
const componentCSS = getCSSTextForNode(container);
|
|
361
414
|
```
|
|
362
415
|
|
|
363
416
|
### Test Environment Detection
|
|
@@ -366,7 +419,7 @@ const componentCSS = getCssTextForNode(container);
|
|
|
366
419
|
// Automatically detected test environments:
|
|
367
420
|
// - NODE_ENV === 'test'
|
|
368
421
|
// - Jest globals (jest, describe, it, expect)
|
|
369
|
-
// - jsdom user agent
|
|
422
|
+
// - jsdom / HappyDOM user agent
|
|
370
423
|
// - Vitest globals (vitest)
|
|
371
424
|
// - Mocha globals (mocha)
|
|
372
425
|
|
|
@@ -465,7 +518,7 @@ metrics.cleanupHistory.forEach(cleanup => {
|
|
|
465
518
|
|
|
466
519
|
```typescript
|
|
467
520
|
// ✅ Reuse styles - identical CSS gets deduplicated
|
|
468
|
-
const buttonBase =
|
|
521
|
+
const buttonBase = 'padding: 8px 16px; border-radius: 4px;';
|
|
469
522
|
|
|
470
523
|
// ✅ Avoid frequent disposal and re-injection
|
|
471
524
|
// Let the reference counting system handle cleanup
|
package/docs/methodology.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Methodology
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
State maps keep a property’s branches from fighting. This guide applies the same goal to component architecture: keep state ownership explicit, expose intentional public APIs, and make extension predictable as a component system grows.
|
|
4
|
+
|
|
5
|
+
The patterns are recommended rather than required. Tasty works without them, but they help design-system teams carry its state-resolution guarantees across roots, sub-elements, typed props, tokens, and styled wrappers.
|
|
4
6
|
|
|
5
7
|
---
|
|
6
8
|
|
|
@@ -75,7 +77,7 @@ const Nav = tasty({
|
|
|
75
77
|
'': '#text',
|
|
76
78
|
'@own(:hover)': '#primary',
|
|
77
79
|
'@own(:focus-visible)': '#primary',
|
|
78
|
-
|
|
80
|
+
selected: '#primary',
|
|
79
81
|
},
|
|
80
82
|
},
|
|
81
83
|
},
|
|
@@ -117,16 +119,16 @@ Style props accept state maps, so responsive values work through the same API:
|
|
|
117
119
|
|
|
118
120
|
Tasty exports predefined style prop lists that group properties by role. Use them instead of hand-picking arrays:
|
|
119
121
|
|
|
120
|
-
| Preset
|
|
121
|
-
|
|
122
|
-
| `FLOW_STYLES`
|
|
123
|
-
| `POSITION_STYLES`
|
|
124
|
-
| `DIMENSION_STYLES` | width, height, flexBasis, flexGrow, flexShrink, flex
|
|
125
|
-
| `COLOR_STYLES`
|
|
126
|
-
| `BLOCK_STYLES`
|
|
127
|
-
| `CONTAINER_STYLES` | All of the above combined (+ BASE_STYLES)
|
|
128
|
-
| `OUTER_STYLES`
|
|
129
|
-
| `INNER_STYLES`
|
|
122
|
+
| Preset | Properties | Typical use |
|
|
123
|
+
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------- |
|
|
124
|
+
| `FLOW_STYLES` | flow, gap, columnGap, rowGap, align, justify, placeItems, placeContent, alignItems, alignContent, justifyItems, justifyContent, gridColumns, gridRows, gridTemplate, gridAreas | Layout containers (`Space`, `Grid`) |
|
|
125
|
+
| `POSITION_STYLES` | gridArea, gridColumn, gridRow, order, placeSelf, alignSelf, justifySelf, zIndex, margin, inset, position | Positioned elements (`Button`, `Badge`) |
|
|
126
|
+
| `DIMENSION_STYLES` | width, height, flexBasis, flexGrow, flexShrink, flex | Sized elements |
|
|
127
|
+
| `COLOR_STYLES` | color, fill, fade, image | Color-customizable elements |
|
|
128
|
+
| `BLOCK_STYLES` | padding, paddingInline, paddingBlock, overflow, scrollbar, textAlign, border, radius, shadow, outline | Block-level containers |
|
|
129
|
+
| `CONTAINER_STYLES` | All of the above combined (+ BASE_STYLES) | Fully flexible containers |
|
|
130
|
+
| `OUTER_STYLES` | POSITION_STYLES + DIMENSION_STYLES + block outer (border, radius, shadow, outline) | Components whose outer shell is customizable |
|
|
131
|
+
| `INNER_STYLES` | BASE_STYLES + COLOR_STYLES + block inner (padding, overflow, scrollbar) + FLOW_STYLES | Components whose inner layout is customizable |
|
|
130
132
|
|
|
131
133
|
```tsx
|
|
132
134
|
import { tasty, FLOW_STYLES, POSITION_STYLES } from '@tenphi/tasty';
|
|
@@ -159,7 +161,7 @@ Match the preset to the component's role:
|
|
|
159
161
|
|
|
160
162
|
### The governance trade-off
|
|
161
163
|
|
|
162
|
-
Exposing every CSS property as a prop defeats the purpose of a design system. The more props a component exposes, the more ways product engineers can deviate from the intended design. A good rule of thumb: expose props that product engineers
|
|
164
|
+
Exposing every CSS property as a prop defeats the purpose of a design system. The more props a component exposes, the more ways product engineers can deviate from the intended design. A good rule of thumb: expose props that product engineers _need_ to adjust for layout and composition, and keep visual identity (colors, borders, typography) controlled through the component definition, variants, or styled wrappers.
|
|
163
165
|
|
|
164
166
|
---
|
|
165
167
|
|
|
@@ -180,17 +182,19 @@ const Card = tasty({
|
|
|
180
182
|
});
|
|
181
183
|
|
|
182
184
|
// Clean prop API — no mods object needed
|
|
183
|
-
<Card isLoading isSelected>
|
|
185
|
+
<Card isLoading isSelected>
|
|
186
|
+
Content
|
|
187
|
+
</Card>;
|
|
184
188
|
```
|
|
185
189
|
|
|
186
190
|
### When to use which
|
|
187
191
|
|
|
188
|
-
| Pattern
|
|
189
|
-
|
|
190
|
-
| `modProps`
|
|
191
|
-
| `mods` prop
|
|
192
|
-
| Both
|
|
193
|
-
| `styleProps` | Exposing CSS properties (layout, sizing) for customization — different from modifiers.
|
|
192
|
+
| Pattern | Use when |
|
|
193
|
+
| ------------ | --------------------------------------------------------------------------------------------------------------------------------------- |
|
|
194
|
+
| `modProps` | The component has a fixed set of known boolean/string states that drive styles. Provides TypeScript autocomplete and a cleaner JSX API. |
|
|
195
|
+
| `mods` prop | The component needs arbitrary or dynamic modifiers that aren't known at definition time. |
|
|
196
|
+
| Both | Combine `modProps` for the known states and `mods` for ad-hoc overrides. Mod props take precedence. |
|
|
197
|
+
| `styleProps` | Exposing CSS properties (layout, sizing) for customization — different from modifiers. |
|
|
194
198
|
|
|
195
199
|
### Typed modProps vs array form
|
|
196
200
|
|
|
@@ -214,7 +218,7 @@ The array form is simpler but types all values as `ModValue`:
|
|
|
214
218
|
modProps: ['isLoading', 'isSelected'] as const,
|
|
215
219
|
```
|
|
216
220
|
|
|
217
|
-
For the full API reference, see [
|
|
221
|
+
For the full API reference, see [React API — Mod Props](react-api.md#mod-props).
|
|
218
222
|
|
|
219
223
|
---
|
|
220
224
|
|
|
@@ -239,20 +243,20 @@ const ProgressBar = tasty({
|
|
|
239
243
|
});
|
|
240
244
|
|
|
241
245
|
// Usage: the progress value comes from a prop, not from styles
|
|
242
|
-
<ProgressBar tokens={{
|
|
246
|
+
<ProgressBar tokens={{ $progress: `${percent}%` }} />;
|
|
243
247
|
```
|
|
244
248
|
|
|
245
249
|
The `tokens` prop sets `style="--progress: 75%"` on the DOM element. The `$progress` reference in styles maps to `var(--progress)`, so the bar width updates without regenerating any CSS.
|
|
246
250
|
|
|
247
251
|
### When to use tokens vs other mechanisms
|
|
248
252
|
|
|
249
|
-
| Need
|
|
250
|
-
|
|
251
|
-
| Value changes per instance at render time (progress, user color, avatar size) | `tokens` prop (on component)
|
|
252
|
-
| Value is constant across all instances (card padding, border radius)
|
|
253
|
-
| Value should be inlined at parse time (alias for another token)
|
|
254
|
-
| Value changes based on component state (hover, disabled, breakpoint)
|
|
255
|
-
| Value changes based on a variant (primary, danger, outline)
|
|
253
|
+
| Need | Use |
|
|
254
|
+
| ----------------------------------------------------------------------------- | --------------------------------------------------------- |
|
|
255
|
+
| Value changes per instance at render time (progress, user color, avatar size) | `tokens` prop (on component) |
|
|
256
|
+
| Value is constant across all instances (card padding, border radius) | `configure({ tokens })` for `:root` CSS custom properties |
|
|
257
|
+
| Value should be inlined at parse time (alias for another token) | `configure({ replaceTokens })` |
|
|
258
|
+
| Value changes based on component state (hover, disabled, breakpoint) | State map in `styles` |
|
|
259
|
+
| Value changes based on a variant (primary, danger, outline) | `variants` option |
|
|
256
260
|
|
|
257
261
|
Design tokens (via `configure({ tokens })`) are injected as CSS custom properties on `:root`. Replace tokens (via `configure({ replaceTokens })`) are resolved at parse time and baked into the generated CSS. The `tokens` prop on components is resolved at render time via inline CSS custom properties. Use design tokens for design-system constants, replace tokens for value aliases, and the `tokens` prop for truly dynamic per-instance values.
|
|
258
262
|
|
|
@@ -271,11 +275,11 @@ const ProgressBar = tasty({
|
|
|
271
275
|
});
|
|
272
276
|
|
|
273
277
|
// Clean prop API — no tokens object needed
|
|
274
|
-
<ProgressBar progress="75%" accentColor="#purple"
|
|
278
|
+
<ProgressBar progress="75%" accentColor="#purple" />;
|
|
275
279
|
|
|
276
280
|
// Conversion:
|
|
277
281
|
// 'progress' → $progress → --progress
|
|
278
|
-
// 'accentColor' → #accent → --accent-color
|
|
282
|
+
// 'accentColor' → #accent → --accent-color
|
|
279
283
|
```
|
|
280
284
|
|
|
281
285
|
#### Object form
|
|
@@ -291,7 +295,7 @@ const Card = tasty({
|
|
|
291
295
|
styles: { padding: '$card-size', fill: '#card-accent' },
|
|
292
296
|
});
|
|
293
297
|
|
|
294
|
-
<Card size="4x" color="#purple"
|
|
298
|
+
<Card size="4x" color="#purple" />;
|
|
295
299
|
```
|
|
296
300
|
|
|
297
301
|
#### Merge order
|
|
@@ -326,7 +330,7 @@ const LargeCard = tasty(Card, {
|
|
|
326
330
|
styles: { padding: '6x', Title: { color: '#danger' } },
|
|
327
331
|
});
|
|
328
332
|
|
|
329
|
-
<LargeCard
|
|
333
|
+
<LargeCard />;
|
|
330
334
|
```
|
|
331
335
|
|
|
332
336
|
Why? Styled wrappers are:
|
|
@@ -399,6 +403,34 @@ tasty(Button, {
|
|
|
399
403
|
|
|
400
404
|
For full details on merge semantics, `@inherit`, `null`, and `false` tombstones, see [Style DSL — Extending vs. Replacing State Maps](dsl.md#extending-vs-replacing-state-maps).
|
|
401
405
|
|
|
406
|
+
### Styling non-Tasty components or string tags
|
|
407
|
+
|
|
408
|
+
`tasty(Component, { ... })` always forwards every prop to `Component`, which means `Component` must be Tasty-aware (i.e. it knows how to consume `styles`, `mods`, `qa`, etc.). To apply styles to a third-party component (Next.js `Link`, `react-router`'s `Link`, Radix primitives, MUI, etc.) or to a plain DOM tag, use the options-only form with `as`:
|
|
409
|
+
|
|
410
|
+
```tsx
|
|
411
|
+
import NextLink from 'next/link';
|
|
412
|
+
|
|
413
|
+
const Link = tasty({
|
|
414
|
+
as: NextLink,
|
|
415
|
+
styles: {
|
|
416
|
+
color: { '': '#accent-text', ':hover': '#text' },
|
|
417
|
+
textDecoration: 'underline',
|
|
418
|
+
},
|
|
419
|
+
styleProps: ['padding'],
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
const Span = tasty({
|
|
423
|
+
as: 'span',
|
|
424
|
+
styles: { preset: 'strong' },
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
<Link href="/blog" padding="1x">
|
|
428
|
+
Blog
|
|
429
|
+
</Link>;
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
The wrapped component only needs to forward `className` (and ideally `style` and `ref`) to its underlying DOM node. Tasty-specific props (`qa`, `qaVal`, `mods`, `tokens`, `isDisabled`, `isHidden`, `isChecked`, and any `styleProps`/`modProps`/`tokenProps` you declared) are consumed by the wrapper and converted to `data-*` attributes or CSS custom properties — they never leak to the DOM.
|
|
433
|
+
|
|
402
434
|
### When to use styleProps vs wrapping
|
|
403
435
|
|
|
404
436
|
If the component exposes the properties you need as `styleProps`, use them directly — that is what they are for:
|
|
@@ -567,7 +599,7 @@ Modifiers are compiled into exclusive selectors once. Changing `styles` at runti
|
|
|
567
599
|
|
|
568
600
|
```tsx
|
|
569
601
|
// Bad: bypassing Tasty for custom styling
|
|
570
|
-
<Button style={{ backgroundColor: 'red', padding: '12px 24px' }}
|
|
602
|
+
<Button style={{ backgroundColor: 'red', padding: '12px 24px' }} />;
|
|
571
603
|
|
|
572
604
|
// Good: create a styled wrapper
|
|
573
605
|
const DangerButton = tasty(Button, {
|
|
@@ -584,7 +616,7 @@ The `style` prop bypasses tokens, units, and state maps. It should only be used
|
|
|
584
616
|
<Card>
|
|
585
617
|
<div data-element="Title">Card Title</div>
|
|
586
618
|
<div data-element="Content">Card content</div>
|
|
587
|
-
</Card
|
|
619
|
+
</Card>;
|
|
588
620
|
|
|
589
621
|
// Better: declare elements for typed sub-components
|
|
590
622
|
const Card = tasty({
|
|
@@ -598,7 +630,7 @@ const Card = tasty({
|
|
|
598
630
|
<Card>
|
|
599
631
|
<Card.Title>Card Title</Card.Title>
|
|
600
632
|
<Card.Content>Card content</Card.Content>
|
|
601
|
-
</Card
|
|
633
|
+
</Card>;
|
|
602
634
|
```
|
|
603
635
|
|
|
604
636
|
The `elements` prop gives you typed sub-components with automatic `data-element` attributes, `mods` support, and better discoverability.
|