@aziontech/theme 4.1.0 → 4.3.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 +110 -335
- package/dist/v4/globals.css +81 -50
- package/dist/v4/globals.scss +81 -50
- package/package.json +3 -13
- package/src/scripts/build-tokens.mjs +23 -6
- package/src/scripts/compile-primitives.js +9 -5
- package/src/scripts/compile-theme.js +12 -6
- package/src/scripts/refs.d.ts +1 -0
- package/src/scripts/refs.d.ts.map +1 -1
- package/src/scripts/refs.js +11 -0
- package/src/scripts/zero-unit.mjs +64 -0
- package/src/tokens/README.md +19 -28
- package/src/tokens/index.d.ts +0 -1
- package/src/tokens/index.js +0 -1
- package/src/tokens/primitives/animations/animate.d.ts +2 -0
- package/src/tokens/primitives/animations/animate.d.ts.map +1 -1
- package/src/tokens/primitives/animations/animate.js +7 -2
- package/src/tokens/primitives/animations/keyframes.d.ts +4 -0
- package/src/tokens/primitives/animations/keyframes.d.ts.map +1 -1
- package/src/tokens/primitives/animations/keyframes.js +11 -2
- package/src/tokens/primitives/shape/container.d.ts.map +1 -1
- package/src/tokens/primitives/shape/container.js +30 -13
- package/src/tokens/primitives/typography/leading.d.ts +1 -0
- package/src/tokens/primitives/typography/leading.js +1 -0
- package/src/tokens/primitives/typography/tracking.js +12 -6
- package/src/tokens/semantic/colors.js +5 -2
- package/src/tokens/semantic/texts.data.d.ts +6 -6
- package/src/tokens/semantic/texts.data.d.ts.map +1 -1
- package/src/tokens/semantic/texts.data.js +23 -21
- package/src/tokens/semantic/z-indices.data.d.ts +38 -0
- package/src/tokens/semantic/z-indices.data.d.ts.map +1 -0
- package/src/tokens/semantic/z-indices.data.js +30 -0
- package/src/tokens/theme/accent.js +18 -6
- package/src/tokens/theme/background.d.ts +12 -0
- package/src/tokens/theme/background.js +11 -2
- package/src/tokens/theme/code-sintax.d.ts +6 -0
- package/src/tokens/theme/code-sintax.js +2 -0
- package/src/tokens/theme/feedback/info.js +2 -2
- package/src/tokens/theme/text.js +2 -2
- package/src/scripts/css-vars.d.ts +0 -7
- package/src/scripts/css-vars.d.ts.map +0 -1
- package/src/scripts/css-vars.js +0 -46
- package/src/scripts/resolve.d.ts +0 -5
- package/src/scripts/resolve.d.ts.map +0 -1
- package/src/scripts/resolve.js +0 -107
|
@@ -26,24 +26,24 @@ import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
|
26
26
|
import { dirname, resolve } from 'node:path';
|
|
27
27
|
import { fileURLToPath } from 'node:url';
|
|
28
28
|
|
|
29
|
-
import { animate } from '../tokens/primitives/animations/animate.js';
|
|
29
|
+
import { animate, curve, duration } from '../tokens/primitives/animations/animate.js';
|
|
30
30
|
import { animateExtras, keyframes } from '../tokens/primitives/animations/keyframes.js';
|
|
31
31
|
import { breakpoints } from '../tokens/primitives/breakpoints.js';
|
|
32
|
-
import {
|
|
32
|
+
import { compilePrimitivesVars } from './compile-primitives.js';
|
|
33
33
|
import { compileThemeCss, compileThemeVars } from './compile-theme.js';
|
|
34
34
|
import { containersData } from '../tokens/semantic/containers.data.js';
|
|
35
35
|
import { spacingsData } from '../tokens/semantic/spacings.data.js';
|
|
36
36
|
import { textsData } from '../tokens/semantic/texts.data.js';
|
|
37
|
+
import { zIndicesData } from '../tokens/semantic/z-indices.data.js';
|
|
38
|
+
import { assertNoZeroWithUnit } from './zero-unit.mjs';
|
|
37
39
|
|
|
38
40
|
const BREAKPOINT_ORDER = ['sm', 'md', 'lg', 'xl', '2xl'];
|
|
39
41
|
|
|
40
42
|
const kebab = (s) => s.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
41
43
|
|
|
42
44
|
// ─── 1. Primitives ──────────────────────────────────────────────────────────
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return flatten(varsTree, refsTree);
|
|
46
|
-
};
|
|
45
|
+
// compilePrimitivesVars throws on any unresolved tokenRef (see refs.js).
|
|
46
|
+
const flattenPrimitives = () => compilePrimitivesVars();
|
|
47
47
|
|
|
48
48
|
// ─── 2. Semantic flattening ─────────────────────────────────────────────────
|
|
49
49
|
const splitResponsive = (value) => {
|
|
@@ -91,6 +91,7 @@ const buildFlatModel = () => ({
|
|
|
91
91
|
primitives: flattenPrimitives(),
|
|
92
92
|
containers: flattenSingleValue(containersData, (k) => `--container-${k}`),
|
|
93
93
|
spacings: flattenSingleValue(spacingsData, (k) => `--${k}`),
|
|
94
|
+
zIndices: flattenSingleValue(zIndicesData, (k) => `--${k}`),
|
|
94
95
|
texts: flattenBundle(textsData),
|
|
95
96
|
});
|
|
96
97
|
|
|
@@ -291,10 +292,24 @@ const emitCssV4 = () => {
|
|
|
291
292
|
themeVars[`--animate-${name}`] = shorthand;
|
|
292
293
|
}
|
|
293
294
|
|
|
295
|
+
// Named `duration-*` / `ease-*` utilities. Without these the design system's
|
|
296
|
+
// own `duration-moderate-02` / `ease-productive-entrance` classes compile to
|
|
297
|
+
// NOTHING (Tailwind v4 silently drops an unknown named step), and every
|
|
298
|
+
// component that declares one falls back to Tailwind's default 150ms `ease`.
|
|
299
|
+
// The namespaces are fixed by Tailwind: `--transition-duration-*` backs
|
|
300
|
+
// `duration-*`, `--ease-*` backs `ease-*`.
|
|
301
|
+
for (const [name, value] of Object.entries(duration)) {
|
|
302
|
+
themeVars[`--transition-duration-${name}`] = value;
|
|
303
|
+
}
|
|
304
|
+
for (const [name, value] of Object.entries(curve)) {
|
|
305
|
+
themeVars[`--ease-${name}`] = value;
|
|
306
|
+
}
|
|
307
|
+
|
|
294
308
|
const semanticBase = {
|
|
295
309
|
...rootPrimitiveVars,
|
|
296
310
|
...(m.containers._ || {}),
|
|
297
311
|
...(m.spacings._ || {}),
|
|
312
|
+
...(m.zIndices._ || {}),
|
|
298
313
|
...(m.texts._ || {}),
|
|
299
314
|
};
|
|
300
315
|
|
|
@@ -303,6 +318,7 @@ const emitCssV4 = () => {
|
|
|
303
318
|
const merged = {
|
|
304
319
|
...(m.containers[bp] || {}),
|
|
305
320
|
...(m.spacings[bp] || {}),
|
|
321
|
+
...(m.zIndices[bp] || {}),
|
|
306
322
|
...(m.texts[bp] || {}),
|
|
307
323
|
};
|
|
308
324
|
if (Object.keys(merged).length === 0) continue;
|
|
@@ -378,6 +394,7 @@ const importIdx = rawCss.indexOf(IMPORT_LINE);
|
|
|
378
394
|
if (importIdx === -1) throw new Error('emitCssV4 output is missing the tailwind import line');
|
|
379
395
|
const afterImport = importIdx + IMPORT_LINE.length;
|
|
380
396
|
const css = `${rawCss.slice(0, afterImport)}\n\n${fontsCss}${rawCss.slice(afterImport)}`;
|
|
397
|
+
assertNoZeroWithUnit(css, 'globals.css');
|
|
381
398
|
await writeFile(resolve(dir, 'globals.css'), css, 'utf8');
|
|
382
399
|
await writeFile(resolve(dir, 'globals.scss'), css, 'utf8');
|
|
383
400
|
console.log(`✓ v4 → ${dir}`);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Imports every primitive module (colors, shape, typography, effects,
|
|
5
5
|
* breakpoints, border-widths, ring-offset), resolves `tokenRef(...)` aliases,
|
|
6
|
-
* and produces a `:root { ... }` block. Mirrors
|
|
6
|
+
* and produces a `:root { ... }` block. Mirrors `injectThemeCss` (compile-theme.js)
|
|
7
7
|
* but for primitives only — no semantic light/dark split.
|
|
8
8
|
*/
|
|
9
9
|
|
|
@@ -33,7 +33,7 @@ import { fontWeight } from '../tokens/primitives/typography/font-weight.js'
|
|
|
33
33
|
import { leading } from '../tokens/primitives/typography/leading.js'
|
|
34
34
|
import { lineHeight } from '../tokens/primitives/typography/line-height.js'
|
|
35
35
|
import { tracking } from '../tokens/primitives/typography/tracking.js'
|
|
36
|
-
import { isTokenRef } from './refs.js'
|
|
36
|
+
import { assertResolvedRefs, isTokenRef } from './refs.js'
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* Returns two trees:
|
|
@@ -123,17 +123,18 @@ const varNameFor = (path) => {
|
|
|
123
123
|
return `--${segments.join('-')}`
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
export const flatten = (obj, refsTree, prefix = []) => {
|
|
126
|
+
export const flatten = (obj, refsTree, prefix = [], unresolved = null) => {
|
|
127
127
|
const result = {}
|
|
128
128
|
Object.entries(obj).forEach(([key, value]) => {
|
|
129
129
|
const nextPath = [...prefix, key]
|
|
130
130
|
if (isTokenRef(value)) {
|
|
131
131
|
const resolved = resolveRef(value.__ref, refsTree)
|
|
132
|
+
if (resolved == null) unresolved?.push(`${varNameFor(nextPath)} → ${value.__ref}`)
|
|
132
133
|
result[varNameFor(nextPath)] = resolved ?? value.__ref
|
|
133
134
|
return
|
|
134
135
|
}
|
|
135
136
|
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
136
|
-
Object.assign(result, flatten(value, refsTree, nextPath))
|
|
137
|
+
Object.assign(result, flatten(value, refsTree, nextPath, unresolved))
|
|
137
138
|
return
|
|
138
139
|
}
|
|
139
140
|
if (typeof value === 'string' || typeof value === 'number') {
|
|
@@ -145,7 +146,10 @@ export const flatten = (obj, refsTree, prefix = []) => {
|
|
|
145
146
|
|
|
146
147
|
export const compilePrimitivesVars = () => {
|
|
147
148
|
const { refsTree, varsTree } = buildTrees()
|
|
148
|
-
|
|
149
|
+
const unresolved = []
|
|
150
|
+
const vars = flatten(varsTree, refsTree, [], unresolved)
|
|
151
|
+
assertResolvedRefs('primitives', unresolved)
|
|
152
|
+
return vars
|
|
149
153
|
}
|
|
150
154
|
|
|
151
155
|
export const compilePrimitivesCss = () => {
|
|
@@ -24,7 +24,7 @@ import { ring } from '../tokens/theme/ring.js'
|
|
|
24
24
|
import { secondary } from '../tokens/theme/secondary.js'
|
|
25
25
|
import { surfaces } from '../tokens/theme/surfaces.js'
|
|
26
26
|
import { text } from '../tokens/theme/text.js'
|
|
27
|
-
import { isTokenRef } from './refs.js'
|
|
27
|
+
import { assertResolvedRefs, isTokenRef } from './refs.js'
|
|
28
28
|
|
|
29
29
|
const VARIANTS = ['light', 'dark']
|
|
30
30
|
|
|
@@ -58,23 +58,25 @@ const resolveRef = (ref, surfacesResolved) => {
|
|
|
58
58
|
return null
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
const resolveGroup = (group, surfacesResolved) => {
|
|
61
|
+
const resolveGroup = (group, surfacesResolved, variant, unresolved) => {
|
|
62
62
|
const result = {}
|
|
63
63
|
Object.entries(group).forEach(([key, value]) => {
|
|
64
64
|
if (!isTokenRef(value)) return
|
|
65
65
|
const resolved = resolveRef(value.__ref, surfacesResolved)
|
|
66
66
|
if (resolved != null) result[`--${key}`] = String(resolved)
|
|
67
|
+
else unresolved.push(`[${variant}] --${key} → ${value.__ref}`)
|
|
67
68
|
})
|
|
68
69
|
return result
|
|
69
70
|
}
|
|
70
71
|
|
|
71
|
-
const compileVariant = (variant) => {
|
|
72
|
+
const compileVariant = (variant, unresolved) => {
|
|
72
73
|
// Surfaces resolved first — other groups depend on them.
|
|
73
74
|
const surfacesResolved = {}
|
|
74
75
|
Object.entries(surfaces[variant]).forEach(([key, value]) => {
|
|
75
76
|
if (!isTokenRef(value)) return
|
|
76
77
|
const v = resolveRef(value.__ref, {})
|
|
77
78
|
if (v != null) surfacesResolved[key] = String(v)
|
|
79
|
+
else unresolved.push(`[${variant}] --${key} → ${value.__ref}`)
|
|
78
80
|
})
|
|
79
81
|
|
|
80
82
|
const vars = {}
|
|
@@ -96,12 +98,16 @@ const compileVariant = (variant) => {
|
|
|
96
98
|
danger[variant],
|
|
97
99
|
info[variant]
|
|
98
100
|
]
|
|
99
|
-
groups.forEach((g) => Object.assign(vars, resolveGroup(g, surfacesResolved)))
|
|
101
|
+
groups.forEach((g) => Object.assign(vars, resolveGroup(g, surfacesResolved, variant, unresolved)))
|
|
100
102
|
return vars
|
|
101
103
|
}
|
|
102
104
|
|
|
103
|
-
export const compileThemeVars = () =>
|
|
104
|
-
|
|
105
|
+
export const compileThemeVars = () => {
|
|
106
|
+
const unresolved = []
|
|
107
|
+
const vars = Object.fromEntries(VARIANTS.map((v) => [v, compileVariant(v, unresolved)]))
|
|
108
|
+
assertResolvedRefs('semantic theme tokens', unresolved)
|
|
109
|
+
return vars
|
|
110
|
+
}
|
|
105
111
|
|
|
106
112
|
export const compileThemeCss = () => {
|
|
107
113
|
const { light, dark } = compileThemeVars()
|
package/src/scripts/refs.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refs.d.ts","sourceRoot":"","sources":["refs.js"],"names":[],"mappings":"AAIO;;EAA4C;AAE5C,gDAA6F"}
|
|
1
|
+
{"version":3,"file":"refs.d.ts","sourceRoot":"","sources":["refs.js"],"names":[],"mappings":"AAIO;;EAA4C;AAE5C,gDAA6F;AAO7F,wEAIN"}
|
package/src/scripts/refs.js
CHANGED
|
@@ -5,3 +5,14 @@
|
|
|
5
5
|
export const tokenRef = (path) => ({ __ref: path })
|
|
6
6
|
|
|
7
7
|
export const isTokenRef = (value) => typeof value === 'object' && value !== null && '__ref' in value
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Fail loudly on unresolved refs. A typo'd token must never silently vanish
|
|
11
|
+
* from the compiled CSS or ship as a raw `path.to.token` string — the compilers
|
|
12
|
+
* collect every miss and this throws once with the full list.
|
|
13
|
+
*/
|
|
14
|
+
export const assertResolvedRefs = (context, unresolved) => {
|
|
15
|
+
if (unresolved.length === 0) return
|
|
16
|
+
const lines = unresolved.map((entry) => ` ${entry}`).join('\n')
|
|
17
|
+
throw new Error(`[theme] ${unresolved.length} unresolved tokenRef(s) in ${context}:\n${lines}`)
|
|
18
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zero-with-unit gate for the compiled token stylesheet — the only check that sees token
|
|
3
|
+
* values (authored in JS, so no linter does), run on the final CSS before globals.css is
|
|
4
|
+
* written. A zero length is `0`; inside calc()/min()/max()/clamp() it must carry a unit, and
|
|
5
|
+
* that unit is `rem` (.claude/rules/styling.md). Mirror of the zero checks in packages/webkit
|
|
6
|
+
* token-checks.js, kept in sync — LENGTH_UNITS is the same string. Pure: node built-ins only.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// Opens a math function; balances parens one level deep (a zero nested deeper falls back to
|
|
10
|
+
// the bare-zero check).
|
|
11
|
+
const MATH_FN = '(?:calc|min|max|clamp)\\((?:[^()]|\\([^()]*\\))*';
|
|
12
|
+
|
|
13
|
+
// Complete CSS length-unit set — must be complete, since a missing unit silently passes.
|
|
14
|
+
export const LENGTH_UNITS =
|
|
15
|
+
'px|rem|em|ex|rex|ch|rch|cap|rcap|ic|ric|lh|rlh|vw|vh|vi|vb|vmin|vmax|svw|svh|svi|svb|svmin|svmax|lvw|lvh|lvi|lvb|lvmin|lvmax|dvw|dvh|dvi|dvb|dvmin|dvmax|cqw|cqh|cqi|cqb|cqmin|cqmax|cm|mm|Q|in|pt|pc';
|
|
16
|
+
|
|
17
|
+
// Mutually exclusive, so a value is reported once. Non-global so `.test()` is stateless —
|
|
18
|
+
// findZeroMisuse adds `g` locally to enumerate matches.
|
|
19
|
+
export const ZERO_WITH_UNIT = new RegExp(`(?<![\\w.])(?<!${MATH_FN})0(?:${LENGTH_UNITS})(?![\\w%])`, 'i');
|
|
20
|
+
export const ZERO_UNIT_IN_MATH = new RegExp(
|
|
21
|
+
`(?<=${MATH_FN})(?<![\\w.])0(?!rem)(?:${LENGTH_UNITS})(?![\\w%])`,
|
|
22
|
+
'i',
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Matches of `regex` in `cssText` as `{ line, n }`. Scans the whole string, not line-by-line,
|
|
27
|
+
* so a calc() wrapped across newlines is still seen as in-math.
|
|
28
|
+
*/
|
|
29
|
+
export const findZeroMisuse = (cssText, regex) => {
|
|
30
|
+
const scan = new RegExp(regex.source, `${regex.flags.replace('g', '')}g`);
|
|
31
|
+
const out = [];
|
|
32
|
+
for (let m; (m = scan.exec(cssText)); ) {
|
|
33
|
+
const lineStart = cssText.lastIndexOf('\n', m.index - 1) + 1;
|
|
34
|
+
const nlIdx = cssText.indexOf('\n', m.index);
|
|
35
|
+
const lineEnd = nlIdx === -1 ? cssText.length : nlIdx;
|
|
36
|
+
out.push({ line: cssText.slice(lineStart, lineEnd).trim(), n: cssText.slice(0, m.index).split('\n').length });
|
|
37
|
+
}
|
|
38
|
+
return out;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// The `--custom-property` a line declares, to name the token to fix; null off a `--token:` line.
|
|
42
|
+
const tokenOf = (line) => line.match(/(--[\w-]+)\s*:/)?.[1] ?? null;
|
|
43
|
+
|
|
44
|
+
/** Throw if `cssText` misuses a zero length. `source` names the artifact in the message. */
|
|
45
|
+
export const assertNoZeroWithUnit = (cssText, source = 'globals.css') => {
|
|
46
|
+
const bare = findZeroMisuse(cssText, ZERO_WITH_UNIT);
|
|
47
|
+
const inMath = findZeroMisuse(cssText, ZERO_UNIT_IN_MATH);
|
|
48
|
+
if (bare.length === 0 && inMath.length === 0) return;
|
|
49
|
+
|
|
50
|
+
const detail = (rows) => rows.map(({ line, n }) => ` ${source}:${n} ${line}`).join('\n');
|
|
51
|
+
const tokens = [...new Set([...bare, ...inMath].map(({ line }) => tokenOf(line)).filter(Boolean))];
|
|
52
|
+
const parts = [`build:tokens — ${bare.length + inMath.length} token value(s) misuse a zero.`];
|
|
53
|
+
if (bare.length > 0) {
|
|
54
|
+
parts.push(`A zero length takes no unit: write '0', not '0px' / '0rem' / '0em'.\n${detail(bare)}`);
|
|
55
|
+
}
|
|
56
|
+
if (inMath.length > 0) {
|
|
57
|
+
parts.push(
|
|
58
|
+
`Inside calc()/min()/max()/clamp() the zero needs a unit, and that unit is rem: write '0rem'.\n${detail(inMath)}`,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
const grepHint = tokens.length > 0 ? ` — grep the offending token name (${tokens.join(', ')})` : '';
|
|
62
|
+
parts.push(`Fix the token at its source under src/tokens/**${grepHint}, not the generated ${source}.`);
|
|
63
|
+
throw new Error(parts.join('\n'));
|
|
64
|
+
};
|
package/src/tokens/README.md
CHANGED
|
@@ -39,8 +39,6 @@ tokens/theme/** ─┤ dist/v4/
|
|
|
39
39
|
│
|
|
40
40
|
scripts/{compile-primitives, ─┘
|
|
41
41
|
compile-theme,
|
|
42
|
-
resolve,
|
|
43
|
-
css-vars,
|
|
44
42
|
refs}.js (building blocks used by build-tokens.mjs)
|
|
45
43
|
```
|
|
46
44
|
|
|
@@ -115,17 +113,11 @@ src/
|
|
|
115
113
|
│ │ └── animations.js
|
|
116
114
|
│ ├── theme.js # Tailwind theme.extend (colors + semantic mappings)
|
|
117
115
|
│ └── index.js # public re-exports
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
│ ├── compile-theme.js # legacy theme compiler (used by the harness pages)
|
|
124
|
-
│ └── build-tokens.mjs # main entrypoint: emits dist/v3 and dist/v4 bundles
|
|
125
|
-
└── tests/
|
|
126
|
-
├── primitives.html # visual harness for all primitives
|
|
127
|
-
├── theme.html # semantic tokens with light/dark toggle
|
|
128
|
-
└── tokens.html # combined view
|
|
116
|
+
└── scripts/
|
|
117
|
+
├── refs.js # tokenRef helper + isTokenRef guard + assertResolvedRefs
|
|
118
|
+
├── compile-primitives.js # flattens primitive trees into CSS vars
|
|
119
|
+
├── compile-theme.js # semantic light/dark compiler (exported as ./theme-colors)
|
|
120
|
+
└── build-tokens.mjs # main entrypoint: emits the dist/v4 bundle
|
|
129
121
|
```
|
|
130
122
|
|
|
131
123
|
---
|
|
@@ -216,18 +208,18 @@ Utilities like `text-default`, `bg-surface`, `border-default`, `text-primary`, `
|
|
|
216
208
|
### As JS objects (Node / build steps)
|
|
217
209
|
|
|
218
210
|
```js
|
|
219
|
-
import {
|
|
211
|
+
import { compileThemeVars, compileThemeCss } from '@aziontech/theme/theme-colors'
|
|
220
212
|
|
|
221
|
-
|
|
222
|
-
|
|
213
|
+
compileThemeVars() // → { light: { '--primary': '…', … }, dark: { … } }
|
|
214
|
+
compileThemeCss() // → ':root, [data-theme=light], .azion.azion-light { … }\n\n[data-theme=dark], … { … }'
|
|
223
215
|
```
|
|
224
216
|
|
|
225
217
|
### Injecting at runtime (browser)
|
|
226
218
|
|
|
227
219
|
```js
|
|
228
|
-
import {
|
|
220
|
+
import { injectThemeCss } from '@aziontech/theme/theme-colors'
|
|
229
221
|
|
|
230
|
-
|
|
222
|
+
injectThemeCss() // appends a <style data-azion-theme> element to <head>
|
|
231
223
|
```
|
|
232
224
|
|
|
233
225
|
Only useful if you can't precompile and import `globals.css` — production usage should prefer the static stylesheet.
|
|
@@ -306,18 +298,17 @@ Bundles with `fontSize: 'inherit'` are omitted from the Tailwind `fontSize` pres
|
|
|
306
298
|
|
|
307
299
|
## 🔗 Token references (`tokenRef`)
|
|
308
300
|
|
|
309
|
-
`tokenRef(path)` returns a marker object `{ __ref: path }` that the
|
|
301
|
+
`tokenRef(path)` returns a marker object `{ __ref: path }` that the compilers resolve at build time. Primitive-tree refs (`scripts/compile-primitives.js`) resolve against the full primitives tree (e.g. `shape.container.3xs`). Semantic theme refs (`scripts/compile-theme.js`) support these prefixes:
|
|
310
302
|
|
|
311
|
-
| Prefix
|
|
312
|
-
|
|
|
313
|
-
| `primitives.X.Y.Z`
|
|
314
|
-
| `
|
|
315
|
-
| `brand.
|
|
316
|
-
| `brand.
|
|
317
|
-
| `
|
|
318
|
-
| `brand.absolute.X` | `brandPrimitives.absolute.X` (`black` / `white`) |
|
|
303
|
+
| Prefix | Looks up |
|
|
304
|
+
| ------------------------- | ------------------------------------------------------------------------------------------------------ |
|
|
305
|
+
| `primitives.X.Y.Z` | `tokens/primitives/colors/colors.js` tree (e.g., `primitives.gray.900`, `primitives.alpha.orange.100`) |
|
|
306
|
+
| `brand.primary.primary-N` | `brandPrimitives.primary[N]` (e.g., `brand.primary.primary-500` → `#FE601F`) |
|
|
307
|
+
| `brand.accent.accent-N` | `brandPrimitives.accent[N]` |
|
|
308
|
+
| `brand.absolute.X` | `brandPrimitives.absolute.X` (`black` / `white`) |
|
|
309
|
+
| `theme.surfaces.X` | the variant's pre-resolved surfaces group (`tokens/theme/surfaces.js`) |
|
|
319
310
|
|
|
320
|
-
|
|
311
|
+
A ref that does not resolve — unknown prefix or dead path — **fails the build**: the compilers collect every miss and throw one aggregated `--var → ref` list (`assertResolvedRefs` in `scripts/refs.js`).
|
|
321
312
|
|
|
322
313
|
---
|
|
323
314
|
|
package/src/tokens/index.d.ts
CHANGED
|
@@ -2,5 +2,4 @@ export * from "./primitives/colors/colors.js";
|
|
|
2
2
|
export * from "./semantic/colors.js";
|
|
3
3
|
export * from "./theme.js";
|
|
4
4
|
export { textsData } from "./semantic/texts.data.js";
|
|
5
|
-
export { createCssVars, cssVarsString, injectCssVars } from "../scripts/css-vars.js";
|
|
6
5
|
//# sourceMappingURL=index.d.ts.map
|
package/src/tokens/index.js
CHANGED
|
@@ -33,6 +33,7 @@ export const animate: {
|
|
|
33
33
|
'slide-out-right': string;
|
|
34
34
|
'progress-indeterminate': string;
|
|
35
35
|
'progress-indeterminate-short': string;
|
|
36
|
+
'flow-dash': string;
|
|
36
37
|
};
|
|
37
38
|
export const useWhen: {
|
|
38
39
|
spin: string;
|
|
@@ -53,6 +54,7 @@ export const useWhen: {
|
|
|
53
54
|
'slide-out-right': string;
|
|
54
55
|
'progress-indeterminate': string;
|
|
55
56
|
'progress-indeterminate-short': string;
|
|
57
|
+
'flow-dash': string;
|
|
56
58
|
};
|
|
57
59
|
declare namespace _default {
|
|
58
60
|
export { animate };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"animate.d.ts","sourceRoot":"","sources":["animate.js"],"names":[],"mappings":"AAAA;;;;;EAKC;AAED;;;;;;;;;EASC;AAED
|
|
1
|
+
{"version":3,"file":"animate.d.ts","sourceRoot":"","sources":["animate.js"],"names":[],"mappings":"AAAA;;;;;EAKC;AAED;;;;;;;;;EASC;AAED;;;;;;;;;;;;;;;;;;;;EAsBC;AAED;;;;;;;;;;;;;;;;;;;;EAwBC"}
|
|
@@ -34,7 +34,10 @@ export const animate = {
|
|
|
34
34
|
'slide-in-right': `slideInRight ${duration['moderate-02']} ${curve['productive-entrance']}`,
|
|
35
35
|
'slide-out-right': `slideOutRight ${duration['moderate-01']} ${curve['productive-exit']}`,
|
|
36
36
|
'progress-indeterminate': `progressIndeterminate ${duration['slow-04']} ${curve['productive-entrance']} infinite`,
|
|
37
|
-
'progress-indeterminate-short': `progressIndeterminateShort ${duration['slow-04']} ${curve['expressive-entrance']} ${duration['slow-03']} infinite
|
|
37
|
+
'progress-indeterminate-short': `progressIndeterminateShort ${duration['slow-04']} ${curve['expressive-entrance']} ${duration['slow-03']} infinite`,
|
|
38
|
+
// `linear` (not a curve token) for the same reason as spin/shimmer: an endlessly
|
|
39
|
+
// looping animation must not accelerate, or the seam between repeats is visible.
|
|
40
|
+
'flow-dash': `flowDash ${duration['slow-02']} linear infinite`
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
export const useWhen = {
|
|
@@ -58,7 +61,9 @@ export const useWhen = {
|
|
|
58
61
|
'slide-in-right': 'Right-anchored panel entering (settings/detail drawer).',
|
|
59
62
|
'slide-out-right': 'Right-anchored panel leaving (pair of slide-in-right).',
|
|
60
63
|
'progress-indeterminate': 'Indeterminate linear progress bar (primary sweep).',
|
|
61
|
-
'progress-indeterminate-short': 'Indeterminate linear progress bar (secondary short sweep).'
|
|
64
|
+
'progress-indeterminate-short': 'Indeterminate linear progress bar (secondary short sweep).',
|
|
65
|
+
'flow-dash':
|
|
66
|
+
'Flowing connection along an SVG connector stroke in a node-based / network diagram. Set a stroke-dasharray whose cycle divides 24 (e.g. 4 4) so the loop is seamless.'
|
|
62
67
|
}
|
|
63
68
|
|
|
64
69
|
export default { animate, curve, duration, useWhen }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyframes.d.ts","sourceRoot":"","sources":["keyframes.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"keyframes.d.ts","sourceRoot":"","sources":["keyframes.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmFA;;;;GAIG;AACH;;;;;;;EAGC"}
|
|
@@ -37,12 +37,12 @@ export const keyframes = {
|
|
|
37
37
|
'100%': 'background-position: -200% 0'
|
|
38
38
|
},
|
|
39
39
|
popupScaleIn: {
|
|
40
|
-
'0%': 'opacity: 0; transform: scale(0.
|
|
40
|
+
'0%': 'opacity: 0; transform: scale(0.9)',
|
|
41
41
|
'100%': 'opacity: 1; transform: scale(1)'
|
|
42
42
|
},
|
|
43
43
|
popupScaleOut: {
|
|
44
44
|
'0%': 'opacity: 1; transform: scale(1)',
|
|
45
|
-
'100%': 'opacity: 0; transform: scale(0.
|
|
45
|
+
'100%': 'opacity: 0; transform: scale(0.9)'
|
|
46
46
|
},
|
|
47
47
|
slideInLeft: {
|
|
48
48
|
'0%': 'transform: translateX(-100%)',
|
|
@@ -69,6 +69,15 @@ export const keyframes = {
|
|
|
69
69
|
'0%': 'inset-inline-start: -200%; inset-inline-end: 100%',
|
|
70
70
|
'60%': 'inset-inline-start: 107%; inset-inline-end: -8%',
|
|
71
71
|
'100%': 'inset-inline-start: 107%; inset-inline-end: -8%'
|
|
72
|
+
},
|
|
73
|
+
// Marching dashes along an SVG stroke — the "flowing connection" of a node-based
|
|
74
|
+
// diagram. The travel distance is 24, so the loop is seamless for any
|
|
75
|
+
// `stroke-dasharray` whose cycle DIVIDES 24 (`4 4` = 8, `2 4` = 6, `8 4` = 12): the
|
|
76
|
+
// pattern lands exactly where it started. A cycle that does not divide 24 (`5 5` = 10)
|
|
77
|
+
// visibly jumps on repeat.
|
|
78
|
+
flowDash: {
|
|
79
|
+
'0%': 'stroke-dashoffset: 24',
|
|
80
|
+
'100%': 'stroke-dashoffset: 0'
|
|
72
81
|
}
|
|
73
82
|
}
|
|
74
83
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["container.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["container.js"],"names":[],"mappings":"AAiBA;;;;;;;;;;;;;;EAcC"}
|
|
@@ -1,17 +1,34 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Container widths — a geometric rhythm, not a hand-picked list.
|
|
3
|
+
*
|
|
4
|
+
* The scale is anchored at both ends: `3xs` stays 256px (the narrowest useful
|
|
5
|
+
* field/rail width) and `7xl` is 1620px (the widest page measure). The eleven
|
|
6
|
+
* slots between them are `256 × r^n` with r = (1620 / 256)^(1/12) ≈ 1.1662 —
|
|
7
|
+
* so every neighbouring pair sits at the same ~+16.6% apart and the whole set
|
|
8
|
+
* reads as one progression instead of two grids spliced together (the previous
|
|
9
|
+
* scale stepped +32, then +64, then +96, then +128).
|
|
10
|
+
*
|
|
11
|
+
* Values are rounded to the 4px grid; `7xl` keeps its exact anchor and `4xl`
|
|
12
|
+
* is nudged 4px to land on 1024 (2.6px off the ideal, and a landmark worth
|
|
13
|
+
* keeping). Ratio between neighbours therefore ranges 1.157–1.172.
|
|
14
|
+
*
|
|
15
|
+
* Rounding is 4px, not 8px, because 1620 is not a multiple of 8 — the anchor
|
|
16
|
+
* defines the grid, so a stricter grid could not reach it.
|
|
17
|
+
*/
|
|
1
18
|
export const container = {
|
|
2
|
-
'3xs': '256px',
|
|
3
|
-
'2xs': '
|
|
4
|
-
xs: '
|
|
5
|
-
sm: '
|
|
6
|
-
md: '
|
|
7
|
-
lg: '
|
|
8
|
-
xl: '
|
|
9
|
-
'2xl': '
|
|
10
|
-
'3xl': '
|
|
11
|
-
'4xl': '
|
|
12
|
-
'5xl': '
|
|
13
|
-
'6xl': '
|
|
14
|
-
'7xl': '
|
|
19
|
+
'3xs': '256px', // ×1 — anchor
|
|
20
|
+
'2xs': '300px', // +44
|
|
21
|
+
xs: '348px', // +48
|
|
22
|
+
sm: '408px', // +60
|
|
23
|
+
md: '472px', // +64
|
|
24
|
+
lg: '552px', // +80
|
|
25
|
+
xl: '644px', // +92
|
|
26
|
+
'2xl': '752px', // +108
|
|
27
|
+
'3xl': '876px', // +124
|
|
28
|
+
'4xl': '1024px', // +148
|
|
29
|
+
'5xl': '1192px', // +168
|
|
30
|
+
'6xl': '1388px', // +196
|
|
31
|
+
'7xl': '1620px' // +232 — anchor
|
|
15
32
|
}
|
|
16
33
|
|
|
17
34
|
export default { container }
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Letter-spacing scale, in `rem` so the emitted CSS carries a single measure
|
|
3
|
+
* unit across the whole token set (font sizes, spacings and tracking are all
|
|
4
|
+
* root-relative). Values are the em-scale numbers kept as-is, so `widest`
|
|
5
|
+
* resolves to a fixed 1.6px instead of 10% of the element's font size.
|
|
6
|
+
*/
|
|
1
7
|
export const tracking = {
|
|
2
|
-
tighter: '-0.
|
|
3
|
-
tight: '-0.
|
|
4
|
-
normal: '
|
|
5
|
-
wide: '0.
|
|
6
|
-
wider: '0.
|
|
7
|
-
widest: '0.
|
|
8
|
+
tighter: '-0.05rem',
|
|
9
|
+
tight: '-0.025rem',
|
|
10
|
+
normal: '0',
|
|
11
|
+
wide: '0.025rem',
|
|
12
|
+
wider: '0.05rem',
|
|
13
|
+
widest: '0.1rem'
|
|
8
14
|
}
|
|
9
15
|
|
|
10
16
|
export default { tracking }
|
|
@@ -4,8 +4,11 @@
|
|
|
4
4
|
* Single source of truth for semantic color tokens.
|
|
5
5
|
*
|
|
6
6
|
* - `semanticColorsData`: token refs grouped by category (`text`, `background`,
|
|
7
|
-
* `border`) and mode (`light`, `dark`).
|
|
8
|
-
*
|
|
7
|
+
* `border`) and mode (`light`, `dark`). The raw ref source `semanticColors`
|
|
8
|
+
* derives from; only re-exported via `tokens/index.js` today. Note: its
|
|
9
|
+
* `backdrop` / `primary-mask` refs point at `alpha` shades that do not exist
|
|
10
|
+
* (`alpha.neutral`, `alpha.brand`) — fix them before wiring this data to a
|
|
11
|
+
* compiler, or the unresolved-ref guard will reject it.
|
|
9
12
|
* - `semanticColors`: derived map of `var(--…)` strings, grouped by category,
|
|
10
13
|
* consumed by `tokens/theme.js` to extend Tailwind's `textColor`,
|
|
11
14
|
* `backgroundColor`, and `borderColor`. Generates utilities like
|
|
@@ -100,22 +100,22 @@ export const textsData: {
|
|
|
100
100
|
'text-label-code-sm': {
|
|
101
101
|
fontFamily: string;
|
|
102
102
|
fontSize: string;
|
|
103
|
-
lineHeight:
|
|
104
|
-
fontWeight:
|
|
103
|
+
lineHeight: number;
|
|
104
|
+
fontWeight: number;
|
|
105
105
|
letterSpacing: string;
|
|
106
106
|
};
|
|
107
107
|
'text-label-code-md': {
|
|
108
108
|
fontFamily: string;
|
|
109
109
|
fontSize: string;
|
|
110
|
-
lineHeight:
|
|
111
|
-
fontWeight:
|
|
110
|
+
lineHeight: number;
|
|
111
|
+
fontWeight: number;
|
|
112
112
|
letterSpacing: string;
|
|
113
113
|
};
|
|
114
114
|
'text-label-code-lg': {
|
|
115
115
|
fontFamily: string;
|
|
116
116
|
fontSize: string;
|
|
117
|
-
lineHeight:
|
|
118
|
-
fontWeight:
|
|
117
|
+
lineHeight: number;
|
|
118
|
+
fontWeight: number;
|
|
119
119
|
letterSpacing: string;
|
|
120
120
|
};
|
|
121
121
|
'text-body-lg': {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"texts.data.d.ts","sourceRoot":"","sources":["texts.data.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"texts.data.d.ts","sourceRoot":"","sources":["texts.data.js"],"names":[],"mappings":"AAwBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2JE,8FAA8F;;;;;;;;;;;;;;;;;;EAkB/F"}
|