@tenphi/tasty 0.13.1 → 0.14.1
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 +155 -51
- package/dist/config.d.ts +13 -1
- package/dist/config.js +5 -1
- package/dist/config.js.map +1 -1
- package/dist/core/index.d.ts +5 -3
- package/dist/core/index.js +4 -3
- package/dist/debug.d.ts +26 -141
- package/dist/debug.js +356 -635
- package/dist/debug.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.js +4 -3
- package/dist/parser/classify.js +2 -1
- package/dist/parser/classify.js.map +1 -1
- package/dist/parser/parser.js +1 -1
- package/dist/plugins/okhsl-plugin.js +2 -275
- package/dist/plugins/okhsl-plugin.js.map +1 -1
- package/dist/plugins/types.d.ts +1 -1
- package/dist/properties/index.js +2 -15
- package/dist/properties/index.js.map +1 -1
- package/dist/ssr/format-property.js +9 -7
- package/dist/ssr/format-property.js.map +1 -1
- package/dist/styles/color.js +9 -5
- package/dist/styles/color.js.map +1 -1
- package/dist/styles/createStyle.js +24 -21
- package/dist/styles/createStyle.js.map +1 -1
- package/dist/styles/index.js +1 -1
- package/dist/styles/predefined.js +1 -1
- package/dist/styles/predefined.js.map +1 -1
- package/dist/styles/types.d.ts +19 -4
- package/dist/tasty.d.ts +9 -9
- package/dist/tasty.js +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils/color-math.d.ts +46 -0
- package/dist/utils/color-math.js +749 -0
- package/dist/utils/color-math.js.map +1 -0
- package/dist/utils/color-space.d.ts +5 -0
- package/dist/utils/color-space.js +229 -0
- package/dist/utils/color-space.js.map +1 -0
- package/dist/utils/colors.js +3 -1
- package/dist/utils/colors.js.map +1 -1
- package/dist/utils/mod-attrs.js +1 -1
- package/dist/utils/mod-attrs.js.map +1 -1
- package/dist/utils/process-tokens.d.ts +3 -13
- package/dist/utils/process-tokens.js +18 -98
- package/dist/utils/process-tokens.js.map +1 -1
- package/dist/utils/styles.d.ts +2 -15
- package/dist/utils/styles.js +22 -217
- package/dist/utils/styles.js.map +1 -1
- package/docs/PIPELINE.md +519 -0
- package/docs/README.md +31 -0
- package/docs/adoption.md +16 -6
- package/docs/comparison.md +16 -9
- package/docs/configuration.md +26 -3
- package/docs/debug.md +152 -339
- package/docs/design-system.md +1 -1
- package/docs/dsl.md +3 -1
- package/docs/getting-started.md +29 -13
- package/docs/injector.md +2 -2
- package/docs/methodology.md +3 -1
- package/docs/runtime.md +59 -9
- package/docs/ssr.md +3 -3
- package/docs/styles.md +1 -1
- package/docs/tasty-static.md +13 -2
- package/package.json +4 -3
- package/dist/utils/hsl-to-rgb.js +0 -38
- package/dist/utils/hsl-to-rgb.js.map +0 -1
- package/dist/utils/okhsl-to-rgb.js +0 -296
- package/dist/utils/okhsl-to-rgb.js.map +0 -1
package/docs/comparison.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
# Comparison
|
|
2
2
|
|
|
3
|
-
Tasty is
|
|
3
|
+
Use this guide when you are deciding whether Tasty is the right tool. If you have already decided to adopt it and need rollout guidance, use the [Adoption Guide](adoption.md) instead.
|
|
4
|
+
|
|
5
|
+
Tasty is best understood not as a general-purpose CSS framework, but as a **styling engine for design systems and shared component APIs**.
|
|
6
|
+
|
|
7
|
+
It targets a different layer: helping design-system teams define a **house styling language** on top of CSS.
|
|
8
|
+
|
|
9
|
+
That does not require a big upfront configuration step. Tasty's built-in units and normal CSS color values work out of the box, and `okhsl(...)` is available immediately as the recommended path for color authoring. The extra setup comes later if a team wants shared tokens, aliases, recipes, or stricter conventions.
|
|
4
10
|
|
|
5
11
|
Most styling tools focus on one of these layers:
|
|
6
12
|
|
|
@@ -10,7 +16,7 @@ Most styling tools focus on one of these layers:
|
|
|
10
16
|
- utility composition
|
|
11
17
|
- atomic CSS generation
|
|
12
18
|
|
|
13
|
-
Tasty
|
|
19
|
+
Tasty's house styling language can include tokens, state semantics, style props, recipes, custom units, and sub-element rules.
|
|
14
20
|
|
|
15
21
|
That is why syntax-level comparisons are often shallow. The more meaningful comparison is about:
|
|
16
22
|
|
|
@@ -25,7 +31,7 @@ That is why syntax-level comparisons are often shallow. The more meaningful comp
|
|
|
25
31
|
|
|
26
32
|
| System | Best described as | Main authoring model | Conflict model | Best fit |
|
|
27
33
|
|---|---|---|---|---|
|
|
28
|
-
| **Tasty** | Design-system styling engine | Custom DSL with tokens, state maps, recipes, style props, sub-elements, custom units | **Mutually exclusive selector resolution** for stateful styles |
|
|
34
|
+
| **Tasty** | Design-system styling engine | Custom DSL with tokens, state maps, recipes, style props, sub-elements, custom units | **Mutually exclusive selector resolution** for stateful styles | Teams building shared component APIs or a house styling language |
|
|
29
35
|
| **Tailwind CSS** | Utility-first styling framework | Utility classes in markup | Utility composition, variants, and framework-controlled ordering | Product teams optimizing for speed and direct authoring |
|
|
30
36
|
| **Panda CSS** | Typed styling engine with atomic output | Typed style objects, recipes, generated primitives, style props | Atomic CSS with static analysis | Teams wanting a DS-friendly engine with typed primitives |
|
|
31
37
|
| **vanilla-extract** | Zero-runtime TS-native stylesheet system | `.css.ts` files, theme contracts, style composition | Standard CSS semantics | Teams wanting static CSS and low-level control |
|
|
@@ -83,9 +89,9 @@ Tasty compiles this into selectors where `disabled` is guarded by `:not(:hover)`
|
|
|
83
89
|
|
|
84
90
|
That makes Tasty less of a "better way to write CSS objects" and more of a **state-aware style compiler for design systems**.
|
|
85
91
|
|
|
86
|
-
Beyond state resolution, Tasty
|
|
92
|
+
Beyond state resolution, Tasty also provides several structural capabilities that reinforce the design-system layer:
|
|
87
93
|
|
|
88
|
-
- **CSS properties as typed React props** — `styleProps` lets a component expose selected style properties as normal props (`<Button placeSelf="end">`), including state maps for responsive values.
|
|
94
|
+
- **CSS properties as typed React props** — `styleProps` lets a component expose selected style properties as normal props (`<Button placeSelf="end">`), including state maps for responsive values. This keeps layout and composition controls inside a governed component API instead of pushing teams back to ad hoc styling escapes.
|
|
89
95
|
- **Sub-element styling** — Compound components declare inner parts via capitalized keys in `styles` and `data-element` attributes. States, tokens, and recipes apply across the entire element tree from a single definition. See [Runtime API — Sub-element Styling](runtime.md#sub-element-styling).
|
|
90
96
|
- **Auto-inferred `@property`** — When a custom property is assigned a concrete value, Tasty infers the CSS `@property` syntax and registers it automatically, enabling smooth transitions on custom properties without manual declarations.
|
|
91
97
|
- **AI-friendly style definitions** — Style definitions are declarative, self-contained, and structurally consistent. AI tools can read, refactor, and generate Tasty styles as confidently as a human — no hidden cascade logic or implicit ordering to second-guess.
|
|
@@ -103,7 +109,7 @@ Its strength is speed: developers compose utilities directly where they use them
|
|
|
103
109
|
|
|
104
110
|
Tasty solves a different problem.
|
|
105
111
|
|
|
106
|
-
Tasty is more appropriate when styling should be exposed through a **design-system-owned API** rather than through raw utility composition.
|
|
112
|
+
Tasty is more appropriate when styling should be exposed through a **design-system-owned API** rather than through raw utility composition. You can start using Tasty immediately with its built-in DSL, but it becomes especially compelling when a team wants to define:
|
|
107
113
|
|
|
108
114
|
- approved style props
|
|
109
115
|
- semantic tokens
|
|
@@ -118,7 +124,7 @@ So this is not mainly a comparison of syntax. It is a comparison of **governance
|
|
|
118
124
|
- Tailwind: developers author directly with framework vocabulary
|
|
119
125
|
- Tasty: design-system authors define the vocabulary product teams consume
|
|
120
126
|
|
|
121
|
-
Tailwind is
|
|
127
|
+
Tailwind is a stronger fit for fast product styling with framework-owned vocabulary. Tasty is a stronger fit when styling should be exposed through a design-system-owned API and state resolution needs to stay deterministic as the component model grows.
|
|
122
128
|
|
|
123
129
|
To make this concrete, consider a button with `hover`, `disabled`, and `theme=danger` states.
|
|
124
130
|
|
|
@@ -297,7 +303,7 @@ So while Stitches and Emotion are strong tools for building components, Tasty is
|
|
|
297
303
|
|
|
298
304
|
That makes it narrower in audience, but deeper in architectural ambition.
|
|
299
305
|
|
|
300
|
-
|
|
306
|
+
For teams evaluating runtime styling at scale, Tasty also documents its runtime benchmarks and caching model in the main [README](../README.md#performance). That matters, but it is still secondary to the core question of whether you want Tasty's deterministic selector model.
|
|
301
307
|
|
|
302
308
|
---
|
|
303
309
|
|
|
@@ -356,6 +362,7 @@ That is why generic "feature matrix" comparisons often miss the point. Tasty is
|
|
|
356
362
|
Tasty makes the most sense when:
|
|
357
363
|
|
|
358
364
|
- a real design system exists or is being built
|
|
365
|
+
- a shared component API is emerging even if the design system is still lightweight
|
|
359
366
|
- styling should be governed through a central platform team
|
|
360
367
|
- component state logic is complex
|
|
361
368
|
- the team wants a house styling language instead of raw CSS-shaped authoring
|
|
@@ -369,7 +376,7 @@ Tasty makes the most sense when:
|
|
|
369
376
|
|
|
370
377
|
A different tool may be more appropriate when:
|
|
371
378
|
|
|
372
|
-
- the main goal is styling app code directly with minimal setup
|
|
379
|
+
- the main goal is styling app code directly with minimal setup and without defining shared styling conventions
|
|
373
380
|
- the team prefers a shared framework vocabulary over a custom design-system language
|
|
374
381
|
- the complexity of intersecting states is low
|
|
375
382
|
- low ceremony matters more than central governance
|
package/docs/configuration.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Configuration
|
|
2
2
|
|
|
3
|
-
Configure the Tasty style system before your app renders using the `configure()` function. Configuration must be done **before any styles are generated** (before first render).
|
|
3
|
+
Configure the Tasty style system before your app renders using the `configure()` function. Configuration must be done **before any styles are generated** (before first render). For a higher-level docs map, see the [Docs Hub](README.md).
|
|
4
4
|
|
|
5
5
|
```jsx
|
|
6
6
|
import { configure } from '@tenphi/tasty';
|
|
@@ -13,7 +13,7 @@ configure({
|
|
|
13
13
|
states: {
|
|
14
14
|
'@mobile': '@media(w < 768px)',
|
|
15
15
|
'@tablet': '@media(768px <= w < 1024px)',
|
|
16
|
-
'@dark': '@root(
|
|
16
|
+
'@dark': '@root(schema=dark)',
|
|
17
17
|
},
|
|
18
18
|
|
|
19
19
|
// Parser configuration
|
|
@@ -36,6 +36,8 @@ configure({
|
|
|
36
36
|
});
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
+
These docs use `data-schema="dark"` in examples. If your app already standardizes on a different attribute such as `data-theme`, keep the same pattern and swap the attribute name consistently everywhere you define root-state aliases.
|
|
40
|
+
|
|
39
41
|
---
|
|
40
42
|
|
|
41
43
|
## Options
|
|
@@ -54,6 +56,27 @@ configure({
|
|
|
54
56
|
| `properties` | `Record<string, PropertyDefinition>` | - | Global CSS @property definitions |
|
|
55
57
|
| `autoPropertyTypes` | `boolean` | `true` | Auto-infer and register `@property` types from values |
|
|
56
58
|
| `recipes` | `Record<string, RecipeStyles>` | - | Predefined style recipes (named style bundles) |
|
|
59
|
+
| `colorSpace` | `'rgb' \| 'hsl' \| 'oklch'` | `'oklch'` | Color space for decomposed color token companion variables |
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Color Space
|
|
64
|
+
|
|
65
|
+
Controls the CSS color space used for decomposed color token companion variables. When you define `#name` color tokens, tasty generates both `--name-color` (full color) and `--name-color-{suffix}` (decomposed components for alpha composition).
|
|
66
|
+
|
|
67
|
+
```jsx
|
|
68
|
+
configure({
|
|
69
|
+
colorSpace: 'oklch', // default
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
| Color Space | Suffix | Components Format | Alpha Syntax |
|
|
74
|
+
|---|---|---|---|
|
|
75
|
+
| `rgb` | `-rgb` | `255 128 0` | `rgb(var(--name-color-rgb) / .5)` |
|
|
76
|
+
| `hsl` | `-hsl` | `300 100% 25%` | `hsl(var(--name-color-hsl) / .5)` |
|
|
77
|
+
| `oklch` | `-oklch` | `0.42 0.16 328` | `oklch(var(--name-color-oklch) / .5)` |
|
|
78
|
+
|
|
79
|
+
The `oklch` color space is the default because it provides perceptually uniform color manipulation — alpha fading and color mixing produce more natural-looking results.
|
|
57
80
|
|
|
58
81
|
---
|
|
59
82
|
|
|
@@ -81,7 +104,7 @@ configure({
|
|
|
81
104
|
```
|
|
82
105
|
|
|
83
106
|
- `$name` keys become `--name` CSS custom properties
|
|
84
|
-
- `#name` keys become `--name-color` and `--name-color-
|
|
107
|
+
- `#name` keys become `--name-color` and `--name-color-{colorSpace}` properties (suffix depends on `colorSpace`, default `oklch`)
|
|
85
108
|
|
|
86
109
|
Tokens are automatically emitted in all rendering modes: runtime (client), SSR, and zero-runtime (Babel plugin).
|
|
87
110
|
|