@tenphi/tasty 0.0.0-snapshot.b6cc3cd → 0.0.0-snapshot.b72042f
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 +432 -395
- package/dist/babel-types-DpUCD2L_.d.ts +18 -0
- package/dist/chunks/async-storage-f9j9JRtq.js +37 -0
- package/dist/chunks/async-storage-f9j9JRtq.js.map +1 -0
- package/dist/chunks/build-config-BPbBYr1q.js +60 -0
- package/dist/chunks/build-config-BPbBYr1q.js.map +1 -0
- package/dist/{collector-Di3C8btw.js → chunks/collector-By5kLcSw.js} +25 -119
- package/dist/chunks/collector-By5kLcSw.js.map +1 -0
- package/dist/chunks/config-engine-CQRddZJg.js +272 -0
- package/dist/chunks/config-engine-CQRddZJg.js.map +1 -0
- package/dist/chunks/config-file-DlZXJMj8.js +25 -0
- package/dist/chunks/config-file-DlZXJMj8.js.map +1 -0
- package/dist/chunks/css-definitions-B-JT-fmv.js +900 -0
- package/dist/chunks/css-definitions-B-JT-fmv.js.map +1 -0
- package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
- package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
- package/dist/chunks/debug-DUObLxBL.js +502 -0
- package/dist/chunks/debug-DUObLxBL.js.map +1 -0
- package/dist/chunks/dsl-DRhFWQzo.js +1378 -0
- package/dist/chunks/dsl-DRhFWQzo.js.map +1 -0
- package/dist/chunks/hydration-TRcz5vnk.js +41 -0
- package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
- package/dist/chunks/react-runtime-du7IXuS4.js +689 -0
- package/dist/chunks/react-runtime-du7IXuS4.js.map +1 -0
- package/dist/chunks/runtime-engine-uWrypi9N.js +2431 -0
- package/dist/chunks/runtime-engine-uWrypi9N.js.map +1 -0
- package/dist/chunks/runtime-state-3AzHBp5g.js +141 -0
- package/dist/chunks/runtime-state-3AzHBp5g.js.map +1 -0
- package/dist/{merge-styles-bdh7-1uh.js → chunks/shared-utils-y-HjvPN4.js} +60 -55
- package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
- package/dist/chunks/style-engine-C8qXrvxi.js +5420 -0
- package/dist/chunks/style-engine-C8qXrvxi.js.map +1 -0
- package/dist/{css-writer-CQYbT4g_.js → chunks/zero-engine-wGG9mmhj.js} +65 -145
- package/dist/chunks/zero-engine-wGG9mmhj.js.map +1 -0
- package/dist/{collector-BFuqdF2F.d.ts → collector-D4POJ53X.d.ts} +23 -4
- package/dist/{config-DH7I0Ggx.d.ts → config-DvPUj4cw.d.ts} +198 -77
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.js +9 -6
- package/dist/hydrate-CRyjjAyl.d.ts +22 -0
- package/dist/{index-DljBkZhV.d.ts → index-DC4q-xDq.d.ts} +294 -254
- package/dist/index.d.ts +5 -5
- package/dist/index.js +11 -921
- package/dist/{merge-styles-Cx_6ySBv.d.ts → merge-styles-Jb5iZ-Jf.d.ts} +2 -3
- package/dist/ssr/astro-client.d.ts +1 -1
- package/dist/ssr/astro-client.js +1 -14
- package/dist/ssr/astro-client.js.map +1 -1
- package/dist/ssr/astro-middleware-extract-static.d.ts +10 -0
- package/dist/ssr/astro-middleware-extract-static.js +9 -0
- package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
- package/dist/ssr/astro-middleware-extract.d.ts +10 -0
- package/dist/ssr/astro-middleware-extract.js +9 -0
- package/dist/ssr/astro-middleware-extract.js.map +1 -0
- package/dist/ssr/astro-middleware-static.d.ts +3 -2
- package/dist/ssr/astro-middleware-static.js +0 -11
- package/dist/ssr/astro-middleware-static.js.map +1 -1
- package/dist/ssr/astro-middleware.d.ts +3 -2
- package/dist/ssr/astro-middleware.js +0 -12
- package/dist/ssr/astro-middleware.js.map +1 -1
- package/dist/ssr/astro.d.ts +40 -6
- package/dist/ssr/astro.js +157 -93
- package/dist/ssr/astro.js.map +1 -1
- package/dist/ssr/client.d.ts +2 -0
- package/dist/ssr/client.js +2 -0
- package/dist/ssr/index.d.ts +5 -25
- package/dist/ssr/index.js +5 -5
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/next-config.d.ts +64 -0
- package/dist/ssr/next-config.js +123 -0
- package/dist/ssr/next-config.js.map +1 -0
- package/dist/ssr/next.d.ts +9 -8
- package/dist/ssr/next.js +29 -43
- package/dist/ssr/next.js.map +1 -1
- package/dist/static/index.d.ts +8 -9
- package/dist/static/index.js +4 -22
- package/dist/static/index.js.map +1 -1
- package/dist/static/inject.d.ts +1 -2
- package/dist/{index-LC3O3Jj4.d.ts → types-ZbF2_6LV.d.ts} +863 -812
- package/dist/zero/babel.d.ts +67 -2
- package/dist/zero/babel.js +77 -140
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.d.ts +44 -8
- package/dist/zero/index.js +24 -2
- package/dist/zero/index.js.map +1 -0
- package/dist/zero/next.d.ts +4 -5
- package/dist/zero/next.js +3 -38
- package/dist/zero/next.js.map +1 -1
- package/docs/README.md +16 -8
- package/docs/adoption.md +69 -36
- package/docs/ai-agents.md +115 -86
- package/docs/comparison.md +77 -47
- package/docs/configuration.md +305 -122
- package/docs/debug.md +21 -8
- package/docs/design-system.md +152 -31
- package/docs/dsl.md +356 -219
- package/docs/getting-started.md +130 -50
- package/docs/injector.md +104 -68
- package/docs/methodology.md +80 -49
- package/docs/migration-v3.md +51 -51
- package/docs/pipeline.md +53 -29
- package/docs/plugins.md +58 -74
- package/docs/react-api.md +95 -52
- package/docs/runtime-benchmarks.md +388 -0
- package/docs/ssr.md +277 -99
- package/docs/styles.md +119 -32
- package/docs/tasty-static.md +245 -135
- package/package.json +119 -34
- package/dist/async-storage-DKK-wTD4.js +0 -44
- package/dist/async-storage-DKK-wTD4.js.map +0 -1
- package/dist/babel-D8dm92E_.d.ts +0 -83
- package/dist/collector-Di3C8btw.js.map +0 -1
- package/dist/config-BrDt11hO.js +0 -12886
- package/dist/config-BrDt11hO.js.map +0 -1
- package/dist/context-CA8YKeMn.js +0 -24
- package/dist/context-CA8YKeMn.js.map +0 -1
- package/dist/core-YWn1zgh4.js +0 -1549
- package/dist/core-YWn1zgh4.js.map +0 -1
- package/dist/css-writer-CQYbT4g_.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-DdmLdntR.js +0 -145
- package/dist/format-rules-DdmLdntR.js.map +0 -1
- package/dist/hydrate-D2ivfS-B.js +0 -37
- package/dist/hydrate-D2ivfS-B.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/keyframes-CoLLjBcd.js +0 -424
- package/dist/keyframes-CoLLjBcd.js.map +0 -1
- package/dist/merge-styles-bdh7-1uh.js.map +0 -1
- package/dist/resolve-recipes-9JYSgubn.js +0 -144
- package/dist/resolve-recipes-9JYSgubn.js.map +0 -1
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,17 @@ 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
|
-
| `
|
|
128
|
-
| `
|
|
129
|
-
| `
|
|
122
|
+
| Preset | Properties | Typical use |
|
|
123
|
+
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------- |
|
|
124
|
+
| `FLOW_STYLES` | flow, gap, columnGap, rowGap, align, justify, place, 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, physical/logical margin, inset, scroll margin/padding, position | Positioned elements (`Button`, `Badge`) |
|
|
126
|
+
| `DIMENSION_STYLES` | width, height, blockSize, inlineSize, flexBasis, flexGrow, flexShrink, flex | Sized elements |
|
|
127
|
+
| `COLOR_STYLES` | color, fill, fade, image | Color-customizable elements |
|
|
128
|
+
| `BLOCK_STYLES` | padding, blockPadding, inlinePadding, overflow, scrollbar, textAlign, border, blockBorder, inlineBorder, radius, shadow, outline | Block-level containers |
|
|
129
|
+
| `TEXT_STYLES` | textTransform, fontWeight, fontStyle | Text elements |
|
|
130
|
+
| `CONTAINER_STYLES` | All of the above combined (+ BASE_STYLES) | Fully flexible containers |
|
|
131
|
+
| `OUTER_STYLES` | POSITION_STYLES + DIMENSION_STYLES + block outer (border, radius, shadow, outline) | Components whose outer shell is customizable |
|
|
132
|
+
| `INNER_STYLES` | BASE_STYLES + COLOR_STYLES + block inner (padding, overflow, scrollbar) + FLOW_STYLES | Components whose inner layout is customizable |
|
|
130
133
|
|
|
131
134
|
```tsx
|
|
132
135
|
import { tasty, FLOW_STYLES, POSITION_STYLES } from '@tenphi/tasty';
|
|
@@ -154,12 +157,15 @@ Match the preset to the component's role:
|
|
|
154
157
|
|
|
155
158
|
- **Layout containers** (`Space`, `Box`, `Grid`) — `FLOW_STYLES`, optionally with `DIMENSION_STYLES`
|
|
156
159
|
- **Positioned elements** (`Button`, `Badge`) — `POSITION_STYLES`
|
|
157
|
-
- **Text elements** —
|
|
160
|
+
- **Text elements** — `['color', ...TEXT_STYLES]`
|
|
161
|
+
|
|
162
|
+
`BASE_STYLES` (`display`, `font`, `preset`, `hide`, `whiteSpace`, `opacity`, `transition`) are accepted as props on every component without being listed; extend that set app-wide with [`configure({ baseStyleProps })`](configuration.md#base-style-props).
|
|
163
|
+
|
|
158
164
|
- **Compound components** — typically none; styling happens via sub-elements and extension
|
|
159
165
|
|
|
160
166
|
### The governance trade-off
|
|
161
167
|
|
|
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
|
|
168
|
+
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
169
|
|
|
164
170
|
---
|
|
165
171
|
|
|
@@ -180,17 +186,19 @@ const Card = tasty({
|
|
|
180
186
|
});
|
|
181
187
|
|
|
182
188
|
// Clean prop API — no mods object needed
|
|
183
|
-
<Card isLoading isSelected>
|
|
189
|
+
<Card isLoading isSelected>
|
|
190
|
+
Content
|
|
191
|
+
</Card>;
|
|
184
192
|
```
|
|
185
193
|
|
|
186
194
|
### When to use which
|
|
187
195
|
|
|
188
|
-
| Pattern
|
|
189
|
-
|
|
190
|
-
| `modProps`
|
|
191
|
-
| `mods` prop
|
|
192
|
-
| Both
|
|
193
|
-
| `styleProps` | Exposing CSS properties (layout, sizing) for customization — different from modifiers.
|
|
196
|
+
| Pattern | Use when |
|
|
197
|
+
| ------------ | --------------------------------------------------------------------------------------------------------------------------------------- |
|
|
198
|
+
| `modProps` | The component has a fixed set of known boolean/string states that drive styles. Provides TypeScript autocomplete and a cleaner JSX API. |
|
|
199
|
+
| `mods` prop | The component needs arbitrary or dynamic modifiers that aren't known at definition time. |
|
|
200
|
+
| Both | Combine `modProps` for the known states and `mods` for ad-hoc overrides. Mod props take precedence. |
|
|
201
|
+
| `styleProps` | Exposing CSS properties (layout, sizing) for customization — different from modifiers. |
|
|
194
202
|
|
|
195
203
|
### Typed modProps vs array form
|
|
196
204
|
|
|
@@ -216,6 +224,26 @@ modProps: ['isLoading', 'isSelected'] as const,
|
|
|
216
224
|
|
|
217
225
|
For the full API reference, see [React API — Mod Props](react-api.md#mod-props).
|
|
218
226
|
|
|
227
|
+
### variants vs modProps
|
|
228
|
+
|
|
229
|
+
Use `variants` for looks that replace each other (primary, danger, ghost) and `modProps` for states that combine (`isLoading`, `size`):
|
|
230
|
+
|
|
231
|
+
```tsx
|
|
232
|
+
const Button = tasty({
|
|
233
|
+
as: 'button',
|
|
234
|
+
modProps: { isLoading: Boolean, size: ['sm', 'md', 'lg'] as const },
|
|
235
|
+
styles: { padding: { '': '1.5x 3x', 'size=sm': '1x 2x' }, radius: '1r' },
|
|
236
|
+
variants: {
|
|
237
|
+
default: { fill: '#primary', color: '#on-primary' },
|
|
238
|
+
danger: { fill: '#danger', color: '#on-danger' },
|
|
239
|
+
},
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
<Button variant="danger" size="sm" isLoading />;
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
`variant` is typed from the variant keys, the `default` variant applies when no `variant` prop is passed, and only variants that render emit CSS. See [React API — Variants](react-api.md#variants).
|
|
246
|
+
|
|
219
247
|
---
|
|
220
248
|
|
|
221
249
|
## tokens prop for dynamic values
|
|
@@ -232,27 +260,27 @@ const ProgressBar = tasty({
|
|
|
232
260
|
width: '$progress',
|
|
233
261
|
height: '100%',
|
|
234
262
|
fill: '#primary',
|
|
235
|
-
transition: 'width
|
|
263
|
+
transition: 'width',
|
|
236
264
|
},
|
|
237
265
|
},
|
|
238
266
|
elements: { Bar: 'div' },
|
|
239
267
|
});
|
|
240
268
|
|
|
241
269
|
// Usage: the progress value comes from a prop, not from styles
|
|
242
|
-
<ProgressBar tokens={{
|
|
270
|
+
<ProgressBar tokens={{ $progress: `${percent}%` }} />;
|
|
243
271
|
```
|
|
244
272
|
|
|
245
273
|
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
274
|
|
|
247
275
|
### When to use tokens vs other mechanisms
|
|
248
276
|
|
|
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)
|
|
277
|
+
| Need | Use |
|
|
278
|
+
| ----------------------------------------------------------------------------- | --------------------------------------------------------- |
|
|
279
|
+
| Value changes per instance at render time (progress, user color, avatar size) | `tokens` prop (on component) |
|
|
280
|
+
| Value is constant across all instances (card padding, border radius) | `configure({ tokens })` for `:root` CSS custom properties |
|
|
281
|
+
| Value should be inlined at parse time (alias for another token) | `configure({ replaceTokens })` |
|
|
282
|
+
| Value changes based on component state (hover, disabled, breakpoint) | State map in `styles` |
|
|
283
|
+
| Value changes based on a variant (primary, danger, outline) | `variants` option |
|
|
256
284
|
|
|
257
285
|
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
286
|
|
|
@@ -271,11 +299,11 @@ const ProgressBar = tasty({
|
|
|
271
299
|
});
|
|
272
300
|
|
|
273
301
|
// Clean prop API — no tokens object needed
|
|
274
|
-
<ProgressBar progress="75%" accentColor="#purple"
|
|
302
|
+
<ProgressBar progress="75%" accentColor="#purple" />;
|
|
275
303
|
|
|
276
304
|
// Conversion:
|
|
277
305
|
// 'progress' → $progress → --progress
|
|
278
|
-
// 'accentColor' → #accent → --accent-color
|
|
306
|
+
// 'accentColor' → #accent → --accent-color
|
|
279
307
|
```
|
|
280
308
|
|
|
281
309
|
#### Object form
|
|
@@ -291,7 +319,7 @@ const Card = tasty({
|
|
|
291
319
|
styles: { padding: '$card-size', fill: '#card-accent' },
|
|
292
320
|
});
|
|
293
321
|
|
|
294
|
-
<Card size="4x" color="#purple"
|
|
322
|
+
<Card size="4x" color="#purple" />;
|
|
295
323
|
```
|
|
296
324
|
|
|
297
325
|
#### Merge order
|
|
@@ -326,15 +354,14 @@ const LargeCard = tasty(Card, {
|
|
|
326
354
|
styles: { padding: '6x', Title: { color: '#danger' } },
|
|
327
355
|
});
|
|
328
356
|
|
|
329
|
-
<LargeCard
|
|
357
|
+
<LargeCard />;
|
|
330
358
|
```
|
|
331
359
|
|
|
332
360
|
Why? Styled wrappers are:
|
|
333
361
|
|
|
334
|
-
- **
|
|
335
|
-
- **Stable** — the style object is defined once, not recreated on every render
|
|
362
|
+
- **Stable** — the style object is defined once at module level, not recreated on every render
|
|
336
363
|
- **Composable** — another engineer can extend `LargeCard` further
|
|
337
|
-
- **Inspectable** —
|
|
364
|
+
- **Inspectable** — give it a `qa` (`tasty(Card, { qa: 'LargeCard', styles })`) and it appears as `TastyWrappedComponent(LargeCard)` in React DevTools and as `data-qa="LargeCard"` in the DOM
|
|
338
365
|
- **Lint-friendly** — the ESLint plugin's `no-styles-prop` rule flags direct usage
|
|
339
366
|
|
|
340
367
|
The `styles` prop exists as an escape hatch — for prototyping, one-off overrides during development, or cases where wrapping is impractical. It should not be the default way product engineers customize components.
|
|
@@ -417,10 +444,12 @@ const Link = tasty({
|
|
|
417
444
|
|
|
418
445
|
const Span = tasty({
|
|
419
446
|
as: 'span',
|
|
420
|
-
styles: {
|
|
447
|
+
styles: { preset: 'strong' },
|
|
421
448
|
});
|
|
422
449
|
|
|
423
|
-
<Link href="/blog" padding="1x">
|
|
450
|
+
<Link href="/blog" padding="1x">
|
|
451
|
+
Blog
|
|
452
|
+
</Link>;
|
|
424
453
|
```
|
|
425
454
|
|
|
426
455
|
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.
|
|
@@ -447,11 +476,13 @@ const DangerCard = tasty(Card, {
|
|
|
447
476
|
|
|
448
477
|
This is preferred over `<Card styles={{ border: '1bw solid #danger' }}>` because:
|
|
449
478
|
|
|
450
|
-
1.
|
|
479
|
+
1. The styles live in one module-level definition instead of being rebuilt inside render
|
|
451
480
|
2. `DangerCard` can be extended further by others
|
|
452
|
-
3. It
|
|
481
|
+
3. It is searchable in code, and named in DevTools once you give it a `qa`
|
|
453
482
|
4. The ESLint `no-styles-prop` rule encourages this pattern
|
|
454
483
|
|
|
484
|
+
A wrapper does not re-expose the base's sub-element components: `DangerCard.Title` is `undefined` and not part of its type. Keep using the base's parts inside it — `<DangerCard><Card.Title>…</Card.Title></DangerCard>`. The wrapper's `Title` styles still apply, because they target `[data-element="Title"]`.
|
|
485
|
+
|
|
455
486
|
---
|
|
456
487
|
|
|
457
488
|
## How configuration simplifies components
|
|
@@ -528,7 +559,7 @@ See [Configuration](configuration.md) for the full `configure()` API.
|
|
|
528
559
|
|
|
529
560
|
- **Create styled wrappers** instead of passing `styles` directly — faster, composable, inspectable
|
|
530
561
|
- **Use design tokens and custom units** (`#text`, `2x`, `1r`) instead of raw CSS values
|
|
531
|
-
- **Use semantic transition names** (`transition: 'theme
|
|
562
|
+
- **Use semantic transition names** (`transition: 'theme'`) instead of listing CSS properties; omit the duration to use the motion tokens
|
|
532
563
|
- **Use `elements` prop** to declare typed sub-components for compound components
|
|
533
564
|
- **Use `styleProps`** to define what product engineers can customize
|
|
534
565
|
- **Use `modProps`** to expose known modifier states as clean component props
|
|
@@ -548,7 +579,7 @@ fill: 'oklch(55% 0.25 265)',
|
|
|
548
579
|
fill: '#primary',
|
|
549
580
|
```
|
|
550
581
|
|
|
551
|
-
Tokens ensure consistency across components and make theme changes a one-line update.
|
|
582
|
+
Tokens ensure consistency across components and make theme changes a one-line update. The recommended lint config flags this with `tasty/no-raw-color-values` and `tasty/consistent-token-usage`.
|
|
552
583
|
|
|
553
584
|
### Using CSS property names when Tasty alternatives exist
|
|
554
585
|
|
|
@@ -564,7 +595,7 @@ radius: '1r',
|
|
|
564
595
|
flow: 'column',
|
|
565
596
|
```
|
|
566
597
|
|
|
567
|
-
Tasty's enhanced properties provide concise syntax, better composability, and simpler overrides. See [recommended props](styles.md#recommended-props) for the full mapping.
|
|
598
|
+
Tasty's enhanced properties provide concise syntax, better composability, and simpler overrides. See [recommended props](styles.md#recommended-props) for the full mapping. `tasty/prefer-shorthand-property` flags the native spellings.
|
|
568
599
|
|
|
569
600
|
### Changing styles prop at runtime
|
|
570
601
|
|
|
@@ -587,13 +618,13 @@ const Card = tasty({
|
|
|
587
618
|
});
|
|
588
619
|
```
|
|
589
620
|
|
|
590
|
-
Modifiers are compiled into exclusive selectors once. Changing `styles` at runtime forces Tasty to regenerate and re-inject CSS.
|
|
621
|
+
Modifiers are compiled into exclusive selectors once. Changing `styles` at runtime forces Tasty to regenerate and re-inject CSS. `tasty/no-styles-prop` and `tasty/no-runtime-styles-mutation` flag these patterns.
|
|
591
622
|
|
|
592
623
|
### Overusing style prop
|
|
593
624
|
|
|
594
625
|
```tsx
|
|
595
626
|
// Bad: bypassing Tasty for custom styling
|
|
596
|
-
<Button style={{ backgroundColor: 'red', padding: '12px 24px' }}
|
|
627
|
+
<Button style={{ backgroundColor: 'red', padding: '12px 24px' }} />;
|
|
597
628
|
|
|
598
629
|
// Good: create a styled wrapper
|
|
599
630
|
const DangerButton = tasty(Button, {
|
|
@@ -601,7 +632,7 @@ const DangerButton = tasty(Button, {
|
|
|
601
632
|
});
|
|
602
633
|
```
|
|
603
634
|
|
|
604
|
-
The `style` prop bypasses tokens, units, and state maps. It should only be used for third-party library integration.
|
|
635
|
+
The `style` prop bypasses tokens, units, and state maps. It should only be used for third-party library integration. `tasty/no-style-prop` flags it on Tasty components.
|
|
605
636
|
|
|
606
637
|
### Skipping elements for compound components
|
|
607
638
|
|
|
@@ -610,7 +641,7 @@ The `style` prop bypasses tokens, units, and state maps. It should only be used
|
|
|
610
641
|
<Card>
|
|
611
642
|
<div data-element="Title">Card Title</div>
|
|
612
643
|
<div data-element="Content">Card content</div>
|
|
613
|
-
</Card
|
|
644
|
+
</Card>;
|
|
614
645
|
|
|
615
646
|
// Better: declare elements for typed sub-components
|
|
616
647
|
const Card = tasty({
|
|
@@ -624,7 +655,7 @@ const Card = tasty({
|
|
|
624
655
|
<Card>
|
|
625
656
|
<Card.Title>Card Title</Card.Title>
|
|
626
657
|
<Card.Content>Card content</Card.Content>
|
|
627
|
-
</Card
|
|
658
|
+
</Card>;
|
|
628
659
|
```
|
|
629
660
|
|
|
630
661
|
The `elements` prop gives you typed sub-components with automatic `data-element` attributes, `mods` support, and better discoverability.
|
package/docs/migration-v3.md
CHANGED
|
@@ -21,30 +21,30 @@ Most of the work is mechanical renames — see the [search-and-replace cheat she
|
|
|
21
21
|
|
|
22
22
|
## At a glance
|
|
23
23
|
|
|
24
|
-
| v2.11
|
|
25
|
-
|
|
26
|
-
| `'@properties': { … }`
|
|
27
|
-
| `'@fontFace': { … }`
|
|
28
|
-
| `'@counterStyle': { … }`
|
|
29
|
-
| `padding: '2x 4x top right'`
|
|
30
|
-
| `fade: '3x 1x top bottom'`
|
|
31
|
-
| `configure({ funcs })`
|
|
32
|
-
| `configure({ fontFace })`
|
|
33
|
-
| `configure({ counterStyle })`
|
|
34
|
-
| `getCssText()`
|
|
35
|
-
| `getCssTextForNode()`
|
|
36
|
-
| `getCssTextForClasses()`
|
|
37
|
-
| `getGlobalFontFace()`
|
|
38
|
-
| `getGlobalCounterStyle()`
|
|
39
|
-
| `getGlobalFunction()`
|
|
40
|
-
| `okhslFunc` / `okhstFunc`
|
|
41
|
-
| `CssOptions`
|
|
42
|
-
| `ParserOptions.funcs`
|
|
43
|
-
| `StyleParser#setFuncs()`
|
|
44
|
-
| `ChunkInfo` (from `tastyDebug`) | `DebugChunkInfo`
|
|
45
|
-
| `@tenphi/tasty/next`
|
|
46
|
-
| `getIsTestEnvironment()`
|
|
47
|
-
| `hydrateTastyCache()`
|
|
24
|
+
| v2.11 | v3.0 | Find it with |
|
|
25
|
+
| ------------------------------- | --------------------------------- | ------------------------------ |
|
|
26
|
+
| `'@properties': { … }` | `'@property': { … }` | `rg "'@properties'"` |
|
|
27
|
+
| `'@fontFace': { … }` | `'@font-face': { … }` | `rg "'@fontFace'"` |
|
|
28
|
+
| `'@counterStyle': { … }` | `'@counter-style': { … }` | `rg "'@counterStyle'"` |
|
|
29
|
+
| `padding: '2x 4x top right'` | `padding: '2x top, 4x right'` | dev-mode console warning |
|
|
30
|
+
| `fade: '3x 1x top bottom'` | `fade: '3x top, 1x bottom'` | dev-mode console warning |
|
|
31
|
+
| `configure({ funcs })` | `configure({ functions })` | `rg "funcs"` |
|
|
32
|
+
| `configure({ fontFace })` | `configure({ fontFaces })` | `rg "fontFace:"` |
|
|
33
|
+
| `configure({ counterStyle })` | `configure({ counterStyles })` | `rg "counterStyle:"` |
|
|
34
|
+
| `getCssText()` | `getCSSText()` | `rg "getCssText"` |
|
|
35
|
+
| `getCssTextForNode()` | `getCSSTextForNode()` | `rg "getCssTextForNode"` |
|
|
36
|
+
| `getCssTextForClasses()` | `getCSSTextForClasses()` | `rg "getCssTextForClasses"` |
|
|
37
|
+
| `getGlobalFontFace()` | `getGlobalFontFaces()` | `rg "getGlobalFontFace\b"` |
|
|
38
|
+
| `getGlobalCounterStyle()` | `getGlobalCounterStyles()` | `rg "getGlobalCounterStyle\b"` |
|
|
39
|
+
| `getGlobalFunction()` | `getGlobalFunctions()` | `rg "getGlobalFunction\b"` |
|
|
40
|
+
| `okhslFunc` / `okhstFunc` | `okhslFunction` / `okhstFunction` | `rg "okhs[lt]Func\b"` |
|
|
41
|
+
| `CssOptions` | `CSSOptions` | `rg "CssOptions"` |
|
|
42
|
+
| `ParserOptions.funcs` | `ParserOptions.functions` | `rg "funcs:"` |
|
|
43
|
+
| `StyleParser#setFuncs()` | `StyleParser#setFunctions()` | `rg "setFuncs"` |
|
|
44
|
+
| `ChunkInfo` (from `tastyDebug`) | `DebugChunkInfo` | `rg "ChunkInfo"` |
|
|
45
|
+
| `@tenphi/tasty/next` | `@tenphi/tasty/zero/next` | `rg "tasty/next"` |
|
|
46
|
+
| `getIsTestEnvironment()` | `isTestEnvironment()` | `rg "getIsTestEnvironment"` |
|
|
47
|
+
| `hydrateTastyCache()` | `hydrateTastyClasses()` | `rg "hydrateTastyCache"` |
|
|
48
48
|
|
|
49
49
|
---
|
|
50
50
|
|
|
@@ -73,7 +73,7 @@ At-rule keys now match the real CSS at-rule names Tasty already emits, so they a
|
|
|
73
73
|
|
|
74
74
|
**This is the one change that can alter rendered CSS without a rename.** A style group that names direction modifiers now takes a **single** value, applied to every direction it names.
|
|
75
75
|
|
|
76
|
-
The old form looked positional but never was: the parser buckets values and modifiers into separate arrays per comma group, so `'2x 4x top right'`, `'2x top 4x right'`, and `'top 2x right 4x'` were all the same input, and the pairing was decided by the order the
|
|
76
|
+
The old form looked positional but never was: the parser buckets values and modifiers into separate arrays per comma group, so `'2x 4x top right'`, `'2x top 4x right'`, and `'top 2x right 4x'` were all the same input, and the pairing was decided by the order the _modifiers_ happened to appear in. `'1x 2x right top'` and `'1x 2x top right'` produced different CSS, and `'1x 2x top top'` silently assigned `top` twice.
|
|
77
77
|
|
|
78
78
|
Per-side values now come from comma-separated groups:
|
|
79
79
|
|
|
@@ -155,25 +155,25 @@ A key whose prefix doesn't match its value type is ignored with a development wa
|
|
|
155
155
|
|
|
156
156
|
## 5. Removed exports
|
|
157
157
|
|
|
158
|
-
| Removed
|
|
159
|
-
|
|
160
|
-
| `getIsTestEnvironment()`
|
|
161
|
-
| `hydrateTastyCache()`
|
|
162
|
-
| `customFunc()`
|
|
163
|
-
| `getGlobalFuncs()`
|
|
164
|
-
| `resetGlobalFuncs()`
|
|
165
|
-
| `setGlobalPredefinedTokens()`
|
|
166
|
-
| `resetGlobalPredefinedTokens()`
|
|
167
|
-
| `setMiddlewareTransferCache()` / `getMiddlewareTransferCache()` | internal; no replacement needed
|
|
168
|
-
| `clearWriterCache()`
|
|
169
|
-
| `DEFAULT_PLUGINS`
|
|
170
|
-
| `registerDefaultFunctions()`
|
|
171
|
-
| `warn()` / `deprecationWarning()`
|
|
172
|
-
| `Bucket` enum
|
|
173
|
-
| `Props` type
|
|
174
|
-
| `UseStylesOptions`
|
|
175
|
-
| `GlobalStyledProps`
|
|
176
|
-
| duplicate `PropertyOptions`
|
|
158
|
+
| Removed | Use instead |
|
|
159
|
+
| --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
160
|
+
| `getIsTestEnvironment()` | `isTestEnvironment()` |
|
|
161
|
+
| `hydrateTastyCache()` | `hydrateTastyClasses()` |
|
|
162
|
+
| `customFunc()` | `configure({ functions })` |
|
|
163
|
+
| `getGlobalFuncs()` | `getGlobalFunctions()` for `@function` definitions; the parse-function registry is internal |
|
|
164
|
+
| `resetGlobalFuncs()` | `resetConfig()` |
|
|
165
|
+
| `setGlobalPredefinedTokens()` | `configure({ replaceTokens })` |
|
|
166
|
+
| `resetGlobalPredefinedTokens()` | `resetConfig()` |
|
|
167
|
+
| `setMiddlewareTransferCache()` / `getMiddlewareTransferCache()` | internal; no replacement needed |
|
|
168
|
+
| `clearWriterCache()` | internal test utility |
|
|
169
|
+
| `DEFAULT_PLUGINS` | nothing — it was never consumed, and passing it to `configure({ plugins })` was a no-op. The default `okhsl`/`okhst` functions are registered automatically. |
|
|
170
|
+
| `registerDefaultFunctions()` | internal bootstrap helper |
|
|
171
|
+
| `warn()` / `deprecationWarning()` | internal helpers with no callers |
|
|
172
|
+
| `Bucket` enum | parser-internal |
|
|
173
|
+
| `Props` type | inline `Record<string, any>` |
|
|
174
|
+
| `UseStylesOptions` | `useStyles()` takes `Styles \| undefined` directly |
|
|
175
|
+
| `GlobalStyledProps` | its only member was the already-dead `breakpoints` prop |
|
|
176
|
+
| duplicate `PropertyOptions` | the single `PropertyOptions` from `injector/types` |
|
|
177
177
|
|
|
178
178
|
`getGlobalFuncs()` deserves a note: it returned the **live mutable internal registry**, and writing to it bypassed the parser's cache invalidation, so the write silently never took effect. If you were mutating it, move to `configure({ functions })`.
|
|
179
179
|
|
|
@@ -188,17 +188,17 @@ A key whose prefix doesn't match its value type is ignored with a development wa
|
|
|
188
188
|
## 7. Moved subpath
|
|
189
189
|
|
|
190
190
|
```diff
|
|
191
|
-
- import {
|
|
192
|
-
+ import {
|
|
191
|
+
- import { withTastyZero } from '@tenphi/tasty/next';
|
|
192
|
+
+ import { withTastyZero } from '@tenphi/tasty/zero/next';
|
|
193
193
|
```
|
|
194
194
|
|
|
195
|
-
The
|
|
195
|
+
The build-time extraction Next.js wrapper already lived under the `zero` namespace internally; the top-level `/next` path collided confusingly with `@tenphi/tasty/ssr/next`, which is a different integration.
|
|
196
196
|
|
|
197
197
|
---
|
|
198
198
|
|
|
199
199
|
## 8. Behavior changes that are not renames
|
|
200
200
|
|
|
201
|
-
**Repeated `configure()` calls now merge.** `recipes`, `keyframes`, `properties`, `fontFaces`, `counterStyles`, and CSS `@function` definitions used to replace wholesale, so a design-system `configure()` followed by an application `configure()` silently dropped the design system's values. All of them now merge, with the later call winning on a key conflict — matching `tokens` and `globalStyles`, which already merged. If you were relying on a second call to
|
|
201
|
+
**Repeated `configure()` calls now merge.** `recipes`, `keyframes`, `properties`, `fontFaces`, `counterStyles`, and CSS `@function` definitions used to replace wholesale, so a design-system `configure()` followed by an application `configure()` silently dropped the design system's values. All of them now merge, with the later call winning on a key conflict — matching `tokens` and `globalStyles`, which already merged. If you were relying on a second call to _clear_ a collection, use `resetConfig()`.
|
|
202
202
|
|
|
203
203
|
`configure({ polyfills })` is now correctly rejected after the first render, like every sibling option, and shallow-merges so an unrelated later call cannot switch a polyfill off.
|
|
204
204
|
|
|
@@ -208,7 +208,7 @@ The zero-runtime Next.js wrapper already lived under the `zero` namespace intern
|
|
|
208
208
|
|
|
209
209
|
**Replacing a built-in style handler now warns.** Built-in handlers are shared across style names, so `configure({ handlers: { fill } })` also takes over `image` and the whole `background-*` family, and `configure({ handlers: { display } })` takes down `flow`, `gap`, `hide`, `overflow`, `whiteSpace`, and `textOverflow`. This was always true; what's new is that a development-mode warning now names exactly what was displaced. If you see it, either declare the whole group and delegate the rest to `styleHandlers.*`, or pick a narrower name. See [Plugins](plugins.md#custom-style-handlers).
|
|
210
210
|
|
|
211
|
-
**Multi-dependency custom handlers are fixed.** A handler whose dependencies mixed known and unknown style names was invoked once per chunk with only
|
|
211
|
+
**Multi-dependency custom handlers are fixed.** A handler whose dependencies mixed known and unknown style names was invoked once per chunk with only _part_ of its dependencies, and could emit stale CSS. Unknown names now join their handler's chunk, so it is invoked once with all of them. No built-in style moved, so no existing class name changes.
|
|
212
212
|
|
|
213
213
|
**`isChecked` added to the root prop types.** It already worked at runtime; it was just missing from `BaseProps` / `AllBaseProps`.
|
|
214
214
|
|
|
@@ -220,7 +220,7 @@ The zero-runtime Next.js wrapper already lived under the `zero` namespace intern
|
|
|
220
220
|
|
|
221
221
|
Nothing here is required to upgrade.
|
|
222
222
|
|
|
223
|
-
- **CSS `@function` support** — reusable, parameterized functions via the `'@function'` styles key, the `useFunction` style function, or `configure({ functions })`. Works across client, SSR/RSC, and
|
|
223
|
+
- **CSS `@function` support** — reusable, parameterized functions via the `'@function'` styles key, the `useFunction` style function, or `configure({ functions })`. Works across client rendering, SSR/RSC, and build-time extraction. `configure({ polyfills: { functions: true } })` inlines every call into plain CSS for browsers that don't ship the at-rule yet. See [Style DSL](dsl.md#functions-function).
|
|
224
224
|
- **Custom color plugins with no core special-casing** — `okhsl`/`okhst` are now ordinary one-line plugins, and a third-party color space can achieve identical integration. New `createColorFunc` and `resolveFunctionColor` helpers.
|
|
225
225
|
- **`configure({ propHandlers })`** — props middleware for every component: props in, props out. The extension point for props that aren't style values.
|
|
226
226
|
- **`configure({ baseStyleProps })`** — expose style properties as props on every component without listing them in each `styleProps`.
|
|
@@ -279,7 +279,7 @@ Worth stating explicitly, because it's easy to assume otherwise:
|
|
|
279
279
|
|
|
280
280
|
- **At-rule styles-object keys are CSS-spec-faithful, not JS-conventional.** `@keyframes`, `@property`, `@font-face`, `@counter-style`, `@function`, `@starting` — kebab-case, matching what Tasty emits.
|
|
281
281
|
- **The `func()` injector method stays abbreviated.** `function` is a reserved word.
|
|
282
|
-
- `injector.fontFace()` and `injector.counterStyle()` keep their singular names — only the
|
|
282
|
+
- `injector.fontFace()` and `injector.counterStyle()` keep their singular names — only the _config keys_ and _getters_ were pluralized.
|
|
283
283
|
- `useFontFace` and `useCounterStyle` are unchanged.
|
|
284
284
|
- `configure({ properties })` and `autoPropertyTypes` are unchanged; only the styles-object `@property` key was renamed.
|
|
285
285
|
- **The deprecated style aliases are retained deliberately.** `backgroundColor`, `background`, `backgroundImage`, `flex`, `grid`, and `flexDirection` still carry `@deprecated` tags and still work. They are the guardrail that discourages their use in projects that have not enabled `@tenphi/eslint-plugin-tasty` yet — read the tags as guidance, not as a removal notice.
|