@tenphi/tasty 0.0.0-snapshot.275370e → 0.0.0-snapshot.27b6708
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 +175 -109
- package/dist/{ssr/async-storage.js → async-storage-DKK-wTD4.js} +2 -2
- package/dist/async-storage-DKK-wTD4.js.map +1 -0
- package/dist/babel-BUQGeOXA.d.ts +83 -0
- package/dist/{ssr/collector.js → collector-DTahQUiV.js} +97 -28
- package/dist/collector-DTahQUiV.js.map +1 -0
- package/dist/{ssr/collector.d.ts → collector-DUaHCcTS.d.ts} +54 -7
- package/dist/config-B5kHzuNz.js +12269 -0
- package/dist/config-B5kHzuNz.js.map +1 -0
- package/dist/config-YsxGv4tq.d.ts +1263 -0
- package/dist/{ssr/context.js → context-CA8YKeMn.js} +11 -3
- package/dist/context-CA8YKeMn.js.map +1 -0
- package/dist/core/index.d.ts +5 -34
- package/dist/core/index.js +6 -27
- package/dist/core-Dr4u1NVD.js +1566 -0
- package/dist/core-Dr4u1NVD.js.map +1 -0
- package/dist/{zero/extractor.js → css-writer-B-J87ncv.js} +148 -24
- package/dist/css-writer-B-J87ncv.js.map +1 -0
- package/dist/{ssr/format-global-rules.js → format-global-rules-DklyaXv-.js} +2 -2
- package/dist/format-global-rules-DklyaXv-.js.map +1 -0
- package/dist/{ssr/format-rules.js → format-rules-DKOA-6qu.js} +59 -2
- package/dist/format-rules-DKOA-6qu.js.map +1 -0
- package/dist/{ssr/hydrate.js → hydrate-OeMX99We.js} +3 -11
- package/dist/hydrate-OeMX99We.js.map +1 -0
- package/dist/index-Cd45t5NM.d.ts +1521 -0
- package/dist/index-PqN-DIpn.d.ts +1911 -0
- package/dist/index.d.ts +5 -51
- package/dist/index.js +922 -36
- package/dist/index.js.map +1 -0
- package/dist/keyframes-CV8azJf3.js +493 -0
- package/dist/keyframes-CV8azJf3.js.map +1 -0
- package/dist/{utils/merge-styles.d.ts → merge-styles-CU7JbEwg.d.ts} +3 -3
- package/dist/{utils/merge-styles.js → merge-styles-oklji0KB.js} +3 -4
- package/dist/merge-styles-oklji0KB.js.map +1 -0
- package/dist/{utils/resolve-recipes.js → resolve-recipes-DTG81rzl.js} +4 -6
- package/dist/resolve-recipes-DTG81rzl.js.map +1 -0
- package/dist/ssr/astro-client.js +1 -1
- package/dist/ssr/astro-client.js.map +1 -1
- package/dist/ssr/astro-middleware-static.d.ts +16 -0
- package/dist/ssr/astro-middleware-static.js +18 -0
- package/dist/ssr/astro-middleware-static.js.map +1 -0
- package/dist/ssr/astro-middleware.d.ts +8 -6
- package/dist/ssr/astro-middleware.js +10 -10
- package/dist/ssr/astro-middleware.js.map +1 -1
- package/dist/ssr/astro.d.ts +2 -17
- package/dist/ssr/astro.js +29 -21
- package/dist/ssr/astro.js.map +1 -1
- package/dist/ssr/index.d.ts +37 -4
- package/dist/ssr/index.js +5 -5
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/next.d.ts +2 -3
- package/dist/ssr/next.js +7 -8
- package/dist/ssr/next.js.map +1 -1
- package/dist/static/index.d.ts +91 -5
- package/dist/static/index.js +49 -3
- package/dist/static/index.js.map +1 -0
- package/dist/static/inject.js.map +1 -1
- package/dist/zero/babel.d.ts +2 -81
- package/dist/zero/babel.js +45 -29
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.d.ts +81 -3
- package/dist/zero/index.js +2 -3
- package/dist/zero/next.d.ts +1 -1
- package/dist/zero/next.js +1 -1
- package/dist/zero/next.js.map +1 -1
- package/docs/README.md +13 -7
- package/docs/adoption.md +53 -28
- package/docs/ai-agents.md +224 -0
- package/docs/comparison.md +59 -30
- package/docs/configuration.md +498 -69
- package/docs/debug.md +18 -16
- package/docs/design-system.md +43 -24
- package/docs/dsl.md +510 -177
- package/docs/getting-started.md +55 -34
- package/docs/injector.md +60 -7
- package/docs/methodology.md +68 -36
- package/docs/migration-v3.md +285 -0
- package/docs/pipeline.md +741 -0
- package/docs/plugins.md +349 -0
- package/docs/react-api.md +162 -38
- package/docs/ssr.md +45 -35
- package/docs/styles.md +65 -16
- package/docs/tasty-static.md +25 -8
- package/package.json +44 -21
- package/tasty.config.ts +6 -0
- package/dist/_virtual/_rolldown/runtime.js +0 -7
- package/dist/chunks/cacheKey.d.ts +0 -1
- package/dist/chunks/cacheKey.js +0 -77
- package/dist/chunks/cacheKey.js.map +0 -1
- package/dist/chunks/definitions.d.ts +0 -37
- package/dist/chunks/definitions.js +0 -258
- package/dist/chunks/definitions.js.map +0 -1
- package/dist/chunks/index.d.ts +0 -1
- package/dist/chunks/renderChunk.d.ts +0 -1
- package/dist/chunks/renderChunk.js +0 -59
- package/dist/chunks/renderChunk.js.map +0 -1
- package/dist/compute-styles.d.ts +0 -31
- package/dist/compute-styles.js +0 -322
- package/dist/compute-styles.js.map +0 -1
- package/dist/config.d.ts +0 -407
- package/dist/config.js +0 -591
- package/dist/config.js.map +0 -1
- package/dist/counter-style/index.js +0 -51
- package/dist/counter-style/index.js.map +0 -1
- package/dist/debug.d.ts +0 -89
- package/dist/debug.js +0 -453
- package/dist/debug.js.map +0 -1
- package/dist/font-face/index.js +0 -63
- package/dist/font-face/index.js.map +0 -1
- package/dist/hooks/index.d.ts +0 -7
- package/dist/hooks/useCounterStyle.d.ts +0 -36
- package/dist/hooks/useCounterStyle.js +0 -65
- package/dist/hooks/useCounterStyle.js.map +0 -1
- package/dist/hooks/useFontFace.d.ts +0 -45
- package/dist/hooks/useFontFace.js +0 -66
- package/dist/hooks/useFontFace.js.map +0 -1
- package/dist/hooks/useGlobalStyles.d.ts +0 -46
- package/dist/hooks/useGlobalStyles.js +0 -88
- package/dist/hooks/useGlobalStyles.js.map +0 -1
- package/dist/hooks/useKeyframes.d.ts +0 -58
- package/dist/hooks/useKeyframes.js +0 -55
- package/dist/hooks/useKeyframes.js.map +0 -1
- package/dist/hooks/useProperty.d.ts +0 -81
- package/dist/hooks/useProperty.js +0 -96
- package/dist/hooks/useProperty.js.map +0 -1
- package/dist/hooks/useRawCSS.d.ts +0 -22
- package/dist/hooks/useRawCSS.js +0 -103
- package/dist/hooks/useRawCSS.js.map +0 -1
- package/dist/hooks/useStyles.d.ts +0 -40
- package/dist/hooks/useStyles.js +0 -31
- package/dist/hooks/useStyles.js.map +0 -1
- package/dist/injector/index.d.ts +0 -182
- package/dist/injector/index.js +0 -185
- package/dist/injector/index.js.map +0 -1
- package/dist/injector/injector.d.ts +0 -198
- package/dist/injector/injector.js +0 -651
- package/dist/injector/injector.js.map +0 -1
- package/dist/injector/sheet-manager.d.ts +0 -132
- package/dist/injector/sheet-manager.js +0 -699
- package/dist/injector/sheet-manager.js.map +0 -1
- package/dist/injector/types.d.ts +0 -235
- package/dist/keyframes/index.js +0 -206
- package/dist/keyframes/index.js.map +0 -1
- package/dist/parser/classify.js +0 -319
- package/dist/parser/classify.js.map +0 -1
- package/dist/parser/const.js +0 -60
- package/dist/parser/const.js.map +0 -1
- package/dist/parser/lru.js +0 -109
- package/dist/parser/lru.js.map +0 -1
- package/dist/parser/parser.d.ts +0 -25
- package/dist/parser/parser.js +0 -115
- package/dist/parser/parser.js.map +0 -1
- package/dist/parser/tokenizer.js +0 -69
- package/dist/parser/tokenizer.js.map +0 -1
- package/dist/parser/types.d.ts +0 -51
- package/dist/parser/types.js +0 -46
- package/dist/parser/types.js.map +0 -1
- package/dist/pipeline/conditions.d.ts +0 -134
- package/dist/pipeline/conditions.js +0 -406
- package/dist/pipeline/conditions.js.map +0 -1
- package/dist/pipeline/exclusive.js +0 -285
- package/dist/pipeline/exclusive.js.map +0 -1
- package/dist/pipeline/index.d.ts +0 -55
- package/dist/pipeline/index.js +0 -708
- package/dist/pipeline/index.js.map +0 -1
- package/dist/pipeline/materialize.js +0 -1157
- package/dist/pipeline/materialize.js.map +0 -1
- package/dist/pipeline/parseStateKey.d.ts +0 -15
- package/dist/pipeline/parseStateKey.js +0 -446
- package/dist/pipeline/parseStateKey.js.map +0 -1
- package/dist/pipeline/simplify.js +0 -690
- package/dist/pipeline/simplify.js.map +0 -1
- package/dist/pipeline/warnings.js +0 -18
- package/dist/pipeline/warnings.js.map +0 -1
- package/dist/plugins/index.d.ts +0 -2
- package/dist/plugins/okhsl-plugin.d.ts +0 -35
- package/dist/plugins/okhsl-plugin.js +0 -97
- package/dist/plugins/okhsl-plugin.js.map +0 -1
- package/dist/plugins/types.d.ts +0 -87
- package/dist/properties/index.js +0 -222
- package/dist/properties/index.js.map +0 -1
- package/dist/properties/property-type-resolver.d.ts +0 -24
- package/dist/properties/property-type-resolver.js +0 -90
- package/dist/properties/property-type-resolver.js.map +0 -1
- package/dist/rsc-cache.js +0 -79
- package/dist/rsc-cache.js.map +0 -1
- package/dist/ssr/async-storage.d.ts +0 -17
- package/dist/ssr/async-storage.js.map +0 -1
- package/dist/ssr/collect-auto-properties.js +0 -58
- package/dist/ssr/collect-auto-properties.js.map +0 -1
- package/dist/ssr/collector.js.map +0 -1
- package/dist/ssr/context.js.map +0 -1
- package/dist/ssr/format-global-rules.js.map +0 -1
- package/dist/ssr/format-keyframes.js +0 -69
- package/dist/ssr/format-keyframes.js.map +0 -1
- package/dist/ssr/format-property.js +0 -49
- package/dist/ssr/format-property.js.map +0 -1
- package/dist/ssr/format-rules.js.map +0 -1
- package/dist/ssr/hydrate.d.ts +0 -29
- package/dist/ssr/hydrate.js.map +0 -1
- package/dist/ssr/ssr-collector-ref.js +0 -29
- package/dist/ssr/ssr-collector-ref.js.map +0 -1
- package/dist/states/index.d.ts +0 -49
- package/dist/states/index.js +0 -170
- package/dist/states/index.js.map +0 -1
- package/dist/static/tastyStatic.d.ts +0 -46
- package/dist/static/tastyStatic.js +0 -30
- package/dist/static/tastyStatic.js.map +0 -1
- package/dist/static/types.d.ts +0 -49
- package/dist/static/types.js +0 -24
- package/dist/static/types.js.map +0 -1
- package/dist/styles/border.d.ts +0 -25
- package/dist/styles/border.js +0 -120
- package/dist/styles/border.js.map +0 -1
- package/dist/styles/color.d.ts +0 -14
- package/dist/styles/color.js +0 -26
- package/dist/styles/color.js.map +0 -1
- package/dist/styles/const.js +0 -17
- package/dist/styles/const.js.map +0 -1
- package/dist/styles/createStyle.js +0 -79
- package/dist/styles/createStyle.js.map +0 -1
- package/dist/styles/dimension.js +0 -109
- package/dist/styles/dimension.js.map +0 -1
- package/dist/styles/directional.js +0 -133
- package/dist/styles/directional.js.map +0 -1
- package/dist/styles/display.d.ts +0 -30
- package/dist/styles/display.js +0 -73
- package/dist/styles/display.js.map +0 -1
- package/dist/styles/fade.d.ts +0 -15
- package/dist/styles/fade.js +0 -62
- package/dist/styles/fade.js.map +0 -1
- package/dist/styles/fill.d.ts +0 -42
- package/dist/styles/fill.js +0 -51
- package/dist/styles/fill.js.map +0 -1
- package/dist/styles/flow.d.ts +0 -16
- package/dist/styles/flow.js +0 -12
- package/dist/styles/flow.js.map +0 -1
- package/dist/styles/gap.d.ts +0 -31
- package/dist/styles/gap.js +0 -38
- package/dist/styles/gap.js.map +0 -1
- package/dist/styles/height.d.ts +0 -17
- package/dist/styles/height.js +0 -19
- package/dist/styles/height.js.map +0 -1
- package/dist/styles/index.d.ts +0 -1
- package/dist/styles/index.js +0 -8
- package/dist/styles/index.js.map +0 -1
- package/dist/styles/inset.d.ts +0 -24
- package/dist/styles/inset.js +0 -34
- package/dist/styles/inset.js.map +0 -1
- package/dist/styles/list.d.ts +0 -16
- package/dist/styles/list.js +0 -100
- package/dist/styles/list.js.map +0 -1
- package/dist/styles/margin.d.ts +0 -24
- package/dist/styles/margin.js +0 -32
- package/dist/styles/margin.js.map +0 -1
- package/dist/styles/outline.d.ts +0 -29
- package/dist/styles/outline.js +0 -55
- package/dist/styles/outline.js.map +0 -1
- package/dist/styles/padding.d.ts +0 -24
- package/dist/styles/padding.js +0 -32
- package/dist/styles/padding.js.map +0 -1
- package/dist/styles/placement.d.ts +0 -37
- package/dist/styles/placement.js +0 -74
- package/dist/styles/placement.js.map +0 -1
- package/dist/styles/predefined.d.ts +0 -71
- package/dist/styles/predefined.js +0 -237
- package/dist/styles/predefined.js.map +0 -1
- package/dist/styles/preset.d.ts +0 -52
- package/dist/styles/preset.js +0 -127
- package/dist/styles/preset.js.map +0 -1
- package/dist/styles/radius.d.ts +0 -12
- package/dist/styles/radius.js +0 -83
- package/dist/styles/radius.js.map +0 -1
- package/dist/styles/scrollMargin.d.ts +0 -24
- package/dist/styles/scrollMargin.js +0 -32
- package/dist/styles/scrollMargin.js.map +0 -1
- package/dist/styles/scrollbar.d.ts +0 -25
- package/dist/styles/scrollbar.js +0 -51
- package/dist/styles/scrollbar.js.map +0 -1
- package/dist/styles/shadow.d.ts +0 -14
- package/dist/styles/shadow.js +0 -25
- package/dist/styles/shadow.js.map +0 -1
- package/dist/styles/shared.js +0 -17
- package/dist/styles/shared.js.map +0 -1
- package/dist/styles/transition.d.ts +0 -14
- package/dist/styles/transition.js +0 -159
- package/dist/styles/transition.js.map +0 -1
- package/dist/styles/types.d.ts +0 -564
- package/dist/styles/width.d.ts +0 -17
- package/dist/styles/width.js +0 -19
- package/dist/styles/width.js.map +0 -1
- package/dist/tasty.d.ts +0 -134
- package/dist/tasty.js +0 -248
- package/dist/tasty.js.map +0 -1
- package/dist/types.d.ts +0 -184
- package/dist/utils/cache-wrapper.js +0 -21
- package/dist/utils/cache-wrapper.js.map +0 -1
- package/dist/utils/case-converter.js +0 -8
- package/dist/utils/case-converter.js.map +0 -1
- package/dist/utils/color-math.d.ts +0 -46
- package/dist/utils/color-math.js +0 -749
- package/dist/utils/color-math.js.map +0 -1
- package/dist/utils/color-space.d.ts +0 -5
- package/dist/utils/color-space.js +0 -228
- package/dist/utils/color-space.js.map +0 -1
- package/dist/utils/colors.d.ts +0 -5
- package/dist/utils/colors.js +0 -10
- package/dist/utils/colors.js.map +0 -1
- package/dist/utils/css-types.d.ts +0 -7
- package/dist/utils/deps-equal.js +0 -15
- package/dist/utils/deps-equal.js.map +0 -1
- package/dist/utils/dotize.d.ts +0 -26
- package/dist/utils/dotize.js +0 -122
- package/dist/utils/dotize.js.map +0 -1
- package/dist/utils/filter-base-props.d.ts +0 -15
- package/dist/utils/filter-base-props.js +0 -45
- package/dist/utils/filter-base-props.js.map +0 -1
- package/dist/utils/get-display-name.d.ts +0 -7
- package/dist/utils/get-display-name.js +0 -10
- package/dist/utils/get-display-name.js.map +0 -1
- package/dist/utils/has-keys.js +0 -13
- package/dist/utils/has-keys.js.map +0 -1
- package/dist/utils/hash.js +0 -14
- package/dist/utils/hash.js.map +0 -1
- package/dist/utils/is-dev-env.js +0 -19
- package/dist/utils/is-dev-env.js.map +0 -1
- package/dist/utils/is-valid-element-type.js +0 -15
- package/dist/utils/is-valid-element-type.js.map +0 -1
- package/dist/utils/merge-styles.js.map +0 -1
- package/dist/utils/mod-attrs.d.ts +0 -6
- package/dist/utils/mod-attrs.js +0 -20
- package/dist/utils/mod-attrs.js.map +0 -1
- package/dist/utils/process-tokens.d.ts +0 -17
- package/dist/utils/process-tokens.js +0 -83
- package/dist/utils/process-tokens.js.map +0 -1
- package/dist/utils/resolve-recipes.d.ts +0 -17
- package/dist/utils/resolve-recipes.js.map +0 -1
- package/dist/utils/selector-transform.js +0 -32
- package/dist/utils/selector-transform.js.map +0 -1
- package/dist/utils/string.js +0 -8
- package/dist/utils/string.js.map +0 -1
- package/dist/utils/styles.d.ts +0 -99
- package/dist/utils/styles.js +0 -220
- package/dist/utils/styles.js.map +0 -1
- package/dist/utils/typography.d.ts +0 -58
- package/dist/utils/typography.js +0 -51
- package/dist/utils/typography.js.map +0 -1
- package/dist/utils/warnings.d.ts +0 -16
- package/dist/utils/warnings.js +0 -16
- package/dist/utils/warnings.js.map +0 -1
- package/dist/zero/css-writer.d.ts +0 -45
- package/dist/zero/css-writer.js +0 -73
- package/dist/zero/css-writer.js.map +0 -1
- package/dist/zero/extractor.d.ts +0 -24
- package/dist/zero/extractor.js.map +0 -1
- package/docs/PIPELINE.md +0 -519
package/dist/zero/index.d.ts
CHANGED
|
@@ -1,3 +1,81 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { b as Styles } from "../index-Cd45t5NM.js";
|
|
2
|
+
|
|
3
|
+
//#region src/zero/extractor.d.ts
|
|
4
|
+
interface ExtractedChunk {
|
|
5
|
+
className: string;
|
|
6
|
+
css: string;
|
|
7
|
+
}
|
|
8
|
+
interface ExtractedSelector {
|
|
9
|
+
selector: string;
|
|
10
|
+
css: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Extract styles using chunking (for className mode).
|
|
14
|
+
* Returns multiple classes, one per chunk.
|
|
15
|
+
*/
|
|
16
|
+
declare function extractStylesWithChunks(styles: Styles): ExtractedChunk[];
|
|
17
|
+
/**
|
|
18
|
+
* Extract styles for a specific selector (for global/selector mode).
|
|
19
|
+
* Returns a single CSS block.
|
|
20
|
+
*/
|
|
21
|
+
declare function extractStylesForSelector(selector: string, styles: Styles): ExtractedSelector;
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/zero/css-writer.d.ts
|
|
24
|
+
interface CSSWriterOptions {
|
|
25
|
+
/** Enable source comments in output (e.g., "from: Button.tsx") */
|
|
26
|
+
devMode?: boolean;
|
|
27
|
+
}
|
|
28
|
+
declare class CSSWriter {
|
|
29
|
+
private cssBlocks;
|
|
30
|
+
private outputPath;
|
|
31
|
+
private devMode;
|
|
32
|
+
constructor(outputPath: string, options?: CSSWriterOptions);
|
|
33
|
+
/**
|
|
34
|
+
* Add CSS block with deduplication key
|
|
35
|
+
* @param key - Unique key for deduplication
|
|
36
|
+
* @param css - CSS content
|
|
37
|
+
* @param source - Optional source file path (used in devMode)
|
|
38
|
+
*/
|
|
39
|
+
add(key: string, css: string, source?: string): void;
|
|
40
|
+
/**
|
|
41
|
+
* Check if a key already exists
|
|
42
|
+
*/
|
|
43
|
+
has(key: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Get the number of CSS blocks
|
|
46
|
+
*/
|
|
47
|
+
get size(): number;
|
|
48
|
+
/**
|
|
49
|
+
* Write all collected CSS to the output file
|
|
50
|
+
*/
|
|
51
|
+
write(): void;
|
|
52
|
+
/**
|
|
53
|
+
* Get all CSS as string (for testing or in-memory use)
|
|
54
|
+
*/
|
|
55
|
+
getCSS(): string;
|
|
56
|
+
/**
|
|
57
|
+
* Clear all collected CSS
|
|
58
|
+
*/
|
|
59
|
+
clear(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Get the output path
|
|
62
|
+
*/
|
|
63
|
+
getOutputPath(): string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Factory for creating a {@link CSSWriter} instance.
|
|
67
|
+
*
|
|
68
|
+
* Canonical functional entry point; the `CSSWriter` class remains exported
|
|
69
|
+
* for advanced/internal use.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* import { createCSSWriter } from '@tenphi/tasty/zero';
|
|
74
|
+
*
|
|
75
|
+
* const writer = createCSSWriter('output.css', { devMode: true });
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
declare function createCSSWriter(outputPath: string, options?: CSSWriterOptions): CSSWriter;
|
|
79
|
+
//#endregion
|
|
80
|
+
export { CSSWriter, type CSSWriterOptions, type ExtractedChunk, type ExtractedSelector, createCSSWriter, extractStylesForSelector, extractStylesWithChunks };
|
|
81
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/zero/index.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { extractStylesForSelector, extractStylesWithChunks } from "
|
|
2
|
-
|
|
3
|
-
export { CSSWriter, extractStylesForSelector, extractStylesWithChunks };
|
|
1
|
+
import { c as extractStylesForSelector, l as extractStylesWithChunks, n as createCSSWriter, t as CSSWriter } from "../css-writer-B-J87ncv.js";
|
|
2
|
+
export { CSSWriter, createCSSWriter, extractStylesForSelector, extractStylesWithChunks };
|
package/dist/zero/next.d.ts
CHANGED
package/dist/zero/next.js
CHANGED
|
@@ -20,7 +20,7 @@ import { fileURLToPath } from "url";
|
|
|
20
20
|
* @example
|
|
21
21
|
* ```javascript
|
|
22
22
|
* // next.config.js
|
|
23
|
-
* const { withTastyZero } = require('@tenphi/tasty/next');
|
|
23
|
+
* const { withTastyZero } = require('@tenphi/tasty/zero/next');
|
|
24
24
|
*
|
|
25
25
|
* module.exports = withTastyZero({
|
|
26
26
|
* output: 'public/tasty.css',
|
package/dist/zero/next.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.js","names":[],"sources":["../../src/zero/next.ts"],"sourcesContent":["/**\n * Next.js configuration wrapper for tasty-zero.\n *\n * Supports both webpack and Turbopack bundlers:\n * - **webpack**: Injects a babel-loader rule with the tasty-zero Babel plugin\n * via `webpack()` config hook. Config is passed as a jiti factory function.\n * - **Turbopack**: Adds a `turbopack.rules` entry with babel-loader and\n * JSON-serializable options (`configFile` path instead of a function).\n * The Babel plugin loads the config internally via jiti.\n *\n * The generated CSS is injected automatically — `@tenphi/tasty/static`\n * imports are replaced with an import of the output CSS file at build time.\n * No manual CSS import in layout files is needed.\n *\n * @example\n * ```javascript\n * // next.config.js\n * const { withTastyZero } = require('@tenphi/tasty/next');\n *\n * module.exports = withTastyZero({\n * output: 'public/tasty.css',\n * configFile: './app/tasty-zero.config.ts',\n * })({\n * // your Next.js config\n * });\n * ```\n */\n\nimport { createRequire } from 'module';\nimport * as path from 'path';\nimport { fileURLToPath } from 'url';\n\nimport { createJiti } from 'jiti';\n\nimport type { TastyZeroBabelOptions, TastyZeroConfig } from './babel';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n// Next.js types (inline to avoid requiring next as a dependency)\ninterface WebpackConfigContext {\n isServer: boolean;\n dev: boolean;\n buildId: string;\n dir: string;\n}\n\n/* eslint-disable @typescript-eslint/no-explicit-any -- webpack/Next.js config types are complex */\ninterface TurbopackLoaderItem {\n loader: string;\n options?: Record<string, unknown>;\n}\n\ninterface TurbopackRuleConfig {\n loaders: (string | TurbopackLoaderItem)[];\n as?: string;\n condition?: unknown;\n}\n\ninterface TurbopackConfig {\n rules?: Record<string, TurbopackRuleConfig | TurbopackRuleConfig[]>;\n [key: string]: unknown;\n}\n\ninterface NextConfig {\n webpack?: (config: any, context: WebpackConfigContext) => any;\n turbopack?: TurbopackConfig;\n [key: string]: unknown;\n}\n\nexport interface TastyZeroNextOptions {\n /**\n * Output path for CSS relative to project root.\n * @default 'public/tasty.css'\n */\n output?: string;\n\n /**\n * Whether to enable the plugin.\n * @default true\n */\n enabled?: boolean;\n\n /**\n * Tasty configuration for build-time processing.\n * For static configs that don't change during dev.\n *\n * For configs that depend on theme files, use `configFile` instead.\n */\n config?: TastyZeroConfig;\n\n /**\n * Path to a TypeScript/JavaScript module that exports the tasty zero config\n * as its default export. The module is re-evaluated on each\n * compilation, enabling hot reload when the file (or its imports) change.\n *\n * @example './app/tasty-zero.config.ts'\n */\n configFile?: string;\n\n /**\n * Extra file paths (relative to project root) that the config depends on.\n * When any of these files change, the Babel cache is invalidated and\n * the config is re-evaluated.\n *\n * The `configFile` itself is always tracked automatically.\n * Use this for transitive dependencies that aren't directly imported\n * by the config file, or when using `config` instead of `configFile`.\n *\n * @example ['./app/theme.ts']\n */\n configDeps?: string[];\n\n /**\n * Output mode for extracted CSS.\n *\n * - `'file'` (default): CSS is written to a single output file.\n * - `'inject'`: CSS is embedded inline in JS and injected at runtime.\n * No CSS file is written. Best for reusable components and extensions.\n *\n * When `mode` is `'inject'`, `output` is ignored.\n *\n * @default 'file'\n */\n mode?: 'file' | 'inject';\n}\n\n/**\n * Next.js configuration wrapper for tasty-zero.\n * Configures both webpack and Turbopack bundlers automatically.\n */\nexport function withTastyZero(options: TastyZeroNextOptions = {}) {\n const {\n output = 'public/tasty.css',\n enabled = true,\n config: tastyConfig,\n configFile,\n configDeps = [],\n mode,\n } = options;\n\n return (nextConfig: NextConfig = {}): NextConfig => {\n if (!enabled) {\n return nextConfig;\n }\n\n const projectDir = process.cwd();\n const absoluteOutput = path.resolve(projectDir, output);\n const babelPluginPath = path.resolve(__dirname, 'babel.js');\n\n const absoluteConfigFile = configFile\n ? path.resolve(projectDir, configFile)\n : undefined;\n\n const allDeps = [\n ...(absoluteConfigFile ? [absoluteConfigFile] : []),\n ...configDeps.map((dep) => path.resolve(projectDir, dep)),\n ];\n\n // --- Turbopack configuration ---\n // Turbopack loader options must be JSON-serializable (no functions).\n // The Babel plugin loads config internally via `configFile` path + jiti.\n const turbopackBabelOptions: Record<string, unknown> = {\n babelrc: false,\n configFile: false,\n parserOpts: {\n plugins: ['typescript', 'jsx', 'decorators-legacy'],\n },\n plugins: [\n [\n babelPluginPath,\n {\n output: absoluteOutput,\n injectImport: true,\n ...(mode ? { mode } : {}),\n ...(absoluteConfigFile\n ? { configFile: absoluteConfigFile }\n : tastyConfig\n ? { config: tastyConfig }\n : {}),\n ...(allDeps.length > 0 ? { configDeps: allDeps } : {}),\n },\n ],\n ],\n };\n\n const existingTurbopack = nextConfig.turbopack || {};\n const existingRules = existingTurbopack.rules || {};\n\n const existingExperimental =\n (nextConfig.experimental as Record<string, unknown>) || {};\n\n return {\n ...nextConfig,\n\n experimental: {\n ...existingExperimental,\n turbopackUseBuiltinBabel: true,\n },\n\n turbopack: {\n ...existingTurbopack,\n rules: {\n ...existingRules,\n '*.{ts,tsx,js,jsx}': {\n condition: { not: 'foreign' },\n loaders: [\n {\n loader: 'babel-loader',\n options: turbopackBabelOptions,\n },\n ],\n },\n },\n },\n\n webpack(config: any, context: WebpackConfigContext) {\n const { dir } = context;\n\n const wpProjectDir = dir || projectDir;\n const wpAbsoluteOutput = path.resolve(wpProjectDir, output);\n const projectRequire = createRequire(\n path.resolve(wpProjectDir, 'package.json'),\n );\n\n const wpAbsoluteConfigFile = configFile\n ? path.resolve(wpProjectDir, configFile)\n : undefined;\n\n const wpAllDeps = [\n ...(wpAbsoluteConfigFile ? [wpAbsoluteConfigFile] : []),\n ...configDeps.map((dep) => path.resolve(wpProjectDir, dep)),\n ];\n\n const babelPluginOptions: TastyZeroBabelOptions = {\n output: wpAbsoluteOutput,\n injectImport: true,\n ...(mode ? { mode } : {}),\n };\n\n if (wpAbsoluteConfigFile) {\n const jiti = createJiti(wpProjectDir, {\n moduleCache: false,\n });\n\n babelPluginOptions.config = () => {\n return jiti(wpAbsoluteConfigFile) as TastyZeroConfig;\n };\n } else if (tastyConfig) {\n babelPluginOptions.config = tastyConfig;\n }\n\n if (wpAllDeps.length > 0) {\n babelPluginOptions.configDeps = wpAllDeps;\n }\n\n const babelPluginConfig = [babelPluginPath, babelPluginOptions];\n\n const existingRule = config.module?.rules?.find(\n (rule: any) =>\n rule.use?.loader === 'babel-loader' ||\n rule.use?.some?.((u: any) => u.loader === 'babel-loader'),\n );\n\n if (existingRule) {\n const babelUse = Array.isArray(existingRule.use)\n ? existingRule.use.find((u: any) => u.loader === 'babel-loader')\n : existingRule.use;\n\n if (babelUse?.options) {\n babelUse.options.plugins = babelUse.options.plugins || [];\n babelUse.options.plugins.push(babelPluginConfig);\n }\n } else {\n config.module = config.module || {};\n config.module.rules = config.module.rules || [];\n config.module.rules.push({\n test: /\\.(tsx?|jsx?)$/,\n exclude: /node_modules/,\n use: [\n {\n loader: projectRequire.resolve('babel-loader'),\n options: {\n babelrc: false,\n configFile: false,\n parserOpts: {\n plugins: ['typescript', 'jsx', 'decorators-legacy'],\n },\n plugins: [babelPluginConfig],\n },\n },\n ],\n });\n }\n\n if (typeof nextConfig.webpack === 'function') {\n return nextConfig.webpack(config, context);\n }\n\n return config;\n },\n };\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAM,aAAa,cAAc,OAAO,KAAK,IAAI;AACjD,MAAM,YAAY,KAAK,QAAQ,WAAW;;;;;AA8F1C,SAAgB,cAAc,UAAgC,EAAE,EAAE;CAChE,MAAM,EACJ,SAAS,oBACT,UAAU,MACV,QAAQ,aACR,YACA,aAAa,EAAE,EACf,SACE;AAEJ,SAAQ,aAAyB,EAAE,KAAiB;AAClD,MAAI,CA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,WAChC,QAAO,WAAW,QAAQ,QAAQ,QAAQ;AAG5C,WAAO;;GAEV"}
|
|
1
|
+
{"version":3,"file":"next.js","names":[],"sources":["../../src/zero/next.ts"],"sourcesContent":["/**\n * Next.js configuration wrapper for tasty-zero.\n *\n * Supports both webpack and Turbopack bundlers:\n * - **webpack**: Injects a babel-loader rule with the tasty-zero Babel plugin\n * via `webpack()` config hook. Config is passed as a jiti factory function.\n * - **Turbopack**: Adds a `turbopack.rules` entry with babel-loader and\n * JSON-serializable options (`configFile` path instead of a function).\n * The Babel plugin loads the config internally via jiti.\n *\n * The generated CSS is injected automatically — `@tenphi/tasty/static`\n * imports are replaced with an import of the output CSS file at build time.\n * No manual CSS import in layout files is needed.\n *\n * @example\n * ```javascript\n * // next.config.js\n * const { withTastyZero } = require('@tenphi/tasty/zero/next');\n *\n * module.exports = withTastyZero({\n * output: 'public/tasty.css',\n * configFile: './app/tasty-zero.config.ts',\n * })({\n * // your Next.js config\n * });\n * ```\n */\n\nimport { createRequire } from 'module';\nimport * as path from 'path';\nimport { fileURLToPath } from 'url';\n\nimport { createJiti } from 'jiti';\n\nimport type { TastyZeroBabelOptions, TastyZeroConfig } from './babel';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n// Next.js types (inline to avoid requiring next as a dependency)\ninterface WebpackConfigContext {\n isServer: boolean;\n dev: boolean;\n buildId: string;\n dir: string;\n}\n\n/* eslint-disable @typescript-eslint/no-explicit-any -- webpack/Next.js config types are complex */\ninterface TurbopackLoaderItem {\n loader: string;\n options?: Record<string, unknown>;\n}\n\ninterface TurbopackRuleConfig {\n loaders: (string | TurbopackLoaderItem)[];\n as?: string;\n condition?: unknown;\n}\n\ninterface TurbopackConfig {\n rules?: Record<string, TurbopackRuleConfig | TurbopackRuleConfig[]>;\n [key: string]: unknown;\n}\n\ninterface NextConfig {\n webpack?: (config: any, context: WebpackConfigContext) => any;\n turbopack?: TurbopackConfig;\n [key: string]: unknown;\n}\n\nexport interface TastyZeroNextOptions {\n /**\n * Output path for CSS relative to project root.\n * @default 'public/tasty.css'\n */\n output?: string;\n\n /**\n * Whether to enable the plugin.\n * @default true\n */\n enabled?: boolean;\n\n /**\n * Tasty configuration for build-time processing.\n * For static configs that don't change during dev.\n *\n * For configs that depend on theme files, use `configFile` instead.\n */\n config?: TastyZeroConfig;\n\n /**\n * Path to a TypeScript/JavaScript module that exports the tasty zero config\n * as its default export. The module is re-evaluated on each\n * compilation, enabling hot reload when the file (or its imports) change.\n *\n * @example './app/tasty-zero.config.ts'\n */\n configFile?: string;\n\n /**\n * Extra file paths (relative to project root) that the config depends on.\n * When any of these files change, the Babel cache is invalidated and\n * the config is re-evaluated.\n *\n * The `configFile` itself is always tracked automatically.\n * Use this for transitive dependencies that aren't directly imported\n * by the config file, or when using `config` instead of `configFile`.\n *\n * @example ['./app/theme.ts']\n */\n configDeps?: string[];\n\n /**\n * Output mode for extracted CSS.\n *\n * - `'file'` (default): CSS is written to a single output file.\n * - `'inject'`: CSS is embedded inline in JS and injected at runtime.\n * No CSS file is written. Best for reusable components and extensions.\n *\n * When `mode` is `'inject'`, `output` is ignored.\n *\n * @default 'file'\n */\n mode?: 'file' | 'inject';\n}\n\n/**\n * Next.js configuration wrapper for tasty-zero.\n * Configures both webpack and Turbopack bundlers automatically.\n */\nexport function withTastyZero(options: TastyZeroNextOptions = {}) {\n const {\n output = 'public/tasty.css',\n enabled = true,\n config: tastyConfig,\n configFile,\n configDeps = [],\n mode,\n } = options;\n\n return (nextConfig: NextConfig = {}): NextConfig => {\n if (!enabled) {\n return nextConfig;\n }\n\n const projectDir = process.cwd();\n const absoluteOutput = path.resolve(projectDir, output);\n const babelPluginPath = path.resolve(__dirname, 'babel.js');\n\n const absoluteConfigFile = configFile\n ? path.resolve(projectDir, configFile)\n : undefined;\n\n const allDeps = [\n ...(absoluteConfigFile ? [absoluteConfigFile] : []),\n ...configDeps.map((dep) => path.resolve(projectDir, dep)),\n ];\n\n // --- Turbopack configuration ---\n // Turbopack loader options must be JSON-serializable (no functions).\n // The Babel plugin loads config internally via `configFile` path + jiti.\n const turbopackBabelOptions: Record<string, unknown> = {\n babelrc: false,\n configFile: false,\n parserOpts: {\n plugins: ['typescript', 'jsx', 'decorators-legacy'],\n },\n plugins: [\n [\n babelPluginPath,\n {\n output: absoluteOutput,\n injectImport: true,\n ...(mode ? { mode } : {}),\n ...(absoluteConfigFile\n ? { configFile: absoluteConfigFile }\n : tastyConfig\n ? { config: tastyConfig }\n : {}),\n ...(allDeps.length > 0 ? { configDeps: allDeps } : {}),\n },\n ],\n ],\n };\n\n const existingTurbopack = nextConfig.turbopack || {};\n const existingRules = existingTurbopack.rules || {};\n\n const existingExperimental =\n (nextConfig.experimental as Record<string, unknown>) || {};\n\n return {\n ...nextConfig,\n\n experimental: {\n ...existingExperimental,\n turbopackUseBuiltinBabel: true,\n },\n\n turbopack: {\n ...existingTurbopack,\n rules: {\n ...existingRules,\n '*.{ts,tsx,js,jsx}': {\n condition: { not: 'foreign' },\n loaders: [\n {\n loader: 'babel-loader',\n options: turbopackBabelOptions,\n },\n ],\n },\n },\n },\n\n webpack(config: any, context: WebpackConfigContext) {\n const { dir } = context;\n\n const wpProjectDir = dir || projectDir;\n const wpAbsoluteOutput = path.resolve(wpProjectDir, output);\n const projectRequire = createRequire(\n path.resolve(wpProjectDir, 'package.json'),\n );\n\n const wpAbsoluteConfigFile = configFile\n ? path.resolve(wpProjectDir, configFile)\n : undefined;\n\n const wpAllDeps = [\n ...(wpAbsoluteConfigFile ? [wpAbsoluteConfigFile] : []),\n ...configDeps.map((dep) => path.resolve(wpProjectDir, dep)),\n ];\n\n const babelPluginOptions: TastyZeroBabelOptions = {\n output: wpAbsoluteOutput,\n injectImport: true,\n ...(mode ? { mode } : {}),\n };\n\n if (wpAbsoluteConfigFile) {\n const jiti = createJiti(wpProjectDir, {\n moduleCache: false,\n });\n\n babelPluginOptions.config = () => {\n return jiti(wpAbsoluteConfigFile) as TastyZeroConfig;\n };\n } else if (tastyConfig) {\n babelPluginOptions.config = tastyConfig;\n }\n\n if (wpAllDeps.length > 0) {\n babelPluginOptions.configDeps = wpAllDeps;\n }\n\n const babelPluginConfig = [babelPluginPath, babelPluginOptions];\n\n const existingRule = config.module?.rules?.find(\n (rule: any) =>\n rule.use?.loader === 'babel-loader' ||\n rule.use?.some?.((u: any) => u.loader === 'babel-loader'),\n );\n\n if (existingRule) {\n const babelUse = Array.isArray(existingRule.use)\n ? existingRule.use.find((u: any) => u.loader === 'babel-loader')\n : existingRule.use;\n\n if (babelUse?.options) {\n babelUse.options.plugins = babelUse.options.plugins || [];\n babelUse.options.plugins.push(babelPluginConfig);\n }\n } else {\n config.module = config.module || {};\n config.module.rules = config.module.rules || [];\n config.module.rules.push({\n test: /\\.(tsx?|jsx?)$/,\n exclude: /node_modules/,\n use: [\n {\n loader: projectRequire.resolve('babel-loader'),\n options: {\n babelrc: false,\n configFile: false,\n parserOpts: {\n plugins: ['typescript', 'jsx', 'decorators-legacy'],\n },\n plugins: [babelPluginConfig],\n },\n },\n ],\n });\n }\n\n if (typeof nextConfig.webpack === 'function') {\n return nextConfig.webpack(config, context);\n }\n\n return config;\n },\n };\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAM,aAAa,cAAc,OAAO,KAAK,GAAG;AAChD,MAAM,YAAY,KAAK,QAAQ,UAAU;;;;;AA8FzC,SAAgB,cAAc,UAAgC,CAAC,GAAG;CAChE,MAAM,EACJ,SAAS,oBACT,UAAU,MACV,QAAQ,aACR,YACA,aAAa,CAAC,GACd,SACE;CAEJ,QAAQ,aAAyB,CAAC,MAAkB;EAClD,IAAI,CAAC,SACH,OAAO;EAGT,MAAM,aAAa,QAAQ,IAAI;EAC/B,MAAM,iBAAiB,KAAK,QAAQ,YAAY,MAAM;EACtD,MAAM,kBAAkB,KAAK,QAAQ,WAAW,UAAU;EAE1D,MAAM,qBAAqB,aACvB,KAAK,QAAQ,YAAY,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|
|
|
3
|
-
Tasty is
|
|
3
|
+
Tasty is CSS-in-JS for React design systems. You describe hover, disabled, variants, themes, responsive behavior, and other conditions as state maps; Tasty compiles them so one branch wins without specificity fights or source-order surprises.
|
|
4
|
+
|
|
5
|
+
Use this hub to move from the core idea to a working component, then into design-system patterns or API reference as needed.
|
|
4
6
|
|
|
5
7
|
## Start Here
|
|
6
8
|
|
|
7
|
-
- **
|
|
8
|
-
- **
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
9
|
+
- **Understand why**: [Introduction](../README.md) for the problem, the state-map model, and the product overview.
|
|
10
|
+
- **Try it**: [Getting Started](getting-started.md) to build a stateful component, add shared configuration, and choose a rendering mode.
|
|
11
|
+
- **Build a component system**: [Methodology](methodology.md) for root + sub-elements, typed public APIs, tokens, and extension patterns; then [Building a Design System](design-system.md).
|
|
12
|
+
- **Evaluate or adopt it**: [Comparison](comparison.md) for tool-selection context and [Adoption Guide](adoption.md) for an incremental rollout.
|
|
13
|
+
- **Understand the compiler**: [Style rendering pipeline](pipeline.md) for how state maps become mutually exclusive selectors.
|
|
11
14
|
|
|
12
15
|
## By Role
|
|
13
16
|
|
|
@@ -20,12 +23,15 @@ Tasty is a styling engine for design systems that turns component state into det
|
|
|
20
23
|
- **React components**: [React API](react-api.md)
|
|
21
24
|
- **Zero-runtime / build-time extraction**: [Zero Runtime (tastyStatic)](tasty-static.md)
|
|
22
25
|
- **Runtime `tasty()` with server collection and hydration**: [Server-Side Rendering](ssr.md)
|
|
26
|
+
- **Upgrading from v2**: [Migration Guide (v2 → v3)](migration-v3.md)
|
|
23
27
|
|
|
24
28
|
## By Task
|
|
25
29
|
|
|
26
30
|
- **Learn the style language**: [Style DSL](dsl.md)
|
|
31
|
+
- **Brief an AI agent (or yourself) on writing correct styles**: [Style Rules for AI Agents](ai-agents.md)
|
|
27
32
|
- **Look up a property handler**: [Style Properties](styles.md)
|
|
28
|
-
- **Define tokens, units, recipes, keyframes, or
|
|
33
|
+
- **Define tokens, units, recipes, keyframes, properties, functions, or polyfills globally**: [Configuration](configuration.md)
|
|
34
|
+
- **Extend Tasty with a plugin, custom handler, or custom prop**: [Plugins & Extension Points](plugins.md)
|
|
29
35
|
- **Debug generated CSS or cache behavior**: [Debug Utilities](debug.md)
|
|
30
|
-
- **Understand how selector generation works internally**: [Style rendering pipeline](
|
|
36
|
+
- **Understand how selector generation works internally**: [Style rendering pipeline](pipeline.md)
|
|
31
37
|
- **Understand runtime injection internals**: [Style Injector](injector.md)
|
package/docs/adoption.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# Adoption Guide
|
|
2
2
|
|
|
3
|
-
Tasty is
|
|
3
|
+
Tasty is most useful where reusable component styling has become a state-resolution problem: hover intersects with disabled, variants intersect with themes, and every extension makes selector behavior harder to predict.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
It normally sits underneath a design system’s existing components. You can preserve their public React APIs while moving their style logic into state maps that produce one declared winner. Adoption should start with a small, state-heavy component—not an all-at-once rewrite.
|
|
6
|
+
|
|
7
|
+
This guide is for design-system maintainers and platform engineers evaluating Tasty or introducing it into an existing codebase. Use it for rollout strategy and adoption sequencing; use the [Comparison guide](comparison.md) when the open question is whether Tasty is the right tool.
|
|
6
8
|
|
|
7
9
|
---
|
|
8
10
|
|
|
@@ -18,12 +20,14 @@ Product code
|
|
|
18
20
|
```
|
|
19
21
|
|
|
20
22
|
**What Tasty owns:**
|
|
23
|
+
|
|
21
24
|
- The DSL and value parser (tokens, custom units, auto-calc, color opacity)
|
|
22
25
|
- State compilation (mutually exclusive selectors from state maps)
|
|
23
26
|
- Style injection and deduplication (runtime or build-time)
|
|
24
27
|
- The `tasty()` component factory and hooks API
|
|
25
28
|
|
|
26
29
|
**What the DS team owns:**
|
|
30
|
+
|
|
27
31
|
- Token names and values (colors, spacing, typography)
|
|
28
32
|
- Custom units and their semantics
|
|
29
33
|
- State aliases (`@mobile`, `@dark`, `@compact`)
|
|
@@ -39,12 +43,14 @@ Two teams using Tasty can end up with very different authoring models. That is b
|
|
|
39
43
|
## Who should adopt Tasty
|
|
40
44
|
|
|
41
45
|
**Strong fit:**
|
|
42
|
-
|
|
46
|
+
|
|
47
|
+
- A design-system or platform team that owns shared component APIs
|
|
43
48
|
- Components with complex, intersecting states (hover + disabled + theme + breakpoint)
|
|
44
49
|
- Teams that need deterministic style resolution without cascade/specificity bugs
|
|
45
|
-
- Organizations
|
|
50
|
+
- Organizations that want tokens, states, and extension rules to stay consistent across products
|
|
46
51
|
|
|
47
52
|
**Not the right fit:**
|
|
53
|
+
|
|
48
54
|
- Solo developers building a one-off app with minimal UI structure
|
|
49
55
|
- Teams that want a shared utility vocabulary and direct markup authoring (Tailwind is better here)
|
|
50
56
|
- Projects where low ceremony matters more than central governance
|
|
@@ -58,16 +64,16 @@ For a detailed comparison with Tailwind, Panda CSS, vanilla-extract, StyleX, Sti
|
|
|
58
64
|
|
|
59
65
|
Tasty provides the engine. The DS team defines the language that runs on it. Here is what that typically involves:
|
|
60
66
|
|
|
61
|
-
| Layer
|
|
62
|
-
|
|
63
|
-
| **Tokens**
|
|
64
|
-
| **Units**
|
|
65
|
-
| **State aliases**
|
|
66
|
-
| **Recipes**
|
|
67
|
-
| **Typography**
|
|
68
|
-
| **Style props**
|
|
69
|
-
| **Sub-elements**
|
|
70
|
-
| **Override rules** | How product engineers extend or constrain components
|
|
67
|
+
| Layer | What you define | Where |
|
|
68
|
+
| ------------------ | ---------------------------------------------------------- | ------------------------------------------ |
|
|
69
|
+
| **Tokens** | Color names, spacing scale, border widths, radii | `configure({ tokens })` |
|
|
70
|
+
| **Units** | Custom multiplier units (`x`, `r`, `bw`, or your own) | `configure({ units })` |
|
|
71
|
+
| **State aliases** | Responsive breakpoints, theme modes, feature flags | `configure({ states })` |
|
|
72
|
+
| **Recipes** | Reusable style bundles (card, elevated, input-reset) | `configure({ recipes })` |
|
|
73
|
+
| **Typography** | Preset definitions (h1-h6, t1-t4, etc.) | `configure({ presets: { ... } })` |
|
|
74
|
+
| **Style props** | Which CSS properties each component exposes as React props | `styleProps` in each component |
|
|
75
|
+
| **Sub-elements** | Inner parts of compound components (Title, Icon, Content) | `elements` + capitalized keys in `styles` |
|
|
76
|
+
| **Override rules** | How product engineers extend or constrain components | Styled wrappers via `tasty(Base, { ... })` |
|
|
71
77
|
|
|
72
78
|
The same engine can power a minimal design system with a handful of tokens:
|
|
73
79
|
|
|
@@ -85,9 +91,15 @@ Here is how the layers connect end-to-end. The DS team configures the engine, de
|
|
|
85
91
|
```tsx
|
|
86
92
|
// ds/config.ts — DS team defines the language
|
|
87
93
|
configure({
|
|
88
|
-
tokens: {
|
|
94
|
+
tokens: {
|
|
95
|
+
'#primary': 'oklch(55% 0.25 265)',
|
|
96
|
+
'#surface': '#fff',
|
|
97
|
+
'#text': '#111',
|
|
98
|
+
},
|
|
89
99
|
states: { '@mobile': '@media(w < 768px)', '@dark': '@root(schema=dark)' },
|
|
90
|
-
recipes: {
|
|
100
|
+
recipes: {
|
|
101
|
+
card: { padding: '4x', fill: '#surface', radius: '1r', border: true },
|
|
102
|
+
},
|
|
91
103
|
});
|
|
92
104
|
|
|
93
105
|
// ds/components/Card.tsx — DS team builds components on top
|
|
@@ -105,7 +117,7 @@ const Card = tasty({
|
|
|
105
117
|
<Card padding={{ '': '4x', '@mobile': '2x' }}>
|
|
106
118
|
<Card.Title>Monthly Revenue</Card.Title>
|
|
107
119
|
<Card.Body>$1.2M — up 12% from last month</Card.Body>
|
|
108
|
-
</Card
|
|
120
|
+
</Card>;
|
|
109
121
|
```
|
|
110
122
|
|
|
111
123
|
See [Configuration](configuration.md) for the full `configure()` API.
|
|
@@ -116,9 +128,21 @@ See [Configuration](configuration.md) for the full `configure()` API.
|
|
|
116
128
|
|
|
117
129
|
You do not need to adopt everything at once. Tasty is designed to be introduced layer by layer.
|
|
118
130
|
|
|
119
|
-
A practical
|
|
131
|
+
A practical first slice is one component that already suffers from intersecting state and variant logic: a button, input, menu item, disclosure, or interactive card. Keep its public API unchanged, move one or two properties into Tasty state maps, and verify that the declared priority matches the behavior your team expects.
|
|
132
|
+
|
|
133
|
+
This proves the differentiator before you invest in a complete token vocabulary or migrate an entire component library.
|
|
134
|
+
|
|
135
|
+
### Phase 1 -- Pilot one state-heavy component
|
|
136
|
+
|
|
137
|
+
Choose a component with a known hover/disabled, focus/error, or variant/theme interaction. Preserve its external props and visual behavior. The pilot should answer three questions:
|
|
138
|
+
|
|
139
|
+
1. Is the state map easier to review than the existing selectors or conditional class logic?
|
|
140
|
+
2. Does extending the component keep the intended state priority?
|
|
141
|
+
3. Can your current tokens and component API move over without product-code churn?
|
|
142
|
+
|
|
143
|
+
If the answer is yes, establish the shared design-system vocabulary around the successful slice.
|
|
120
144
|
|
|
121
|
-
### Phase
|
|
145
|
+
### Phase 2 -- Tokens and units
|
|
122
146
|
|
|
123
147
|
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.
|
|
124
148
|
|
|
@@ -136,14 +160,14 @@ configure({
|
|
|
136
160
|
// A DS typically redefines them to use CSS custom properties
|
|
137
161
|
// so that the actual scale is controlled via CSS, not JS:
|
|
138
162
|
units: {
|
|
139
|
-
x: 'var(--gap)',
|
|
163
|
+
x: 'var(--gap)', // 2x → calc(var(--gap) * 2)
|
|
140
164
|
r: 'var(--radius)',
|
|
141
165
|
bw: 'var(--border-width)',
|
|
142
166
|
},
|
|
143
167
|
});
|
|
144
168
|
```
|
|
145
169
|
|
|
146
|
-
### Phase
|
|
170
|
+
### Phase 3 -- State aliases and recipes
|
|
147
171
|
|
|
148
172
|
Define the state vocabulary your components will share. This is where you start encoding your team's conventions.
|
|
149
173
|
|
|
@@ -152,7 +176,8 @@ configure({
|
|
|
152
176
|
states: {
|
|
153
177
|
'@mobile': '@media(w < 768px)',
|
|
154
178
|
'@tablet': '@media(w < 1024px)',
|
|
155
|
-
'@dark':
|
|
179
|
+
'@dark':
|
|
180
|
+
'@root(schema=dark) | (!@root(schema) & @media(prefers-color-scheme: dark))',
|
|
156
181
|
},
|
|
157
182
|
recipes: {
|
|
158
183
|
card: { padding: '4x', fill: '#surface', radius: '1r', border: true },
|
|
@@ -161,7 +186,7 @@ configure({
|
|
|
161
186
|
});
|
|
162
187
|
```
|
|
163
188
|
|
|
164
|
-
### Phase
|
|
189
|
+
### Phase 4 -- Migrate a few primitives
|
|
165
190
|
|
|
166
191
|
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.
|
|
167
192
|
|
|
@@ -179,7 +204,7 @@ const Box = tasty({
|
|
|
179
204
|
|
|
180
205
|
At this point you can validate the DSL, token workflow, and component authoring experience before expanding the rollout.
|
|
181
206
|
|
|
182
|
-
### Phase
|
|
207
|
+
### Phase 5 -- Expand state resolution
|
|
183
208
|
|
|
184
209
|
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.
|
|
185
210
|
|
|
@@ -209,7 +234,7 @@ const Button = tasty({
|
|
|
209
234
|
});
|
|
210
235
|
```
|
|
211
236
|
|
|
212
|
-
### Phase
|
|
237
|
+
### Phase 6 -- Standardize style props and sub-elements
|
|
213
238
|
|
|
214
239
|
Define which style props each component category exposes. Layout components get flow/gap/padding. Interactive components get positioning. Compound components declare sub-elements.
|
|
215
240
|
|
|
@@ -225,7 +250,7 @@ const Card = tasty({
|
|
|
225
250
|
});
|
|
226
251
|
```
|
|
227
252
|
|
|
228
|
-
### Phase
|
|
253
|
+
### Phase 7 -- Expand to full DS coverage
|
|
229
254
|
|
|
230
255
|
Migrate the remaining components, add the [ESLint plugin](https://github.com/tenphi/eslint-plugin-tasty) to enforce style conventions at lint time, and consider [zero-runtime mode](tasty-static.md) for static or performance-critical pages.
|
|
231
256
|
|
|
@@ -254,8 +279,8 @@ const DangerButton = tasty(Button, {
|
|
|
254
279
|
const LoadingButton = tasty(Button, {
|
|
255
280
|
styles: {
|
|
256
281
|
fill: {
|
|
257
|
-
loading: '#yellow',
|
|
258
|
-
disabled: '#gray.20',
|
|
282
|
+
loading: '#yellow', // new state appended
|
|
283
|
+
disabled: '#gray.20', // existing state overridden in place
|
|
259
284
|
},
|
|
260
285
|
},
|
|
261
286
|
});
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# Tasty Style Rules for AI Agents
|
|
2
|
+
|
|
3
|
+
A compact ruleset for **writing correct `@tenphi/tasty` styles**. It is not an API tour — most rules here are machine-checked by [`@tenphi/eslint-plugin-tasty`](https://www.npmjs.com/package/@tenphi/eslint-plugin-tasty), so following it generally means clean lint output. The plugin ships separately and can lag a new DSL rule, so treat this page as the source of truth and the plugin as the enforcement that catches most of it. For explanations and the complete API, see [Style DSL](dsl.md), [Style Properties](styles.md), [React API](react-api.md).
|
|
4
|
+
|
|
5
|
+
Notation: ❌ wrong → ✅ correct.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 0. Read the project config first
|
|
10
|
+
|
|
11
|
+
Color tokens (`#name`), custom properties (`$name`), `preset` names, `recipe` names, state aliases (`@mobile`) and extra units are **project-defined** in `tasty.config.ts` or a `configure({ … })` call. Look them up before writing styles. Never invent a name — reuse an existing one, or add it to the config.
|
|
12
|
+
|
|
13
|
+
## 1. Where styles go
|
|
14
|
+
|
|
15
|
+
```jsx
|
|
16
|
+
const Card = tasty({ as: 'div', styles: { … }, styleProps: ['padding'] }); // new component
|
|
17
|
+
const Hero = tasty(Card, { styles: { … } }); // extend a component
|
|
18
|
+
const cls = useStyles({ … }); // ad-hoc class name
|
|
19
|
+
tastyStatic('.card', { … }); // build-time, zero runtime
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
- Wrap, don't pass styles per instance: ❌ `<Box styles={{ padding: '2x' }} />` → ✅ `const Box = tasty({ styles: { padding: '2x' } })`.
|
|
23
|
+
- Style values are **static**. Route anything conditional through a state map plus `mods` (or `tokens` / `styleProps`):
|
|
24
|
+
❌ `fill: isOpen ? '#primary' : '#surface'` → ✅ `fill: { '': '#surface', open: '#primary' }` with `mods={{ open: isOpen }}`.
|
|
25
|
+
|
|
26
|
+
## 2. Property names
|
|
27
|
+
|
|
28
|
+
Keys are camelCase — a Tasty property or a real CSS property. No kebab-case, no invented names.
|
|
29
|
+
|
|
30
|
+
Prefer the Tasty shorthand over its CSS equivalents:
|
|
31
|
+
|
|
32
|
+
| Use | Instead of |
|
|
33
|
+
|-----|------------|
|
|
34
|
+
| `fill` | `backgroundColor`, `background` |
|
|
35
|
+
| `image` | `backgroundImage` |
|
|
36
|
+
| `border` | `borderColor`, `borderWidth`, `borderStyle`, `borderTop`/`Right`/`Bottom`/`Left` |
|
|
37
|
+
| `radius` | `borderRadius` |
|
|
38
|
+
| `outline` | `outlineColor`, `outlineWidth`, `outlineStyle`, `outlineOffset` |
|
|
39
|
+
| `shadow` | `boxShadow` |
|
|
40
|
+
| `padding` | `paddingTop`/`Right`/`Bottom`/`Left` |
|
|
41
|
+
| `margin` | `marginTop`/`Right`/`Bottom`/`Left` |
|
|
42
|
+
| `inset` | `top`, `right`, `bottom`, `left` |
|
|
43
|
+
| `width` / `height` | `minWidth`/`maxWidth`, `minHeight`/`maxHeight` |
|
|
44
|
+
| `flow` | `flexDirection`, `flexWrap`, `flexFlow`, `gridAutoFlow` |
|
|
45
|
+
| `preset` | `fontSize`, `lineHeight`, `letterSpacing`, `fontWeight`, `fontStyle`, `textTransform` |
|
|
46
|
+
| `font` | `fontFamily` |
|
|
47
|
+
| `scrollbar` | `scrollbarWidth`, `scrollbarColor`, `scrollbarGutter` |
|
|
48
|
+
| `gridColumns` / `gridRows` / `gridAreas` | `gridTemplateColumns` / `Rows` / `Areas` |
|
|
49
|
+
| `textOverflow: 'ellipsis / 3'` | `lineClamp` |
|
|
50
|
+
| `hide: true` | `display: 'none'` |
|
|
51
|
+
| `flexGrow` / `flexShrink` / `flexBasis` | `flex` |
|
|
52
|
+
|
|
53
|
+
The last row goes the other way — longhands over the shorthand — because `flex` is lossy: it resets the components you omit to non-initial values (`flex: '0'` silently sets `flex-basis: 0%`) and cannot express `flexShrink: 0` at all. The longhands also carry separate state maps.
|
|
54
|
+
|
|
55
|
+
## 3. Values
|
|
56
|
+
|
|
57
|
+
### Tokens
|
|
58
|
+
|
|
59
|
+
| Syntax | Meaning |
|
|
60
|
+
|--------|---------|
|
|
61
|
+
| `#name` | color token → `var(--name-color)` |
|
|
62
|
+
| `#name.50` | token at 50% opacity (`0`–`100`) |
|
|
63
|
+
| `#name.$opacity` | opacity from a custom property |
|
|
64
|
+
| `#clear` / `#current` | `transparent` / `currentcolor` |
|
|
65
|
+
| `$name` | custom property → `var(--name)` |
|
|
66
|
+
| `(#a, #b)` | fallback chain |
|
|
67
|
+
| `$$name` / `##name` | the custom property *name* (not its value) — inside `transition` |
|
|
68
|
+
| `$$name(…)` | call a CSS `@function` declared via `@function`, `useFunction`, or config |
|
|
69
|
+
|
|
70
|
+
- ❌ `#f5f5f5`, `rgb(0 0 0)`, `oklch(…)`, `okhsl(…)`, `red` → ✅ `#surface` (add the token to the config if it doesn't exist).
|
|
71
|
+
- ❌ `var(--gap)` → ✅ `$gap` · ❌ `$accent-color` → ✅ `#accent` · ❌ `transparent` → ✅ `#clear` · ❌ `currentColor` → ✅ `#current`.
|
|
72
|
+
- A `$name` must be declared as a `'$name': value` key in the same styles object, or in the config.
|
|
73
|
+
- Names are case-sensitive and start lowercase — `$myVar` → `--myVar`; a leading capital folds (`$Foo` → `--foo`). Prefer kebab-case.
|
|
74
|
+
- A `$name` reference is untyped: it fills the first free slot in a shorthand (`border: '1bw $my-style'` → the line style). Write colors as `#name`; `$name-color` is a fallback for pointing at a raw CSS custom property that holds a color.
|
|
75
|
+
- `preset` and `transition` take token *names*, not values, so a `$name` cannot stand in for one (it warns in dev and is ignored).
|
|
76
|
+
|
|
77
|
+
### Units
|
|
78
|
+
|
|
79
|
+
Tasty units: `x` (gap multiple), `r` (radius), `cr` (card radius), `bw` (border width), `ow` (outline width), `sf` (`minmax(0, Nfr)`). All CSS units work too, plus anything in `units` in the config. Any other unit is an error.
|
|
80
|
+
|
|
81
|
+
Prefer units over raw pixels: `8px` → `1x` … `64px` → `8x`; `radius: '6px'` → `'1r'`; `border: '1px …'` → `'1bw …'`.
|
|
82
|
+
|
|
83
|
+
### Math
|
|
84
|
+
|
|
85
|
+
❌ `calc(100% - 2x)` → ✅ `(100% - 2x)`. Parentheses are wrapped in `calc()` automatically — and must be balanced.
|
|
86
|
+
|
|
87
|
+
### `true`
|
|
88
|
+
|
|
89
|
+
`true` means "the design-system default" and is accepted **only** by: `border`, `radius`, `outline`, `shadow`, `padding`, `margin`, `gap`, `inset`, `width`, `height`, `fill`, `color`, `fade`, `preset`, `font`, `scrollbar`, `hide`. Anywhere else it is an error.
|
|
90
|
+
|
|
91
|
+
### `!important`
|
|
92
|
+
|
|
93
|
+
Never use it. Tasty owns specificity through doubled selectors and state ordering; `!important` breaks that. Express the exception as a state instead.
|
|
94
|
+
|
|
95
|
+
### Modifiers
|
|
96
|
+
|
|
97
|
+
A value is `[values…] [modifiers…]`, and several groups can be comma-separated (later groups override earlier ones). A group that names **direction** modifiers takes a **single** value, applied to every direction it names — per-side values come from comma groups. A group naming no direction keeps plain CSS shorthand order (1–4 values). (`inset` + `dock` is the one exception: a second value insets the spanned sides.) Only the modifiers a property knows are valid:
|
|
98
|
+
|
|
99
|
+
| Property | Modifiers |
|
|
100
|
+
|----------|-----------|
|
|
101
|
+
| `padding`, `margin`, `inset`, `fade` | `top` `right` `bottom` `left` |
|
|
102
|
+
| `border` | the four directions + `solid` `dashed` `dotted` `double` `groove` `ridge` `inset` `outset` `none` `hidden` |
|
|
103
|
+
| `outline` | the style keywords above |
|
|
104
|
+
| `radius` | `top` `right` `bottom` `left` + shapes `round` `ellipse` `leaf` `backleaf` |
|
|
105
|
+
| `width`, `height` | `min` `max` `fixed` |
|
|
106
|
+
| `flow` | `row` `column` `row-reverse` `column-reverse` `wrap` `nowrap` `dense` |
|
|
107
|
+
| `overflow` | `visible` `hidden` `scroll` `clip` `auto` `overlay` |
|
|
108
|
+
| `position` | `static` `relative` `absolute` `fixed` `sticky` |
|
|
109
|
+
| `shadow` | `inset` |
|
|
110
|
+
| `preset` | `name / strong` (or `bold`) `italic` `icon` `tight` |
|
|
111
|
+
| box properties | `longhand` — emit CSS longhands instead of the shorthand |
|
|
112
|
+
|
|
113
|
+
Directional modifiers beat placeholder zeros:
|
|
114
|
+
|
|
115
|
+
- ❌ `padding: '0 0 2x 0'` → ✅ `padding: '2x bottom'`
|
|
116
|
+
- ❌ `padding: '1x 1x 2x 1x'` → ✅ `padding: '1x, 2x bottom'`
|
|
117
|
+
- ❌ `border: '0 0 1bw 0'` — four tokens parse as *one* border value, so this renders no border at all → ✅ `border: '1bw bottom'`
|
|
118
|
+
- ❌ `padding: '2x 4x top right'` — a directional group takes one value, so `4x` is dropped → ✅ `padding: '2x top, 4x right'`
|
|
119
|
+
- ❌ `fade: '3x 1x top bottom'` → ✅ `fade: '3x top, 1x bottom'`
|
|
120
|
+
|
|
121
|
+
Value-only properties reject both colors and modifiers: `gap`, `columnGap`, `rowGap`, `opacity`, `zIndex`, `order`, `flexGrow`, `flexShrink`, `flexBasis`, `aspectRatio`, `lineClamp`, `tabSize`, `paddingInline`, `paddingBlock`. `fill` and `color` take a color (plus `none` / `transparent`); `caretColor` and `accentColor` take a color only.
|
|
122
|
+
|
|
123
|
+
### `transition`
|
|
124
|
+
|
|
125
|
+
Use semantic names, not CSS property names: `fade` `fill` `color` `theme` `border` `radius` `shadow` `outline` `preset` `text` `gap` `opacity` `translate` `rotate` `scale` `filter` `image` `background` `width` `height` `zIndex` `inset` `flow` `dimension`.
|
|
126
|
+
|
|
127
|
+
❌ `transition: 'background-color 0.2s'` → ✅ `transition: 'fill 0.2s'`
|
|
128
|
+
|
|
129
|
+
## 4. State maps
|
|
130
|
+
|
|
131
|
+
A property value can be an object of `state: value`. Key order is priority — later keys win.
|
|
132
|
+
|
|
133
|
+
| Key | Generated selector |
|
|
134
|
+
|-----|--------------------|
|
|
135
|
+
| `hovered` | `[data-hovered]` (boolean modifier from `mods`) |
|
|
136
|
+
| `theme=danger` | `[data-theme="danger"]` (value modifier) |
|
|
137
|
+
| `:hover` | pseudo-class |
|
|
138
|
+
| `.active` | class selector |
|
|
139
|
+
| `[aria-expanded="true"]` | attribute selector |
|
|
140
|
+
| `hovered & .active` | AND |
|
|
141
|
+
| `hovered \| focused` | OR (`,` also means OR) |
|
|
142
|
+
| `!disabled` | NOT |
|
|
143
|
+
| `hovered ^ focused` | XOR — exactly one (keep chains ≤ 4 operands) |
|
|
144
|
+
|
|
145
|
+
Precedence `!` > `^` > `|` > `&`; use parentheses to override.
|
|
146
|
+
|
|
147
|
+
Rules:
|
|
148
|
+
|
|
149
|
+
1. **`''` comes first.** The bare default is the lowest-priority state; placing it later would override everything above it.
|
|
150
|
+
2. **Every state map needs `''` or `_`** — except when extending (`tasty(Parent, …)`), where omitting `''` merges into the parent's states and including `''` replaces them wholesale.
|
|
151
|
+
3. **`_` is standalone-only** and always first (with `''` right after it, if present). `_` is a never-negated fallback floor for cases where a higher-priority branch may be *unknown* (`@supports`, container queries). If a map contains only `_` and `''`, drop the `''`.
|
|
152
|
+
4. **No nested maps:** ❌ `{ hovered: { pressed: 'x' } }` → ✅ `{ 'hovered & pressed': 'x' }`
|
|
153
|
+
5. **State keys never sit at the top level** of a styles object — `:hover`, `.active`, `[open]` belong inside a property value.
|
|
154
|
+
6. **Prefer automatic native states:** use `disabled` and `checked` in Tasty component styles instead of `[disabled]` and `[checked]`. The concise states track the corresponding native prop or attribute automatically.
|
|
155
|
+
|
|
156
|
+
```jsx
|
|
157
|
+
color: { '': '#text', hovered: '#accent', disabled: '#text.40' }
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Advanced states:
|
|
161
|
+
|
|
162
|
+
| Prefix | Use | Example |
|
|
163
|
+
|--------|-----|---------|
|
|
164
|
+
| `@media(…)` | media query; dimensions `w` `h`; types `@media:print` `:screen` `:all` `:speech` | `@media(w < 768px)`, `@media(600px <= w < 1200px)` |
|
|
165
|
+
| `@(…)` | container query; dimensions `w` `h` `is` `bs` | `@(layout, w >= 600px)`, `@($variant=primary)` |
|
|
166
|
+
| `@supports(…)` | feature query; `$` first argument tests a selector | `@supports(display: grid)`, `@supports($, :has(*))` |
|
|
167
|
+
| `@root(…)` | condition on `:root` | `@root(schema=dark)` |
|
|
168
|
+
| `@parent(…)` | condition on an ancestor; `, >` for the direct parent | `@parent(hovered, >)` |
|
|
169
|
+
| `@own(…)` | a sub-element's own state — **only inside sub-element styles** | `@own(:hover)` |
|
|
170
|
+
| `@starting` | `@starting-style` entry animation | `@starting` |
|
|
171
|
+
| `@name` | project state alias | `@mobile` |
|
|
172
|
+
|
|
173
|
+
- At root level write the selector directly: ❌ `'@own(:hover)'` → ✅ `':hover'`.
|
|
174
|
+
- `@name` aliases must exist in `states` in the config or be declared locally as an `'@name': '<state expression>'` key; alias keys start with `@` and their value must be a valid state expression.
|
|
175
|
+
- `:is()` / `:has()` / `:not()` / `:where()` work in state keys but support at most 2 levels of nested parentheses, and `:has()` is expensive — prefer `@parent()`, `@own()` and modifiers.
|
|
176
|
+
|
|
177
|
+
When extending a parent's state map: `'@inherit'` reuses the parent's value for that state, `null` removes a state (or resets a property, letting recipes fill in), `false` is a tombstone that blocks it entirely.
|
|
178
|
+
|
|
179
|
+
## 5. Sub-elements
|
|
180
|
+
|
|
181
|
+
A **capitalized** key targets `[data-element="Name"]`, and its value must be a style object.
|
|
182
|
+
|
|
183
|
+
```jsx
|
|
184
|
+
styles: { Title: { preset: 'h3' }, Icon: { $: '>@:last-child', color: '#accent' } }
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
❌ nested-selector keys (`'& .title'`, `'&:hover'`) → ✅ sub-elements and state maps. Use the `$` affix property inside a sub-element to control how its selector attaches (`>` direct child, `@` placeholder for the element itself, `&::before` for a root pseudo-element).
|
|
188
|
+
|
|
189
|
+
## 6. Special top-level keys
|
|
190
|
+
|
|
191
|
+
| Key | Shape |
|
|
192
|
+
|-----|-------|
|
|
193
|
+
| `@keyframes` | `{ name: { '0%': styles, … } }` |
|
|
194
|
+
| `@property` | `{ '$name': { syntax, inherits, initialValue } }` |
|
|
195
|
+
| `@font-face` | `{ 'Family Name': descriptors \| descriptors[] }` |
|
|
196
|
+
| `@counter-style` | `{ name: descriptors }` |
|
|
197
|
+
| `@function` | `{ '$$name': { args, returns?, result, '$local'? } }` |
|
|
198
|
+
| `recipe` | a **string** of configured recipe names: `'card elevated'`, `'reset input / autofill'`, `'none / disabled'` |
|
|
199
|
+
|
|
200
|
+
At-rule keys match the real CSS at-rule names, so they are kebab-case, not camelCase. Inside `@function`, the callable is `$$name` but its parameters and local variables are `$name`:
|
|
201
|
+
|
|
202
|
+
```jsx
|
|
203
|
+
styles: {
|
|
204
|
+
'@function': { $$negative: { args: ['$value'], result: '(-1 * $value)' } },
|
|
205
|
+
margin: '$$negative(2x) top',
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## 7. `tastyStatic()`
|
|
210
|
+
|
|
211
|
+
The selector must be a string literal and valid CSS. Values must be static — strings, numbers, booleans, `null`, or objects/arrays of those. No variables, template literals, function calls, or spreads.
|
|
212
|
+
|
|
213
|
+
## 8. Checklist
|
|
214
|
+
|
|
215
|
+
- Token, preset, recipe, unit and `@alias` names exist in the project config.
|
|
216
|
+
- Tasty shorthand chosen over CSS longhands; `flexGrow`/`flexShrink`/`flexBasis` over `flex`; `hide: true` over `display: 'none'`.
|
|
217
|
+
- Colors are `#tokens`, not hex/rgb/oklch/named; `$prop` not `var(--prop)`.
|
|
218
|
+
- Spacing uses `x`/`r`/`bw`/`ow` units; math uses `(…)`, not `calc(…)`.
|
|
219
|
+
- `true` only on the properties that accept it; no `!important`.
|
|
220
|
+
- Modifiers valid for the property; directional shorthand instead of placeholder zeros.
|
|
221
|
+
- Every state map starts with `''` (or `_`), is flat, and lives inside a property value.
|
|
222
|
+
- `@own()` only inside sub-elements; sub-element keys are capitalized and hold objects.
|
|
223
|
+
- At-rule keys are kebab-case (`@property`, `@font-face`, `@counter-style`, `@function`); `@function` names use `$$`, their args and locals use `$`.
|
|
224
|
+
- Values are static; dynamic behavior comes from `mods` / `tokens` / `styleProps`.
|