@tenphi/tasty 0.0.0-snapshot.ef8cc29 → 0.0.0-snapshot.efb24cc
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 +65 -215
- package/dist/_virtual/_rolldown/runtime.js +1 -2
- package/dist/chunks/cacheKey.d.ts +1 -0
- package/dist/chunks/cacheKey.js +1 -2
- package/dist/chunks/cacheKey.js.map +1 -1
- package/dist/chunks/definitions.d.ts +1 -1
- package/dist/chunks/definitions.js +2 -3
- package/dist/chunks/definitions.js.map +1 -1
- package/dist/chunks/index.d.ts +1 -0
- package/dist/chunks/renderChunk.d.ts +1 -0
- package/dist/chunks/renderChunk.js +1 -2
- package/dist/chunks/renderChunk.js.map +1 -1
- package/dist/compute-styles.d.ts +31 -0
- package/dist/compute-styles.js +322 -0
- package/dist/compute-styles.js.map +1 -0
- package/dist/config.d.ts +105 -21
- package/dist/config.js +175 -49
- package/dist/config.js.map +1 -1
- package/dist/core/index.d.ts +7 -7
- package/dist/core/index.js +8 -8
- package/dist/counter-style/index.js +51 -0
- package/dist/counter-style/index.js.map +1 -0
- package/dist/debug.js +5 -6
- package/dist/debug.js.map +1 -1
- package/dist/font-face/index.js +63 -0
- package/dist/font-face/index.js.map +1 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/useCounterStyle.d.ts +36 -0
- package/dist/hooks/useCounterStyle.js +65 -0
- package/dist/hooks/useCounterStyle.js.map +1 -0
- package/dist/hooks/useFontFace.d.ts +45 -0
- package/dist/hooks/useFontFace.js +66 -0
- package/dist/hooks/useFontFace.js.map +1 -0
- package/dist/hooks/useGlobalStyles.d.ts +18 -2
- package/dist/hooks/useGlobalStyles.js +52 -47
- package/dist/hooks/useGlobalStyles.js.map +1 -1
- package/dist/hooks/useKeyframes.d.ts +4 -2
- package/dist/hooks/useKeyframes.js +43 -57
- package/dist/hooks/useKeyframes.js.map +1 -1
- package/dist/hooks/useProperty.d.ts +4 -2
- package/dist/hooks/useProperty.js +30 -48
- package/dist/hooks/useProperty.js.map +1 -1
- package/dist/hooks/useRawCSS.d.ts +13 -44
- package/dist/hooks/useRawCSS.js +91 -28
- package/dist/hooks/useRawCSS.js.map +1 -1
- package/dist/hooks/useStyles.d.ts +3 -8
- package/dist/hooks/useStyles.js +7 -225
- package/dist/hooks/useStyles.js.map +1 -1
- package/dist/index.d.ts +10 -8
- package/dist/index.js +11 -9
- package/dist/injector/index.d.ts +36 -19
- package/dist/injector/index.js +43 -20
- package/dist/injector/index.js.map +1 -1
- package/dist/injector/injector.d.ts +53 -3
- package/dist/injector/injector.js +235 -14
- package/dist/injector/injector.js.map +1 -1
- package/dist/injector/sheet-manager.d.ts +9 -13
- package/dist/injector/sheet-manager.js +41 -71
- package/dist/injector/sheet-manager.js.map +1 -1
- package/dist/injector/types.d.ts +112 -21
- package/dist/keyframes/index.js +1 -1
- package/dist/parser/classify.js +4 -5
- package/dist/parser/classify.js.map +1 -1
- package/dist/parser/const.js +30 -3
- package/dist/parser/const.js.map +1 -1
- package/dist/parser/lru.js +1 -1
- package/dist/parser/lru.js.map +1 -1
- package/dist/parser/parser.js +1 -2
- package/dist/parser/parser.js.map +1 -1
- package/dist/parser/tokenizer.js +1 -1
- package/dist/parser/tokenizer.js.map +1 -1
- package/dist/parser/types.js +1 -1
- package/dist/parser/types.js.map +1 -1
- package/dist/pipeline/conditions.js +1 -1
- package/dist/pipeline/conditions.js.map +1 -1
- package/dist/pipeline/exclusive.js +58 -4
- package/dist/pipeline/exclusive.js.map +1 -1
- package/dist/pipeline/index.d.ts +2 -0
- package/dist/pipeline/index.js +39 -12
- package/dist/pipeline/index.js.map +1 -1
- package/dist/pipeline/materialize.js +57 -5
- package/dist/pipeline/materialize.js.map +1 -1
- package/dist/pipeline/parseStateKey.js +5 -6
- package/dist/pipeline/parseStateKey.js.map +1 -1
- package/dist/pipeline/simplify.js +181 -7
- package/dist/pipeline/simplify.js.map +1 -1
- package/dist/pipeline/warnings.js +1 -1
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/okhsl-plugin.js +1 -2
- package/dist/plugins/okhsl-plugin.js.map +1 -1
- package/dist/plugins/types.d.ts +12 -1
- package/dist/properties/index.js +2 -3
- package/dist/properties/index.js.map +1 -1
- package/dist/properties/property-type-resolver.js +1 -2
- package/dist/properties/property-type-resolver.js.map +1 -1
- package/dist/rsc-cache.js +79 -0
- package/dist/rsc-cache.js.map +1 -0
- package/dist/ssr/astro-client.d.ts +1 -0
- package/dist/ssr/astro-client.js +19 -0
- package/dist/ssr/astro-client.js.map +1 -0
- package/dist/ssr/astro-middleware.d.ts +15 -0
- package/dist/ssr/astro-middleware.js +19 -0
- package/dist/ssr/astro-middleware.js.map +1 -0
- package/dist/ssr/astro.d.ts +89 -10
- package/dist/ssr/astro.js +113 -29
- package/dist/ssr/astro.js.map +1 -1
- package/dist/ssr/async-storage.js +15 -6
- package/dist/ssr/async-storage.js.map +1 -1
- package/dist/ssr/collect-auto-properties.js +29 -11
- package/dist/ssr/collect-auto-properties.js.map +1 -1
- package/dist/ssr/collector.d.ts +26 -13
- package/dist/ssr/collector.js +84 -32
- package/dist/ssr/collector.js.map +1 -1
- package/dist/ssr/context.js +4 -2
- package/dist/ssr/context.js.map +1 -1
- package/dist/ssr/format-global-rules.js +1 -1
- package/dist/ssr/format-keyframes.js +1 -2
- package/dist/ssr/format-keyframes.js.map +1 -1
- package/dist/ssr/format-property.js +1 -2
- package/dist/ssr/format-property.js.map +1 -1
- package/dist/ssr/format-rules.js +8 -5
- package/dist/ssr/format-rules.js.map +1 -1
- package/dist/ssr/hydrate.d.ts +20 -13
- package/dist/ssr/hydrate.js +25 -30
- package/dist/ssr/hydrate.js.map +1 -1
- package/dist/ssr/index.d.ts +3 -4
- package/dist/ssr/index.js +5 -7
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/next.d.ts +6 -5
- package/dist/ssr/next.js +14 -10
- package/dist/ssr/next.js.map +1 -1
- package/dist/ssr/ssr-collector-ref.js +20 -3
- package/dist/ssr/ssr-collector-ref.js.map +1 -1
- package/dist/states/index.js +3 -2
- package/dist/states/index.js.map +1 -1
- package/dist/static/index.js +1 -2
- package/dist/static/inject.d.ts +5 -0
- package/dist/static/inject.js +17 -0
- package/dist/static/inject.js.map +1 -0
- package/dist/static/tastyStatic.js +1 -2
- package/dist/static/tastyStatic.js.map +1 -1
- package/dist/static/types.js +1 -1
- package/dist/styles/border.d.ts +1 -1
- package/dist/styles/border.js +30 -24
- package/dist/styles/border.js.map +1 -1
- package/dist/styles/color.d.ts +1 -1
- package/dist/styles/color.js +2 -3
- package/dist/styles/color.js.map +1 -1
- package/dist/styles/const.js +17 -0
- package/dist/styles/const.js.map +1 -0
- package/dist/styles/createStyle.js +4 -5
- package/dist/styles/createStyle.js.map +1 -1
- package/dist/styles/dimension.js +15 -3
- package/dist/styles/dimension.js.map +1 -1
- package/dist/styles/directional.js +133 -0
- package/dist/styles/directional.js.map +1 -0
- package/dist/styles/display.d.ts +3 -10
- package/dist/styles/display.js +45 -39
- package/dist/styles/display.js.map +1 -1
- package/dist/styles/fade.d.ts +1 -1
- package/dist/styles/fade.js +9 -5
- package/dist/styles/fade.js.map +1 -1
- package/dist/styles/fill.d.ts +2 -2
- package/dist/styles/fill.js +3 -4
- package/dist/styles/fill.js.map +1 -1
- package/dist/styles/flow.js +1 -1
- package/dist/styles/gap.d.ts +1 -1
- package/dist/styles/gap.js +4 -3
- package/dist/styles/gap.js.map +1 -1
- package/dist/styles/height.d.ts +1 -1
- package/dist/styles/height.js +1 -2
- package/dist/styles/height.js.map +1 -1
- package/dist/styles/index.d.ts +0 -1
- package/dist/styles/index.js +3 -4
- package/dist/styles/index.js.map +1 -1
- package/dist/styles/inset.d.ts +1 -29
- package/dist/styles/inset.js +19 -135
- package/dist/styles/inset.js.map +1 -1
- package/dist/styles/list.d.ts +5 -5
- package/dist/styles/list.js +4 -2
- package/dist/styles/list.js.map +1 -1
- package/dist/styles/margin.d.ts +1 -1
- package/dist/styles/margin.js +17 -89
- package/dist/styles/margin.js.map +1 -1
- package/dist/styles/outline.d.ts +1 -1
- package/dist/styles/outline.js +6 -16
- package/dist/styles/outline.js.map +1 -1
- package/dist/styles/padding.d.ts +1 -1
- package/dist/styles/padding.js +17 -89
- package/dist/styles/padding.js.map +1 -1
- package/dist/styles/placement.d.ts +37 -0
- package/dist/styles/placement.js +74 -0
- package/dist/styles/placement.js.map +1 -0
- package/dist/styles/predefined.d.ts +4 -4
- package/dist/styles/predefined.js +8 -9
- package/dist/styles/predefined.js.map +1 -1
- package/dist/styles/preset.d.ts +6 -1
- package/dist/styles/preset.js +54 -53
- package/dist/styles/preset.js.map +1 -1
- package/dist/styles/radius.d.ts +1 -3
- package/dist/styles/radius.js +38 -6
- package/dist/styles/radius.js.map +1 -1
- package/dist/styles/scrollMargin.d.ts +24 -0
- package/dist/styles/scrollMargin.js +32 -0
- package/dist/styles/scrollMargin.js.map +1 -0
- package/dist/styles/scrollbar.d.ts +1 -1
- package/dist/styles/scrollbar.js +8 -5
- package/dist/styles/scrollbar.js.map +1 -1
- package/dist/styles/shadow.d.ts +1 -1
- package/dist/styles/shadow.js +4 -3
- package/dist/styles/shadow.js.map +1 -1
- package/dist/styles/shared.js +17 -0
- package/dist/styles/shared.js.map +1 -0
- package/dist/styles/transition.d.ts +1 -1
- package/dist/styles/transition.js +5 -4
- package/dist/styles/transition.js.map +1 -1
- package/dist/styles/types.d.ts +52 -11
- package/dist/styles/width.d.ts +1 -1
- package/dist/styles/width.js +1 -2
- package/dist/styles/width.js.map +1 -1
- package/dist/tasty.d.ts +46 -893
- package/dist/tasty.js +96 -67
- package/dist/tasty.js.map +1 -1
- package/dist/utils/cache-wrapper.js +1 -2
- package/dist/utils/cache-wrapper.js.map +1 -1
- package/dist/utils/case-converter.js +1 -1
- package/dist/utils/color-math.js +1 -1
- package/dist/utils/color-math.js.map +1 -1
- package/dist/utils/color-space.js +1 -2
- package/dist/utils/color-space.js.map +1 -1
- package/dist/utils/colors.js +1 -2
- package/dist/utils/colors.js.map +1 -1
- package/dist/utils/deps-equal.js +15 -0
- package/dist/utils/deps-equal.js.map +1 -0
- package/dist/utils/dotize.js +1 -1
- package/dist/utils/dotize.js.map +1 -1
- package/dist/utils/filter-base-props.d.ts +1 -1
- package/dist/utils/filter-base-props.js +1 -1
- package/dist/utils/filter-base-props.js.map +1 -1
- package/dist/utils/get-display-name.js +1 -1
- package/dist/utils/has-keys.js +1 -1
- package/dist/utils/hash.js +14 -0
- package/dist/utils/hash.js.map +1 -0
- package/dist/utils/is-dev-env.js +1 -1
- package/dist/utils/is-dev-env.js.map +1 -1
- package/dist/utils/is-valid-element-type.js +1 -1
- package/dist/utils/merge-styles.js +1 -2
- package/dist/utils/merge-styles.js.map +1 -1
- package/dist/utils/mod-attrs.d.ts +0 -2
- package/dist/utils/mod-attrs.js +1 -2
- package/dist/utils/mod-attrs.js.map +1 -1
- package/dist/utils/process-tokens.d.ts +1 -5
- package/dist/utils/process-tokens.js +3 -11
- package/dist/utils/process-tokens.js.map +1 -1
- package/dist/utils/resolve-recipes.js +1 -2
- package/dist/utils/resolve-recipes.js.map +1 -1
- package/dist/utils/selector-transform.js +1 -1
- package/dist/utils/string.js +1 -1
- package/dist/utils/styles.d.ts +1 -3
- package/dist/utils/styles.js +2 -5
- package/dist/utils/styles.js.map +1 -1
- package/dist/utils/typography.d.ts +21 -10
- package/dist/utils/typography.js +10 -2
- package/dist/utils/typography.js.map +1 -1
- package/dist/utils/warnings.js +1 -1
- package/dist/zero/babel.d.ts +27 -101
- package/dist/zero/babel.js +164 -48
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/css-writer.js +1 -2
- package/dist/zero/css-writer.js.map +1 -1
- package/dist/zero/extractor.js +54 -3
- package/dist/zero/extractor.js.map +1 -1
- package/dist/zero/index.js +1 -2
- package/dist/zero/next.d.ts +12 -0
- package/dist/zero/next.js +5 -4
- package/dist/zero/next.js.map +1 -1
- package/docs/README.md +2 -2
- package/docs/adoption.md +5 -3
- package/docs/comparison.md +24 -25
- package/docs/configuration.md +130 -1
- package/docs/design-system.md +47 -12
- package/docs/dsl.md +115 -9
- package/docs/getting-started.md +10 -10
- package/docs/injector.md +41 -25
- package/docs/methodology.md +119 -6
- package/docs/react-api.md +557 -0
- package/docs/ssr.md +141 -81
- package/docs/styles.md +45 -23
- package/docs/tasty-static.md +103 -2
- package/package.json +20 -9
- package/dist/ssr/context.d.ts +0 -8
- package/dist/styles/align.d.ts +0 -15
- package/dist/styles/align.js +0 -14
- package/dist/styles/align.js.map +0 -1
- package/dist/styles/justify.d.ts +0 -15
- package/dist/styles/justify.js +0 -14
- package/dist/styles/justify.js.map +0 -1
- package/docs/runtime.md +0 -317
package/docs/tasty-static.md
CHANGED
|
@@ -157,12 +157,27 @@ module.exports = {
|
|
|
157
157
|
| Option | Type | Default | Description |
|
|
158
158
|
|--------|------|---------|-------------|
|
|
159
159
|
| `output` | `string` | `'tasty.css'` | Path for generated CSS file |
|
|
160
|
+
| `mode` | `'file' \| 'inject'` | `'file'` | `'file'` writes CSS to disk; `'inject'` embeds CSS inline in JS (see [Inject Mode](#inject-mode)) |
|
|
160
161
|
| `configFile` | `string` | — | Absolute path to a TS/JS module that default-exports a `TastyZeroConfig` object. JSON-serializable alternative to `config` — required for Turbopack. |
|
|
161
162
|
| `config` | `TastyZeroConfig \| () => TastyZeroConfig` | `{}` | Inline config object or factory function. Takes precedence over `configFile`. |
|
|
162
163
|
| `configDeps` | `string[]` | `[]` | Absolute file paths that affect config (for cache invalidation) |
|
|
163
|
-
| `
|
|
164
|
+
| `injectImport` | `boolean` | `true` | Replace `@tenphi/tasty/static` imports with an import of the generated CSS file. Set to `false` to manage CSS imports manually. |
|
|
165
|
+
| `config.states` | `Record<string, string>` | `{}` | Predefined state aliases (e.g. `{ '@mobile': '@media(w < 768px)' }`) |
|
|
164
166
|
| `config.devMode` | `boolean` | `false` | Add source comments to CSS |
|
|
167
|
+
| `config.tokens` | `ConfigTokens` | — | Design tokens injected as CSS custom properties on `:root`. Values are parsed through the Tasty DSL. Supports state maps for responsive/themed tokens. |
|
|
168
|
+
| `config.replaceTokens` | `Record<string, string \| number>` | — | Parse-time token substitution. Keys use `$name` for custom properties and `#name` for color tokens. |
|
|
165
169
|
| `config.recipes` | `Record<string, RecipeStyles>` | `{}` | Predefined style recipes |
|
|
170
|
+
| `config.keyframes` | `Record<string, KeyframesSteps>` | — | Global `@keyframes` definitions available to all `tastyStatic` calls |
|
|
171
|
+
| `config.fontFace` | `Record<string, FontFaceInput>` | — | Global `@font-face` definitions |
|
|
172
|
+
| `config.counterStyle` | `Record<string, CounterStyleDescriptors>` | — | Global `@counter-style` definitions |
|
|
173
|
+
| `config.units` | `Record<string, string \| UnitHandler>` | — | Custom units for the style parser (merged with built-ins). E.g. `{ em: 'em', vw: 'vw' }` |
|
|
174
|
+
| `config.funcs` | `Record<string, Function>` | — | Custom functions for the style parser (merged with existing) |
|
|
175
|
+
| `config.plugins` | `TastyPlugin[]` | — | Plugins that extend tasty with custom functions, units, states, and handlers |
|
|
176
|
+
| `config.handlers` | `Record<string, StyleHandlerDefinition>` | — | Custom style handlers that transform style properties into CSS declarations |
|
|
177
|
+
| `config.presets` | `Record<string, TypographyPreset>` | — | Typography presets — shorthand for `generateTypographyTokens()`. Generated tokens merge under explicit `tokens`. |
|
|
178
|
+
| `config.globalStyles` | `Record<string, Styles>` | — | Global Tasty styles keyed by CSS selector. Supports the full style syntax. |
|
|
179
|
+
| `config.autoPropertyTypes` | `boolean` | `true` | Automatically infer and register CSS `@property` declarations from values |
|
|
180
|
+
| `config.parserCacheSize` | `number` | `1000` | Parser LRU cache size. Larger values improve performance for builds with many unique style values |
|
|
166
181
|
|
|
167
182
|
---
|
|
168
183
|
|
|
@@ -222,6 +237,7 @@ export default withTastyZero({
|
|
|
222
237
|
| Option | Type | Default | Description |
|
|
223
238
|
|--------|------|---------|-------------|
|
|
224
239
|
| `output` | `string` | `'public/tasty.css'` | Output path for CSS relative to project root |
|
|
240
|
+
| `mode` | `'file' \| 'inject'` | `'file'` | `'file'` writes CSS to disk; `'inject'` embeds CSS inline in JS |
|
|
225
241
|
| `enabled` | `boolean` | `true` | Enable/disable the plugin |
|
|
226
242
|
| `configFile` | `string` | — | Path to a TS/JS module that default-exports `TastyZeroConfig`. Recommended for Turbopack compatibility. |
|
|
227
243
|
| `config` | `TastyZeroConfig` | — | Inline config object. For static configs that don't change during dev. |
|
|
@@ -331,6 +347,91 @@ export const Button = () => <button className={button}>Click</button>;
|
|
|
331
347
|
|
|
332
348
|
---
|
|
333
349
|
|
|
350
|
+
## Inject Mode
|
|
351
|
+
|
|
352
|
+
By default the Babel plugin writes CSS to a file (`mode: 'file'`). **Inject mode** (`mode: 'inject'`) embeds CSS inline in your JavaScript and injects it at runtime via a tiny injector. No CSS file is produced.
|
|
353
|
+
|
|
354
|
+
This is ideal for **reusable components**, **extensions**, and **libraries** where consumers shouldn't need to manage an external CSS file.
|
|
355
|
+
|
|
356
|
+
### How It Works
|
|
357
|
+
|
|
358
|
+
1. The Babel plugin extracts CSS at build time (same pipeline as file mode).
|
|
359
|
+
2. Instead of writing to a `.css` file, the CSS is embedded as string literals in the JS output.
|
|
360
|
+
3. The `@tenphi/tasty/static` import is rewritten to `@tenphi/tasty/static/inject`.
|
|
361
|
+
4. Each `tastyStatic` call becomes a self-contained expression that injects its CSS and evaluates to a `StaticStyle` object.
|
|
362
|
+
|
|
363
|
+
### Configuration
|
|
364
|
+
|
|
365
|
+
```javascript
|
|
366
|
+
// babel.config.js
|
|
367
|
+
module.exports = {
|
|
368
|
+
plugins: [
|
|
369
|
+
['@tenphi/tasty/babel-plugin', {
|
|
370
|
+
mode: 'inject',
|
|
371
|
+
config: {
|
|
372
|
+
states: { '@mobile': '@media(w < 768px)' },
|
|
373
|
+
},
|
|
374
|
+
}]
|
|
375
|
+
]
|
|
376
|
+
};
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
With Next.js:
|
|
380
|
+
|
|
381
|
+
```typescript
|
|
382
|
+
// next.config.ts
|
|
383
|
+
import { withTastyZero } from '@tenphi/tasty/next';
|
|
384
|
+
|
|
385
|
+
export default withTastyZero({
|
|
386
|
+
mode: 'inject',
|
|
387
|
+
configFile: './app/tasty-zero.config.ts',
|
|
388
|
+
})({
|
|
389
|
+
reactStrictMode: true,
|
|
390
|
+
});
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
When `mode` is `'inject'`, the `output` and `injectImport` options are ignored.
|
|
394
|
+
|
|
395
|
+
### Build Transformation (inject mode)
|
|
396
|
+
|
|
397
|
+
**Before:**
|
|
398
|
+
|
|
399
|
+
```tsx
|
|
400
|
+
import { tastyStatic } from '@tenphi/tasty/static';
|
|
401
|
+
|
|
402
|
+
const button = tastyStatic({
|
|
403
|
+
padding: '2x 4x',
|
|
404
|
+
fill: '#purple',
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
tastyStatic('.heading', { preset: 'h1' });
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
**After:**
|
|
411
|
+
|
|
412
|
+
```tsx
|
|
413
|
+
import { injectCSS as _$i } from '@tenphi/tasty/static/inject';
|
|
414
|
+
|
|
415
|
+
const button = (_$i("ts3f2a1b ts8c4d2e", ".ts3f2a1b.ts3f2a1b{padding:16px 32px}\n.ts8c4d2e.ts8c4d2e{background:#9370db}"), {
|
|
416
|
+
className: 'ts3f2a1b ts8c4d2e',
|
|
417
|
+
styles: { padding: '2x 4x', fill: '#purple' },
|
|
418
|
+
toString() { return this.className; }
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
_$i(".heading", ".heading{font-size:2.5rem;font-weight:700;line-height:1.2}");
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
### Dev Mode / HMR
|
|
425
|
+
|
|
426
|
+
Class names are content-hashed (`ts` + MD5). When styles change, a new hash produces a new `_$i` call that injects fresh CSS. The injector deduplicates by id, so unchanged styles are skipped. Old CSS stays in the DOM but is harmless since no elements reference those class names.
|
|
427
|
+
|
|
428
|
+
### Limitations (inject mode)
|
|
429
|
+
|
|
430
|
+
- **Client-side only** — Styles are injected via the DOM, so they are not available during SSR. For server-rendered apps, use `mode: 'file'` or the runtime `tasty()`.
|
|
431
|
+
- **Larger JS bundle** — CSS is embedded in JavaScript, increasing bundle size. Best suited for components and extensions, not full-app styling.
|
|
432
|
+
|
|
433
|
+
---
|
|
434
|
+
|
|
334
435
|
## Style Extension
|
|
335
436
|
|
|
336
437
|
```tsx
|
|
@@ -427,5 +528,5 @@ const card = tastyStatic({
|
|
|
427
528
|
|
|
428
529
|
- [Docs Hub](README.md) — Choose the right guide by task or rendering mode
|
|
429
530
|
- [Style DSL](dsl.md) — State maps, tokens, units, extending semantics (shared by runtime and static)
|
|
430
|
-
- [
|
|
531
|
+
- [React API](react-api.md) — Runtime styling: `tasty()` factory, component props, variants, sub-elements, style functions
|
|
431
532
|
- [Configuration](configuration.md) — Global configuration: tokens, recipes, custom units, and style handlers
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tenphi/tasty",
|
|
3
|
-
"version": "0.0.0-snapshot.
|
|
3
|
+
"version": "0.0.0-snapshot.efb24cc",
|
|
4
4
|
"description": "A design-system-integrated styling system and DSL for concise, state-aware UI styling",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -17,6 +17,11 @@
|
|
|
17
17
|
"import": "./dist/static/index.js",
|
|
18
18
|
"default": "./dist/static/index.js"
|
|
19
19
|
},
|
|
20
|
+
"./static/inject": {
|
|
21
|
+
"types": "./dist/static/inject.d.ts",
|
|
22
|
+
"import": "./dist/static/inject.js",
|
|
23
|
+
"default": "./dist/static/inject.js"
|
|
24
|
+
},
|
|
20
25
|
"./babel-plugin": {
|
|
21
26
|
"types": "./dist/zero/babel.d.ts",
|
|
22
27
|
"import": "./dist/zero/babel.js",
|
|
@@ -52,6 +57,11 @@
|
|
|
52
57
|
"import": "./dist/ssr/astro.js",
|
|
53
58
|
"default": "./dist/ssr/astro.js"
|
|
54
59
|
},
|
|
60
|
+
"./ssr/astro-client": {
|
|
61
|
+
"types": "./dist/ssr/astro-client.d.ts",
|
|
62
|
+
"import": "./dist/ssr/astro-client.js",
|
|
63
|
+
"default": "./dist/ssr/astro-client.js"
|
|
64
|
+
},
|
|
55
65
|
"./tasty.config": "./tasty.config.ts"
|
|
56
66
|
},
|
|
57
67
|
"files": [
|
|
@@ -62,7 +72,8 @@
|
|
|
62
72
|
"sideEffects": [
|
|
63
73
|
"./dist/ssr/index.js",
|
|
64
74
|
"./dist/ssr/next.js",
|
|
65
|
-
"./dist/ssr/astro.js"
|
|
75
|
+
"./dist/ssr/astro.js",
|
|
76
|
+
"./dist/ssr/astro-client.js"
|
|
66
77
|
],
|
|
67
78
|
"engines": {
|
|
68
79
|
"node": ">=20"
|
|
@@ -136,7 +147,7 @@
|
|
|
136
147
|
},
|
|
137
148
|
"devDependencies": {
|
|
138
149
|
"@babel/core": "^7.24.0",
|
|
139
|
-
"@changesets/changelog-github": "^0.
|
|
150
|
+
"@changesets/changelog-github": "^0.6.0",
|
|
140
151
|
"@changesets/cli": "^2.29.8",
|
|
141
152
|
"@eslint/js": "^10.0.1",
|
|
142
153
|
"@size-limit/esbuild": "^12.0.0",
|
|
@@ -150,11 +161,11 @@
|
|
|
150
161
|
"@vitest/runner": "^4.0.18",
|
|
151
162
|
"eslint": "^10.0.0",
|
|
152
163
|
"eslint-config-prettier": "^10.1.8",
|
|
153
|
-
"jsdom": "^
|
|
164
|
+
"jsdom": "^29.0.1",
|
|
154
165
|
"prettier": "^3.8.1",
|
|
155
166
|
"react": "^19.0.0",
|
|
156
167
|
"size-limit": "^12.0.0",
|
|
157
|
-
"tsdown": "^0.
|
|
168
|
+
"tsdown": "^0.21.7",
|
|
158
169
|
"typescript": "^5.9.3",
|
|
159
170
|
"typescript-eslint": "^8.56.0",
|
|
160
171
|
"vitest": "^4.0.18"
|
|
@@ -170,13 +181,13 @@
|
|
|
170
181
|
"name": "main (import *)",
|
|
171
182
|
"path": "dist/index.js",
|
|
172
183
|
"import": "*",
|
|
173
|
-
"limit": "
|
|
184
|
+
"limit": "50 kB"
|
|
174
185
|
},
|
|
175
186
|
{
|
|
176
187
|
"name": "core (import *)",
|
|
177
188
|
"path": "dist/core/index.js",
|
|
178
189
|
"import": "*",
|
|
179
|
-
"limit": "
|
|
190
|
+
"limit": "47.5 kB"
|
|
180
191
|
},
|
|
181
192
|
{
|
|
182
193
|
"name": "static",
|
|
@@ -193,7 +204,7 @@
|
|
|
193
204
|
"path",
|
|
194
205
|
"crypto"
|
|
195
206
|
],
|
|
196
|
-
"limit": "
|
|
207
|
+
"limit": "29.5 kB"
|
|
197
208
|
},
|
|
198
209
|
{
|
|
199
210
|
"name": "babel-plugin",
|
|
@@ -204,7 +215,7 @@
|
|
|
204
215
|
"path",
|
|
205
216
|
"crypto"
|
|
206
217
|
],
|
|
207
|
-
"limit": "
|
|
218
|
+
"limit": "43.5 kB"
|
|
208
219
|
}
|
|
209
220
|
]
|
|
210
221
|
}
|
package/dist/ssr/context.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ServerStyleCollector } from "./collector.js";
|
|
2
|
-
import * as react from "react";
|
|
3
|
-
|
|
4
|
-
//#region src/ssr/context.d.ts
|
|
5
|
-
declare const TastySSRContext: react.Context<ServerStyleCollector | null>;
|
|
6
|
-
//#endregion
|
|
7
|
-
export { TastySSRContext };
|
|
8
|
-
//# sourceMappingURL=context.d.ts.map
|
package/dist/styles/align.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
//#region src/styles/align.d.ts
|
|
2
|
-
declare function alignStyle({
|
|
3
|
-
align
|
|
4
|
-
}: {
|
|
5
|
-
align?: string;
|
|
6
|
-
}): {
|
|
7
|
-
'align-items': string;
|
|
8
|
-
'align-content': string;
|
|
9
|
-
} | undefined;
|
|
10
|
-
declare namespace alignStyle {
|
|
11
|
-
var __lookupStyles: string[];
|
|
12
|
-
}
|
|
13
|
-
//#endregion
|
|
14
|
-
export { alignStyle };
|
|
15
|
-
//# sourceMappingURL=align.d.ts.map
|
package/dist/styles/align.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
//#region src/styles/align.ts
|
|
2
|
-
function alignStyle({ align }) {
|
|
3
|
-
if (typeof align !== "string") return;
|
|
4
|
-
if (!align) return;
|
|
5
|
-
return {
|
|
6
|
-
"align-items": align,
|
|
7
|
-
"align-content": align
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
alignStyle.__lookupStyles = ["align"];
|
|
11
|
-
|
|
12
|
-
//#endregion
|
|
13
|
-
export { alignStyle };
|
|
14
|
-
//# sourceMappingURL=align.js.map
|
package/dist/styles/align.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"align.js","names":[],"sources":["../../src/styles/align.ts"],"sourcesContent":["export function alignStyle({ align }: { align?: string }) {\n if (typeof align !== 'string') return;\n\n if (!align) return;\n\n return {\n 'align-items': align,\n 'align-content': align,\n };\n}\n\nalignStyle.__lookupStyles = ['align'];\n"],"mappings":";AAAA,SAAgB,WAAW,EAAE,SAA6B;AACxD,KAAI,OAAO,UAAU,SAAU;AAE/B,KAAI,CAAC,MAAO;AAEZ,QAAO;EACL,eAAe;EACf,iBAAiB;EAClB;;AAGH,WAAW,iBAAiB,CAAC,QAAQ"}
|
package/dist/styles/justify.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
//#region src/styles/justify.d.ts
|
|
2
|
-
declare function justifyStyle({
|
|
3
|
-
justify
|
|
4
|
-
}: {
|
|
5
|
-
justify?: string;
|
|
6
|
-
}): {
|
|
7
|
-
'justify-items': string;
|
|
8
|
-
'justify-content': string;
|
|
9
|
-
} | undefined;
|
|
10
|
-
declare namespace justifyStyle {
|
|
11
|
-
var __lookupStyles: string[];
|
|
12
|
-
}
|
|
13
|
-
//#endregion
|
|
14
|
-
export { justifyStyle };
|
|
15
|
-
//# sourceMappingURL=justify.d.ts.map
|
package/dist/styles/justify.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
//#region src/styles/justify.ts
|
|
2
|
-
function justifyStyle({ justify }) {
|
|
3
|
-
if (typeof justify !== "string") return;
|
|
4
|
-
if (!justify) return;
|
|
5
|
-
return {
|
|
6
|
-
"justify-items": justify,
|
|
7
|
-
"justify-content": justify
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
justifyStyle.__lookupStyles = ["justify"];
|
|
11
|
-
|
|
12
|
-
//#endregion
|
|
13
|
-
export { justifyStyle };
|
|
14
|
-
//# sourceMappingURL=justify.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"justify.js","names":[],"sources":["../../src/styles/justify.ts"],"sourcesContent":["export function justifyStyle({ justify }: { justify?: string }) {\n if (typeof justify !== 'string') return;\n\n if (!justify) return;\n\n return {\n 'justify-items': justify,\n 'justify-content': justify,\n };\n}\n\njustifyStyle.__lookupStyles = ['justify'];\n"],"mappings":";AAAA,SAAgB,aAAa,EAAE,WAAiC;AAC9D,KAAI,OAAO,YAAY,SAAU;AAEjC,KAAI,CAAC,QAAS;AAEd,QAAO;EACL,iBAAiB;EACjB,mBAAmB;EACpB;;AAGH,aAAa,iBAAiB,CAAC,UAAU"}
|
package/docs/runtime.md
DELETED
|
@@ -1,317 +0,0 @@
|
|
|
1
|
-
# Runtime API
|
|
2
|
-
|
|
3
|
-
The React-specific `tasty()` component factory, component props, and hooks. For the shared style language (state maps, tokens, units, extending semantics), see [Style DSL](dsl.md). For global configuration, see [Configuration](configuration.md). For the broader docs map, see the [Docs Hub](README.md).
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Component Creation
|
|
8
|
-
|
|
9
|
-
### Create a new component
|
|
10
|
-
|
|
11
|
-
```jsx
|
|
12
|
-
import { tasty } from '@tenphi/tasty';
|
|
13
|
-
|
|
14
|
-
const Card = tasty({
|
|
15
|
-
as: 'div',
|
|
16
|
-
styles: {
|
|
17
|
-
padding: '4x',
|
|
18
|
-
fill: '#white',
|
|
19
|
-
border: true,
|
|
20
|
-
radius: true,
|
|
21
|
-
},
|
|
22
|
-
styleProps: ['padding', 'fill'],
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
<Card>Hello World</Card>
|
|
26
|
-
<Card padding="6x" fill="#gray.05">Custom Card</Card>
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
### Extend an existing component
|
|
30
|
-
|
|
31
|
-
```jsx
|
|
32
|
-
const PrimaryButton = tasty(Button, {
|
|
33
|
-
styles: {
|
|
34
|
-
fill: '#purple',
|
|
35
|
-
color: '#white',
|
|
36
|
-
padding: '2x 4x',
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
Style maps merge intelligently — see [Style DSL — Extending vs. Replacing State Maps](dsl.md#extending-vs-replacing-state-maps) for extend mode, replace mode, `@inherit`, `null`, and `false` tombstones.
|
|
42
|
-
|
|
43
|
-
---
|
|
44
|
-
|
|
45
|
-
## Style Props
|
|
46
|
-
|
|
47
|
-
Use `styleProps` to expose style properties as direct component props:
|
|
48
|
-
|
|
49
|
-
```jsx
|
|
50
|
-
const FlexibleBox = tasty({
|
|
51
|
-
as: 'div',
|
|
52
|
-
styles: {
|
|
53
|
-
display: 'flex',
|
|
54
|
-
padding: '2x',
|
|
55
|
-
},
|
|
56
|
-
styleProps: ['gap', 'align', 'placeContent', 'fill'],
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
<FlexibleBox gap="2x" align="center" fill="#surface">
|
|
60
|
-
Content
|
|
61
|
-
</FlexibleBox>
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
Style props accept state maps, so responsive values work through the same API:
|
|
65
|
-
|
|
66
|
-
```jsx
|
|
67
|
-
<FlexibleBox
|
|
68
|
-
gap={{ '': '2x', '@tablet': '4x' }}
|
|
69
|
-
fill={{ '': '#surface', '@dark': '#surface-dark' }}
|
|
70
|
-
>
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
For predefined style prop lists (`FLOW_STYLES`, `POSITION_STYLES`, `DIMENSION_STYLES`, etc.) and guidance on which props to expose per component category, see [Methodology — styleProps as the public API](methodology.md#styleprops-as-the-public-api).
|
|
74
|
-
|
|
75
|
-
---
|
|
76
|
-
|
|
77
|
-
## Variants
|
|
78
|
-
|
|
79
|
-
Define named style variations. Only CSS for variants actually used at runtime is injected:
|
|
80
|
-
|
|
81
|
-
```jsx
|
|
82
|
-
const Button = tasty({
|
|
83
|
-
styles: {
|
|
84
|
-
padding: '2x 4x',
|
|
85
|
-
border: true,
|
|
86
|
-
},
|
|
87
|
-
variants: {
|
|
88
|
-
default: { fill: '#blue', color: '#white' },
|
|
89
|
-
danger: { fill: '#red', color: '#white' },
|
|
90
|
-
outline: { fill: 'transparent', color: '#blue', border: '1bw solid #blue' },
|
|
91
|
-
},
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
<Button variant="danger">Delete</Button>
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
### Extending Variants with Base State Maps
|
|
98
|
-
|
|
99
|
-
When base `styles` contain an extend-mode state map (an object **without** a `''` key), it is applied **after** the variant merge. This lets you add or override states across all variants without repeating yourself:
|
|
100
|
-
|
|
101
|
-
```jsx
|
|
102
|
-
const Badge = tasty({
|
|
103
|
-
styles: {
|
|
104
|
-
padding: '1x 2x',
|
|
105
|
-
border: {
|
|
106
|
-
'type=primary': '#clear',
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
variants: {
|
|
110
|
-
primary: {
|
|
111
|
-
border: { '': '#white.2', pressed: '#primary-text', disabled: '#clear' },
|
|
112
|
-
fill: { '': '#white #primary', hovered: '#white #primary-text' },
|
|
113
|
-
},
|
|
114
|
-
secondary: {
|
|
115
|
-
border: { '': '#primary.15', pressed: '#primary.3' },
|
|
116
|
-
fill: '#primary.10',
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
// Both variants get 'type=primary': '#clear' appended to their border map
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
Properties that are **not** extend-mode (simple values, state maps with `''`, `null`, `false`, selectors, sub-elements) merge with variants as before — the variant can fully replace them.
|
|
125
|
-
|
|
126
|
-
---
|
|
127
|
-
|
|
128
|
-
## Sub-element Styling
|
|
129
|
-
|
|
130
|
-
Sub-elements are inner parts of a compound component, styled via capitalized keys in `styles` and identified by `data-element` attributes in the DOM.
|
|
131
|
-
|
|
132
|
-
> Use the `elements` prop to declare sub-element components. This gives you typed, reusable sub-components (`Card.Title`, `Card.Content`) instead of manually writing `data-element` attributes.
|
|
133
|
-
|
|
134
|
-
```jsx
|
|
135
|
-
const Card = tasty({
|
|
136
|
-
styles: {
|
|
137
|
-
padding: '4x',
|
|
138
|
-
Title: { preset: 'h3', color: '#primary' },
|
|
139
|
-
Content: { color: '#text' },
|
|
140
|
-
},
|
|
141
|
-
elements: {
|
|
142
|
-
Title: 'h3',
|
|
143
|
-
Content: 'div',
|
|
144
|
-
},
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
<Card>
|
|
148
|
-
<Card.Title>Card Title</Card.Title>
|
|
149
|
-
<Card.Content>Card content</Card.Content>
|
|
150
|
-
</Card>
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
Each entry in `elements` can be a tag name string or a config object:
|
|
154
|
-
|
|
155
|
-
```jsx
|
|
156
|
-
elements: {
|
|
157
|
-
Title: 'h3', // shorthand: tag name only
|
|
158
|
-
Icon: { as: 'span', qa: 'card-icon' }, // full form: tag + QA attribute
|
|
159
|
-
}
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
The sub-components produced by `elements` support `mods`, `tokens`, `isDisabled`, `isHidden`, and `isChecked` props — the same modifier interface as the root component.
|
|
163
|
-
|
|
164
|
-
If you don't need sub-components (e.g., the inner elements are already rendered by a third-party library), you can still style them by key alone — just omit `elements` and apply `data-element` manually:
|
|
165
|
-
|
|
166
|
-
```jsx
|
|
167
|
-
const Card = tasty({
|
|
168
|
-
styles: {
|
|
169
|
-
padding: '4x',
|
|
170
|
-
Title: { preset: 'h3', color: '#primary' },
|
|
171
|
-
},
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
<Card>
|
|
175
|
-
<div data-element="Title">Card Title</div>
|
|
176
|
-
</Card>
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
### Selector Affix (`$`)
|
|
180
|
-
|
|
181
|
-
The `$` property inside a sub-element's styles controls how its selector attaches to the root selector — combinators, HTML tags, pseudo-elements, the `@` placeholder, and more. For the full reference table and injection rules, see [DSL — Selector Affix](dsl.md#selector-affix-).
|
|
182
|
-
|
|
183
|
-
For the mental model behind sub-elements — how they share root state context and how this differs from BEM — see [Methodology — Component architecture](methodology.md#component-architecture-root--sub-elements).
|
|
184
|
-
|
|
185
|
-
---
|
|
186
|
-
|
|
187
|
-
## Hooks
|
|
188
|
-
|
|
189
|
-
### useStyles
|
|
190
|
-
|
|
191
|
-
Generate a className from a style object:
|
|
192
|
-
|
|
193
|
-
```tsx
|
|
194
|
-
import { useStyles } from '@tenphi/tasty';
|
|
195
|
-
|
|
196
|
-
function MyComponent() {
|
|
197
|
-
const { className } = useStyles({
|
|
198
|
-
padding: '2x',
|
|
199
|
-
fill: '#surface',
|
|
200
|
-
radius: '1r',
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
return <div className={className}>Styled content</div>;
|
|
204
|
-
}
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
### useGlobalStyles
|
|
208
|
-
|
|
209
|
-
Inject global styles for a CSS selector:
|
|
210
|
-
|
|
211
|
-
```tsx
|
|
212
|
-
import { useGlobalStyles } from '@tenphi/tasty';
|
|
213
|
-
|
|
214
|
-
function ThemeStyles() {
|
|
215
|
-
useGlobalStyles('.card', {
|
|
216
|
-
padding: '4x',
|
|
217
|
-
fill: '#surface',
|
|
218
|
-
radius: '1r',
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
return null;
|
|
222
|
-
}
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
### useRawCSS
|
|
226
|
-
|
|
227
|
-
Inject raw CSS strings:
|
|
228
|
-
|
|
229
|
-
```tsx
|
|
230
|
-
import { useRawCSS } from '@tenphi/tasty';
|
|
231
|
-
|
|
232
|
-
function GlobalReset() {
|
|
233
|
-
useRawCSS(`
|
|
234
|
-
body { margin: 0; padding: 0; }
|
|
235
|
-
`);
|
|
236
|
-
|
|
237
|
-
return null;
|
|
238
|
-
}
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
### useKeyframes
|
|
242
|
-
|
|
243
|
-
Inject `@keyframes` rules and return the generated animation name:
|
|
244
|
-
|
|
245
|
-
```tsx
|
|
246
|
-
import { useKeyframes } from '@tenphi/tasty';
|
|
247
|
-
|
|
248
|
-
function Spinner() {
|
|
249
|
-
const spin = useKeyframes(
|
|
250
|
-
{
|
|
251
|
-
from: { transform: 'rotate(0deg)' },
|
|
252
|
-
to: { transform: 'rotate(360deg)' },
|
|
253
|
-
},
|
|
254
|
-
{ name: 'spin' }
|
|
255
|
-
);
|
|
256
|
-
|
|
257
|
-
return <div style={{ animation: `${spin} 1s linear infinite` }} />;
|
|
258
|
-
}
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
`useKeyframes()` also supports a factory function with dependencies:
|
|
262
|
-
|
|
263
|
-
```tsx
|
|
264
|
-
function Pulse({ scale }: { scale: number }) {
|
|
265
|
-
const pulse = useKeyframes(
|
|
266
|
-
() => ({
|
|
267
|
-
'0%': { transform: 'scale(1)' },
|
|
268
|
-
'100%': { transform: `scale(${scale})` },
|
|
269
|
-
}),
|
|
270
|
-
[scale]
|
|
271
|
-
);
|
|
272
|
-
|
|
273
|
-
return <div style={{ animation: `${pulse} 500ms ease-in-out alternate infinite` }} />;
|
|
274
|
-
}
|
|
275
|
-
```
|
|
276
|
-
|
|
277
|
-
### useProperty
|
|
278
|
-
|
|
279
|
-
Register a CSS `@property` rule so a custom property can animate smoothly:
|
|
280
|
-
|
|
281
|
-
```tsx
|
|
282
|
-
import { useProperty } from '@tenphi/tasty';
|
|
283
|
-
|
|
284
|
-
function Spinner() {
|
|
285
|
-
useProperty('$rotation', {
|
|
286
|
-
syntax: '<angle>',
|
|
287
|
-
inherits: false,
|
|
288
|
-
initialValue: '0deg',
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
return <div style={{ transform: 'rotate(var(--rotation))' }} />;
|
|
292
|
-
}
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
`useProperty()` accepts Tasty token syntax for the property name:
|
|
296
|
-
|
|
297
|
-
- `$name` defines `--name`
|
|
298
|
-
- `#name` defines `--name-color` and auto-infers `<color>`
|
|
299
|
-
- `--name` is also supported for existing CSS variables
|
|
300
|
-
|
|
301
|
-
### Troubleshooting
|
|
302
|
-
|
|
303
|
-
- Styles are not updating: make sure `configure()` runs before first render, and verify the generated class name or global rule with [Debug Utilities](debug.md).
|
|
304
|
-
- SSR output looks wrong: check the [SSR guide](ssr.md) because the hooks integrate with SSR collectors differently than the client-only runtime path.
|
|
305
|
-
- Animation/custom property issues: prefer `useKeyframes()` and `useProperty()` over raw CSS when you want Tasty to manage injection and SSR collection for you.
|
|
306
|
-
|
|
307
|
-
---
|
|
308
|
-
|
|
309
|
-
## Learn more
|
|
310
|
-
|
|
311
|
-
- **[Style DSL](dsl.md)** — State maps, tokens, units, extending semantics, keyframes, @property
|
|
312
|
-
- **[Methodology](methodology.md)** — Recommended patterns: root + sub-elements, styleProps, tokens, wrapping
|
|
313
|
-
- **[Configuration](configuration.md)** — Tokens, recipes, custom units, style handlers, TypeScript extensions
|
|
314
|
-
- **[Style Properties](styles.md)** — Complete reference for all enhanced style properties
|
|
315
|
-
- **[Zero Runtime (tastyStatic)](tasty-static.md)** — Build-time static styling with Babel plugin
|
|
316
|
-
- **[Server-Side Rendering](ssr.md)** — SSR setup for Next.js, Astro, and generic frameworks
|
|
317
|
-
- **[Debug Utilities](debug.md)** — Inspect injected CSS, cache state, and active styles at runtime
|