@tenphi/tasty 0.0.0-snapshot.9155dd5 → 0.0.0-snapshot.92cfaf9
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 +208 -248
- package/dist/chunks/definitions.d.ts +1 -1
- package/dist/chunks/definitions.js +1 -1
- package/dist/chunks/definitions.js.map +1 -1
- package/dist/config.d.ts +45 -2
- package/dist/config.js +63 -23
- package/dist/config.js.map +1 -1
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.js +4 -4
- package/dist/counter-style/index.js +51 -0
- package/dist/counter-style/index.js.map +1 -0
- package/dist/debug.d.ts +26 -141
- package/dist/debug.js +356 -635
- 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/resolve-ssr-collector.js +15 -0
- package/dist/hooks/resolve-ssr-collector.js.map +1 -0
- package/dist/hooks/useCounterStyle.d.ts +50 -0
- package/dist/hooks/useCounterStyle.js +47 -0
- package/dist/hooks/useCounterStyle.js.map +1 -0
- package/dist/hooks/useFontFace.d.ts +43 -0
- package/dist/hooks/useFontFace.js +71 -0
- package/dist/hooks/useFontFace.js.map +1 -0
- package/dist/hooks/useGlobalStyles.js +1 -5
- package/dist/hooks/useGlobalStyles.js.map +1 -1
- package/dist/hooks/useKeyframes.js +1 -5
- package/dist/hooks/useKeyframes.js.map +1 -1
- package/dist/hooks/useProperty.js +1 -5
- package/dist/hooks/useProperty.js.map +1 -1
- package/dist/hooks/useRawCSS.js +1 -5
- package/dist/hooks/useRawCSS.js.map +1 -1
- package/dist/hooks/useStyles.js +35 -46
- package/dist/hooks/useStyles.js.map +1 -1
- package/dist/index.d.ts +8 -6
- package/dist/index.js +6 -4
- package/dist/injector/index.d.ts +20 -2
- package/dist/injector/index.js +19 -1
- package/dist/injector/index.js.map +1 -1
- package/dist/injector/injector.d.ts +19 -1
- package/dist/injector/injector.js +35 -0
- package/dist/injector/injector.js.map +1 -1
- package/dist/injector/sheet-manager.js +7 -2
- package/dist/injector/sheet-manager.js.map +1 -1
- package/dist/injector/types.d.ts +61 -1
- package/dist/parser/classify.js +3 -3
- package/dist/parser/classify.js.map +1 -1
- package/dist/parser/const.js +17 -1
- package/dist/parser/const.js.map +1 -1
- package/dist/pipeline/index.d.ts +2 -0
- package/dist/pipeline/index.js +56 -17
- package/dist/pipeline/index.js.map +1 -1
- package/dist/pipeline/materialize.js +0 -1
- package/dist/pipeline/materialize.js.map +1 -1
- package/dist/properties/index.js.map +1 -1
- package/dist/ssr/collector.d.ts +17 -0
- package/dist/ssr/collector.js +50 -6
- package/dist/ssr/collector.js.map +1 -1
- package/dist/ssr/format-rules.js +7 -4
- package/dist/ssr/format-rules.js.map +1 -1
- package/dist/ssr/index.js +1 -1
- package/dist/states/index.js +2 -0
- package/dist/states/index.js.map +1 -1
- package/dist/styles/border.js +2 -2
- package/dist/styles/border.js.map +1 -1
- package/dist/styles/predefined.js +1 -1
- package/dist/styles/predefined.js.map +1 -1
- package/dist/styles/preset.d.ts +5 -0
- package/dist/styles/preset.js +48 -47
- package/dist/styles/preset.js.map +1 -1
- package/dist/styles/types.d.ts +46 -7
- package/dist/tasty.d.ts +30 -892
- package/dist/tasty.js +20 -7
- package/dist/tasty.js.map +1 -1
- package/dist/utils/color-math.d.ts +2 -1
- package/dist/utils/color-math.js +40 -8
- package/dist/utils/color-math.js.map +1 -1
- package/dist/utils/color-space.js +78 -35
- package/dist/utils/color-space.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.js +1 -1
- package/dist/utils/process-tokens.js.map +1 -1
- package/dist/utils/styles.d.ts +1 -3
- package/dist/utils/styles.js +4 -6
- package/dist/utils/styles.js.map +1 -1
- package/dist/utils/typography.js +8 -0
- package/dist/utils/typography.js.map +1 -1
- package/dist/zero/babel.d.ts +14 -2
- package/dist/zero/babel.js +52 -24
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/extractor.js +53 -1
- package/dist/zero/extractor.js.map +1 -1
- package/docs/PIPELINE.md +1 -1
- package/docs/README.md +31 -0
- package/docs/adoption.md +16 -6
- package/docs/comparison.md +16 -9
- package/docs/configuration.md +65 -2
- package/docs/debug.md +152 -339
- package/docs/design-system.md +26 -3
- package/docs/dsl.md +136 -3
- package/docs/getting-started.md +29 -13
- package/docs/injector.md +2 -2
- package/docs/methodology.md +71 -5
- package/docs/runtime.md +228 -34
- package/docs/ssr.md +5 -3
- package/docs/styles.md +28 -23
- package/docs/tasty-static.md +15 -2
- package/package.json +3 -2
package/docs/adoption.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Adoption Guide
|
|
2
2
|
|
|
3
|
-
Tasty is not a drop-in replacement for another styling library. It is a **substrate for building a design-system-defined styling language
|
|
3
|
+
Tasty is not a drop-in replacement for another styling library. It is a **substrate for building a design-system-defined styling language**: what the comparison guide calls a house styling language. That means adoption usually starts where styling for reusable, stateful components has already become a composition problem, not with an all-at-once rewrite.
|
|
4
4
|
|
|
5
|
-
This guide is for design-system maintainers and platform engineers evaluating Tasty or introducing it into an existing codebase.
|
|
5
|
+
This guide is for design-system maintainers and platform engineers evaluating Tasty or introducing it into an existing codebase. Use this document for rollout strategy and adoption sequencing; use the [Comparison guide](comparison.md) when the open question is whether Tasty is the right tool in the first place.
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -74,7 +74,7 @@ The same engine can power a minimal design system with a handful of tokens:
|
|
|
74
74
|
```tsx
|
|
75
75
|
configure({
|
|
76
76
|
tokens: { '#bg': '#white', '#text': '#111' },
|
|
77
|
-
states: { '@dark': '@root(
|
|
77
|
+
states: { '@dark': '@root(schema=dark)' },
|
|
78
78
|
});
|
|
79
79
|
```
|
|
80
80
|
|
|
@@ -116,6 +116,8 @@ See [Configuration](configuration.md) for the full `configure()` API.
|
|
|
116
116
|
|
|
117
117
|
You do not need to adopt everything at once. Tasty is designed to be introduced layer by layer.
|
|
118
118
|
|
|
119
|
+
A practical way to start is with the components that already suffer from intersecting state and variant logic: buttons, inputs, menus, disclosures, dialogs, list items, interactive cards, and compound components. Those are the places where deterministic resolution pays off fastest.
|
|
120
|
+
|
|
119
121
|
### Phase 1 -- Tokens and units
|
|
120
122
|
|
|
121
123
|
Start by defining your design tokens and custom units. This is the lowest-risk step: it only configures the parser and does not require rewriting any components.
|
|
@@ -161,7 +163,7 @@ configure({
|
|
|
161
163
|
|
|
162
164
|
### Phase 3 -- Migrate a few primitives
|
|
163
165
|
|
|
164
|
-
Pick 2-3
|
|
166
|
+
Pick 2-3 widely used primitives (Box, Text, Button) and rewrite them with `tasty()`. Keep the public API identical so product code does not need to change.
|
|
165
167
|
|
|
166
168
|
```tsx
|
|
167
169
|
const Box = tasty({
|
|
@@ -175,11 +177,11 @@ const Box = tasty({
|
|
|
175
177
|
});
|
|
176
178
|
```
|
|
177
179
|
|
|
178
|
-
At this point you can validate the DSL, token workflow, and component authoring experience before
|
|
180
|
+
At this point you can validate the DSL, token workflow, and component authoring experience before expanding the rollout.
|
|
179
181
|
|
|
180
182
|
### Phase 4 -- Encode complex states
|
|
181
183
|
|
|
182
|
-
Move components with intersecting states (buttons with hover + disabled + theme variants, inputs with focus + error + readonly) to Tasty's state map syntax. This is where mutually exclusive selectors start paying off.
|
|
184
|
+
Move the components with the most painful intersecting states (buttons with hover + disabled + theme variants, inputs with focus + error + readonly) to Tasty's state map syntax. This is where mutually exclusive selectors start paying off.
|
|
183
185
|
|
|
184
186
|
```tsx
|
|
185
187
|
const Button = tasty({
|
|
@@ -272,6 +274,14 @@ const LoadingButton = tasty(Button, {
|
|
|
272
274
|
|
|
273
275
|
---
|
|
274
276
|
|
|
277
|
+
## Migration and Interop Notes
|
|
278
|
+
|
|
279
|
+
- **From Tailwind**: keep utility-authored product surfaces as-is at first, and use Tasty to build or replace the design-system primitives underneath them instead of forcing an all-at-once markup rewrite.
|
|
280
|
+
- **From CSS-in-JS libraries**: start with shared primitives such as `Box`, `Text`, and `Button`, preserve the external component API, and move state logic into Tasty state maps so behavior changes without product-code churn.
|
|
281
|
+
- **From CSS Modules or plain CSS**: migrate token definitions and repeated patterns first, then wrap existing DOM structure with `tasty()` components gradually rather than converting every stylesheet at once.
|
|
282
|
+
|
|
283
|
+
---
|
|
284
|
+
|
|
275
285
|
## Learn more
|
|
276
286
|
|
|
277
287
|
- [README](../README.md) -- overview, quick start, and feature highlights
|
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. In other words, it is a governed styling model, not just another syntax for writing CSS.
|
|
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
|
|
@@ -52,6 +54,8 @@ configure({
|
|
|
52
54
|
| `replaceTokens` | `Record<string, string \| number>` | - | Parse-time token substitution (inline replacement) |
|
|
53
55
|
| `keyframes` | `Record<string, KeyframesSteps>` | - | Global keyframes for animations |
|
|
54
56
|
| `properties` | `Record<string, PropertyDefinition>` | - | Global CSS @property definitions |
|
|
57
|
+
| `fontFace` | `Record<string, FontFaceInput>` | - | Global @font-face definitions |
|
|
58
|
+
| `counterStyle` | `Record<string, CounterStyleDescriptors>` | - | Global @counter-style definitions |
|
|
55
59
|
| `autoPropertyTypes` | `boolean` | `true` | Auto-infer and register `@property` types from values |
|
|
56
60
|
| `recipes` | `Record<string, RecipeStyles>` | - | Predefined style recipes (named style bundles) |
|
|
57
61
|
| `colorSpace` | `'rgb' \| 'hsl' \| 'oklch'` | `'oklch'` | Color space for decomposed color token companion variables |
|
|
@@ -131,6 +135,65 @@ See [Replace Tokens](dsl.md#replace-tokens) in the Style DSL reference.
|
|
|
131
135
|
|
|
132
136
|
---
|
|
133
137
|
|
|
138
|
+
## Font Face
|
|
139
|
+
|
|
140
|
+
Register custom fonts globally so every component can reference them by family name. Values are descriptor objects or arrays (for multiple weights/styles). Rules are injected eagerly when styles are first generated.
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
configure({
|
|
144
|
+
fontFace: {
|
|
145
|
+
'Brand Sans': [
|
|
146
|
+
{
|
|
147
|
+
src: 'url("/fonts/brand-regular.woff2") format("woff2")',
|
|
148
|
+
fontWeight: 400,
|
|
149
|
+
fontDisplay: 'swap',
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
src: 'url("/fonts/brand-bold.woff2") format("woff2")',
|
|
153
|
+
fontWeight: 700,
|
|
154
|
+
fontDisplay: 'swap',
|
|
155
|
+
},
|
|
156
|
+
],
|
|
157
|
+
Icons: {
|
|
158
|
+
src: 'url("/fonts/icons.woff2") format("woff2")',
|
|
159
|
+
fontDisplay: 'block',
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Now any component can use `fontFamily: '"Brand Sans", sans-serif'` and the browser will already have the `@font-face` rules in the stylesheet.
|
|
166
|
+
|
|
167
|
+
See [Font Face (`@fontFace`)](dsl.md#font-face-fontface) for inline usage inside component styles and the full list of supported descriptors.
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Counter Style
|
|
172
|
+
|
|
173
|
+
Define custom list-marker algorithms globally. Rules are injected eagerly when styles are first generated.
|
|
174
|
+
|
|
175
|
+
```ts
|
|
176
|
+
configure({
|
|
177
|
+
counterStyle: {
|
|
178
|
+
thumbs: {
|
|
179
|
+
system: 'cyclic',
|
|
180
|
+
symbols: '"👍"',
|
|
181
|
+
suffix: '" "',
|
|
182
|
+
},
|
|
183
|
+
'lower-roman-parens': {
|
|
184
|
+
system: 'extends lower-roman',
|
|
185
|
+
suffix: '") "',
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Components can then reference `listStyleType: 'thumbs'` directly.
|
|
192
|
+
|
|
193
|
+
See [Counter Style (`@counterStyle`)](dsl.md#counter-style-counterstyle) for inline usage inside component styles and the full list of supported descriptors.
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
134
197
|
## Recipes
|
|
135
198
|
|
|
136
199
|
Recipes are predefined, named style bundles. Define them globally via `configure()`:
|