@tenphi/tasty 0.0.0-snapshot.002b1b3

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.
Files changed (82) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +637 -0
  3. package/dist/async-storage-B7_o6FKt.js +44 -0
  4. package/dist/async-storage-B7_o6FKt.js.map +1 -0
  5. package/dist/collector-LuU1vZ68.d.ts +98 -0
  6. package/dist/collector-MOYY2SOr.js +230 -0
  7. package/dist/collector-MOYY2SOr.js.map +1 -0
  8. package/dist/config-A237aY9H.js +10235 -0
  9. package/dist/config-A237aY9H.js.map +1 -0
  10. package/dist/config-vuCRkBWX.d.ts +884 -0
  11. package/dist/context-CkSg-kDT.js +24 -0
  12. package/dist/context-CkSg-kDT.js.map +1 -0
  13. package/dist/core/index.d.ts +5 -0
  14. package/dist/core/index.js +6 -0
  15. package/dist/core-BkKav78f.js +1592 -0
  16. package/dist/core-BkKav78f.js.map +1 -0
  17. package/dist/css-writer-Cos9tQRM.js +329 -0
  18. package/dist/css-writer-Cos9tQRM.js.map +1 -0
  19. package/dist/format-global-rules-Dbc_1tc3.js +22 -0
  20. package/dist/format-global-rules-Dbc_1tc3.js.map +1 -0
  21. package/dist/format-rules-C2oiTsEO.js +143 -0
  22. package/dist/format-rules-C2oiTsEO.js.map +1 -0
  23. package/dist/hydrate-miFzWIKR.js +45 -0
  24. package/dist/hydrate-miFzWIKR.js.map +1 -0
  25. package/dist/index-CJMXAAO5.d.ts +1602 -0
  26. package/dist/index-dUtwpOux.d.ts +1266 -0
  27. package/dist/index.d.ts +5 -0
  28. package/dist/index.js +732 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/keyframes-DDtNo_hl.js +587 -0
  31. package/dist/keyframes-DDtNo_hl.js.map +1 -0
  32. package/dist/merge-styles-CtDJMhpJ.d.ts +7 -0
  33. package/dist/merge-styles-D_HbBOlq.js +144 -0
  34. package/dist/merge-styles-D_HbBOlq.js.map +1 -0
  35. package/dist/resolve-recipes-B7-823LL.js +144 -0
  36. package/dist/resolve-recipes-B7-823LL.js.map +1 -0
  37. package/dist/ssr/astro-client.d.ts +1 -0
  38. package/dist/ssr/astro-client.js +19 -0
  39. package/dist/ssr/astro-client.js.map +1 -0
  40. package/dist/ssr/astro-middleware.d.ts +15 -0
  41. package/dist/ssr/astro-middleware.js +19 -0
  42. package/dist/ssr/astro-middleware.js.map +1 -0
  43. package/dist/ssr/astro.d.ts +97 -0
  44. package/dist/ssr/astro.js +149 -0
  45. package/dist/ssr/astro.js.map +1 -0
  46. package/dist/ssr/index.d.ts +44 -0
  47. package/dist/ssr/index.js +10 -0
  48. package/dist/ssr/index.js.map +1 -0
  49. package/dist/ssr/next.d.ts +46 -0
  50. package/dist/ssr/next.js +75 -0
  51. package/dist/ssr/next.js.map +1 -0
  52. package/dist/static/index.d.ts +91 -0
  53. package/dist/static/index.js +50 -0
  54. package/dist/static/index.js.map +1 -0
  55. package/dist/static/inject.d.ts +5 -0
  56. package/dist/static/inject.js +17 -0
  57. package/dist/static/inject.js.map +1 -0
  58. package/dist/zero/babel.d.ts +81 -0
  59. package/dist/zero/babel.js +466 -0
  60. package/dist/zero/babel.js.map +1 -0
  61. package/dist/zero/index.d.ts +67 -0
  62. package/dist/zero/index.js +2 -0
  63. package/dist/zero/next.d.ts +86 -0
  64. package/dist/zero/next.js +143 -0
  65. package/dist/zero/next.js.map +1 -0
  66. package/docs/README.md +31 -0
  67. package/docs/adoption.md +298 -0
  68. package/docs/comparison.md +419 -0
  69. package/docs/configuration.md +394 -0
  70. package/docs/debug.md +320 -0
  71. package/docs/design-system.md +436 -0
  72. package/docs/dsl.md +688 -0
  73. package/docs/getting-started.md +217 -0
  74. package/docs/injector.md +544 -0
  75. package/docs/methodology.md +616 -0
  76. package/docs/pipeline.md +673 -0
  77. package/docs/react-api.md +557 -0
  78. package/docs/ssr.md +442 -0
  79. package/docs/styles.md +596 -0
  80. package/docs/tasty-static.md +532 -0
  81. package/package.json +222 -0
  82. package/tasty.config.ts +15 -0
@@ -0,0 +1,217 @@
1
+ # Getting Started
2
+
3
+ This guide walks you from zero to a working Tasty component, then through the optional shared configuration and tooling layers. It is the right starting point when you already want to try Tasty in code. If you are still deciding whether Tasty fits your team, start with [Comparison](comparison.md) and [Adoption Guide](adoption.md) first. For a feature overview, see the [README](../README.md). For the full style language reference, see the [Style DSL](dsl.md). For the React API, see the [React API](react-api.md). For the rest of the docs by role or task, see the [Docs Hub](README.md).
4
+
5
+ ---
6
+
7
+ ## Prerequisites
8
+
9
+ - **Node.js** >= 20
10
+ - **React** >= 18 (peer dependency)
11
+ - **Package manager**: pnpm, npm, or yarn
12
+
13
+ Tasty can be used immediately in a React app, but it is most compelling for teams building reusable components with intersecting states, variants, tokens, and design-system conventions.
14
+
15
+ ---
16
+
17
+ ## Install
18
+
19
+ ```bash
20
+ pnpm add @tenphi/tasty
21
+ ```
22
+
23
+ ---
24
+
25
+ ## Your first component
26
+
27
+ ```tsx
28
+ import { tasty } from '@tenphi/tasty';
29
+
30
+ const Card = tasty({
31
+ as: 'div',
32
+ styles: {
33
+ display: 'flex',
34
+ flow: 'column',
35
+ padding: '4x',
36
+ gap: '2x',
37
+ fill: '#white',
38
+ border: true,
39
+ radius: true,
40
+ },
41
+ });
42
+
43
+ export default function App() {
44
+ return <Card>Hello, Tasty!</Card>;
45
+ }
46
+ ```
47
+
48
+ `tasty()` returns a normal React component. Values like `4x`, `#white`, `true`, and `1r` are Tasty DSL — they map to CSS custom properties, shorthand expansions, and design tokens. See [Style Properties](styles.md) for the full reference.
49
+
50
+ ---
51
+
52
+ ## Optional: add shared configuration
53
+
54
+ Use `configure()` once, before your app renders, when your app or design system needs shared state aliases, tokens, recipes, or parser extensions:
55
+
56
+ ```tsx
57
+ // src/tasty-config.ts
58
+ import { configure } from '@tenphi/tasty';
59
+
60
+ configure({
61
+ states: {
62
+ '@mobile': '@media(w < 768px)',
63
+ '@dark': '@root(schema=dark)',
64
+ },
65
+ });
66
+ ```
67
+
68
+ These examples use `data-schema="dark"` as the root-state convention. If your app already uses a different attribute such as `data-theme="dark"`, keep the pattern and swap the attribute name consistently across your config and components.
69
+
70
+ Import this file at the top of your app entry point so it runs before any component renders:
71
+
72
+ ```tsx
73
+ // src/main.tsx
74
+ import './tasty-config';
75
+ import { createRoot } from 'react-dom/client';
76
+ import App from './App';
77
+
78
+ createRoot(document.getElementById('root')!).render(<App />);
79
+ ```
80
+
81
+ ### Define shared tokens and override default unit values
82
+
83
+ Color tokens like `#primary` resolve to CSS custom properties at runtime (e.g. `var(--primary-color)`). Built-in units like `x`, `r`, and `bw` already work without setup and multiply CSS custom properties by default. Use `configure({ tokens })` when you want to define shared token values or override the defaults your app uses:
84
+
85
+ ```tsx
86
+ // src/tasty-config.ts
87
+ import { configure } from '@tenphi/tasty';
88
+
89
+ configure({
90
+ tokens: {
91
+ '#primary': 'oklch(55% 0.25 265)',
92
+ '#surface': '#fff',
93
+ '#text': '#111',
94
+ '$gap': '8px',
95
+ '$radius': '4px',
96
+ '$border-width': '1px',
97
+ '$outline-width': '2px',
98
+ },
99
+ });
100
+ ```
101
+
102
+ Tokens support state maps for responsive or theme-aware values:
103
+
104
+ ```tsx
105
+ configure({
106
+ tokens: {
107
+ '#primary': {
108
+ '': 'oklch(55% 0.25 265)',
109
+ '@dark': 'oklch(75% 0.2 265)',
110
+ },
111
+ },
112
+ });
113
+ ```
114
+
115
+ Every component using `#primary`, `2x`, or `1r` adjusts automatically. Tokens are injected as `:root` CSS custom properties when the first style is rendered. You can also use standard CSS color values such as `rgb(...)`, `hsl(...)`, and named colors directly; `okhsl(...)` is the recommended choice when you want authored colors that stay aligned with Tasty's design-system-oriented workflow.
116
+
117
+ > **Note:** `configure({ replaceTokens })` is a separate mechanism — it replaces tokens with literal values at parse time (baked into CSS). Use it for value aliases like `$card-padding: '4x'` that should be resolved during style generation, not for defining color or unit values. See [Configuration — Replace Tokens](configuration.md#replace-tokens-parse-time-substitution) for details.
118
+
119
+ See [Configuration](configuration.md) for the full `configure()` API — tokens, replace tokens, recipes, custom units, style handlers, and TypeScript extensions.
120
+
121
+ ---
122
+
123
+ ## ESLint plugin
124
+
125
+ The ESLint plugin catches invalid style properties, bad token references, malformed state keys, and other mistakes at lint time — before they reach the browser.
126
+
127
+ ### Install
128
+
129
+ ```bash
130
+ pnpm add -D @tenphi/eslint-plugin-tasty
131
+ ```
132
+
133
+ ### Configure
134
+
135
+ Add the plugin to your flat config:
136
+
137
+ ```js
138
+ // eslint.config.js
139
+ import tasty from '@tenphi/eslint-plugin-tasty';
140
+
141
+ export default [
142
+ // ...your other configs
143
+ tasty.configs.recommended,
144
+ ];
145
+ ```
146
+
147
+ ### What `recommended` catches
148
+
149
+ The `recommended` config enables 18 of the plugin's 27 total rules. It covers the most common issues without turning on the stricter governance rules:
150
+
151
+ | Category | Rules | Examples |
152
+ |----------|-------|---------|
153
+ | Property validation | `known-property`, `valid-boolean-property`, `valid-sub-element` | Flags typos like `pading` or invalid boolean usage |
154
+ | Value validation | `valid-value`, `valid-color-token`, `valid-custom-unit` | Catches `#nonexistent` tokens, bad unit syntax |
155
+ | State validation | `valid-state-key`, `no-nested-state-map`, `require-default-state` | Validates state key syntax, ensures `''` default exists |
156
+ | Structure | `valid-styles-structure`, `no-important`, `no-nested-selector` | Prevents `!important`, invalid nesting |
157
+ | Static mode | `static-no-dynamic-values`, `static-valid-selector` | Enforces build-time constraints in `tastyStatic()` |
158
+ | Style properties | `valid-preset`, `valid-recipe`, `valid-transition`, `valid-directional-modifier`, `valid-radius-shape` | Validates preset names, recipe references, transition syntax |
159
+
160
+ ### Strict config
161
+
162
+ For stricter governance, use `tasty.configs.strict`. It adds rules that enforce best practices like preferring shorthand properties, consistent token usage, and flagging direct `styles` prop usage:
163
+
164
+ ```js
165
+ export default [
166
+ tasty.configs.strict,
167
+ ];
168
+ ```
169
+
170
+ ---
171
+
172
+ ## Editor support
173
+
174
+ **[VS Code Extension](https://github.com/tenphi/tasty-vscode-extension)** — Syntax highlighting for Tasty styles in TypeScript/TSX/JavaScript/JSX. Highlights color tokens, custom units, state keys, presets, and style properties inside `tasty()` and `tastyStatic()` calls. Install from the VS Code marketplace or from a `.vsix` file.
175
+
176
+ **[Glaze](https://github.com/tenphi/glaze)** — OKHSL-based color theme generator with automatic WCAG contrast solving. Generate light, dark, and high-contrast color palettes from a single hue and export them directly as Tasty color tokens. See the [Ecosystem section](../README.md#ecosystem) in the README.
177
+
178
+ ---
179
+
180
+ ## Choosing a rendering mode
181
+
182
+ `tasty()` is the default for all React apps. All `tasty()` components and style functions are hook-free and work as React Server Components without `'use client'`. In server-only contexts, they produce zero client JavaScript with the full feature set.
183
+
184
+ | Approach | Entry point | Best for | Trade-off |
185
+ |------|-------------|----------|-----------|
186
+ | **Runtime (default)** | `tasty()` from `@tenphi/tasty` | All React apps — server-rendered by default, zero client JS until you need interactivity | Full feature set (styleProps, sub-elements, variants); CSS computed during rendering |
187
+ | **Runtime + SSR integration** | Add `@tenphi/tasty/ssr/*` | Apps with client-side hydration (Next.js client components, Astro islands) | Adds CSS batching, deduplication, FOUC prevention, and client cache hydration |
188
+ | **Zero-runtime** | `tastyStatic()` from `@tenphi/tasty/static` | Non-React frameworks or build-time extraction without React | Requires Babel plugin; no `styleProps` or runtime-only APIs |
189
+
190
+ Both `tasty()` and `tastyStatic()` share the same DSL, tokens, units, and state mappings.
191
+
192
+ - **Runtime** is the default and requires no extra setup beyond `@tenphi/tasty`. In server-only contexts (Next.js RSC, Astro without `client:*` directives, SSG), `tasty()` produces static HTML + CSS with zero client JavaScript — the same end result as `tastyStatic()` but with the full feature set. For example, `tasty()` + `tastyIntegration()` in Astro without islands gives you the complete API with zero JS shipped.
193
+ - **SSR integration** is only needed when your app also has client-side rendering. Add `@tenphi/tasty/ssr/next`, `@tenphi/tasty/ssr/astro`, or the core SSR API to get CSS deduplication and cache hydration. See [Server-Side Rendering](ssr.md).
194
+ - **Zero-runtime** requires the Babel plugin and additional peer dependencies. Use it when you need build-time extraction without a React runtime. See [Zero Runtime (tastyStatic)](tasty-static.md).
195
+
196
+ ---
197
+
198
+ ## Next steps
199
+
200
+ - **[Docs Hub](README.md)** — Pick the next guide by role, styling approach, or task
201
+ - **[Methodology](methodology.md)** — The recommended patterns for structuring Tasty components: sub-elements, styleProps, tokens, extension
202
+ - **[Style DSL](dsl.md)** — State maps, tokens, units, extending semantics, keyframes, @property
203
+ - **[React API](react-api.md)** — `tasty()` factory, component props, variants, sub-elements, style functions
204
+ - **[Building a Design System](design-system.md)** — Practical guide to building a DS layer with Tasty: tokens, recipes, primitives, compound components
205
+ - **[Adoption Guide](adoption.md)** — Roll out Tasty inside an existing design system or platform team
206
+ - **[Comparison](comparison.md)** — Evaluate Tasty against other styling systems
207
+ - **[Configuration](configuration.md)** — Full `configure()` API: tokens, recipes, custom units, style handlers, TypeScript extensions
208
+ - **[Style Properties](styles.md)** — Complete reference for all enhanced style properties
209
+ - **[Debug Utilities](debug.md)** — Inspect generated CSS and debug runtime behavior when styles do not look right
210
+
211
+ ---
212
+
213
+ ## Common issues
214
+
215
+ - Styles are missing on first render: make sure the file that calls `configure()` is imported before any `tasty()` component renders.
216
+ - Token or unit values are not what you expect: check your `configure({ tokens, units })` setup, then inspect the generated CSS variables with [Debug Utilities](debug.md).
217
+ - You need build-time extraction or server-rendered CSS delivery: use [Zero Runtime (tastyStatic)](tasty-static.md) for extraction, or add [Server-Side Rendering](ssr.md) on top of runtime `tasty()` when your framework renders on the server.