@tenphi/tasty 0.0.0-snapshot.08a6610
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/LICENSE +21 -0
- package/README.md +666 -0
- package/dist/_virtual/_rolldown/runtime.js +8 -0
- package/dist/chunks/cacheKey.js +70 -0
- package/dist/chunks/cacheKey.js.map +1 -0
- package/dist/chunks/definitions.d.ts +37 -0
- package/dist/chunks/definitions.js +259 -0
- package/dist/chunks/definitions.js.map +1 -0
- package/dist/chunks/renderChunk.js +61 -0
- package/dist/chunks/renderChunk.js.map +1 -0
- package/dist/config.d.ts +311 -0
- package/dist/config.js +458 -0
- package/dist/config.js.map +1 -0
- package/dist/core/index.d.ts +32 -0
- package/dist/core/index.js +26 -0
- package/dist/debug.d.ts +204 -0
- package/dist/debug.js +733 -0
- package/dist/debug.js.map +1 -0
- package/dist/hooks/useGlobalStyles.d.ts +30 -0
- package/dist/hooks/useGlobalStyles.js +83 -0
- package/dist/hooks/useGlobalStyles.js.map +1 -0
- package/dist/hooks/useKeyframes.d.ts +56 -0
- package/dist/hooks/useKeyframes.js +69 -0
- package/dist/hooks/useKeyframes.js.map +1 -0
- package/dist/hooks/useProperty.d.ts +79 -0
- package/dist/hooks/useProperty.js +114 -0
- package/dist/hooks/useProperty.js.map +1 -0
- package/dist/hooks/useRawCSS.d.ts +53 -0
- package/dist/hooks/useRawCSS.js +40 -0
- package/dist/hooks/useRawCSS.js.map +1 -0
- package/dist/hooks/useStyles.d.ts +45 -0
- package/dist/hooks/useStyles.js +248 -0
- package/dist/hooks/useStyles.js.map +1 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +33 -0
- package/dist/injector/index.d.ts +165 -0
- package/dist/injector/index.js +162 -0
- package/dist/injector/index.js.map +1 -0
- package/dist/injector/injector.d.ts +148 -0
- package/dist/injector/injector.js +430 -0
- package/dist/injector/injector.js.map +1 -0
- package/dist/injector/sheet-manager.d.ts +136 -0
- package/dist/injector/sheet-manager.js +729 -0
- package/dist/injector/sheet-manager.js.map +1 -0
- package/dist/injector/types.d.ts +144 -0
- package/dist/keyframes/index.js +206 -0
- package/dist/keyframes/index.js.map +1 -0
- package/dist/parser/classify.js +319 -0
- package/dist/parser/classify.js.map +1 -0
- package/dist/parser/const.js +33 -0
- package/dist/parser/const.js.map +1 -0
- package/dist/parser/lru.js +109 -0
- package/dist/parser/lru.js.map +1 -0
- package/dist/parser/parser.d.ts +25 -0
- package/dist/parser/parser.js +116 -0
- package/dist/parser/parser.js.map +1 -0
- package/dist/parser/tokenizer.js +69 -0
- package/dist/parser/tokenizer.js.map +1 -0
- package/dist/parser/types.d.ts +51 -0
- package/dist/parser/types.js +46 -0
- package/dist/parser/types.js.map +1 -0
- package/dist/pipeline/conditions.d.ts +134 -0
- package/dist/pipeline/conditions.js +406 -0
- package/dist/pipeline/conditions.js.map +1 -0
- package/dist/pipeline/exclusive.js +231 -0
- package/dist/pipeline/exclusive.js.map +1 -0
- package/dist/pipeline/index.d.ts +53 -0
- package/dist/pipeline/index.js +660 -0
- package/dist/pipeline/index.js.map +1 -0
- package/dist/pipeline/materialize.js +856 -0
- package/dist/pipeline/materialize.js.map +1 -0
- package/dist/pipeline/parseStateKey.d.ts +15 -0
- package/dist/pipeline/parseStateKey.js +451 -0
- package/dist/pipeline/parseStateKey.js.map +1 -0
- package/dist/pipeline/simplify.js +516 -0
- package/dist/pipeline/simplify.js.map +1 -0
- package/dist/pipeline/warnings.js +18 -0
- package/dist/pipeline/warnings.js.map +1 -0
- package/dist/plugins/okhsl-plugin.d.ts +35 -0
- package/dist/plugins/okhsl-plugin.js +371 -0
- package/dist/plugins/okhsl-plugin.js.map +1 -0
- package/dist/plugins/types.d.ts +76 -0
- package/dist/properties/index.js +236 -0
- package/dist/properties/index.js.map +1 -0
- package/dist/properties/property-type-resolver.d.ts +24 -0
- package/dist/properties/property-type-resolver.js +91 -0
- package/dist/properties/property-type-resolver.js.map +1 -0
- package/dist/ssr/astro.d.ts +29 -0
- package/dist/ssr/astro.js +65 -0
- package/dist/ssr/astro.js.map +1 -0
- package/dist/ssr/async-storage.d.ts +17 -0
- package/dist/ssr/async-storage.js +35 -0
- package/dist/ssr/async-storage.js.map +1 -0
- package/dist/ssr/collect-auto-properties.js +40 -0
- package/dist/ssr/collect-auto-properties.js.map +1 -0
- package/dist/ssr/collector.d.ts +85 -0
- package/dist/ssr/collector.js +183 -0
- package/dist/ssr/collector.js.map +1 -0
- package/dist/ssr/context.d.ts +8 -0
- package/dist/ssr/context.js +14 -0
- package/dist/ssr/context.js.map +1 -0
- package/dist/ssr/format-global-rules.js +22 -0
- package/dist/ssr/format-global-rules.js.map +1 -0
- package/dist/ssr/format-keyframes.js +70 -0
- package/dist/ssr/format-keyframes.js.map +1 -0
- package/dist/ssr/format-property.js +48 -0
- package/dist/ssr/format-property.js.map +1 -0
- package/dist/ssr/format-rules.js +70 -0
- package/dist/ssr/format-rules.js.map +1 -0
- package/dist/ssr/hydrate.d.ts +22 -0
- package/dist/ssr/hydrate.js +50 -0
- package/dist/ssr/hydrate.js.map +1 -0
- package/dist/ssr/index.d.ts +5 -0
- package/dist/ssr/index.js +12 -0
- package/dist/ssr/index.js.map +1 -0
- package/dist/ssr/next.d.ts +45 -0
- package/dist/ssr/next.js +71 -0
- package/dist/ssr/next.js.map +1 -0
- package/dist/ssr/ssr-collector-ref.js +12 -0
- package/dist/ssr/ssr-collector-ref.js.map +1 -0
- package/dist/states/index.d.ts +49 -0
- package/dist/states/index.js +416 -0
- package/dist/states/index.js.map +1 -0
- package/dist/static/index.d.ts +5 -0
- package/dist/static/index.js +5 -0
- package/dist/static/tastyStatic.d.ts +46 -0
- package/dist/static/tastyStatic.js +31 -0
- package/dist/static/tastyStatic.js.map +1 -0
- package/dist/static/types.d.ts +49 -0
- package/dist/static/types.js +24 -0
- package/dist/static/types.js.map +1 -0
- package/dist/styles/align.d.ts +15 -0
- package/dist/styles/align.js +14 -0
- package/dist/styles/align.js.map +1 -0
- package/dist/styles/border.d.ts +25 -0
- package/dist/styles/border.js +114 -0
- package/dist/styles/border.js.map +1 -0
- package/dist/styles/color.d.ts +14 -0
- package/dist/styles/color.js +23 -0
- package/dist/styles/color.js.map +1 -0
- package/dist/styles/createStyle.js +77 -0
- package/dist/styles/createStyle.js.map +1 -0
- package/dist/styles/dimension.js +97 -0
- package/dist/styles/dimension.js.map +1 -0
- package/dist/styles/display.d.ts +37 -0
- package/dist/styles/display.js +67 -0
- package/dist/styles/display.js.map +1 -0
- package/dist/styles/fade.d.ts +15 -0
- package/dist/styles/fade.js +58 -0
- package/dist/styles/fade.js.map +1 -0
- package/dist/styles/fill.d.ts +42 -0
- package/dist/styles/fill.js +52 -0
- package/dist/styles/fill.js.map +1 -0
- package/dist/styles/flow.d.ts +16 -0
- package/dist/styles/flow.js +12 -0
- package/dist/styles/flow.js.map +1 -0
- package/dist/styles/gap.d.ts +31 -0
- package/dist/styles/gap.js +37 -0
- package/dist/styles/gap.js.map +1 -0
- package/dist/styles/height.d.ts +17 -0
- package/dist/styles/height.js +20 -0
- package/dist/styles/height.js.map +1 -0
- package/dist/styles/index.d.ts +2 -0
- package/dist/styles/index.js +9 -0
- package/dist/styles/index.js.map +1 -0
- package/dist/styles/inset.d.ts +52 -0
- package/dist/styles/inset.js +150 -0
- package/dist/styles/inset.js.map +1 -0
- package/dist/styles/justify.d.ts +15 -0
- package/dist/styles/justify.js +14 -0
- package/dist/styles/justify.js.map +1 -0
- package/dist/styles/list.d.ts +16 -0
- package/dist/styles/list.js +98 -0
- package/dist/styles/list.js.map +1 -0
- package/dist/styles/margin.d.ts +24 -0
- package/dist/styles/margin.js +104 -0
- package/dist/styles/margin.js.map +1 -0
- package/dist/styles/outline.d.ts +29 -0
- package/dist/styles/outline.js +65 -0
- package/dist/styles/outline.js.map +1 -0
- package/dist/styles/padding.d.ts +24 -0
- package/dist/styles/padding.js +104 -0
- package/dist/styles/padding.js.map +1 -0
- package/dist/styles/predefined.d.ts +71 -0
- package/dist/styles/predefined.js +238 -0
- package/dist/styles/predefined.js.map +1 -0
- package/dist/styles/preset.d.ts +47 -0
- package/dist/styles/preset.js +126 -0
- package/dist/styles/preset.js.map +1 -0
- package/dist/styles/radius.d.ts +14 -0
- package/dist/styles/radius.js +51 -0
- package/dist/styles/radius.js.map +1 -0
- package/dist/styles/scrollbar.d.ts +25 -0
- package/dist/styles/scrollbar.js +48 -0
- package/dist/styles/scrollbar.js.map +1 -0
- package/dist/styles/shadow.d.ts +14 -0
- package/dist/styles/shadow.js +24 -0
- package/dist/styles/shadow.js.map +1 -0
- package/dist/styles/transition.d.ts +14 -0
- package/dist/styles/transition.js +158 -0
- package/dist/styles/transition.js.map +1 -0
- package/dist/styles/types.d.ts +508 -0
- package/dist/styles/width.d.ts +17 -0
- package/dist/styles/width.js +20 -0
- package/dist/styles/width.js.map +1 -0
- package/dist/tasty.d.ts +981 -0
- package/dist/tasty.js +206 -0
- package/dist/tasty.js.map +1 -0
- package/dist/types.d.ts +184 -0
- package/dist/utils/cache-wrapper.js +26 -0
- package/dist/utils/cache-wrapper.js.map +1 -0
- package/dist/utils/case-converter.js +8 -0
- package/dist/utils/case-converter.js.map +1 -0
- package/dist/utils/colors.d.ts +5 -0
- package/dist/utils/colors.js +9 -0
- package/dist/utils/colors.js.map +1 -0
- package/dist/utils/css-types.d.ts +7 -0
- package/dist/utils/dotize.d.ts +26 -0
- package/dist/utils/dotize.js +122 -0
- package/dist/utils/dotize.js.map +1 -0
- package/dist/utils/filter-base-props.d.ts +15 -0
- package/dist/utils/filter-base-props.js +45 -0
- package/dist/utils/filter-base-props.js.map +1 -0
- package/dist/utils/get-display-name.d.ts +7 -0
- package/dist/utils/get-display-name.js +10 -0
- package/dist/utils/get-display-name.js.map +1 -0
- package/dist/utils/hsl-to-rgb.js +38 -0
- package/dist/utils/hsl-to-rgb.js.map +1 -0
- package/dist/utils/is-dev-env.js +19 -0
- package/dist/utils/is-dev-env.js.map +1 -0
- package/dist/utils/is-valid-element-type.js +15 -0
- package/dist/utils/is-valid-element-type.js.map +1 -0
- package/dist/utils/merge-styles.d.ts +7 -0
- package/dist/utils/merge-styles.js +146 -0
- package/dist/utils/merge-styles.js.map +1 -0
- package/dist/utils/mod-attrs.d.ts +8 -0
- package/dist/utils/mod-attrs.js +21 -0
- package/dist/utils/mod-attrs.js.map +1 -0
- package/dist/utils/okhsl-to-rgb.js +296 -0
- package/dist/utils/okhsl-to-rgb.js.map +1 -0
- package/dist/utils/process-tokens.d.ts +31 -0
- package/dist/utils/process-tokens.js +171 -0
- package/dist/utils/process-tokens.js.map +1 -0
- package/dist/utils/resolve-recipes.d.ts +17 -0
- package/dist/utils/resolve-recipes.js +147 -0
- package/dist/utils/resolve-recipes.js.map +1 -0
- package/dist/utils/selector-transform.js +32 -0
- package/dist/utils/selector-transform.js.map +1 -0
- package/dist/utils/string.js +8 -0
- package/dist/utils/string.js.map +1 -0
- package/dist/utils/styles.d.ts +177 -0
- package/dist/utils/styles.js +730 -0
- package/dist/utils/styles.js.map +1 -0
- package/dist/utils/typography.d.ts +47 -0
- package/dist/utils/typography.js +43 -0
- package/dist/utils/typography.js.map +1 -0
- package/dist/utils/warnings.d.ts +16 -0
- package/dist/utils/warnings.js +16 -0
- package/dist/utils/warnings.js.map +1 -0
- package/dist/zero/babel.d.ts +147 -0
- package/dist/zero/babel.js +331 -0
- package/dist/zero/babel.js.map +1 -0
- package/dist/zero/css-writer.d.ts +45 -0
- package/dist/zero/css-writer.js +74 -0
- package/dist/zero/css-writer.js.map +1 -0
- package/dist/zero/extractor.d.ts +24 -0
- package/dist/zero/extractor.js +215 -0
- package/dist/zero/extractor.js.map +1 -0
- package/dist/zero/index.d.ts +3 -0
- package/dist/zero/index.js +4 -0
- package/dist/zero/next.d.ts +74 -0
- package/dist/zero/next.js +129 -0
- package/dist/zero/next.js.map +1 -0
- package/docs/adoption.md +286 -0
- package/docs/comparison.md +413 -0
- package/docs/configuration.md +242 -0
- package/docs/debug.md +505 -0
- package/docs/design-system.md +401 -0
- package/docs/dsl.md +540 -0
- package/docs/getting-started.md +201 -0
- package/docs/injector.md +528 -0
- package/docs/methodology.md +501 -0
- package/docs/runtime.md +291 -0
- package/docs/ssr.md +382 -0
- package/docs/styles.md +574 -0
- package/docs/tasty-static.md +421 -0
- package/package.json +209 -0
- package/tasty.config.ts +14 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Andrey Yamanov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,666 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/tasty.svg" width="128" height="128" alt="Tasty logo">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">Tasty</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong>The styling engine built for design systems.</strong><br>
|
|
9
|
+
Deterministic CSS generation. State-aware DSL. Zero specificity conflicts. Ever.
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="https://www.npmjs.com/package/@tenphi/tasty"><img src="https://img.shields.io/npm/v/@tenphi/tasty.svg" alt="npm version"></a>
|
|
14
|
+
<a href="https://github.com/tenphi/tasty/actions/workflows/ci.yml"><img src="https://github.com/tenphi/tasty/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI"></a>
|
|
15
|
+
<a href="https://github.com/tenphi/tasty/blob/main/LICENSE"><img src="https://img.shields.io/github/license/tenphi/tasty" alt="license"></a>
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
Most CSS-in-JS libraries emit rules that compete through cascade and specificity. Tasty emits **mutually exclusive CSS selectors** — for any component state combination, exactly one selector matches each property at a time. No cascade conflicts, no specificity wars, no `!important` escapes. Components compose and extend without breaking each other.
|
|
21
|
+
|
|
22
|
+
That guarantee unlocks a concise, CSS-like DSL where design tokens, custom units, responsive states, container queries, sub-element styling, and theming all compose without surprises — one coherent system that scales from a single component to an enterprise design system.
|
|
23
|
+
|
|
24
|
+
## Why Tasty
|
|
25
|
+
|
|
26
|
+
- **Deterministic at any scale** — Exclusive selector generation eliminates the entire class of cascade/specificity bugs. Every state combination resolves to exactly one CSS rule per property. Refactor freely. See [How It Actually Works](#how-it-actually-works).
|
|
27
|
+
- **AI-friendly by design** — Style definitions are declarative, self-contained, and structurally consistent. AI tools can read, understand, and refactor even advanced state bindings as confidently as a human — because there's no hidden cascade logic or implicit ordering to second-guess.
|
|
28
|
+
- **DSL that feels like CSS** — Property names you already know (`padding`, `color`, `display`) with syntax sugar that removes boilerplate. Learn the DSL in minutes, not days. See [Style Properties](docs/styles.md).
|
|
29
|
+
- **CSS properties as normal component props** — `styleProps` lets you expose selected styles as typed React props. Use `<Button placeSelf="end">` or `<Space flow="row" gap="2x">` without extra wrappers, utility classes, or `styles` overrides. The same props also accept state maps, so responsive values work with the same API. See [CSS properties as props](#css-properties-as-props).
|
|
30
|
+
- **Design-system native** — Color tokens (`#primary`), spacing units (`2x`), typography presets (`h1`, `t2`), border radius (`1r`), and recipes are first-class primitives, not afterthoughts. See [Configuration](docs/configuration.md).
|
|
31
|
+
- **Near-complete modern CSS coverage** — Media queries, container queries, `@supports`, `:has()`, `@starting-style`, `@property`, `@keyframes`, etc. Some features that don't fit Tasty's component model (such as `@layer` and `!important`) are intentionally omitted, but real-world use cases are covered almost completely.
|
|
32
|
+
- **Runtime, zero-runtime, or SSR — your call** — Use `tasty()` for dynamic React components with runtime injection, `tastyStatic()` with the Babel plugin for zero-runtime CSS extraction, or enable SSR with zero-cost client hydration for Next.js, Astro, or any React framework (experimental). Same DSL, same tokens, same output.
|
|
33
|
+
- **Only generate what is used** — In runtime mode, Tasty injects CSS on demand for mounted components/variants, so your app avoids shipping style rules for UI states that are never rendered.
|
|
34
|
+
- **Runtime performance that holds at scale** — The runtime path is tested against enterprise-scale applications and tuned with multi-level caching, chunk-level style reuse, style garbage collection, and a dedicated injector.
|
|
35
|
+
- **Composable and extensible by design** — Extend any component's styles with proper merge semantics, and evolve built-in behavior through configuration and plugins.
|
|
36
|
+
- **TypeScript-first** — Full type definitions, module augmentation for custom properties, and autocomplete for tokens, presets, and themes. See [Configuration](docs/configuration.md).
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pnpm add @tenphi/tasty
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Quick Start
|
|
45
|
+
|
|
46
|
+
### Create a styled component
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
import { tasty } from '@tenphi/tasty';
|
|
50
|
+
|
|
51
|
+
const Card = tasty({
|
|
52
|
+
as: 'div',
|
|
53
|
+
styles: {
|
|
54
|
+
display: 'flex',
|
|
55
|
+
flow: 'column',
|
|
56
|
+
padding: '4x',
|
|
57
|
+
gap: '2x',
|
|
58
|
+
fill: '#surface',
|
|
59
|
+
border: '#border bottom',
|
|
60
|
+
radius: '1r',
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Just a React component
|
|
65
|
+
<Card>Hello World</Card>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Every value maps to CSS you'd recognize — but with tokens and units that keep your design system consistent by default.
|
|
69
|
+
|
|
70
|
+
### Add state-driven styles
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
const Button = tasty({
|
|
74
|
+
as: 'button',
|
|
75
|
+
styles: {
|
|
76
|
+
padding: '1.5x 3x',
|
|
77
|
+
fill: {
|
|
78
|
+
'': '#primary',
|
|
79
|
+
':hover': '#primary-hover',
|
|
80
|
+
':active': '#primary-pressed',
|
|
81
|
+
'[disabled]': '#surface',
|
|
82
|
+
},
|
|
83
|
+
color: {
|
|
84
|
+
'': '#on-primary',
|
|
85
|
+
'[disabled]': '#text.40',
|
|
86
|
+
},
|
|
87
|
+
cursor: {
|
|
88
|
+
'': 'pointer',
|
|
89
|
+
'[disabled]': 'not-allowed',
|
|
90
|
+
},
|
|
91
|
+
transition: 'theme',
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
State keys support pseudo-classes first (`:hover`, `:active`), then modifiers (`theme=danger`), attributes (`[disabled]`), media/container queries, root states, and more. Tasty compiles them into exclusive selectors automatically.
|
|
97
|
+
|
|
98
|
+
### Extend any component
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
import { Button } from 'my-ui-lib';
|
|
102
|
+
|
|
103
|
+
const DangerButton = tasty(Button, {
|
|
104
|
+
styles: {
|
|
105
|
+
fill: {
|
|
106
|
+
'': '#danger',
|
|
107
|
+
':hover': '#danger-hover',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Child styles merge with parent styles intelligently — state maps can extend or replace parent states per-property.
|
|
114
|
+
|
|
115
|
+
### Configure once, use everywhere
|
|
116
|
+
|
|
117
|
+
```tsx
|
|
118
|
+
import { configure } from '@tenphi/tasty';
|
|
119
|
+
|
|
120
|
+
configure({
|
|
121
|
+
states: {
|
|
122
|
+
'@mobile': '@media(w < 768px)',
|
|
123
|
+
'@tablet': '@media(w < 1024px)',
|
|
124
|
+
'@dark': '@root(schema=dark) | (!@root(schema) & @media(prefers-color-scheme: dark))',
|
|
125
|
+
},
|
|
126
|
+
recipes: {
|
|
127
|
+
card: { padding: '4x', fill: '#surface', radius: '1r', border: true },
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Predefined states turn complex selector logic into single tokens. Use `@mobile` instead of writing media query expressions in every component.
|
|
133
|
+
|
|
134
|
+
### CSS properties as props
|
|
135
|
+
|
|
136
|
+
With `styleProps`, a component can expose the styles you choose as normal typed props. That means you can adjust layout, spacing, alignment, or positioning right where the component is used, instead of introducing wrapper elements or reaching for a separate styling API.
|
|
137
|
+
|
|
138
|
+
This is especially good for prototyping and fast UI iteration: you can shape interfaces quickly, while still staying inside a typed, design-system-aware component API that scales to production.
|
|
139
|
+
|
|
140
|
+
```tsx
|
|
141
|
+
import { tasty, FLOW_STYLES, POSITION_STYLES } from '@tenphi/tasty';
|
|
142
|
+
|
|
143
|
+
const Space = tasty({
|
|
144
|
+
styles: {
|
|
145
|
+
display: 'flex',
|
|
146
|
+
flow: 'column',
|
|
147
|
+
gap: '1x',
|
|
148
|
+
},
|
|
149
|
+
styleProps: FLOW_STYLES,
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
const Button = tasty({
|
|
153
|
+
as: 'button',
|
|
154
|
+
styles: {
|
|
155
|
+
padding: '1.5x 3x',
|
|
156
|
+
fill: '#primary',
|
|
157
|
+
color: '#primary-text',
|
|
158
|
+
radius: true,
|
|
159
|
+
},
|
|
160
|
+
styleProps: POSITION_STYLES,
|
|
161
|
+
});
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Now you can compose layout and tweak component positioning directly in JSX:
|
|
165
|
+
|
|
166
|
+
```tsx
|
|
167
|
+
<Space flow="row" gap="2x" placeItems="center">
|
|
168
|
+
<Title>Dashboard</Title>
|
|
169
|
+
<Button placeSelf="end">Add Item</Button>
|
|
170
|
+
</Space>
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
The same props also support state maps, so responsive values use the exact same API:
|
|
174
|
+
|
|
175
|
+
```tsx
|
|
176
|
+
<Space
|
|
177
|
+
flow={{ '': 'column', '@tablet': 'row' }}
|
|
178
|
+
gap={{ '': '2x', '@tablet': '4x' }}
|
|
179
|
+
>
|
|
180
|
+
<Sidebar />
|
|
181
|
+
<Content />
|
|
182
|
+
</Space>
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Layout components can expose flow props. Buttons can expose positioning props. Each component can offer only the style props that make sense for its role, while still keeping tokens, custom units, and state maps fully typed. This works in runtime `tasty()` components, not in `tastyStatic()`.
|
|
186
|
+
|
|
187
|
+
## How It Actually Works
|
|
188
|
+
|
|
189
|
+
This is the core idea that makes everything else possible.
|
|
190
|
+
|
|
191
|
+
Traditional CSS has two structural problems.
|
|
192
|
+
|
|
193
|
+
First, the **cascade** resolves conflicts by specificity and source order: when multiple selectors match, the one with the highest specificity wins, or — if specificity is equal — the last one in source order wins. That makes styles inherently fragile. Reordering imports, adding a media query, or composing components from different libraries can silently break styling.
|
|
194
|
+
|
|
195
|
+
A small example makes this tangible. Two rules for a button's background:
|
|
196
|
+
|
|
197
|
+
```css
|
|
198
|
+
.btn:hover { background: dodgerblue; }
|
|
199
|
+
.btn[disabled] { background: gray; }
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Both selectors have specificity `(0, 1, 1)`. When the button is hovered **and** disabled, both match — and the last rule in source order wins. Swap the two lines and a hovered disabled button silently turns blue instead of gray. This class of bug is invisible in code review because the logic is correct; only the ordering is wrong.
|
|
203
|
+
|
|
204
|
+
Second, **authoring selectors that capture real-world state logic is fundamentally hard.** A single state like "dark mode" may depend on a root attribute, an OS preference, or both — each branch needing its own selector, proper negation of competing branches, and correct `@media` nesting. The example below shows the CSS you'd write by hand for just *one* property with *one* state. Scale that across dozens of properties, then add breakpoints and container queries, and the selector logic quickly becomes unmanageable.
|
|
205
|
+
|
|
206
|
+
Tasty solves both problems at once: **every state mapping compiles into mutually exclusive selectors.**
|
|
207
|
+
|
|
208
|
+
```tsx
|
|
209
|
+
const Text = tasty({
|
|
210
|
+
styles: {
|
|
211
|
+
color: {
|
|
212
|
+
'': '#text',
|
|
213
|
+
'@dark': '#text-on-dark',
|
|
214
|
+
},
|
|
215
|
+
padding: {
|
|
216
|
+
'': '4x',
|
|
217
|
+
'@mobile': '2x',
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
});
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
If `@dark` expands to `@root(schema=dark) | (!@root(schema) & @media(prefers-color-scheme: dark))`, try writing the CSS by hand. A first attempt might look like this:
|
|
224
|
+
|
|
225
|
+
```css
|
|
226
|
+
/* First attempt — the @media branch is too broad */
|
|
227
|
+
.t0 { color: var(--text-color); }
|
|
228
|
+
:root[data-schema="dark"] .t0 { color: var(--text-on-dark-color); }
|
|
229
|
+
@media (prefers-color-scheme: dark) {
|
|
230
|
+
.t0 { color: var(--text-on-dark-color); }
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
The `@media` branch fires even when `data-schema="light"` is explicitly set. Fix that:
|
|
235
|
+
|
|
236
|
+
```css
|
|
237
|
+
/* Second attempt — @media is scoped, but the default is still too broad */
|
|
238
|
+
.t0 { color: var(--text-color); }
|
|
239
|
+
:root[data-schema="dark"] .t0 { color: var(--text-on-dark-color); }
|
|
240
|
+
@media (prefers-color-scheme: dark) {
|
|
241
|
+
:root:not([data-schema]) .t0 { color: var(--text-on-dark-color); }
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
Better — but the bare `.t0` default still matches unconditionally. It matches in dark mode, it matches when `data-schema="dark"` is set, and it can beat the attribute selector by source order if another rule re-declares it later. There is no selector that says "apply this default only when none of the dark branches win."
|
|
246
|
+
|
|
247
|
+
This is just *one* property with *one* state, and getting it right already takes multiple iterations. The correct selectors require negating every other branch — which is exactly what Tasty generates automatically:
|
|
248
|
+
|
|
249
|
+
Tasty generates the correct version automatically:
|
|
250
|
+
|
|
251
|
+
```css
|
|
252
|
+
/* Branch 1: Explicit dark schema */
|
|
253
|
+
:root[data-schema="dark"] .t0.t0 {
|
|
254
|
+
color: var(--text-on-dark-color);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/* Branch 2: No schema attribute + OS prefers dark */
|
|
258
|
+
@media (prefers-color-scheme: dark) {
|
|
259
|
+
:root:not([data-schema]) .t0.t0 {
|
|
260
|
+
color: var(--text-on-dark-color);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/* Default: no schema + OS does not prefer dark */
|
|
265
|
+
@media (not (prefers-color-scheme: dark)) {
|
|
266
|
+
:root:not([data-schema="dark"]) .t0.t0 {
|
|
267
|
+
color: var(--text-color);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/* Default: schema is set but not dark (any OS preference) */
|
|
272
|
+
:root:not([data-schema="dark"])[data-schema] .t0.t0 {
|
|
273
|
+
color: var(--text-color);
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
Every rule is guarded by the negation of higher-priority rules. No two rules can match at the same time. No specificity arithmetic. No source-order dependence. Components compose and extend without collisions.
|
|
278
|
+
|
|
279
|
+
By absorbing selector complexity, Tasty makes advanced CSS patterns practical again — nested container queries, multi-condition `@supports` gates, and combined root-state/media branches. You stay in pure CSS instead of relying on JavaScript workarounds, so the browser can optimize layout, painting, and transitions natively. Tasty doesn't limit CSS; it unlocks its full potential by removing the complexity that held teams back.
|
|
280
|
+
|
|
281
|
+
[Try it in the Tasty Playground →](https://cube-ui-kit.vercel.app/?path=/story/getting-started-tasty-playground--playground)
|
|
282
|
+
|
|
283
|
+
## Capabilities
|
|
284
|
+
|
|
285
|
+
### Design Tokens and Custom Units
|
|
286
|
+
|
|
287
|
+
Tokens are first-class. Colors use `#name` syntax. Spacing, radius, and border width use multiplier units tied to CSS custom properties:
|
|
288
|
+
|
|
289
|
+
```tsx
|
|
290
|
+
fill: '#surface', // → var(--surface-color)
|
|
291
|
+
color: '#text.80', // → 80% opacity text token
|
|
292
|
+
padding: '2x', // → calc(var(--gap) * 2)
|
|
293
|
+
radius: '1r', // → var(--radius)
|
|
294
|
+
border: '1bw solid #border',
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
| Unit | Maps to | Example |
|
|
298
|
+
|------|---------|---------|
|
|
299
|
+
| `x` | `--gap` multiplier | `2x` → `calc(var(--gap) * 2)` |
|
|
300
|
+
| `r` | `--radius` multiplier | `1r` → `var(--radius)` |
|
|
301
|
+
| `bw` | `--border-width` multiplier | `1bw` → `var(--border-width)` |
|
|
302
|
+
| `ow` | `--outline-width` multiplier | `1ow` → `var(--outline-width)` |
|
|
303
|
+
| `cr` | `--card-radius` multiplier | `1cr` → `var(--card-radius)` |
|
|
304
|
+
|
|
305
|
+
Define your own units via `configure({ units: { ... } })`.
|
|
306
|
+
|
|
307
|
+
### State System
|
|
308
|
+
|
|
309
|
+
Every style property accepts a state mapping object. Keys can be combined with boolean logic:
|
|
310
|
+
|
|
311
|
+
| State type | Syntax | CSS output |
|
|
312
|
+
|------------|--------|------------|
|
|
313
|
+
| Data attribute (boolean modifier) | `disabled` | `[data-disabled]` |
|
|
314
|
+
| Data attribute (value modifier) | `theme=danger` | `[data-theme="danger"]` |
|
|
315
|
+
| Pseudo-class | `:hover` | `:hover` |
|
|
316
|
+
| Attribute selector | `[role="tab"]` | `[role="tab"]` |
|
|
317
|
+
| Class selector (supported) | `.is-active` | `.is-active` |
|
|
318
|
+
| Media query | `@media(w < 768px)` | `@media (width < 768px)` |
|
|
319
|
+
| Container query | `@(panel, w >= 300px)` | `@container panel (width >= 300px)` |
|
|
320
|
+
| Root state | `@root(theme=dark)` | `:root[data-theme="dark"]` |
|
|
321
|
+
| Parent state | `@parent(theme=danger)` | `:is([data-theme="danger"] *)` |
|
|
322
|
+
| Feature query | `@supports(display: grid)` | `@supports (display: grid)` |
|
|
323
|
+
| Entry animation | `@starting` | `@starting-style` |
|
|
324
|
+
|
|
325
|
+
Combine with `&` (AND), `|` (OR), `!` (NOT):
|
|
326
|
+
|
|
327
|
+
```tsx
|
|
328
|
+
fill: {
|
|
329
|
+
'': '#surface',
|
|
330
|
+
'theme=danger & :hover': '#danger-hover',
|
|
331
|
+
'[aria-selected="true"]': '#accent-subtle',
|
|
332
|
+
}
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
### Sub-Element Styling
|
|
336
|
+
|
|
337
|
+
Style inner elements from the parent component definition. No extra components, no CSS leakage:
|
|
338
|
+
|
|
339
|
+
```tsx
|
|
340
|
+
const Card = tasty({
|
|
341
|
+
styles: {
|
|
342
|
+
padding: '4x',
|
|
343
|
+
Title: { preset: 'h3', color: '#primary' },
|
|
344
|
+
Content: { color: '#text', preset: 't2' },
|
|
345
|
+
},
|
|
346
|
+
elements: { Title: 'h2', Content: 'div' },
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
<Card>
|
|
350
|
+
<Card.Title>Heading</Card.Title>
|
|
351
|
+
<Card.Content>Body text</Card.Content>
|
|
352
|
+
</Card>
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
Sub-elements use `data-element` attributes — no extra class names, no naming conventions.
|
|
356
|
+
|
|
357
|
+
By default, sub-elements participate in the same state context as the root component. That means mappings like `:hover`, `theme=danger`, `[role="button"]`, and other keys are evaluated as one unified block, which keeps styling logic predictable across the whole markup tree.
|
|
358
|
+
|
|
359
|
+
Use `@own(...)` when a sub-element should react to its own state instead of the root state context.
|
|
360
|
+
|
|
361
|
+
Class selectors are also supported, but modifiers/pseudo-classes are usually the better default in design-system code.
|
|
362
|
+
|
|
363
|
+
Use the sub-element selector `$` when you need precise descendant targeting to avoid leakage in deeply nested component trees.
|
|
364
|
+
|
|
365
|
+
### Variants
|
|
366
|
+
|
|
367
|
+
Variants are designed to keep single-component CSS lean. Instead of generating dozens of static button classes up front, define all versions once and let runtime usage decide what CSS is actually emitted.
|
|
368
|
+
|
|
369
|
+
```tsx
|
|
370
|
+
const Button = tasty({
|
|
371
|
+
styles: { padding: '2x 4x', radius: '1r' },
|
|
372
|
+
variants: {
|
|
373
|
+
default: { fill: '#primary', color: '#on-primary' },
|
|
374
|
+
danger: { fill: '#danger', color: '#on-danger' },
|
|
375
|
+
outline: { fill: 'transparent', border: '1bw solid #primary' },
|
|
376
|
+
},
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
<Button variant="danger">Delete</Button>
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
### Recipes
|
|
383
|
+
|
|
384
|
+
Recipes are predefined style sets that work like composable styling classes for Tasty. They can be pre-applied or post-applied to current styles, which lets you add reusable state logic while still allowing local style overrides.
|
|
385
|
+
|
|
386
|
+
```tsx
|
|
387
|
+
configure({
|
|
388
|
+
recipes: {
|
|
389
|
+
card: { padding: '4x', fill: '#surface', radius: '1r', border: true },
|
|
390
|
+
elevated: { shadow: '0 2x 4x #shadow' },
|
|
391
|
+
},
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
const ProfileCard = tasty({
|
|
395
|
+
styles: {
|
|
396
|
+
recipe: 'card elevated',
|
|
397
|
+
color: '#text',
|
|
398
|
+
},
|
|
399
|
+
});
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
Use `/` to post-apply recipes after local styles when you need recipe states/styles to win the final merge order. Use `none` to skip base recipes: `recipe: 'none / disabled'`.
|
|
403
|
+
|
|
404
|
+
### Auto-Inferred `@property`
|
|
405
|
+
|
|
406
|
+
CSS custom properties do not animate smoothly by default because the browser does not know how to interpolate their values. The [`@property`](https://developer.mozilla.org/en-US/docs/Web/CSS/@property) at-rule fixes that by declaring a property's syntax, such as `<number>` or `<color>`.
|
|
407
|
+
|
|
408
|
+
In Tasty, you usually do not need to declare `@property` manually. When a custom property is assigned a concrete value, Tasty infers the syntax and registers the matching `@property` for you:
|
|
409
|
+
|
|
410
|
+
```tsx
|
|
411
|
+
const Pulse = tasty({
|
|
412
|
+
styles: {
|
|
413
|
+
animation: 'pulse 2s infinite',
|
|
414
|
+
transform: 'scale($pulse-scale)',
|
|
415
|
+
'@keyframes': {
|
|
416
|
+
pulse: {
|
|
417
|
+
'0%, 100%': { '$pulse-scale': 1 },
|
|
418
|
+
'50%': { '$pulse-scale': 1.05 },
|
|
419
|
+
},
|
|
420
|
+
},
|
|
421
|
+
},
|
|
422
|
+
});
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
Here, `$pulse-scale: 1` is inferred as `<number>`, so Tasty injects `@property --pulse-scale` automatically before using it in the animation. Numeric types (`<number>`, `<length>`, `<percentage>`, `<angle>`, `<time>`) are inferred from values; `<color>` is inferred from the `#name` token convention.
|
|
426
|
+
|
|
427
|
+
If you prefer full manual control, disable auto-inference globally with `configure({ autoPropertyTypes: false })`.
|
|
428
|
+
|
|
429
|
+
### Explicit `@properties`
|
|
430
|
+
|
|
431
|
+
Declare `@properties` yourself only when you need to override the defaults, for example to set `inherits: false` or provide a custom `initialValue`:
|
|
432
|
+
|
|
433
|
+
```tsx
|
|
434
|
+
'@properties': {
|
|
435
|
+
'$pulse-scale': { syntax: '<number>', inherits: false, initialValue: 1 },
|
|
436
|
+
},
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
### React Hooks
|
|
440
|
+
|
|
441
|
+
For cases where you don't need a full component:
|
|
442
|
+
|
|
443
|
+
```tsx
|
|
444
|
+
import { useStyles, useGlobalStyles, useRawCSS } from '@tenphi/tasty';
|
|
445
|
+
|
|
446
|
+
function App() {
|
|
447
|
+
const { className } = useStyles({ padding: '2x', fill: '#surface' });
|
|
448
|
+
useGlobalStyles('body', { margin: '0' });
|
|
449
|
+
useRawCSS('@font-face { font-family: "Custom"; src: url(...); }');
|
|
450
|
+
|
|
451
|
+
return <main className={className}>...</main>;
|
|
452
|
+
}
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
### Zero-Runtime Mode
|
|
456
|
+
|
|
457
|
+
Extract all CSS at build time. Zero JavaScript overhead in production:
|
|
458
|
+
|
|
459
|
+
```tsx
|
|
460
|
+
import { tastyStatic } from '@tenphi/tasty/static';
|
|
461
|
+
|
|
462
|
+
const card = tastyStatic({
|
|
463
|
+
padding: '4x',
|
|
464
|
+
fill: '#surface',
|
|
465
|
+
radius: '1r',
|
|
466
|
+
color: { '': '#text', '@dark': '#text-on-dark' },
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
// card is a CSS class name string
|
|
470
|
+
<div className={card}>Static styles, zero runtime</div>
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
Configure the Babel plugin:
|
|
474
|
+
|
|
475
|
+
```js
|
|
476
|
+
module.exports = {
|
|
477
|
+
plugins: [
|
|
478
|
+
['@tenphi/tasty/babel-plugin', {
|
|
479
|
+
output: 'public/tasty.css',
|
|
480
|
+
config: {
|
|
481
|
+
states: { '@dark': '@root(theme=dark)' },
|
|
482
|
+
},
|
|
483
|
+
}],
|
|
484
|
+
],
|
|
485
|
+
};
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
### `tasty` vs `tastyStatic`
|
|
489
|
+
|
|
490
|
+
| | `tasty` (runtime) | `tastyStatic` (zero-runtime) |
|
|
491
|
+
|---|---|---|
|
|
492
|
+
| **Output** | React component | CSS class name |
|
|
493
|
+
| **CSS injection** | Runtime `<style>` tags | Build-time extraction |
|
|
494
|
+
| **Runtime cost** | Style generation on mount | None |
|
|
495
|
+
| **Generated CSS scope** | Only styles/variants used at runtime | All extracted static styles at build time |
|
|
496
|
+
| **Dynamic values** | Fully supported | Via CSS custom properties |
|
|
497
|
+
| **Sub-elements** | Built-in (`<C.Title>`) | Manual (`data-element`) |
|
|
498
|
+
| **Variants** | Built-in (`variants` option) | Separate static styles |
|
|
499
|
+
| **Framework** | React | Any (requires Babel) |
|
|
500
|
+
| **Best for** | Interactive apps, design systems | Static sites, SSG, landing pages |
|
|
501
|
+
|
|
502
|
+
Both share the same DSL, tokens, units, state mappings, and recipes.
|
|
503
|
+
|
|
504
|
+
### Runtime Performance
|
|
505
|
+
|
|
506
|
+
If you choose the runtime approach, performance is usually a non-issue in practice:
|
|
507
|
+
|
|
508
|
+
- CSS is generated and injected only when styles are actually used.
|
|
509
|
+
- Multi-level caching avoids repeated parsing and style recomputation.
|
|
510
|
+
- Styles are split into reusable chunks and applied as multiple class names, so matching chunks can be reused across components instead of re-injected.
|
|
511
|
+
- Style normalization guarantees equivalent style input resolves to the same chunks, improving deduplication hit rates.
|
|
512
|
+
- A style garbage collector removes unused styles/chunks over time.
|
|
513
|
+
- A dedicated style injector minimizes DOM/style-tag overhead.
|
|
514
|
+
- This approach is validated in enterprise-scale apps where runtime styling overhead is not noticeable in normal UI flows.
|
|
515
|
+
|
|
516
|
+
### Server-Side Rendering (Experimental)
|
|
517
|
+
|
|
518
|
+
SSR with zero-cost client hydration. Existing `tasty()` components work unchanged — SSR is opt-in and requires no per-component modifications. Supports Next.js (App Router with streaming), Astro (middleware + islands), and any React-based framework via the core API. Requires React 19+.
|
|
519
|
+
|
|
520
|
+
**Next.js setup:**
|
|
521
|
+
|
|
522
|
+
```tsx
|
|
523
|
+
// app/tasty-registry.tsx
|
|
524
|
+
'use client';
|
|
525
|
+
|
|
526
|
+
import { TastyRegistry } from '@tenphi/tasty/ssr/next';
|
|
527
|
+
|
|
528
|
+
export default function TastyStyleRegistry({
|
|
529
|
+
children,
|
|
530
|
+
}: {
|
|
531
|
+
children: React.ReactNode;
|
|
532
|
+
}) {
|
|
533
|
+
return <TastyRegistry>{children}</TastyRegistry>;
|
|
534
|
+
}
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
```tsx
|
|
538
|
+
// app/layout.tsx
|
|
539
|
+
import TastyStyleRegistry from './tasty-registry';
|
|
540
|
+
|
|
541
|
+
export default function RootLayout({
|
|
542
|
+
children,
|
|
543
|
+
}: {
|
|
544
|
+
children: React.ReactNode;
|
|
545
|
+
}) {
|
|
546
|
+
return (
|
|
547
|
+
<html>
|
|
548
|
+
<body>
|
|
549
|
+
<TastyStyleRegistry>{children}</TastyStyleRegistry>
|
|
550
|
+
</body>
|
|
551
|
+
</html>
|
|
552
|
+
);
|
|
553
|
+
}
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
See the [full SSR guide](docs/ssr.md) for Astro integration, streaming SSR, generic framework usage, and the complete API reference.
|
|
557
|
+
|
|
558
|
+
## Entry Points
|
|
559
|
+
|
|
560
|
+
| Import | Description | Platform |
|
|
561
|
+
|--------|-------------|----------|
|
|
562
|
+
| `@tenphi/tasty` | Runtime style engine (`tasty`, hooks, `configure`) | Browser |
|
|
563
|
+
| `@tenphi/tasty/static` | Zero-runtime static styles (`tastyStatic`) | Browser |
|
|
564
|
+
| `@tenphi/tasty/core` | Lower-level internals (config, parser, pipeline, injector, style handlers) for tooling and advanced use | Browser / Node |
|
|
565
|
+
| `@tenphi/tasty/babel-plugin` | Babel plugin for zero-runtime CSS extraction | Node |
|
|
566
|
+
| `@tenphi/tasty/zero` | Programmatic extraction API | Node |
|
|
567
|
+
| `@tenphi/tasty/next` | Next.js integration wrapper | Node |
|
|
568
|
+
| `@tenphi/tasty/ssr` | Core SSR API (collector, context, hydration) | Node |
|
|
569
|
+
| `@tenphi/tasty/ssr/next` | Next.js App Router SSR integration | Node |
|
|
570
|
+
| `@tenphi/tasty/ssr/astro` | Astro middleware + auto-hydration | Node / Browser |
|
|
571
|
+
|
|
572
|
+
## Ecosystem
|
|
573
|
+
|
|
574
|
+
Tasty is the core of a production-ready styling platform. These companion tools complete the picture:
|
|
575
|
+
|
|
576
|
+
### [ESLint Plugin](https://github.com/tenphi/eslint-plugin-tasty)
|
|
577
|
+
|
|
578
|
+
`@tenphi/eslint-plugin-tasty` — 27 lint rules that validate style property names, value syntax, token existence, state keys, and enforce best practices. Catch typos and invalid styles at lint time, not at runtime.
|
|
579
|
+
|
|
580
|
+
```bash
|
|
581
|
+
pnpm add -D @tenphi/eslint-plugin-tasty
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
```js
|
|
585
|
+
import tasty from '@tenphi/eslint-plugin-tasty';
|
|
586
|
+
export default [tasty.configs.recommended];
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
### [Glaze](https://github.com/tenphi/glaze)
|
|
590
|
+
|
|
591
|
+
`@tenphi/glaze` — OKHSL-based color theme generator with automatic WCAG contrast solving. Generate light, dark, and high-contrast palettes from a single hue, and export them directly as Tasty color tokens.
|
|
592
|
+
|
|
593
|
+
```tsx
|
|
594
|
+
import { glaze } from '@tenphi/glaze';
|
|
595
|
+
|
|
596
|
+
const theme = glaze(280, 80);
|
|
597
|
+
theme.colors({
|
|
598
|
+
surface: { lightness: 97 },
|
|
599
|
+
text: { base: 'surface', lightness: '-52', contrast: 'AAA' },
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
const tokens = theme.tasty(); // Ready-to-use Tasty tokens
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
### [VS Code Extension](https://github.com/tenphi/tasty-vscode-extension)
|
|
606
|
+
|
|
607
|
+
Syntax highlighting for Tasty styles in TypeScript, TSX, JavaScript, and JSX. Highlights color tokens, custom units, state keys, presets, and style properties inside `tasty()`, `tastyStatic()`, and related APIs.
|
|
608
|
+
|
|
609
|
+
<p align="center">
|
|
610
|
+
<img src="assets/tasty-vscode-highlight.png" width="512" alt="Tasty VS Code syntax highlighting example">
|
|
611
|
+
</p>
|
|
612
|
+
|
|
613
|
+
## Built with Tasty
|
|
614
|
+
|
|
615
|
+
### [tasty.style](https://tasty.style) ([source](https://github.com/tenphi/tasty.style))
|
|
616
|
+
|
|
617
|
+
The official Tasty documentation and landing page — itself built entirely with Tasty. A showcase for zero-runtime styling via `tastyStatic`, SSR with Next.js, and OKHSL color theming with Glaze.
|
|
618
|
+
|
|
619
|
+
### [Cube Cloud](https://cube.dev/)
|
|
620
|
+
|
|
621
|
+
Enterprise universal semantic layer platform by Cube Dev, Inc. Cube Cloud unifies data modeling, caching, access control, and APIs (REST, GraphQL, SQL, AI) for analytics at scale. Tasty has powered its frontend for over 5 years in production.
|
|
622
|
+
|
|
623
|
+
### [Cube Cloud for Excel and Google Sheets](https://cube.dev/)
|
|
624
|
+
|
|
625
|
+
A single spreadsheet add-in deployed to both [Microsoft Excel](https://marketplace.microsoft.com/en-us/product/office/WA200008486) and [Google Sheets](https://workspace.google.com/u/0/marketplace/app/cube_cloud_for_sheets/641460343379). Connects spreadsheets to any cloud data platform (BigQuery, Databricks, Snowflake, Redshift, and more) via Cube Cloud's universal semantic layer.
|
|
626
|
+
|
|
627
|
+
### [Cube UI Kit](https://github.com/cube-js/cube-ui-kit) ([storybook](https://cube-ui-kit.vercel.app/))
|
|
628
|
+
|
|
629
|
+
Open-source React UI kit built on Tasty + React Aria. 100+ production components proving Tasty works at design-system scale. A reference implementation and a ready-to-use component library.
|
|
630
|
+
|
|
631
|
+
## Documentation
|
|
632
|
+
|
|
633
|
+
### Start here
|
|
634
|
+
|
|
635
|
+
- **[Getting Started](docs/getting-started.md)** — Installation, first component, configuration, ESLint plugin setup, editor tooling, and rendering mode decision tree
|
|
636
|
+
- **[Methodology](docs/methodology.md)** — The recommended patterns for structuring Tasty components: root + sub-elements, styleProps, tokens, styles vs style, wrapping and extension
|
|
637
|
+
|
|
638
|
+
### Guides
|
|
639
|
+
|
|
640
|
+
- **[Building a Design System](docs/design-system.md)** — Practical guide to building a DS layer: token vocabulary, state aliases, recipes, primitives, compound components, override contracts
|
|
641
|
+
- **[Adoption Guide](docs/adoption.md)** — Where Tasty sits in the stack, who should adopt it, what you define yourself, and how to introduce it incrementally into an existing design system
|
|
642
|
+
|
|
643
|
+
### Reference
|
|
644
|
+
|
|
645
|
+
- **[Style DSL](docs/dsl.md)** — The Tasty style language: state maps, tokens, units, color syntax, extending semantics, recipes, keyframes, and @property
|
|
646
|
+
- **[Runtime API](docs/runtime.md)** — React-specific API: `tasty()` factory, component props, variants, sub-elements, and hooks
|
|
647
|
+
- **[Configuration](docs/configuration.md)** — Global configuration: tokens, recipes, custom units, style handlers, and TypeScript extensions
|
|
648
|
+
- **[Style Properties](docs/styles.md)** — Complete reference for all enhanced style properties: syntax, values, modifiers, and recommendations
|
|
649
|
+
|
|
650
|
+
### Rendering modes
|
|
651
|
+
|
|
652
|
+
- **[Zero Runtime (tastyStatic)](docs/tasty-static.md)** — Build-time static styling: Babel plugin setup, Next.js integration, and static style patterns
|
|
653
|
+
- **[Server-Side Rendering](docs/ssr.md)** — SSR setup for Next.js, Astro, and generic frameworks: streaming support, cache hydration, and troubleshooting
|
|
654
|
+
|
|
655
|
+
### Internals
|
|
656
|
+
|
|
657
|
+
- **[Style Injector](docs/injector.md)** — Internal CSS injection engine: `inject()`, `injectGlobal()`, `injectRawCSS()`, `keyframes()`, deduplication, reference counting, cleanup, SSR support, and Shadow DOM
|
|
658
|
+
- **[Debug Utilities](docs/debug.md)** — Runtime CSS inspection via `tastyDebug`: CSS extraction, element inspection, cache metrics, chunk breakdown, and performance monitoring
|
|
659
|
+
|
|
660
|
+
### Context
|
|
661
|
+
|
|
662
|
+
- **[Comparison](docs/comparison.md)** — How Tasty compares to Tailwind, Panda CSS, vanilla-extract, StyleX, Stitches, and Emotion: positioning, trade-offs, and when each tool fits best
|
|
663
|
+
|
|
664
|
+
## License
|
|
665
|
+
|
|
666
|
+
[MIT](LICENSE)
|