@tenphi/tasty 0.0.0-snapshot.b6cc3cd → 0.0.0-snapshot.b7bfdb1
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 +147 -129
- package/dist/{babel-D8dm92E_.d.ts → babel-Brsw7Ax_.d.ts} +2 -2
- package/dist/{collector-BFuqdF2F.d.ts → collector-0YO-P1vW.d.ts} +2 -2
- package/dist/{collector-Di3C8btw.js → collector-DJqx7XO0.js} +3 -3
- package/dist/{collector-Di3C8btw.js.map → collector-DJqx7XO0.js.map} +1 -1
- package/dist/{config-DH7I0Ggx.d.ts → config-CscQCTAM.d.ts} +133 -40
- package/dist/{config-BrDt11hO.js → config-DsqqkmUs.js} +496 -1009
- package/dist/config-DsqqkmUs.js.map +1 -0
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.js +6 -6
- package/dist/{core-YWn1zgh4.js → core-KVEKOhEi.js} +145 -105
- package/dist/core-KVEKOhEi.js.map +1 -0
- package/dist/{css-writer-CQYbT4g_.js → css-writer-Cdrh5gHj.js} +3 -3
- package/dist/{css-writer-CQYbT4g_.js.map → css-writer-Cdrh5gHj.js.map} +1 -1
- package/dist/{format-rules-DdmLdntR.js → format-rules-CHNmNGhw.js} +5 -20
- package/dist/format-rules-CHNmNGhw.js.map +1 -0
- package/dist/{hydrate-D2ivfS-B.js → hydrate-DJhwbWq4.js} +3 -3
- package/dist/{hydrate-D2ivfS-B.js.map → hydrate-DJhwbWq4.js.map} +1 -1
- package/dist/{index-DljBkZhV.d.ts → index-BR9as3qn.d.ts} +52 -22
- package/dist/{index-LC3O3Jj4.d.ts → index-BmogEzTo.d.ts} +75 -16
- package/dist/index.d.ts +5 -5
- package/dist/index.js +9 -8
- package/dist/index.js.map +1 -1
- package/dist/{keyframes-CoLLjBcd.js → keyframes-CQY-i8dO.js} +110 -21
- package/dist/keyframes-CQY-i8dO.js.map +1 -0
- package/dist/{merge-styles-Cx_6ySBv.d.ts → merge-styles-BcLl1u_d.d.ts} +2 -2
- package/dist/{merge-styles-bdh7-1uh.js → merge-styles-voA8J__3.js} +2 -2
- package/dist/{merge-styles-bdh7-1uh.js.map → merge-styles-voA8J__3.js.map} +1 -1
- package/dist/{resolve-recipes-9JYSgubn.js → resolve-recipes-BP2NqOtQ.js} +3 -3
- package/dist/{resolve-recipes-9JYSgubn.js.map → resolve-recipes-BP2NqOtQ.js.map} +1 -1
- package/dist/ssr/astro-client.js +1 -1
- package/dist/ssr/astro.js +3 -3
- package/dist/ssr/index.d.ts +1 -1
- package/dist/ssr/index.js +3 -3
- package/dist/ssr/next.d.ts +1 -1
- package/dist/ssr/next.js +4 -4
- package/dist/static/index.d.ts +2 -2
- package/dist/static/index.js +1 -1
- package/dist/zero/babel.d.ts +1 -1
- package/dist/zero/babel.js +4 -4
- package/dist/zero/index.d.ts +1 -1
- package/dist/zero/index.js +1 -1
- package/dist/zero/next.d.ts +1 -1
- package/docs/README.md +13 -8
- package/docs/adoption.md +56 -31
- package/docs/ai-agents.md +78 -77
- package/docs/comparison.md +69 -40
- package/docs/configuration.md +164 -101
- package/docs/debug.md +4 -2
- package/docs/design-system.md +41 -22
- package/docs/dsl.md +263 -198
- package/docs/getting-started.md +60 -39
- package/docs/injector.md +63 -26
- package/docs/methodology.md +43 -37
- package/docs/migration-v3.md +49 -49
- package/docs/pipeline.md +1 -4
- package/docs/plugins.md +37 -33
- package/docs/react-api.md +66 -45
- package/docs/runtime-benchmarks.md +178 -0
- package/docs/ssr.md +56 -57
- package/docs/styles.md +9 -2
- package/docs/tasty-static.md +137 -104
- package/package.json +12 -7
- package/dist/config-BrDt11hO.js.map +0 -1
- package/dist/core-YWn1zgh4.js.map +0 -1
- package/dist/format-rules-DdmLdntR.js.map +0 -1
- package/dist/keyframes-CoLLjBcd.js.map +0 -1
package/docs/dsl.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# Style DSL Reference
|
|
2
2
|
|
|
3
|
-
This is the Tasty
|
|
3
|
+
This is the language behind Tasty’s predictable state resolution. Every property can use a state map; later branches declare higher priority, and Tasty compiles them so only one generated selector can match.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The same value syntax, state maps, tokens, units, extension semantics, and special declarations apply to React `tasty()`—whether rendered on the client or server—and build-time `tastyStatic()`.
|
|
6
|
+
|
|
7
|
+
For the React API (`tasty()`, style functions, component props), see [React API](react-api.md). For all enhanced style properties, see [Style Properties](styles.md). For global configuration, see [Configuration](configuration.md).
|
|
6
8
|
|
|
7
9
|
---
|
|
8
10
|
|
|
@@ -18,17 +20,28 @@ fill: { '': '#white', hovered: '#gray.05', 'theme=danger': '#red' }
|
|
|
18
20
|
|
|
19
21
|
#### State Key Types
|
|
20
22
|
|
|
21
|
-
| Syntax
|
|
22
|
-
|
|
23
|
-
| Boolean modifier
|
|
24
|
-
| Value modifier
|
|
25
|
-
| Pseudo-class
|
|
26
|
-
| Class selector
|
|
27
|
-
| Attribute selector | `[aria-expanded="true"]` | `[aria-expanded="true"]`
|
|
28
|
-
| Combined (AND)
|
|
29
|
-
| Combined (OR)
|
|
30
|
-
| Negated (NOT)
|
|
31
|
-
| Exclusive (XOR)
|
|
23
|
+
| Syntax | Example | Generated CSS |
|
|
24
|
+
| ------------------ | ------------------------ | ------------------------------------------------------------------------ |
|
|
25
|
+
| Boolean modifier | `hovered` | `[data-hovered]` |
|
|
26
|
+
| Value modifier | `theme=danger` | `[data-theme="danger"]` |
|
|
27
|
+
| Pseudo-class | `:hover` | `:hover` |
|
|
28
|
+
| Class selector | `.active` | `.active` |
|
|
29
|
+
| Attribute selector | `[aria-expanded="true"]` | `[aria-expanded="true"]` |
|
|
30
|
+
| Combined (AND) | `hovered & .active` | `[data-hovered].active` |
|
|
31
|
+
| Combined (OR) | `hovered \| focused` | `[data-hovered], [data-focused]` |
|
|
32
|
+
| Negated (NOT) | `!disabled` | `:not([data-disabled])` |
|
|
33
|
+
| Exclusive (XOR) | `hovered ^ focused` | `[data-hovered]:not([data-focused]), :not([data-hovered])[data-focused]` |
|
|
34
|
+
|
|
35
|
+
#### Automatic Native States
|
|
36
|
+
|
|
37
|
+
`disabled` and `checked` are built-in automatic states. On a Tasty component, they track the corresponding native prop or attribute, so these pairs express the same component state:
|
|
38
|
+
|
|
39
|
+
| Concise Tasty state | Explicit attribute selector |
|
|
40
|
+
| ------------------- | --------------------------- |
|
|
41
|
+
| `disabled` | `[disabled]` |
|
|
42
|
+
| `checked` | `[checked]` |
|
|
43
|
+
|
|
44
|
+
Prefer the concise form when authoring Tasty component styles. Explicit attribute selectors remain valid and can be useful when targeting arbitrary attributes or when CSS-shaped syntax makes an introductory example easier to recognize.
|
|
32
45
|
|
|
33
46
|
Operator precedence (highest to lowest): `!` (NOT) > `^` (XOR) > `|` (OR) > `&` (AND). Use parentheses to override: `hovered & (pressed ^ focused)`.
|
|
34
47
|
|
|
@@ -53,14 +66,18 @@ color: { '': '#text', hovered: '#accent' }
|
|
|
53
66
|
color: { hovered: '#accent', '': '#text' }
|
|
54
67
|
```
|
|
55
68
|
|
|
56
|
-
The bare `''` default still **receives negation** (it is turned off when a higher-priority state matches). For a value that must always apply as a guaranteed floor — even where a query is
|
|
69
|
+
The bare `''` default still **receives negation** (it is turned off when a higher-priority state matches). For a value that must always apply as a guaranteed floor — even where a query is _unknown_ — use the [`_` fallback floor](#_--fallback-floor) instead. The two can coexist: `''` is the negated default, `_` is the always-on floor. If a map contains only `_` and `''` (no other states), the `''` default is redundant — Tasty keeps the `_` value and drops `''` with a `REDUNDANT_DEFAULT_STATE` warning.
|
|
57
70
|
|
|
58
71
|
### Sub-element
|
|
59
72
|
|
|
60
73
|
Element styled using a capitalized key. Identified by `data-element` attribute:
|
|
61
74
|
|
|
62
75
|
```jsx
|
|
63
|
-
styles: {
|
|
76
|
+
styles: {
|
|
77
|
+
Title: {
|
|
78
|
+
preset: 'h3';
|
|
79
|
+
}
|
|
80
|
+
}
|
|
64
81
|
// Targets: <div data-element="Title">
|
|
65
82
|
```
|
|
66
83
|
|
|
@@ -70,19 +87,19 @@ Control how a sub-element selector attaches to the root selector using the `$` p
|
|
|
70
87
|
|
|
71
88
|
Examples below assume the sub-element key is **Cell** (i.e. `[data-element="Cell"]` in CSS):
|
|
72
89
|
|
|
73
|
-
| Pattern
|
|
74
|
-
|
|
75
|
-
|
|
|
76
|
-
| `>`
|
|
77
|
-
| `>Body>`
|
|
78
|
-
| `> Cell`
|
|
79
|
-
| `h1`
|
|
80
|
-
| `h1 >`
|
|
81
|
-
| `h1 *`
|
|
82
|
-
| `*`
|
|
83
|
-
| `&::before` | `::before`
|
|
84
|
-
| `@::before` | `[data-element="Cell"]::before`
|
|
85
|
-
| `>@.active` | `> [data-element="Cell"].active`
|
|
90
|
+
| Pattern | Result | Description |
|
|
91
|
+
| ----------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
92
|
+
| _(none)_ | `[data-element="Cell"]` | Descendant (default) |
|
|
93
|
+
| `>` | `> [data-element="Cell"]` | Direct child |
|
|
94
|
+
| `>Body>` | `> [data-element="Body"] > [data-element="Cell"]` | Chained elements |
|
|
95
|
+
| `> Cell` | `> [data-element="Cell"]` | Self-name shorthand — when the trailing element name matches the sub-element's own key, it acts as the placeholder (same as `@`); no duplication |
|
|
96
|
+
| `h1` | `h1` | Tag selector (no key injection) |
|
|
97
|
+
| `h1 >` | `h1 > [data-element="Cell"]` | Key is direct child of tag |
|
|
98
|
+
| `h1 *` | `h1 *` | Any descendant of tag |
|
|
99
|
+
| `*` | `*` | All descendants |
|
|
100
|
+
| `&::before` | `::before` | Root pseudo (no key); `&` is required |
|
|
101
|
+
| `@::before` | `[data-element="Cell"]::before` | Pseudo on the sub-element |
|
|
102
|
+
| `>@.active` | `> [data-element="Cell"].active` | Class on the sub-element |
|
|
86
103
|
|
|
87
104
|
Rules for key injection (`[data-element="..."]`):
|
|
88
105
|
|
|
@@ -111,7 +128,7 @@ const List = tasty({
|
|
|
111
128
|
Named color prefixed with `#` that maps to CSS custom properties. Supports opacity with `.N` suffix:
|
|
112
129
|
|
|
113
130
|
```jsx
|
|
114
|
-
fill: '#purple.5'
|
|
131
|
+
fill: '#purple.5'; // → oklch(from var(--purple-color) l c h / .5)
|
|
115
132
|
```
|
|
116
133
|
|
|
117
134
|
### Modifier
|
|
@@ -146,14 +163,14 @@ fill: '#purple.5';
|
|
|
146
163
|
```
|
|
147
164
|
|
|
148
165
|
The channels are copied over and the alpha slot is written, which asks nothing of
|
|
149
|
-
the color beyond
|
|
166
|
+
the color beyond _being_ a color. That means the suffix works on every one of
|
|
150
167
|
these:
|
|
151
168
|
|
|
152
169
|
- a token holding a `color-mix()`, a `light-dark()`, or a `color()` in a space
|
|
153
170
|
Tasty cannot convert — none of which have channels to decompose
|
|
154
|
-
- `#current`, which resolves to
|
|
171
|
+
- `#current`, which resolves to the color the element inherits
|
|
155
172
|
- a `--name-color` variable declared in your own CSS, with no Tasty token
|
|
156
|
-
definition
|
|
173
|
+
definition behind it
|
|
157
174
|
|
|
158
175
|
Two properties follow from writing the alpha slot rather than compositing:
|
|
159
176
|
|
|
@@ -163,9 +180,44 @@ Two properties follow from writing the alpha slot rather than compositing:
|
|
|
163
180
|
`/ var(--fade)` unchanged, so it works whether `$fade` holds `.5` or `50%` —
|
|
164
181
|
which is what `--*-opacity` properties are registered to accept.
|
|
165
182
|
|
|
183
|
+
### `#current` is the keyword
|
|
184
|
+
|
|
185
|
+
`#current` emits the `currentcolor` keyword, so it resolves against the element
|
|
186
|
+
that reads it. That is what lets it follow a color an ancestor faded — a ramp
|
|
187
|
+
that expresses its disabled state once, in `color`, fades everything painted from
|
|
188
|
+
`#current` below it with no further declarations.
|
|
189
|
+
|
|
190
|
+
The `color` style also publishes `--current-color` beside every color it sets,
|
|
191
|
+
for anything that needs the inherited color _as a color_ rather than as the
|
|
192
|
+
keyword — hand-authored CSS, or a place the keyword will not do. Read it as
|
|
193
|
+
`$current-color`. It is registered with `initial-value: currentcolor`, so where
|
|
194
|
+
nothing published it, it still resolves against each element's own color:
|
|
195
|
+
|
|
196
|
+
```jsx
|
|
197
|
+
fill: '$current-color'; // → var(--current-color)
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
A color that already reads the color it inherits — `#current`, a `#current` fade
|
|
201
|
+
— is not published into it: resolving such a value a second time at a descendant
|
|
202
|
+
would fade it twice.
|
|
203
|
+
|
|
204
|
+
One case needs the wider floor to be considered. A token _defined_ as `#current`
|
|
205
|
+
and then faded gives relative color syntax a `currentcolor` origin, which Safari
|
|
206
|
+
supports only from 18:
|
|
207
|
+
|
|
208
|
+
```jsx
|
|
209
|
+
{ '#ink': '#current', fill: '#ink.5' }
|
|
210
|
+
// --ink-color: currentcolor
|
|
211
|
+
// fill: oklch(from currentcolor l c h / .5) → Chrome, Firefox, Safari 18+
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Put the fade in the token instead — `{ '#ink': '#current.5' }` — and it goes
|
|
215
|
+
through `color-mix()`, which works from Safari 16.2 and composes like every other
|
|
216
|
+
`#current` fade.
|
|
217
|
+
|
|
166
218
|
### `#current` composes instead
|
|
167
219
|
|
|
168
|
-
`#current` is the one exception, and the difference is deliberate. A token
|
|
220
|
+
`#current` is the one exception, and the difference is deliberate. A token _names_
|
|
169
221
|
a color, so fading it sets its alpha. `currentcolor` is the color an element
|
|
170
222
|
**inherits**, which an ancestor may already have faded — `#current.4` means "40%
|
|
171
223
|
of what reaches me":
|
|
@@ -182,9 +234,9 @@ step. Because a `color-mix()` percentage cannot be a `<number>`, an opacity
|
|
|
182
234
|
custom property used as `#current.$fade` must hold a unitless number; a token
|
|
183
235
|
accepts either form.
|
|
184
236
|
|
|
185
|
-
The space is always `oklch
|
|
186
|
-
|
|
187
|
-
|
|
237
|
+
The space is always `oklch`: it is unbounded, so a wide-gamut color survives a
|
|
238
|
+
round trip that a gamut-limited space would clamp. Nothing configures this —
|
|
239
|
+
see [Color space](configuration.md#color-space).
|
|
188
240
|
|
|
189
241
|
---
|
|
190
242
|
|
|
@@ -231,22 +283,22 @@ configure({
|
|
|
231
283
|
},
|
|
232
284
|
});
|
|
233
285
|
|
|
234
|
-
fill: '#solid.5';
|
|
235
|
-
fill: '#adaptive.5';
|
|
286
|
+
fill: '#solid.5'; // → hsl(220 90% 50% / .5)
|
|
287
|
+
fill: '#adaptive.5'; // → oklch(from light-dark(…) l c h / .5)
|
|
236
288
|
```
|
|
237
289
|
|
|
238
290
|
---
|
|
239
291
|
|
|
240
292
|
## Built-in Units
|
|
241
293
|
|
|
242
|
-
| Unit | Description
|
|
243
|
-
|
|
244
|
-
| `x`
|
|
245
|
-
| `r`
|
|
246
|
-
| `cr` | Card border radius | `1cr`
|
|
247
|
-
| `bw` | Border width
|
|
248
|
-
| `ow` | Outline width
|
|
249
|
-
| `sf` | Stable fraction
|
|
294
|
+
| Unit | Description | Example | CSS Output |
|
|
295
|
+
| ---- | ------------------ | ------- | ------------------------------- |
|
|
296
|
+
| `x` | Gap multiplier | `2x` | `calc(var(--gap) * 2)` |
|
|
297
|
+
| `r` | Border radius | `1r` | `var(--radius)` |
|
|
298
|
+
| `cr` | Card border radius | `1cr` | `var(--card-radius)` |
|
|
299
|
+
| `bw` | Border width | `2bw` | `calc(var(--border-width) * 2)` |
|
|
300
|
+
| `ow` | Outline width | `1ow` | `var(--outline-width)` |
|
|
301
|
+
| `sf` | Stable fraction | `1sf` | `minmax(0, 1fr)` |
|
|
250
302
|
|
|
251
303
|
You can register additional custom units via [`configure()`](configuration.md#options).
|
|
252
304
|
|
|
@@ -291,7 +343,7 @@ const ElevatedCard = tasty({
|
|
|
291
343
|
|
|
292
344
|
**Post-merge recipes (`/` separator):**
|
|
293
345
|
|
|
294
|
-
Recipes listed after `/` are applied
|
|
346
|
+
Recipes listed after `/` are applied _after_ component styles using `mergeStyles`:
|
|
295
347
|
|
|
296
348
|
```jsx
|
|
297
349
|
const Input = tasty({
|
|
@@ -329,8 +381,8 @@ When a style property uses a state map, the merge behavior depends on whether th
|
|
|
329
381
|
const MyButton = tasty(Button, {
|
|
330
382
|
styles: {
|
|
331
383
|
fill: {
|
|
332
|
-
|
|
333
|
-
|
|
384
|
+
loading: '#yellow', // append new state
|
|
385
|
+
disabled: '#gray.20', // override existing state in place
|
|
334
386
|
},
|
|
335
387
|
},
|
|
336
388
|
});
|
|
@@ -340,7 +392,7 @@ const MyButton = tasty(Button, {
|
|
|
340
392
|
styles: {
|
|
341
393
|
fill: {
|
|
342
394
|
'': '#red',
|
|
343
|
-
|
|
395
|
+
hovered: '#blue',
|
|
344
396
|
},
|
|
345
397
|
},
|
|
346
398
|
});
|
|
@@ -365,8 +417,12 @@ fill: {
|
|
|
365
417
|
Use `null` inside a state map to remove a state, or `false` to block it entirely (tombstone):
|
|
366
418
|
|
|
367
419
|
```jsx
|
|
368
|
-
fill: {
|
|
369
|
-
|
|
420
|
+
fill: {
|
|
421
|
+
pressed: null;
|
|
422
|
+
} // removes pressed from the result
|
|
423
|
+
fill: {
|
|
424
|
+
disabled: false;
|
|
425
|
+
} // tombstone — no CSS for disabled, blocks recipe too
|
|
370
426
|
```
|
|
371
427
|
|
|
372
428
|
### Resetting Properties with `null` and `false`
|
|
@@ -374,36 +430,36 @@ fill: { disabled: false } // tombstone — no CSS for disabled, blocks recipe to
|
|
|
374
430
|
```jsx
|
|
375
431
|
const SimpleButton = tasty(Button, {
|
|
376
432
|
styles: {
|
|
377
|
-
fill: null,
|
|
433
|
+
fill: null, // discard parent's fill, let recipe fill in
|
|
378
434
|
border: false, // no border at all (tombstone — blocks recipe too)
|
|
379
435
|
},
|
|
380
436
|
});
|
|
381
437
|
```
|
|
382
438
|
|
|
383
|
-
| Value
|
|
384
|
-
|
|
385
|
-
| `undefined` | Not provided — parent preserved
|
|
386
|
-
| `null`
|
|
387
|
-
| `false`
|
|
439
|
+
| Value | Meaning | Recipe fills in? |
|
|
440
|
+
| ----------- | ------------------------------------ | ---------------- |
|
|
441
|
+
| `undefined` | Not provided — parent preserved | N/A |
|
|
442
|
+
| `null` | Intentional unset — parent discarded | Yes |
|
|
443
|
+
| `false` | Tombstone — blocks everything | No |
|
|
388
444
|
|
|
389
445
|
---
|
|
390
446
|
|
|
391
447
|
## Advanced States (`@` prefix)
|
|
392
448
|
|
|
393
|
-
| Prefix
|
|
394
|
-
|
|
395
|
-
| `@media`
|
|
396
|
-
| `@(...)`
|
|
397
|
-
| `@supports` | Feature/selector support
|
|
398
|
-
| `@root`
|
|
399
|
-
| `@parent`
|
|
400
|
-
| `@own`
|
|
401
|
-
| `@starting` | Entry animation
|
|
402
|
-
| `_`
|
|
403
|
-
| `:is()`
|
|
404
|
-
| `:has()`
|
|
405
|
-
| `:not()`
|
|
406
|
-
| `:where()`
|
|
449
|
+
| Prefix | Purpose | Example |
|
|
450
|
+
| ----------- | ----------------------------------------- | -------------------------- |
|
|
451
|
+
| `@media` | Media queries | `@media(w < 768px)` |
|
|
452
|
+
| `@(...)` | Container queries | `@(panel, w >= 300px)` |
|
|
453
|
+
| `@supports` | Feature/selector support | `@supports(display: grid)` |
|
|
454
|
+
| `@root` | Root element states | `@root(schema=dark)` |
|
|
455
|
+
| `@parent` | Parent/ancestor element states | `@parent(hovered)` |
|
|
456
|
+
| `@own` | Sub-element's own state | `@own(hovered)` |
|
|
457
|
+
| `@starting` | Entry animation | `@starting` |
|
|
458
|
+
| `_` | Fallback floor (always-on, never negated) | `_` |
|
|
459
|
+
| `:is()` | CSS `:is()` structural pseudo-class | `:is(fieldset > label)` |
|
|
460
|
+
| `:has()` | CSS `:has()` relational pseudo-class | `:has(> Icon)` |
|
|
461
|
+
| `:not()` | CSS `:not()` negation (prefer `!:is()`) | `:not(:first-child)` |
|
|
462
|
+
| `:where()` | CSS `:where()` (zero specificity) | `:where(Section)` |
|
|
407
463
|
|
|
408
464
|
> **Specificity.** All state selectors Tasty generates (modifiers, pseudo-classes,
|
|
409
465
|
> `:is()`/`:not()` groups, and `@root` / `@parent` context) are wrapped in
|
|
@@ -419,9 +475,9 @@ const SimpleButton = tasty(Button, {
|
|
|
419
475
|
Media queries support dimension shorthands and custom unit expansion:
|
|
420
476
|
|
|
421
477
|
| Shorthand | Expands to |
|
|
422
|
-
|
|
423
|
-
| `w`
|
|
424
|
-
| `h`
|
|
478
|
+
| --------- | ---------- |
|
|
479
|
+
| `w` | `width` |
|
|
480
|
+
| `h` | `height` |
|
|
425
481
|
|
|
426
482
|
```jsx
|
|
427
483
|
fill: {
|
|
@@ -432,14 +488,14 @@ fill: {
|
|
|
432
488
|
}
|
|
433
489
|
```
|
|
434
490
|
|
|
435
|
-
| Tasty syntax
|
|
436
|
-
|
|
437
|
-
| `@media(w < 768px)`
|
|
438
|
-
| `@media(600px <= w < 1200px)`
|
|
439
|
-
| `@media:print`
|
|
440
|
-
| `@media:screen`
|
|
491
|
+
| Tasty syntax | CSS output |
|
|
492
|
+
| ------------------------------------ | ------------------------------------- |
|
|
493
|
+
| `@media(w < 768px)` | `@media (width < 768px)` |
|
|
494
|
+
| `@media(600px <= w < 1200px)` | `@media (600px <= width < 1200px)` |
|
|
495
|
+
| `@media:print` | `@media print` |
|
|
496
|
+
| `@media:screen` | `@media screen` |
|
|
441
497
|
| `@media(prefers-color-scheme: dark)` | `@media (prefers-color-scheme: dark)` |
|
|
442
|
-
| `@media(prefers-reduced-motion)`
|
|
498
|
+
| `@media(prefers-reduced-motion)` | `@media (prefers-reduced-motion)` |
|
|
443
499
|
|
|
444
500
|
Custom units work inside media queries: `@media(w < 40x)` → `@media (width < calc(var(--gap) * 40))`.
|
|
445
501
|
|
|
@@ -449,12 +505,12 @@ In practice, define state aliases via `configure({ states })` and use `@mobile`
|
|
|
449
505
|
|
|
450
506
|
Container queries use the syntax `@(name, condition)` for named containers or `@(condition)` for the nearest ancestor container. Dimension shorthands (`w`, `h`, `is`, `bs`) are expanded the same way as `@media`.
|
|
451
507
|
|
|
452
|
-
| Shorthand | Expands to
|
|
453
|
-
|
|
454
|
-
| `w`
|
|
455
|
-
| `h`
|
|
456
|
-
| `is`
|
|
457
|
-
| `bs`
|
|
508
|
+
| Shorthand | Expands to |
|
|
509
|
+
| --------- | ------------- |
|
|
510
|
+
| `w` | `width` |
|
|
511
|
+
| `h` | `height` |
|
|
512
|
+
| `is` | `inline-size` |
|
|
513
|
+
| `bs` | `block-size` |
|
|
458
514
|
|
|
459
515
|
```jsx
|
|
460
516
|
const Panel = tasty({
|
|
@@ -467,14 +523,14 @@ const Panel = tasty({
|
|
|
467
523
|
});
|
|
468
524
|
```
|
|
469
525
|
|
|
470
|
-
| Tasty syntax
|
|
471
|
-
|
|
472
|
-
| `@(layout, w < 600px)`
|
|
473
|
-
| `@(w < 600px)`
|
|
474
|
-
| `@(layout, $variant=danger)`
|
|
475
|
-
| `@(layout, $compact)`
|
|
476
|
-
| `@(scroll-state(stuck: top))`
|
|
477
|
-
| `@(nav, scroll-state(stuck: top))` | `@container nav scroll-state(stuck: top)`
|
|
526
|
+
| Tasty syntax | CSS output |
|
|
527
|
+
| ---------------------------------- | ---------------------------------------------- |
|
|
528
|
+
| `@(layout, w < 600px)` | `@container layout (width < 600px)` |
|
|
529
|
+
| `@(w < 600px)` | `@container (width < 600px)` |
|
|
530
|
+
| `@(layout, $variant=danger)` | `@container layout style(--variant: "danger")` |
|
|
531
|
+
| `@(layout, $compact)` | `@container layout style(--compact)` |
|
|
532
|
+
| `@(scroll-state(stuck: top))` | `@container scroll-state(stuck: top)` |
|
|
533
|
+
| `@(nav, scroll-state(stuck: top))` | `@container nav scroll-state(stuck: top)` |
|
|
478
534
|
|
|
479
535
|
Container style queries use `$prop` (boolean) or `$prop=value` syntax, which maps to CSS `style(--prop)` or `style(--prop: "value")`.
|
|
480
536
|
|
|
@@ -482,10 +538,10 @@ Container style queries use `$prop` (boolean) or `$prop=value` syntax, which map
|
|
|
482
538
|
|
|
483
539
|
Feature queries test CSS property support. Use `$` as the first argument to test selector support:
|
|
484
540
|
|
|
485
|
-
| Tasty syntax
|
|
486
|
-
|
|
487
|
-
| `@supports(display: grid)`
|
|
488
|
-
| `@supports($, :has(*))`
|
|
541
|
+
| Tasty syntax | CSS output |
|
|
542
|
+
| --------------------------- | --------------------------------- |
|
|
543
|
+
| `@supports(display: grid)` | `@supports (display: grid)` |
|
|
544
|
+
| `@supports($, :has(*))` | `@supports selector(:has(*))` |
|
|
489
545
|
| `!@supports(display: grid)` | `@supports (not (display: grid))` |
|
|
490
546
|
|
|
491
547
|
```jsx
|
|
@@ -504,7 +560,7 @@ that assumption: `@supports(...)` and `@(...)` queries can be **unknown** (not
|
|
|
504
560
|
just true/false), and `not(unknown)` is also unknown — so a negated default
|
|
505
561
|
branch silently never applies. The classic case is `scroll-state`: a browser can
|
|
506
562
|
support `container-type: scroll-state` while a specific `scroll-state(...)` query
|
|
507
|
-
is unknown, leaving
|
|
563
|
+
is unknown, leaving _no_ branch active.
|
|
508
564
|
|
|
509
565
|
The `_` fallback floor solves this. Use `_` as a **standalone key** and its value
|
|
510
566
|
**always applies** as a guaranteed floor: it never receives negation, and
|
|
@@ -519,10 +575,14 @@ inset: {
|
|
|
519
575
|
```
|
|
520
576
|
|
|
521
577
|
```css
|
|
522
|
-
.t0.t0 {
|
|
578
|
+
.t0.t0 {
|
|
579
|
+
inset: 0...;
|
|
580
|
+
}
|
|
523
581
|
@container scroll-state(scrolled: block-end) {
|
|
524
582
|
@supports (container-type: scroll-state) {
|
|
525
|
-
.t0.t0 {
|
|
583
|
+
.t0.t0 {
|
|
584
|
+
inset: -80px...;
|
|
585
|
+
}
|
|
526
586
|
}
|
|
527
587
|
}
|
|
528
588
|
```
|
|
@@ -553,13 +613,13 @@ cause is always the same: **`''` is mutually exclusive (turned off by negation),
|
|
|
553
613
|
while `_` is always on (layered underneath).**
|
|
554
614
|
|
|
555
615
|
- **Unknown / invalid branches.** If a higher-priority branch sits behind a query
|
|
556
|
-
that can be
|
|
616
|
+
that can be _unknown_ (`@supports`, container, `scroll-state`) or uses a
|
|
557
617
|
selector the browser drops, the negated `''` default disappears along with it
|
|
558
618
|
(`not(unknown) = unknown`), leaving the property with no rule. The `_` floor
|
|
559
619
|
survives because it is an unconditional bare rule. This is the case `_` exists
|
|
560
620
|
for.
|
|
561
621
|
|
|
562
|
-
- **Empty / "unset" states.** A state can intentionally produce
|
|
622
|
+
- **Empty / "unset" states.** A state can intentionally produce _no_ output (an
|
|
563
623
|
empty value) to leave a property unset while that state is active. With `''`
|
|
564
624
|
this works — the default is negated away and nothing replaces it, so the
|
|
565
625
|
property unsets. With `_` the floor can never be turned off, so its value keeps
|
|
@@ -571,14 +631,14 @@ while `_` is always on (layered underneath).**
|
|
|
571
631
|
```
|
|
572
632
|
|
|
573
633
|
- **States with different output shapes.** Because `_` layers additively, when
|
|
574
|
-
different states emit
|
|
634
|
+
different states emit _different sets_ of declarations, the floor's
|
|
575
635
|
declarations bleed through wherever the winning state does not override the
|
|
576
636
|
same property — which can produce inconsistent combinations. A `''` default is
|
|
577
637
|
swapped out cleanly by its mutually-exclusive condition.
|
|
578
638
|
|
|
579
639
|
Rule of thumb: **use `''` for the normal default** (clean mutual exclusivity,
|
|
580
640
|
supports unsetting), and reach for `_` only when a value must survive an
|
|
581
|
-
|
|
641
|
+
_unknown_ higher-priority branch.
|
|
582
642
|
|
|
583
643
|
### `@root(...)` — Root Element States
|
|
584
644
|
|
|
@@ -594,13 +654,13 @@ color: {
|
|
|
594
654
|
}
|
|
595
655
|
```
|
|
596
656
|
|
|
597
|
-
| Tasty syntax
|
|
598
|
-
|
|
599
|
-
| `@root(schema=dark)`
|
|
600
|
-
| `@root(hovered)`
|
|
601
|
-
| `@root(.premium-user)` | `:root.premium-user`
|
|
602
|
-
| `@root([lang="en"])`
|
|
603
|
-
| `!@root(schema=dark)`
|
|
657
|
+
| Tasty syntax | CSS selector |
|
|
658
|
+
| ---------------------- | --------------------------------- |
|
|
659
|
+
| `@root(schema=dark)` | `:root[data-schema="dark"]` |
|
|
660
|
+
| `@root(hovered)` | `:root[data-hovered]` |
|
|
661
|
+
| `@root(.premium-user)` | `:root.premium-user` |
|
|
662
|
+
| `@root([lang="en"])` | `:root[lang="en"]` |
|
|
663
|
+
| `!@root(schema=dark)` | `:root:not([data-schema="dark"])` |
|
|
604
664
|
|
|
605
665
|
Root conditions are prepended to the component selector: `:root[data-schema="dark"] .t0.t0 { ... }`.
|
|
606
666
|
|
|
@@ -616,7 +676,7 @@ const Nav = tasty({
|
|
|
616
676
|
'': '#text',
|
|
617
677
|
'@own(:hover)': '#primary',
|
|
618
678
|
'@own(:focus-visible)': '#primary',
|
|
619
|
-
|
|
679
|
+
selected: '#primary', // root-level modifier
|
|
620
680
|
},
|
|
621
681
|
},
|
|
622
682
|
},
|
|
@@ -624,11 +684,11 @@ const Nav = tasty({
|
|
|
624
684
|
});
|
|
625
685
|
```
|
|
626
686
|
|
|
627
|
-
| Tasty syntax (inside sub-element) | CSS output
|
|
628
|
-
|
|
629
|
-
| `@own(:hover)`
|
|
630
|
-
| `@own(hovered)`
|
|
631
|
-
| `@own(theme=dark)`
|
|
687
|
+
| Tasty syntax (inside sub-element) | CSS output |
|
|
688
|
+
| --------------------------------- | ------------------------------------------------- |
|
|
689
|
+
| `@own(:hover)` | `:hover` on the sub-element selector |
|
|
690
|
+
| `@own(hovered)` | `[data-hovered]` on the sub-element selector |
|
|
691
|
+
| `@own(theme=dark)` | `[data-theme="dark"]` on the sub-element selector |
|
|
632
692
|
|
|
633
693
|
`@own()` is only valid inside sub-element styles. Using it on root styles emits a warning and is treated as a regular modifier.
|
|
634
694
|
|
|
@@ -646,9 +706,9 @@ const FadeIn = tasty({
|
|
|
646
706
|
});
|
|
647
707
|
```
|
|
648
708
|
|
|
649
|
-
| Tasty syntax | CSS output
|
|
650
|
-
|
|
651
|
-
| `@starting`
|
|
709
|
+
| Tasty syntax | CSS output |
|
|
710
|
+
| ------------ | ------------------------------------ |
|
|
711
|
+
| `@starting` | `@starting-style { .t0.t0 { ... } }` |
|
|
652
712
|
|
|
653
713
|
### `@parent(...)` — Parent Element States
|
|
654
714
|
|
|
@@ -659,22 +719,22 @@ const Highlight = tasty({
|
|
|
659
719
|
styles: {
|
|
660
720
|
fill: {
|
|
661
721
|
'': '#white',
|
|
662
|
-
'@parent(hovered)': '#gray.05',
|
|
663
|
-
'@parent(theme=dark, >)': '#dark-02',
|
|
722
|
+
'@parent(hovered)': '#gray.05', // Any ancestor has [data-hovered]
|
|
723
|
+
'@parent(theme=dark, >)': '#dark-02', // Direct parent has [data-theme="dark"]
|
|
664
724
|
},
|
|
665
725
|
},
|
|
666
726
|
});
|
|
667
727
|
```
|
|
668
728
|
|
|
669
|
-
| Syntax
|
|
670
|
-
|
|
671
|
-
| `@parent(hovered)`
|
|
672
|
-
| `!@parent(hovered)`
|
|
673
|
-
| `@parent(hovered, >)`
|
|
674
|
-
| `@parent(.active)`
|
|
675
|
-
| `@parent(hovered & focused)`
|
|
729
|
+
| Syntax | CSS Output |
|
|
730
|
+
| ------------------------------------- | -------------------------------------------------------------------- |
|
|
731
|
+
| `@parent(hovered)` | `:is([data-hovered] *)` |
|
|
732
|
+
| `!@parent(hovered)` | `:not([data-hovered] *)` |
|
|
733
|
+
| `@parent(hovered, >)` | `:is([data-hovered] > *)` (direct parent) |
|
|
734
|
+
| `@parent(.active)` | `:is(.active *)` |
|
|
735
|
+
| `@parent(hovered & focused)` | `:is([data-hovered][data-focused] *)` (same ancestor) |
|
|
676
736
|
| `@parent(hovered) & @parent(focused)` | `:is([data-hovered] *):is([data-focused] *)` (independent ancestors) |
|
|
677
|
-
| `@parent(hovered \| focused)`
|
|
737
|
+
| `@parent(hovered \| focused)` | `:is([data-hovered] *, [data-focused] *)` (OR inside single wrapper) |
|
|
678
738
|
|
|
679
739
|
For sub-elements, the parent check applies to the root element's ancestors:
|
|
680
740
|
|
|
@@ -705,38 +765,38 @@ const Card = tasty({
|
|
|
705
765
|
styles: {
|
|
706
766
|
display: {
|
|
707
767
|
'': 'block',
|
|
708
|
-
':has(> Icon)': 'grid',
|
|
709
|
-
':has(+ Icon)': 'grid',
|
|
710
|
-
':has(~ Icon)': 'grid',
|
|
711
|
-
':has(Icon +)': 'grid',
|
|
712
|
-
':has(Icon ~)': 'grid',
|
|
713
|
-
':is(fieldset > label)': 'inline',
|
|
714
|
-
'!:has(> Icon)': 'flex',
|
|
768
|
+
':has(> Icon)': 'grid', // has Icon as direct child
|
|
769
|
+
':has(+ Icon)': 'grid', // immediately followed by an Icon sibling
|
|
770
|
+
':has(~ Icon)': 'grid', // has an Icon sibling somewhere after
|
|
771
|
+
':has(Icon +)': 'grid', // immediately preceded by an Icon sibling (auto-completes to `Icon + *`)
|
|
772
|
+
':has(Icon ~)': 'grid', // has an Icon sibling somewhere before (auto-completes to `Icon ~ *`)
|
|
773
|
+
':is(fieldset > label)': 'inline', // is a label inside a fieldset (HTML tags)
|
|
774
|
+
'!:has(> Icon)': 'flex', // negation: no Icon child
|
|
715
775
|
},
|
|
716
776
|
},
|
|
717
777
|
});
|
|
718
778
|
```
|
|
719
779
|
|
|
720
|
-
| Syntax
|
|
721
|
-
|
|
722
|
-
| `:has(> Icon)`
|
|
723
|
-
| `:has(+ Icon)`
|
|
724
|
-
| `:has(~ Icon)`
|
|
725
|
-
| `:has(Icon +)`
|
|
726
|
-
| `:has(Icon ~)`
|
|
727
|
-
| `:has(>)`
|
|
728
|
-
| `:is(> Field + input)` | `:is(> [data-element="Field"] + input)` | Structural match
|
|
729
|
-
| `:has(button)`
|
|
730
|
-
| `!:has(> Icon)`
|
|
731
|
-
| `!:is(Panel)`
|
|
780
|
+
| Syntax | CSS Output | Meaning |
|
|
781
|
+
| ---------------------- | --------------------------------------- | --------------------------------------- |
|
|
782
|
+
| `:has(> Icon)` | `:has(> [data-element="Icon"])` | Has Icon as direct child |
|
|
783
|
+
| `:has(+ Icon)` | `:has(+ [data-element="Icon"])` | Immediately followed by an Icon sibling |
|
|
784
|
+
| `:has(~ Icon)` | `:has(~ [data-element="Icon"])` | Has an Icon sibling somewhere after |
|
|
785
|
+
| `:has(Icon +)` | `:has([data-element="Icon"] + *)` | Immediately preceded by an Icon sibling |
|
|
786
|
+
| `:has(Icon ~)` | `:has([data-element="Icon"] ~ *)` | Has an Icon sibling somewhere before |
|
|
787
|
+
| `:has(>)` | `:has(> *)` | Has any direct child |
|
|
788
|
+
| `:is(> Field + input)` | `:is(> [data-element="Field"] + input)` | Structural match |
|
|
789
|
+
| `:has(button)` | `:has(button)` | HTML tag (lowercase, unchanged) |
|
|
790
|
+
| `!:has(> Icon)` | `:not(:has(> [data-element="Icon"]))` | Negation (use `!`) |
|
|
791
|
+
| `!:is(Panel)` | `:not([data-element="Panel"])` | Negation (use `!:is`) |
|
|
732
792
|
|
|
733
793
|
Combine with other states using boolean logic (`&`, `|`, `!`, `^`):
|
|
734
794
|
|
|
735
795
|
```jsx
|
|
736
|
-
':has(> Icon) & hovered'
|
|
737
|
-
'@parent(hovered) & :has(> Icon)'
|
|
738
|
-
':has(> Icon) | :has(> Button)'
|
|
739
|
-
':has(> Icon) ^ :has(> Button)'
|
|
796
|
+
':has(> Icon) & hovered'; // AND: structural + data attribute
|
|
797
|
+
'@parent(hovered) & :has(> Icon)'; // AND: parent check + structural
|
|
798
|
+
':has(> Icon) | :has(> Button)'; // OR: either sub-element present
|
|
799
|
+
':has(> Icon) ^ :has(> Button)'; // XOR: exactly one present
|
|
740
800
|
```
|
|
741
801
|
|
|
742
802
|
> **Nesting limit:** The state key parser supports up to 2 levels of nested parentheses inside `:is()`, `:has()`, `:not()`, and `:where()` — e.g. `:has(Input:not(:disabled))` works, but 3+ levels like `:has(:is(:not(:hover)))` will not be tokenized correctly. This covers virtually all practical use cases.
|
|
@@ -772,7 +832,7 @@ const AnimatedGradient = tasty({
|
|
|
772
832
|
styles: {
|
|
773
833
|
'$gradient-angle': '0deg',
|
|
774
834
|
'#theme': 'okhst(280 80% 50%)',
|
|
775
|
-
|
|
835
|
+
image: 'linear-gradient($gradient-angle, #theme, #clear)',
|
|
776
836
|
transition: '$$gradient-angle 0.3s, ##theme 0.3s',
|
|
777
837
|
},
|
|
778
838
|
});
|
|
@@ -803,7 +863,7 @@ const Heading = tasty({
|
|
|
803
863
|
fontDisplay: 'swap',
|
|
804
864
|
},
|
|
805
865
|
},
|
|
806
|
-
|
|
866
|
+
font: '"Brand Sans", sans-serif',
|
|
807
867
|
},
|
|
808
868
|
});
|
|
809
869
|
```
|
|
@@ -823,20 +883,20 @@ Supply an array to register several variants of the same family:
|
|
|
823
883
|
|
|
824
884
|
### Supported descriptors
|
|
825
885
|
|
|
826
|
-
| Descriptor
|
|
827
|
-
|
|
828
|
-
| `src` (required)
|
|
829
|
-
| `fontWeight`
|
|
830
|
-
| `fontStyle`
|
|
831
|
-
| `fontStretch`
|
|
832
|
-
| `fontDisplay`
|
|
833
|
-
| `unicodeRange`
|
|
834
|
-
| `ascentOverride`
|
|
835
|
-
| `descentOverride`
|
|
836
|
-
| `lineGapOverride`
|
|
837
|
-
| `sizeAdjust`
|
|
838
|
-
| `fontFeatureSettings`
|
|
839
|
-
| `fontVariationSettings` | `font-variation-settings` | `string`
|
|
886
|
+
| Descriptor | CSS property | Type |
|
|
887
|
+
| ----------------------- | ------------------------- | --------------------------------------------------------- |
|
|
888
|
+
| `src` (required) | `src` | `string` |
|
|
889
|
+
| `fontWeight` | `font-weight` | `string \| number` |
|
|
890
|
+
| `fontStyle` | `font-style` | `string` |
|
|
891
|
+
| `fontStretch` | `font-stretch` | `string` |
|
|
892
|
+
| `fontDisplay` | `font-display` | `'auto' \| 'block' \| 'swap' \| 'fallback' \| 'optional'` |
|
|
893
|
+
| `unicodeRange` | `unicode-range` | `string` |
|
|
894
|
+
| `ascentOverride` | `ascent-override` | `string` |
|
|
895
|
+
| `descentOverride` | `descent-override` | `string` |
|
|
896
|
+
| `lineGapOverride` | `line-gap-override` | `string` |
|
|
897
|
+
| `sizeAdjust` | `size-adjust` | `string` |
|
|
898
|
+
| `fontFeatureSettings` | `font-feature-settings` | `string` |
|
|
899
|
+
| `fontVariationSettings` | `font-variation-settings` | `string` |
|
|
840
900
|
|
|
841
901
|
> Font-face rules are permanent — they are injected once and never cleaned up, matching how browsers handle `@font-face`.
|
|
842
902
|
|
|
@@ -864,18 +924,18 @@ const EmojiList = tasty({
|
|
|
864
924
|
|
|
865
925
|
### Supported descriptors
|
|
866
926
|
|
|
867
|
-
| Descriptor
|
|
868
|
-
|
|
869
|
-
| `system` (required) | `system`
|
|
870
|
-
| `symbols`
|
|
871
|
-
| `additiveSymbols`
|
|
872
|
-
| `prefix`
|
|
873
|
-
| `suffix`
|
|
874
|
-
| `negative`
|
|
875
|
-
| `range`
|
|
876
|
-
| `pad`
|
|
877
|
-
| `fallback`
|
|
878
|
-
| `speakAs`
|
|
927
|
+
| Descriptor | CSS property | Type |
|
|
928
|
+
| ------------------- | ------------------ | ---------------------------------------------------------------------------------------- |
|
|
929
|
+
| `system` (required) | `system` | `'cyclic' \| 'numeric' \| 'alphabetic' \| 'symbolic' \| 'additive' \| 'fixed' \| string` |
|
|
930
|
+
| `symbols` | `symbols` | `string` |
|
|
931
|
+
| `additiveSymbols` | `additive-symbols` | `string` |
|
|
932
|
+
| `prefix` | `prefix` | `string` |
|
|
933
|
+
| `suffix` | `suffix` | `string` |
|
|
934
|
+
| `negative` | `negative` | `string` |
|
|
935
|
+
| `range` | `range` | `string` |
|
|
936
|
+
| `pad` | `pad` | `string` |
|
|
937
|
+
| `fallback` | `fallback` | `string` |
|
|
938
|
+
| `speakAs` | `speak-as` | `string` |
|
|
879
939
|
|
|
880
940
|
> Counter-style rules are permanent — they are injected once and never cleaned up, matching how browsers handle `@counter-style`.
|
|
881
941
|
|
|
@@ -897,18 +957,18 @@ const Box = tasty({
|
|
|
897
957
|
styles: {
|
|
898
958
|
'@function': {
|
|
899
959
|
// simplest: one bare param + result (auto-calc, no explicit calc())
|
|
900
|
-
|
|
960
|
+
$$negative: { args: ['$value'], result: '(-1 * $value)' },
|
|
901
961
|
|
|
902
962
|
// typed param + default + return type + local variable
|
|
903
|
-
|
|
963
|
+
$$shadow: {
|
|
904
964
|
args: { '$shadow-color': { syntax: '<color>', default: 'inherit' } },
|
|
905
965
|
returns: '<color>',
|
|
906
|
-
|
|
966
|
+
$offset: '2px', // local variable
|
|
907
967
|
result: '$offset $offset ($shadow-color, black)',
|
|
908
968
|
},
|
|
909
969
|
},
|
|
910
|
-
|
|
911
|
-
|
|
970
|
+
margin: '$$negative(10px) top', // → margin: --negative(10px) 0 0 0
|
|
971
|
+
shadow: '$$shadow(#accent)', // → box-shadow: --shadow(var(--accent-color))
|
|
912
972
|
},
|
|
913
973
|
});
|
|
914
974
|
```
|
|
@@ -916,22 +976,27 @@ const Box = tasty({
|
|
|
916
976
|
Generated CSS:
|
|
917
977
|
|
|
918
978
|
```css
|
|
919
|
-
@function --negative(--value) {
|
|
979
|
+
@function --negative(--value) {
|
|
980
|
+
result: calc(-1 * var(--value));
|
|
981
|
+
}
|
|
920
982
|
@function --shadow(--shadow-color <color>: inherit) returns <color> {
|
|
921
983
|
--offset: 2px;
|
|
922
984
|
result: var(--offset) var(--offset) var(--shadow-color, black);
|
|
923
985
|
}
|
|
924
|
-
.t0 {
|
|
986
|
+
.t0 {
|
|
987
|
+
margin: --negative(10px) 0 0 0;
|
|
988
|
+
box-shadow: --shadow(var(--accent-color));
|
|
989
|
+
}
|
|
925
990
|
```
|
|
926
991
|
|
|
927
992
|
### Descriptor shape
|
|
928
993
|
|
|
929
|
-
| Field
|
|
930
|
-
|
|
931
|
-
| `result` (required) | `string`
|
|
932
|
-
| `args`
|
|
933
|
-
| `returns`
|
|
934
|
-
| `$name` keys
|
|
994
|
+
| Field | Type | Notes |
|
|
995
|
+
| ------------------- | ------------------------------------------------- | ---------------------------------------------------------------------------------------- |
|
|
996
|
+
| `result` (required) | `string` | The `result:` value, parsed through the Tasty DSL. |
|
|
997
|
+
| `args` | `string[]` \| `Record<string, FunctionParameter>` | Ordered parameters. Array form lists bare names; object form maps names to type/default. |
|
|
998
|
+
| `returns` | `string` | Optional return type, e.g. `'<color>'`. |
|
|
999
|
+
| `$name` keys | `string \| number` | Any `$name` key declares a local variable `--name` (value parsed). |
|
|
935
1000
|
|
|
936
1001
|
A `FunctionParameter` is one of: `true` (bare param), a string CSS type shorthand (`'<length>'`), or `{ syntax?: string; default?: string | number }`.
|
|
937
1002
|
|
|
@@ -953,4 +1018,4 @@ For a complete reference of all enhanced style properties — syntax, values, mo
|
|
|
953
1018
|
- **[Methodology](methodology.md)** — Recommended patterns: root + sub-elements, styleProps, tokens, wrapping
|
|
954
1019
|
- **[Configuration](configuration.md)** — Tokens, recipes, custom units, style handlers, TypeScript extensions
|
|
955
1020
|
- **[Style Properties](styles.md)** — Complete reference for all enhanced style properties
|
|
956
|
-
- **[
|
|
1021
|
+
- **[Build-Time Extraction (`tastyStatic`)](tasty-static.md)** — Static styling with the Babel plugin
|