@tenphi/tasty 0.2.0 → 0.4.0

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 CHANGED
@@ -5,7 +5,8 @@
5
5
  <h1 align="center">Tasty</h1>
6
6
 
7
7
  <p align="center">
8
- A design-system-integrated styling system and DSL for concise, state-aware UI styling
8
+ <strong>The styling engine built for design systems.</strong><br>
9
+ Deterministic CSS generation. State-aware DSL. Zero specificity conflicts. Ever.
9
10
  </p>
10
11
 
11
12
  <p align="center">
@@ -16,21 +17,21 @@
16
17
 
17
18
  ---
18
19
 
19
- Tasty is a powerful CSS-in-JS styling system for React that combines declarative state-aware styling with design system integration. It provides a concise DSL for creating maintainable, themeable components with built-in support for responsive design, dark mode, container queries, and more.
20
+ Most CSS-in-JS libraries generate CSS. Tasty generates **mutually exclusive CSS** — for any combination of states, exactly one rule matches per property. No cascade conflicts, no specificity wars, no `!important` hacks. Components compose and extend without breaking each other. That's the foundation everything else is built on.
20
21
 
21
- ## Features
22
+ On top of that foundation, Tasty gives you a concise, CSS-like DSL with design tokens, custom units, responsive states, container queries, dark mode, sub-element styling, and zero-runtime extraction — all in one coherent system that scales from a single component to an enterprise design system.
22
23
 
23
- - **Declarative state-aware styling** — style objects with state keys (`hovered`, `disabled`, `@media`, `@root`, etc.)
24
- - **Design token integration** — color tokens (`#purple`), custom units (`2x`, `1r`), typography presets
25
- - **Sub-element styling** — style inner elements via capitalized keys with `data-element` attributes
26
- - **Advanced state mapping** — media queries, container queries, root states, supports queries with boolean logic
27
- - **Zero-runtime mode** — Babel plugin extracts CSS at build time for static sites
28
- - **Plugin system** — extensible with custom color functions (OKHSL, etc.)
29
- - **React hooks** — `useStyles`, `useGlobalStyles`, `useRawCSS` for programmatic style injection
30
- - **Style extension** — compose and extend styled components with proper merge semantics
31
- - **Recipes** — named style bundles for reusable patterns
32
- - **TypeScript-first** — full type definitions with module augmentation support
33
- - **Tree-shakeable ESM** — unbundled output with `sideEffects: false`
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.
27
+ - **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.
28
+ - **Design-system native** — Color tokens (`#primary`), spacing units (`2x`), typography presets (`h1`, `t2`), border radius (`1r`), and recipes are first-class primitives, not afterthoughts.
29
+ - **Full modern CSS coverage** — Media queries, container queries, `@supports`, `:has()`, `@starting-style`, `@property`, keyframes, boolean state logic with `&`, `|`, `!` operators. If CSS can do it, Tasty can express it — concisely.
30
+ - **Runtime or zero-runtime — your call** — Use `tasty()` for dynamic React components with runtime injection, or `tastyStatic()` with the Babel plugin for zero-runtime CSS extraction. Same DSL, same tokens, same output.
31
+ - **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.
32
+ - **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.
33
+ - **Composable and extensible by design** — Extend any component's styles with proper merge semantics, and evolve built-in behavior through configuration and plugins.
34
+ - **TypeScript-first** — Full type definitions, module augmentation for custom properties, and autocomplete for tokens, presets, and themes.
34
35
 
35
36
  ## Installation
36
37
 
@@ -38,17 +39,9 @@ Tasty is a powerful CSS-in-JS styling system for React that combines declarative
38
39
  pnpm add @tenphi/tasty
39
40
  ```
40
41
 
41
- ```bash
42
- npm install @tenphi/tasty
43
- ```
44
-
45
- ```bash
46
- yarn add @tenphi/tasty
47
- ```
48
-
49
42
  ## Quick Start
50
43
 
51
- ### Creating Styled Components
44
+ ### Create a styled component
52
45
 
53
46
  ```tsx
54
47
  import { tasty } from '@tenphi/tasty';
@@ -56,50 +49,68 @@ import { tasty } from '@tenphi/tasty';
56
49
  const Card = tasty({
57
50
  as: 'div',
58
51
  styles: {
52
+ display: 'flex',
53
+ flow: 'column',
59
54
  padding: '4x',
60
- fill: '#white',
61
- border: true,
62
- radius: true,
55
+ gap: '2x',
56
+ fill: '#surface',
57
+ border: '#border bottom',
58
+ radius: '1r',
63
59
  },
64
60
  });
65
61
 
62
+ // Just a React component
66
63
  <Card>Hello World</Card>
67
64
  ```
68
65
 
69
- ### State-Based Styling
66
+ Every value maps to CSS you'd recognize — but with tokens and units that keep your design system consistent by default.
67
+
68
+ ### Add state-driven styles
70
69
 
71
70
  ```tsx
72
- const InteractiveCard = tasty({
71
+ const Button = tasty({
72
+ as: 'button',
73
73
  styles: {
74
+ padding: '1.5x 3x',
74
75
  fill: {
75
- '': '#white',
76
- 'hovered': '#gray.05',
77
- 'pressed': '#gray.10',
78
- '@media(w < 768px)': '#surface',
76
+ '': '#primary',
77
+ ':hover': '#primary-hover',
78
+ ':active': '#primary-pressed',
79
+ '[disabled]': '#surface',
79
80
  },
80
- padding: {
81
- '': '4x',
82
- '@media(w < 768px)': '2x',
81
+ color: {
82
+ '': '#on-primary',
83
+ '[disabled]': '#text.40',
83
84
  },
85
+ cursor: {
86
+ '': 'pointer',
87
+ '[disabled]': 'not-allowed',
88
+ },
89
+ transition: 'theme',
84
90
  },
85
91
  });
86
92
  ```
87
93
 
88
- ### Extending Components
94
+ 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.
95
+
96
+ ### Extend any component
89
97
 
90
98
  ```tsx
91
99
  import { Button } from 'my-ui-lib';
92
100
 
93
- const PrimaryButton = tasty(Button, {
101
+ const DangerButton = tasty(Button, {
94
102
  styles: {
95
- fill: '#purple',
96
- color: '#white',
97
- padding: '2x 4x',
103
+ fill: {
104
+ '': '#danger',
105
+ ':hover': '#danger-hover',
106
+ },
98
107
  },
99
108
  });
100
109
  ```
101
110
 
102
- ### Configuration
111
+ Child styles merge with parent styles intelligently — state maps can extend or replace parent states per-property.
112
+
113
+ ### Configure once, use everywhere
103
114
 
104
115
  ```tsx
105
116
  import { configure } from '@tenphi/tasty';
@@ -107,154 +118,346 @@ import { configure } from '@tenphi/tasty';
107
118
  configure({
108
119
  states: {
109
120
  '@mobile': '@media(w < 768px)',
110
- '@dark': '@root(theme=dark)',
121
+ '@tablet': '@media(w < 1024px)',
122
+ '@dark': '@root(schema=dark) | @media(prefers-color-scheme: dark)',
111
123
  },
112
124
  recipes: {
113
- card: {
114
- padding: '4x',
115
- fill: '#surface',
116
- radius: '1r',
117
- border: true,
118
- },
125
+ card: { padding: '4x', fill: '#surface', radius: '1r', border: true },
119
126
  },
120
127
  });
121
128
  ```
122
129
 
123
- ## Entry Points
130
+ Predefined states turn complex selector logic into single tokens. Use `@mobile` instead of writing media query expressions in every component.
124
131
 
125
- | Import | Description | Platform |
126
- |--------|-------------|----------|
127
- | `@tenphi/tasty` | Runtime style engine | Browser |
128
- | `@tenphi/tasty/static` | Build-time static style generation | Browser |
129
- | `@tenphi/tasty/babel-plugin` | Babel plugin for zero-runtime | Node |
130
- | `@tenphi/tasty/zero` | Programmatic extraction API | Node |
131
- | `@tenphi/tasty/next` | Next.js integration wrapper | Node |
132
+ ## How It Actually Works
133
+
134
+ This is the core idea that makes everything else possible.
132
135
 
133
- ## Core Concepts
136
+ Traditional CSS uses the cascade to resolve conflicts: when multiple selectors match, the one with the highest specificity wins, or — if specificity is equal — the last one in source order wins. This makes styles inherently fragile. Reordering imports, adding a new media query, or composing components from different libraries can silently break styling.
134
137
 
135
- ### Design Tokens
138
+ Tasty takes a fundamentally different approach: **every state mapping compiles into selectors that are guaranteed to never overlap.**
136
139
 
137
140
  ```tsx
138
- const TokenCard = tasty({
141
+ const Text = tasty({
139
142
  styles: {
140
- fill: '#surface', // Color token → var(--surface-color)
141
- color: '#text', // Color token
142
- padding: '2x', // Gap multiplier → calc(var(--gap) * 2)
143
- radius: '1r', // Border radius → var(--radius)
144
- border: '1bw solid #border',
143
+ color: {
144
+ '': '#text',
145
+ '@dark': '#text-on-dark',
146
+ },
147
+ padding: {
148
+ '': '4x',
149
+ '@mobile': '2x',
150
+ },
145
151
  },
146
152
  });
147
153
  ```
148
154
 
155
+ If `@dark` expands to `@root(schema=dark) | @media(prefers-color-scheme: dark)`, Tasty generates:
156
+
157
+ ```css
158
+ /* Explicit dark mode */
159
+ :root[data-schema="dark"] .t0.t0 {
160
+ color: var(--text-on-dark-color);
161
+ }
162
+
163
+ /* OS dark preference, no explicit override */
164
+ @media (prefers-color-scheme: dark) {
165
+ :root:not([data-schema="dark"]) .t0.t0 {
166
+ color: var(--text-on-dark-color);
167
+ }
168
+ }
169
+
170
+ /* Light mode — neither condition */
171
+ @media (not (prefers-color-scheme: dark)) {
172
+ :root:not([data-schema="dark"]) .t0.t0 {
173
+ color: var(--text-color);
174
+ }
175
+ }
176
+ ```
177
+
178
+ Every rule is guarded by the negation of all higher-priority rules. No two rules can ever match simultaneously. No specificity arithmetic. No source-order dependence. Components compose and extend without ever colliding.
179
+
180
+ ## Capabilities
181
+
182
+ ### Design Tokens and Custom Units
183
+
184
+ Tokens are first-class. Colors use `#name` syntax. Spacing, radius, and border width use multiplier units tied to CSS custom properties:
185
+
186
+ ```tsx
187
+ fill: '#surface', // → var(--surface-color)
188
+ color: '#text.80', // → 80% opacity text token
189
+ padding: '2x', // → calc(var(--gap) * 2)
190
+ radius: '1r', // → var(--radius)
191
+ border: '1bw solid #border',
192
+ ```
193
+
194
+ | Unit | Maps to | Example |
195
+ |------|---------|---------|
196
+ | `x` | `--gap` multiplier | `2x` → `calc(var(--gap) * 2)` |
197
+ | `r` | `--radius` multiplier | `1r` → `var(--radius)` |
198
+ | `bw` | `--border-width` multiplier | `1bw` → `var(--border-width)` |
199
+ | `ow` | `--outline-width` multiplier | `1ow` → `var(--outline-width)` |
200
+ | `cr` | `--card-radius` multiplier | `1cr` → `var(--card-radius)` |
201
+
202
+ Define your own units via `configure({ units: { ... } })`.
203
+
204
+ ### State System
205
+
206
+ Every style property accepts a state mapping object. Keys can be combined with boolean logic:
207
+
208
+ | State type | Syntax | CSS output |
209
+ |------------|--------|------------|
210
+ | Data attribute (boolean modifier) | `disabled` | `[data-disabled]` |
211
+ | Data attribute (value modifier) | `theme=danger` | `[data-theme="danger"]` |
212
+ | Pseudo-class | `:hover` | `:hover` |
213
+ | Attribute selector | `[role="tab"]` | `[role="tab"]` |
214
+ | Class selector (supported) | `.is-active` | `.is-active` |
215
+ | Media query | `@media(w < 768px)` | `@media (width < 768px)` |
216
+ | Container query | `@(panel, w >= 300px)` | `@container panel (width >= 300px)` |
217
+ | Root state | `@root(theme=dark)` | `:root[data-theme="dark"]` |
218
+ | Parent state | `@parent(theme=danger)` | `:is([data-theme="danger"] *)` |
219
+ | Feature query | `@supports(display: grid)` | `@supports (display: grid)` |
220
+ | Entry animation | `@starting` | `@starting-style` |
221
+
222
+ Combine with `&` (AND), `|` (OR), `!` (NOT):
223
+
224
+ ```tsx
225
+ fill: {
226
+ '': '#surface',
227
+ 'theme=danger & :hover': '#danger-hover',
228
+ '[aria-selected="true"]': '#accent-subtle',
229
+ }
230
+ ```
231
+
149
232
  ### Sub-Element Styling
150
233
 
234
+ Style inner elements from the parent component definition. No extra components, no CSS leakage:
235
+
151
236
  ```tsx
152
237
  const Card = tasty({
153
238
  styles: {
154
239
  padding: '4x',
155
240
  Title: { preset: 'h3', color: '#primary' },
156
- Content: { color: '#text' },
157
- },
158
- elements: {
159
- Title: 'h2',
160
- Content: 'div',
241
+ Content: { color: '#text', preset: 't2' },
161
242
  },
243
+ elements: { Title: 'h2', Content: 'div' },
162
244
  });
163
245
 
164
246
  <Card>
165
- <Card.Title>Title</Card.Title>
166
- <Card.Content>Content</Card.Content>
247
+ <Card.Title>Heading</Card.Title>
248
+ <Card.Content>Body text</Card.Content>
167
249
  </Card>
168
250
  ```
169
251
 
170
- ### Hooks
252
+ Sub-elements use `data-element` attributes — no extra class names, no naming conventions.
253
+
254
+ 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.
255
+
256
+ Use `@own(...)` when a sub-element should react to its own state instead of the root state context.
257
+
258
+ Class selectors are also supported, but modifiers/pseudo-classes are usually the better default in design-system code.
259
+
260
+ Use the sub-element selector `$` when you need precise descendant targeting to avoid leakage in deeply nested component trees.
261
+
262
+ ### Variants
263
+
264
+ 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.
265
+
266
+ ```tsx
267
+ const Button = tasty({
268
+ styles: { padding: '2x 4x', radius: '1r' },
269
+ variants: {
270
+ default: { fill: '#primary', color: '#on-primary' },
271
+ danger: { fill: '#danger', color: '#on-danger' },
272
+ outline: { fill: 'transparent', border: '1bw solid #primary' },
273
+ },
274
+ });
275
+
276
+ <Button variant="danger">Delete</Button>
277
+ ```
278
+
279
+ ### Recipes
280
+
281
+ 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.
171
282
 
172
283
  ```tsx
173
- import { useStyles, useGlobalStyles } from '@tenphi/tasty';
284
+ configure({
285
+ recipes: {
286
+ card: { padding: '4x', fill: '#surface', radius: '1r', border: true },
287
+ elevated: { shadow: '0 2x 4x #shadow' },
288
+ },
289
+ });
174
290
 
175
- function MyComponent() {
176
- const { className } = useStyles({
177
- padding: '2x',
178
- fill: '#surface',
179
- });
291
+ const ProfileCard = tasty({
292
+ styles: {
293
+ recipe: 'card elevated',
294
+ color: '#text',
295
+ },
296
+ });
297
+ ```
180
298
 
181
- useGlobalStyles('.card', {
182
- border: '1bw solid #border',
183
- radius: '1r',
184
- });
299
+ 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'`.
300
+
301
+ ### Keyframes and `@property`
302
+
303
+ Modern CSS features are natively supported:
304
+
305
+ Color tokens are automatically registered as typed properties (`<color>`), so token-based transitions work without extra setup.
306
+
307
+ ```tsx
308
+ const Pulse = tasty({
309
+ styles: {
310
+ '@properties': {
311
+ '$pulse-scale': {
312
+ syntax: '<number>',
313
+ inherits: false,
314
+ initialValue: 1,
315
+ },
316
+ },
317
+ animation: 'pulse 2s infinite',
318
+ transform: 'scale($pulse-scale)',
319
+ '@keyframes': {
320
+ pulse: {
321
+ '0%, 100%': { '$pulse-scale': 1 },
322
+ '50%': { '$pulse-scale': 1.05 },
323
+ },
324
+ },
325
+ },
326
+ });
327
+ ```
328
+
329
+ ### React Hooks
330
+
331
+ For cases where you don't need a full component:
332
+
333
+ ```tsx
334
+ import { useStyles, useGlobalStyles, useRawCSS } from '@tenphi/tasty';
335
+
336
+ function App() {
337
+ const { className } = useStyles({ padding: '2x', fill: '#surface' });
338
+ useGlobalStyles(':root', { '#primary': 'purple', '$gap': '8px' });
339
+ useRawCSS('body { margin: 0; }');
185
340
 
186
- return <div className={className}>Styled</div>;
341
+ return <main className={className}>...</main>;
187
342
  }
188
343
  ```
189
344
 
190
345
  ### Zero-Runtime Mode
191
346
 
347
+ Extract all CSS at build time. Zero JavaScript overhead in production:
348
+
192
349
  ```tsx
193
350
  import { tastyStatic } from '@tenphi/tasty/static';
194
351
 
195
- const button = tastyStatic({
196
- display: 'inline-flex',
197
- padding: '2x 4x',
198
- fill: '#purple',
199
- color: '#white',
352
+ const card = tastyStatic({
353
+ padding: '4x',
354
+ fill: '#surface',
355
+ radius: '1r',
356
+ color: { '': '#text', '@dark': '#text-on-dark' },
200
357
  });
201
358
 
202
- <button className={button}>Click me</button>
359
+ // card is a CSS class name string
360
+ <div className={card}>Static styles, zero runtime</div>
203
361
  ```
204
362
 
205
363
  Configure the Babel plugin:
206
364
 
207
365
  ```js
208
- // babel.config.js
209
366
  module.exports = {
210
367
  plugins: [
211
- ['@tenphi/tasty/babel-plugin', { output: 'public/tasty.css' }],
368
+ ['@tenphi/tasty/babel-plugin', {
369
+ output: 'public/tasty.css',
370
+ config: {
371
+ states: { '@dark': '@root(theme=dark)' },
372
+ },
373
+ }],
212
374
  ],
213
375
  };
214
376
  ```
215
377
 
216
- ## Built-in Units
378
+ ### `tasty` vs `tastyStatic`
379
+
380
+ | | `tasty` (runtime) | `tastyStatic` (zero-runtime) |
381
+ |---|---|---|
382
+ | **Output** | React component | CSS class name |
383
+ | **CSS injection** | Runtime `<style>` tags | Build-time extraction |
384
+ | **Runtime cost** | Style generation on mount | None |
385
+ | **Generated CSS scope** | Only styles/variants used at runtime | All extracted static styles at build time |
386
+ | **Dynamic values** | Fully supported | Via CSS custom properties |
387
+ | **Sub-elements** | Built-in (`<C.Title>`) | Manual (`data-element`) |
388
+ | **Variants** | Built-in (`variants` option) | Separate static styles |
389
+ | **Framework** | React | Any (requires Babel) |
390
+ | **Best for** | Interactive apps, design systems | Static sites, SSG, landing pages |
391
+
392
+ Both share the same DSL, tokens, units, state mappings, and recipes.
393
+
394
+ ### Runtime Performance
395
+
396
+ If you choose the runtime approach, performance is usually a non-issue in practice:
397
+
398
+ - CSS is generated and injected only when styles are actually used.
399
+ - Multi-level caching avoids repeated parsing and style recomputation.
400
+ - Styles are split into reusable chunks and applied as multiple class names, so matching chunks can be reused across components instead of re-injected.
401
+ - Style normalization guarantees equivalent style input resolves to the same chunks, improving deduplication hit rates.
402
+ - A style garbage collector removes unused styles/chunks over time.
403
+ - A dedicated style injector minimizes DOM/style-tag overhead.
404
+ - This approach is validated in enterprise-scale apps where runtime styling overhead is not noticeable in normal UI flows.
405
+
406
+ ## Entry Points
407
+
408
+ | Import | Description | Platform |
409
+ |--------|-------------|----------|
410
+ | `@tenphi/tasty` | Runtime style engine | Browser |
411
+ | `@tenphi/tasty/static` | Zero-runtime static styles | Browser |
412
+ | `@tenphi/tasty/babel-plugin` | Babel plugin for CSS extraction | Node |
413
+ | `@tenphi/tasty/zero` | Programmatic extraction API | Node |
414
+ | `@tenphi/tasty/next` | Next.js integration | Node |
415
+
416
+ ## Ecosystem
217
417
 
218
- | Unit | Description | Example | CSS Output |
219
- |------|-------------|---------|------------|
220
- | `x` | Gap multiplier | `2x` | `calc(var(--gap) * 2)` |
221
- | `r` | Border radius | `1r` | `var(--radius)` |
222
- | `cr` | Card border radius | `1cr` | `var(--card-radius)` |
223
- | `bw` | Border width | `2bw` | `calc(var(--border-width) * 2)` |
224
- | `ow` | Outline width | `1ow` | `var(--outline-width)` |
225
- | `fs` | Font size | `1fs` | `var(--font-size)` |
226
- | `lh` | Line height | `1lh` | `var(--line-height)` |
227
- | `sf` | Stable fraction | `1sf` | `minmax(0, 1fr)` |
418
+ Tasty is the core of a production-ready styling platform. These companion tools complete the picture:
228
419
 
229
- ## `tasty` vs `tastyStatic`
420
+ ### [ESLint Plugin](https://github.com/tenphi/eslint-plugin-tasty)
230
421
 
231
- Tasty ships two styling APIs with different trade-offs. Pick the one that fits your project:
422
+ `@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.
232
423
 
233
- | | `tasty` (runtime) | `tastyStatic` (zero-runtime) |
234
- |---|---|---|
235
- | **Framework** | React only | Framework-agnostic (requires Babel) |
236
- | **Import** | `@tenphi/tasty` | `@tenphi/tasty/static` |
237
- | **Output** | React component | CSS class name (string) |
238
- | **CSS injection** | At runtime via `<style>` tags | At build time via Babel plugin |
239
- | **Runtime overhead** | Style generation + injection on mount | None — CSS is pre-extracted |
240
- | **Requires Babel plugin** | No | Yes (`@tenphi/tasty/babel-plugin`) |
241
- | **Component creation** | `tasty({ as, styles, ... })` | `tastyStatic({ ... })` returns a class |
242
- | **Extending components** | `tasty(BaseComponent, { styles })` | `tastyStatic(baseStyle, { ... })` |
243
- | **Global / selector styles** | `useGlobalStyles(selector, styles)` | `tastyStatic(selector, styles)` |
244
- | **Style props at runtime** | Yes `styleProps`, `styles`, `mods` | No all values must be static |
245
- | **Dynamic values** | Fully supported | Only via CSS custom properties |
246
- | **Sub-elements** | Built-in (`elements` + `<C.Title>`) | Manual (use `data-element` + CSS) |
247
- | **Variants** | Built-in (`variants` option) | Manual (create separate static styles) |
248
- | **Tokens** | `tokens` prop → inline CSS vars | `processTokens()` helper |
249
- | **Design tokens & units** | Full support (`#color`, `2x`, `1r`) | Full support (`#color`, `2x`, `1r`) |
250
- | **State mappings** | Full support (modifiers, media, etc.) | Full support (modifiers, media, etc.) |
251
- | **Recipes** | Supported via `configure()` | Supported via Babel plugin config |
252
- | **Best for** | Interactive React apps, design systems | Static sites, landing pages, SSG |
424
+ ```bash
425
+ pnpm add -D @tenphi/eslint-plugin-tasty
426
+ ```
427
+
428
+ ```js
429
+ import tasty from '@tenphi/eslint-plugin-tasty';
430
+ export default [tasty.configs.recommended];
431
+ ```
432
+
433
+ ### [Glaze](https://github.com/tenphi/glaze)
434
+
435
+ `@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.
436
+
437
+ ```tsx
438
+ import { glaze } from '@tenphi/glaze';
439
+
440
+ const theme = glaze(280, 80);
441
+ theme.colors({
442
+ surface: { lightness: 97 },
443
+ text: { base: 'surface', lightness: '-52', contrast: 'AAA' },
444
+ });
445
+
446
+ const tokens = theme.tasty(); // Ready-to-use Tasty tokens
447
+ ```
448
+
449
+ ### [VS Code Extension](https://github.com/tenphi/tasty-vscode-extension)
450
+
451
+ 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.
452
+
453
+ ### [Cube UI Kit](https://github.com/cube-js/cube-ui-kit)
454
+
455
+ 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.
253
456
 
254
457
  ## Documentation
255
458
 
256
- - [Runtime API (tasty)](docs/tasty.md) — Full runtime styling documentation
257
- - [Zero Runtime (tastyStatic)](docs/tasty-static.md) — Build-time static styling documentation
459
+ - **[Runtime API (tasty)](docs/tasty.md)** — Full runtime styling documentation: component creation, state mappings, sub-elements, variants, hooks, configuration, and style property reference
460
+ - **[Zero Runtime (tastyStatic)](docs/tasty-static.md)** — Build-time static styling: Babel plugin setup, Next.js integration, and static style patterns
258
461
 
259
462
  ## License
260
463
 
package/dist/config.d.ts CHANGED
@@ -178,7 +178,8 @@ interface TastyConfig {
178
178
  * tokens (`$name`/`#name` definitions), local states, `@keyframes`, and `@properties`.
179
179
  *
180
180
  * Components reference recipes via: `recipe: 'name1 name2'` in their styles.
181
- * Use `|` to separate base recipes from post recipes: `recipe: 'base1 base2 | post1'`.
181
+ * Use `/` to separate base recipes from post recipes: `recipe: 'base1 base2 / post1'`.
182
+ * Use `none` to skip base recipes: `recipe: 'none / post1'`.
182
183
  * Resolution order: `base_recipes → component styles → post_recipes`.
183
184
  *
184
185
  * Recipes cannot reference other recipes.
package/dist/config.js CHANGED
@@ -1,8 +1,8 @@
1
- import { CUSTOM_UNITS, getGlobalFuncs, getGlobalParser, normalizeColorTokenValue, resetGlobalPredefinedTokens, setGlobalPredefinedTokens } from "./utils/styles.js";
2
1
  import { isDevEnv } from "./utils/is-dev-env.js";
2
+ import { setGlobalPredefinedStates } from "./states/index.js";
3
+ import { CUSTOM_UNITS, getGlobalFuncs, getGlobalParser, normalizeColorTokenValue, resetGlobalPredefinedTokens, setGlobalPredefinedTokens } from "./utils/styles.js";
3
4
  import { normalizeHandlerDefinition, registerHandler, resetHandlers } from "./styles/predefined.js";
4
5
  import { StyleInjector } from "./injector/injector.js";
5
- import { setGlobalPredefinedStates } from "./states/index.js";
6
6
  import { clearPipelineCache, isSelector } from "./pipeline/index.js";
7
7
 
8
8
  //#region src/config.ts
@@ -223,9 +223,12 @@ function setGlobalRecipes(recipes) {
223
223
  warnOnce("recipes-after-styles", "[Tasty] Cannot update recipes after styles have been generated.\nThe new recipes will be ignored.");
224
224
  return;
225
225
  }
226
- if (devMode) for (const [name, recipeStyles] of Object.entries(recipes)) for (const key of Object.keys(recipeStyles)) {
227
- if (isSelector(key)) warnOnce(`recipe-selector-${name}-${key}`, `[Tasty] Recipe "${name}" contains sub-element key "${key}". Recipes must be flat styles without sub-element keys. Remove the sub-element key from the recipe definition.`);
228
- if (key === "recipe") warnOnce(`recipe-recursive-${name}`, `[Tasty] Recipe "${name}" contains a "recipe" key. Recipes cannot reference other recipes. Use space-separated names for composition: recipe: 'base elevated'.`);
226
+ if (devMode) for (const [name, recipeStyles] of Object.entries(recipes)) {
227
+ if (name === "none") warnOnce("recipe-reserved-none", "[Tasty] Recipe name \"none\" is reserved. It is used as a keyword meaning \"no base recipes\" (e.g. recipe: 'none / post-recipe'). Choose a different name for your recipe.");
228
+ for (const key of Object.keys(recipeStyles)) {
229
+ if (isSelector(key)) warnOnce(`recipe-selector-${name}-${key}`, `[Tasty] Recipe "${name}" contains sub-element key "${key}". Recipes must be flat styles without sub-element keys. Remove the sub-element key from the recipe definition.`);
230
+ if (key === "recipe") warnOnce(`recipe-recursive-${name}`, `[Tasty] Recipe "${name}" contains a "recipe" key. Recipes cannot reference other recipes. Use space-separated names for composition: recipe: 'base elevated'.`);
231
+ }
229
232
  }
230
233
  globalRecipes = recipes;
231
234
  }