@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
|
@@ -15,10 +15,12 @@
|
|
|
15
15
|
* old `mobile` (default, applied >768) → `md` (≥768)
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
+
import { curve, duration } from '../primitives/animations/animate.js'
|
|
18
19
|
import { fontFamily } from '../primitives/typography/font-family.js'
|
|
19
20
|
import { fontSize } from '../primitives/typography/font-size.js'
|
|
20
21
|
import { fontWeight } from '../primitives/typography/font-weight.js'
|
|
21
22
|
import { leading } from '../primitives/typography/leading.js'
|
|
23
|
+
import { tracking } from '../primitives/typography/tracking.js'
|
|
22
24
|
|
|
23
25
|
export const textsData = {
|
|
24
26
|
'text-big-number-md': {
|
|
@@ -77,38 +79,38 @@ export const textsData = {
|
|
|
77
79
|
'text-label-lg': {
|
|
78
80
|
fontSize: fontSize.base,
|
|
79
81
|
lineHeight: leading.normal,
|
|
80
|
-
fontWeight: fontWeight.
|
|
82
|
+
fontWeight: fontWeight.normal
|
|
81
83
|
},
|
|
82
84
|
'text-label-md': {
|
|
83
85
|
fontSize: fontSize.sm,
|
|
84
86
|
lineHeight: leading.normal,
|
|
85
|
-
fontWeight: fontWeight.
|
|
87
|
+
fontWeight: fontWeight.normal
|
|
86
88
|
},
|
|
87
89
|
'text-label-sm': {
|
|
88
90
|
fontSize: fontSize.xs,
|
|
89
91
|
lineHeight: leading.normal,
|
|
90
|
-
fontWeight: fontWeight.
|
|
92
|
+
fontWeight: fontWeight.normal
|
|
91
93
|
},
|
|
92
94
|
'text-label-code-sm': {
|
|
93
95
|
fontFamily: fontFamily.code,
|
|
94
|
-
fontSize:
|
|
95
|
-
lineHeight:
|
|
96
|
-
fontWeight:
|
|
97
|
-
letterSpacing:
|
|
96
|
+
fontSize: fontSize.xs,
|
|
97
|
+
lineHeight: leading.none,
|
|
98
|
+
fontWeight: fontWeight.normal,
|
|
99
|
+
letterSpacing: tracking.normal
|
|
98
100
|
},
|
|
99
101
|
'text-label-code-md': {
|
|
100
102
|
fontFamily: fontFamily.code,
|
|
101
|
-
fontSize:
|
|
102
|
-
lineHeight:
|
|
103
|
-
fontWeight:
|
|
104
|
-
letterSpacing:
|
|
103
|
+
fontSize: fontSize.sm,
|
|
104
|
+
lineHeight: leading.none,
|
|
105
|
+
fontWeight: fontWeight.normal,
|
|
106
|
+
letterSpacing: tracking.normal
|
|
105
107
|
},
|
|
106
108
|
'text-label-code-lg': {
|
|
107
109
|
fontFamily: fontFamily.code,
|
|
108
|
-
fontSize:
|
|
109
|
-
lineHeight:
|
|
110
|
-
fontWeight:
|
|
111
|
-
letterSpacing:
|
|
110
|
+
fontSize: fontSize.base,
|
|
111
|
+
lineHeight: leading.none,
|
|
112
|
+
fontWeight: fontWeight.normal,
|
|
113
|
+
letterSpacing: tracking.normal
|
|
112
114
|
},
|
|
113
115
|
'text-body-lg': {
|
|
114
116
|
fontSize: { _: fontSize.base, md: fontSize.lg },
|
|
@@ -144,21 +146,21 @@ export const textsData = {
|
|
|
144
146
|
fontFamily: fontFamily.display,
|
|
145
147
|
fontSize: { _: fontSize.xs, sm: fontSize.sm },
|
|
146
148
|
lineHeight: leading.snug,
|
|
147
|
-
letterSpacing:
|
|
149
|
+
letterSpacing: tracking.widest,
|
|
148
150
|
textTransform: 'uppercase'
|
|
149
151
|
},
|
|
150
152
|
'text-overline-sm': {
|
|
151
153
|
fontFamily: fontFamily.display,
|
|
152
154
|
fontSize: fontSize.xs,
|
|
153
155
|
lineHeight: leading.snug,
|
|
154
|
-
letterSpacing:
|
|
156
|
+
letterSpacing: tracking.widest,
|
|
155
157
|
textTransform: 'uppercase'
|
|
156
158
|
},
|
|
157
159
|
'text-overline-xs': {
|
|
158
160
|
fontFamily: fontFamily.display,
|
|
159
161
|
fontSize: fontSize.xs,
|
|
160
162
|
lineHeight: leading.snug,
|
|
161
|
-
letterSpacing:
|
|
163
|
+
letterSpacing: tracking.widest,
|
|
162
164
|
textTransform: 'uppercase'
|
|
163
165
|
},
|
|
164
166
|
'text-button-lg': {
|
|
@@ -166,14 +168,14 @@ export const textsData = {
|
|
|
166
168
|
fontSize: fontSize.sm,
|
|
167
169
|
fontWeight: fontWeight.normal,
|
|
168
170
|
lineHeight: leading.tight,
|
|
169
|
-
letterSpacing:
|
|
171
|
+
letterSpacing: tracking.normal
|
|
170
172
|
},
|
|
171
173
|
'text-button-md': {
|
|
172
174
|
fontFamily: fontFamily.sans,
|
|
173
175
|
fontSize: fontSize.xs,
|
|
174
176
|
fontWeight: fontWeight.normal,
|
|
175
177
|
lineHeight: leading.tight,
|
|
176
|
-
letterSpacing:
|
|
178
|
+
letterSpacing: tracking.normal
|
|
177
179
|
},
|
|
178
180
|
/** Inline `<a>` in body/heading — inherits parent size; not the navigation Link component. */
|
|
179
181
|
'text-link': {
|
|
@@ -181,7 +183,7 @@ export const textsData = {
|
|
|
181
183
|
lineHeight: 'inherit',
|
|
182
184
|
color: 'var(--text-link)',
|
|
183
185
|
borderRadius: 'var(--shape-elements)',
|
|
184
|
-
transition:
|
|
186
|
+
transition: `all ${duration['fast-02']} ${curve['productive-entrance']}`,
|
|
185
187
|
states: {
|
|
186
188
|
hover: {
|
|
187
189
|
color: 'var(--text-link-hover)',
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declarative z-index tokens.
|
|
3
|
+
*
|
|
4
|
+
* Intra-input stacking:
|
|
5
|
+
*
|
|
6
|
+
* - `z-input-field` → native field / interactive foreground (e.g. an
|
|
7
|
+
* `<input>` or trigger button) sitting above the
|
|
8
|
+
* input's own background surface, icons, and
|
|
9
|
+
* adornments so keyboard/mouse focus is never
|
|
10
|
+
* hijacked by a decorative sibling.
|
|
11
|
+
* - `z-input-popup` → inline (non-teleported) overlays anchored to the
|
|
12
|
+
* input — dropdown menus, option lists, popovers —
|
|
13
|
+
* that must sit above surrounding form content but
|
|
14
|
+
* within the current stacking context.
|
|
15
|
+
* - `z-input-overlay` → teleported overlays (rendered under `<body>` via
|
|
16
|
+
* `<Teleport>`) that must clear application chrome
|
|
17
|
+
* such as drawers, modals, and fixed headers.
|
|
18
|
+
*
|
|
19
|
+
* Values are intentionally small and well-spaced to make future additions
|
|
20
|
+
* obvious. Consume as `z-[var(--z-input-*)]` in components — do not
|
|
21
|
+
* introduce ad-hoc numeric z-index in input `.vue` files.
|
|
22
|
+
*/
|
|
23
|
+
export const zIndicesData: {
|
|
24
|
+
'z-input-field': {
|
|
25
|
+
_: string;
|
|
26
|
+
};
|
|
27
|
+
'z-input-popup': {
|
|
28
|
+
_: string;
|
|
29
|
+
};
|
|
30
|
+
'z-input-overlay': {
|
|
31
|
+
_: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
declare namespace _default {
|
|
35
|
+
export { zIndicesData };
|
|
36
|
+
}
|
|
37
|
+
export default _default;
|
|
38
|
+
//# sourceMappingURL=z-indices.data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"z-indices.data.d.ts","sourceRoot":"","sources":["z-indices.data.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;;;;;;;EAIE"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declarative z-index tokens.
|
|
3
|
+
*
|
|
4
|
+
* Intra-input stacking:
|
|
5
|
+
*
|
|
6
|
+
* - `z-input-field` → native field / interactive foreground (e.g. an
|
|
7
|
+
* `<input>` or trigger button) sitting above the
|
|
8
|
+
* input's own background surface, icons, and
|
|
9
|
+
* adornments so keyboard/mouse focus is never
|
|
10
|
+
* hijacked by a decorative sibling.
|
|
11
|
+
* - `z-input-popup` → inline (non-teleported) overlays anchored to the
|
|
12
|
+
* input — dropdown menus, option lists, popovers —
|
|
13
|
+
* that must sit above surrounding form content but
|
|
14
|
+
* within the current stacking context.
|
|
15
|
+
* - `z-input-overlay` → teleported overlays (rendered under `<body>` via
|
|
16
|
+
* `<Teleport>`) that must clear application chrome
|
|
17
|
+
* such as drawers, modals, and fixed headers.
|
|
18
|
+
*
|
|
19
|
+
* Values are intentionally small and well-spaced to make future additions
|
|
20
|
+
* obvious. Consume as `z-[var(--z-input-*)]` in components — do not
|
|
21
|
+
* introduce ad-hoc numeric z-index in input `.vue` files.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
export const zIndicesData = {
|
|
25
|
+
'z-input-field': { _: '1' },
|
|
26
|
+
'z-input-popup': { _: '10' },
|
|
27
|
+
'z-input-overlay': { _: '1100' },
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default { zIndicesData };
|
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
import { tokenRef } from '../../scripts/refs.js'
|
|
2
2
|
|
|
3
|
+
// The accent family points at the BLUE primitive ramp (`primitives.blue`, the
|
|
4
|
+
// #0072F5 hue). These values mirror the Figma Theme collection's `accent/*`
|
|
5
|
+
// variables 1-to-1 — Figma is the source of truth, and it already aliases its
|
|
6
|
+
// whole `colors/brand/accent/accent-*` ramp onto `colors/blue/*` (it carries no
|
|
7
|
+
// violet primitives at all). The violet mapping this replaces existed only here.
|
|
8
|
+
//
|
|
9
|
+
// Accent is MODE-INVARIANT, exactly as Figma declares it: Light and Dark resolve
|
|
10
|
+
// to the same values. `accent-contrast` stays black — black on blue-500 is
|
|
11
|
+
// 4.73:1, clearing WCAG AA on the filled accent surface.
|
|
12
|
+
//
|
|
13
|
+
// `brand.accent` still holds violet values in code and ships as
|
|
14
|
+
// `--color-brand-accent-*`; only the semantic `--accent*` group turns blue here.
|
|
3
15
|
export const accent = {
|
|
4
16
|
light: {
|
|
5
|
-
accent: tokenRef('
|
|
6
|
-
'accent-mask': tokenRef('primitives.alpha.
|
|
7
|
-
'accent-selected': tokenRef('
|
|
17
|
+
accent: tokenRef('primitives.blue.500'),
|
|
18
|
+
'accent-mask': tokenRef('primitives.alpha.blue.100'),
|
|
19
|
+
'accent-selected': tokenRef('primitives.blue.500'),
|
|
8
20
|
'accent-contrast': tokenRef('primitives.base.black')
|
|
9
21
|
},
|
|
10
22
|
dark: {
|
|
11
|
-
accent: tokenRef('
|
|
12
|
-
'accent-mask': tokenRef('primitives.alpha.
|
|
13
|
-
'accent-selected': tokenRef('
|
|
23
|
+
accent: tokenRef('primitives.blue.500'),
|
|
24
|
+
'accent-mask': tokenRef('primitives.alpha.blue.100'),
|
|
25
|
+
'accent-selected': tokenRef('primitives.blue.500'),
|
|
14
26
|
'accent-contrast': tokenRef('primitives.base.black')
|
|
15
27
|
}
|
|
16
28
|
}
|
|
@@ -15,6 +15,12 @@ export namespace background {
|
|
|
15
15
|
'bg-surface-overlay': {
|
|
16
16
|
__ref: any;
|
|
17
17
|
};
|
|
18
|
+
'bg-placeholder': {
|
|
19
|
+
__ref: any;
|
|
20
|
+
};
|
|
21
|
+
'bg-placeholder-highlight': {
|
|
22
|
+
__ref: any;
|
|
23
|
+
};
|
|
18
24
|
'bg-hover': {
|
|
19
25
|
__ref: any;
|
|
20
26
|
};
|
|
@@ -50,6 +56,12 @@ export namespace background {
|
|
|
50
56
|
'bg-surface-overlay': {
|
|
51
57
|
__ref: any;
|
|
52
58
|
};
|
|
59
|
+
'bg-placeholder': {
|
|
60
|
+
__ref: any;
|
|
61
|
+
};
|
|
62
|
+
'bg-placeholder-highlight': {
|
|
63
|
+
__ref: any;
|
|
64
|
+
};
|
|
53
65
|
'bg-hover': {
|
|
54
66
|
__ref: any;
|
|
55
67
|
};
|
|
@@ -7,6 +7,8 @@ export const background = {
|
|
|
7
7
|
'bg-surface-raised': tokenRef('theme.surfaces.surface-0'),
|
|
8
8
|
'bg-mask': tokenRef('primitives.alpha.black.50'),
|
|
9
9
|
'bg-surface-overlay': tokenRef('theme.surfaces.surface-50'),
|
|
10
|
+
'bg-placeholder': tokenRef('primitives.alpha.black.100'),
|
|
11
|
+
'bg-placeholder-highlight': tokenRef('primitives.alpha.white.600'),
|
|
10
12
|
'bg-hover': tokenRef('primitives.alpha.black.100'),
|
|
11
13
|
'bg-active': tokenRef('primitives.alpha.black.50'),
|
|
12
14
|
'bg-backdrop': tokenRef('primitives.alpha.black.800'),
|
|
@@ -20,8 +22,15 @@ export const background = {
|
|
|
20
22
|
'bg-surface-raised': tokenRef('theme.surfaces.surface-900'),
|
|
21
23
|
'bg-mask': tokenRef('primitives.alpha.white.50'),
|
|
22
24
|
'bg-surface-overlay': tokenRef('theme.surfaces.surface-700'),
|
|
23
|
-
'bg-
|
|
24
|
-
'bg-
|
|
25
|
+
'bg-placeholder': tokenRef('primitives.alpha.white.100'),
|
|
26
|
+
'bg-placeholder-highlight': tokenRef('primitives.alpha.white.100'),
|
|
27
|
+
// Interaction overlays LIGHTEN in dark. A black alpha over a dark surface is invisible
|
|
28
|
+
// (and a literal no-op over `bg-canvas`, which is pure black), so hover/active follow the
|
|
29
|
+
// same polarity flip `bg-mask` / `bg-placeholder` / `border-default` already make here.
|
|
30
|
+
// `active` stacks on top of `hover` (the row paints both layers while pressed), so it is
|
|
31
|
+
// the smaller increment, mirroring light's 8% + 2%.
|
|
32
|
+
'bg-hover': tokenRef('primitives.alpha.white.100'),
|
|
33
|
+
'bg-active': tokenRef('primitives.alpha.white.50'),
|
|
25
34
|
'bg-backdrop': tokenRef('primitives.alpha.black.800'),
|
|
26
35
|
'bg-selected': tokenRef('theme.surfaces.surface-800'),
|
|
27
36
|
'bg-contrast': tokenRef('theme.surfaces.surface-50'),
|
|
@@ -12,6 +12,9 @@ export namespace codeSintax {
|
|
|
12
12
|
'code-sintax-punctuation': {
|
|
13
13
|
__ref: any;
|
|
14
14
|
};
|
|
15
|
+
'code-sintax-comment': {
|
|
16
|
+
__ref: any;
|
|
17
|
+
};
|
|
15
18
|
'code-sintax-function': {
|
|
16
19
|
__ref: any;
|
|
17
20
|
};
|
|
@@ -35,6 +38,9 @@ export namespace codeSintax {
|
|
|
35
38
|
'code-sintax-punctuation': {
|
|
36
39
|
__ref: any;
|
|
37
40
|
};
|
|
41
|
+
'code-sintax-comment': {
|
|
42
|
+
__ref: any;
|
|
43
|
+
};
|
|
38
44
|
'code-sintax-function': {
|
|
39
45
|
__ref: any;
|
|
40
46
|
};
|
|
@@ -10,6 +10,7 @@ export const codeSintax = {
|
|
|
10
10
|
'code-sintax-line-number': tokenRef('primitives.gray.500'),
|
|
11
11
|
'code-sintax-keyword': tokenRef('primitives.blue.600'),
|
|
12
12
|
'code-sintax-punctuation': tokenRef('primitives.gray.500'),
|
|
13
|
+
'code-sintax-comment': tokenRef('primitives.gray.500'),
|
|
13
14
|
'code-sintax-function': tokenRef('brand.primary.primary-500'),
|
|
14
15
|
'code-sintax-type': tokenRef('primitives.yellow.700'),
|
|
15
16
|
'code-sintax-string': tokenRef('primitives.blue.600')
|
|
@@ -19,6 +20,7 @@ export const codeSintax = {
|
|
|
19
20
|
'code-sintax-line-number': tokenRef('primitives.gray.400'),
|
|
20
21
|
'code-sintax-keyword': tokenRef('primitives.blue.400'),
|
|
21
22
|
'code-sintax-punctuation': tokenRef('primitives.gray.400'),
|
|
23
|
+
'code-sintax-comment': tokenRef('primitives.gray.400'),
|
|
22
24
|
'code-sintax-function': tokenRef('brand.primary.primary-500'),
|
|
23
25
|
'code-sintax-type': tokenRef('primitives.yellow.300'),
|
|
24
26
|
'code-sintax-string': tokenRef('primitives.blue.400')
|
|
@@ -3,12 +3,12 @@ import { tokenRef } from '../../../scripts/refs.js'
|
|
|
3
3
|
export const info = {
|
|
4
4
|
light: {
|
|
5
5
|
info: tokenRef('primitives.blue.100'),
|
|
6
|
-
'info-border': tokenRef('primitives.alpha.
|
|
6
|
+
'info-border': tokenRef('primitives.alpha.blue.400'),
|
|
7
7
|
'info-contrast': tokenRef('primitives.blue.700')
|
|
8
8
|
},
|
|
9
9
|
dark: {
|
|
10
10
|
info: tokenRef('primitives.blue.900'),
|
|
11
|
-
'info-border': tokenRef('primitives.alpha.blue.
|
|
11
|
+
'info-border': tokenRef('primitives.alpha.blue.400'),
|
|
12
12
|
'info-contrast': tokenRef('primitives.blue.300')
|
|
13
13
|
}
|
|
14
14
|
}
|
package/src/tokens/theme/text.js
CHANGED
|
@@ -3,7 +3,7 @@ import { tokenRef } from '../../scripts/refs.js'
|
|
|
3
3
|
export const text = {
|
|
4
4
|
light: {
|
|
5
5
|
'text-default': tokenRef('primitives.gray.900'),
|
|
6
|
-
'text-muted': tokenRef('primitives.gray.
|
|
6
|
+
'text-muted': tokenRef('primitives.gray.500'),
|
|
7
7
|
'text-disabled': tokenRef('primitives.gray.400'),
|
|
8
8
|
'text-link': tokenRef('primitives.blue.600'),
|
|
9
9
|
'text-link-hover': tokenRef('primitives.blue.700'),
|
|
@@ -11,7 +11,7 @@ export const text = {
|
|
|
11
11
|
},
|
|
12
12
|
dark: {
|
|
13
13
|
'text-default': tokenRef('primitives.gray.50'),
|
|
14
|
-
'text-muted': tokenRef('primitives.gray.
|
|
14
|
+
'text-muted': tokenRef('primitives.gray.500'),
|
|
15
15
|
'text-disabled': tokenRef('primitives.gray.700'),
|
|
16
16
|
'text-link': tokenRef('primitives.blue.400'),
|
|
17
17
|
'text-link-hover': tokenRef('primitives.blue.300'),
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"css-vars.d.ts","sourceRoot":"","sources":["css-vars.js"],"names":[],"mappings":"AAgBO;;;EAQH;AAEG,wCAWN;AAEM,kDAMN"}
|
package/src/scripts/css-vars.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CSS variables initializer for semantic tokens.
|
|
3
|
-
*
|
|
4
|
-
* Reads the single source-of-truth in `tokens/semantic/colors.js` and resolves
|
|
5
|
-
* its `tokenRef(...)` entries against the primitive trees, producing a flat
|
|
6
|
-
* `{ light, dark }` map of CSS variable names → resolved color values.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
brandPrimitives,
|
|
11
|
-
primitives,
|
|
12
|
-
surfacePrimitives
|
|
13
|
-
} from '../tokens/primitives/colors/colors.js'
|
|
14
|
-
import { semanticColorsData } from '../tokens/semantic/colors.js'
|
|
15
|
-
import { resolveRefsToCssVars } from './resolve.js'
|
|
16
|
-
|
|
17
|
-
export const createCssVars = () =>
|
|
18
|
-
resolveRefsToCssVars({
|
|
19
|
-
primitives,
|
|
20
|
-
surfacePrimitives,
|
|
21
|
-
brandPrimitives,
|
|
22
|
-
textSemantic: semanticColorsData.text,
|
|
23
|
-
backgroundSemantic: semanticColorsData.background,
|
|
24
|
-
borderSemantic: semanticColorsData.border
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
export const cssVarsString = () => {
|
|
28
|
-
const { light, dark } = createCssVars()
|
|
29
|
-
const format = (vars) =>
|
|
30
|
-
Object.entries(vars)
|
|
31
|
-
.map(([key, value]) => ` ${key}: ${value};`)
|
|
32
|
-
.join('\n')
|
|
33
|
-
|
|
34
|
-
return [
|
|
35
|
-
`:root, [data-theme=light], .azion.azion-light {\n${format(light)}\n}`,
|
|
36
|
-
`[data-theme=dark], .dark, .azion.azion-dark {\n${format(dark)}\n}`
|
|
37
|
-
].join('\n\n')
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export const injectCssVars = () => {
|
|
41
|
-
const style = document.createElement('style')
|
|
42
|
-
style.setAttribute('data-azion-tokens', 'true')
|
|
43
|
-
style.textContent = cssVarsString()
|
|
44
|
-
document.head.appendChild(style)
|
|
45
|
-
return style
|
|
46
|
-
}
|
package/src/scripts/resolve.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["resolve.js"],"names":[],"mappings":"AAiCO;;;EAyEN"}
|
package/src/scripts/resolve.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Resolve token refs to CSS variable map.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { isTokenRef } from './refs.js'
|
|
6
|
-
|
|
7
|
-
const getValueByPath = (obj, path) =>
|
|
8
|
-
path.split('.').reduce((acc, key) => {
|
|
9
|
-
if (acc && typeof acc === 'object' && key in acc) {
|
|
10
|
-
return acc[key]
|
|
11
|
-
}
|
|
12
|
-
return undefined
|
|
13
|
-
}, obj)
|
|
14
|
-
|
|
15
|
-
const flattenToCssVars = (obj, prefix = []) => {
|
|
16
|
-
const result = {}
|
|
17
|
-
Object.entries(obj).forEach(([key, value]) => {
|
|
18
|
-
const nextPath = [...prefix, key]
|
|
19
|
-
if (value && typeof value === 'object' && !Array.isArray(value) && !isTokenRef(value)) {
|
|
20
|
-
Object.assign(result, flattenToCssVars(value, nextPath))
|
|
21
|
-
return
|
|
22
|
-
}
|
|
23
|
-
if (isTokenRef(value)) {
|
|
24
|
-
result[`--${nextPath.join('-')}`] = value.__ref
|
|
25
|
-
return
|
|
26
|
-
}
|
|
27
|
-
if (typeof value === 'string' || typeof value === 'number') {
|
|
28
|
-
result[`--${nextPath.join('-')}`] = String(value)
|
|
29
|
-
}
|
|
30
|
-
})
|
|
31
|
-
return result
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export const resolveRefsToCssVars = (tokens) => {
|
|
35
|
-
const baseForResolve = {
|
|
36
|
-
primitives: tokens.primitives,
|
|
37
|
-
surfacePrimitives: tokens.surfacePrimitives,
|
|
38
|
-
brandPrimitives: tokens.brandPrimitives
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const baseForVars = { primitives: tokens.primitives, surfacePrimitives: tokens.surfacePrimitives }
|
|
42
|
-
|
|
43
|
-
const lightSemantic = {
|
|
44
|
-
text: tokens.textSemantic.light,
|
|
45
|
-
background: tokens.backgroundSemantic.light,
|
|
46
|
-
border: tokens.borderSemantic.light
|
|
47
|
-
}
|
|
48
|
-
const darkSemantic = {
|
|
49
|
-
text: tokens.textSemantic.dark,
|
|
50
|
-
background: tokens.backgroundSemantic.dark,
|
|
51
|
-
border: tokens.borderSemantic.dark
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const resolveBrandRef = (ref) => {
|
|
55
|
-
if (ref.startsWith('brand.surfaces.surface-')) {
|
|
56
|
-
const shade = ref.replace('brand.surfaces.surface-', '')
|
|
57
|
-
const resolved = getValueByPath(baseForResolve, `surfacePrimitives.surface.${shade}`)
|
|
58
|
-
return typeof resolved === 'string' || typeof resolved === 'number' ? String(resolved) : null
|
|
59
|
-
}
|
|
60
|
-
if (ref.startsWith('brand.primary.primary-')) {
|
|
61
|
-
const shade = ref.replace('brand.primary.primary-', '')
|
|
62
|
-
const resolved = getValueByPath(baseForResolve, `brandPrimitives.primary.${shade}`)
|
|
63
|
-
return typeof resolved === 'string' || typeof resolved === 'number' ? String(resolved) : null
|
|
64
|
-
}
|
|
65
|
-
if (ref.startsWith('brand.accent.accent-')) {
|
|
66
|
-
const shade = ref.replace('brand.accent.accent-', '')
|
|
67
|
-
const resolved = getValueByPath(baseForResolve, `brandPrimitives.accent.${shade}`)
|
|
68
|
-
return typeof resolved === 'string' || typeof resolved === 'number' ? String(resolved) : null
|
|
69
|
-
}
|
|
70
|
-
if (ref.startsWith('brand.absolute.')) {
|
|
71
|
-
const name = ref.replace('brand.absolute.', '')
|
|
72
|
-
const resolved = getValueByPath(baseForResolve, `brandPrimitives.absolute.${name}`)
|
|
73
|
-
return typeof resolved === 'string' || typeof resolved === 'number' ? String(resolved) : null
|
|
74
|
-
}
|
|
75
|
-
return null
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const resolveSemantic = (semantic) => {
|
|
79
|
-
const flattened = flattenToCssVars(semantic)
|
|
80
|
-
return Object.fromEntries(
|
|
81
|
-
Object.entries(flattened).map(([key, value]) => {
|
|
82
|
-
if (value.startsWith('brand.')) {
|
|
83
|
-
return [key, resolveBrandRef(value) ?? value]
|
|
84
|
-
}
|
|
85
|
-
if (value.startsWith('primitives.') || value.startsWith('surfacePrimitives.')) {
|
|
86
|
-
const resolved = getValueByPath(baseForResolve, value)
|
|
87
|
-
return [
|
|
88
|
-
key,
|
|
89
|
-
typeof resolved === 'string' || typeof resolved === 'number' ? String(resolved) : value
|
|
90
|
-
]
|
|
91
|
-
}
|
|
92
|
-
return [key, value]
|
|
93
|
-
})
|
|
94
|
-
)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return {
|
|
98
|
-
light: {
|
|
99
|
-
...flattenToCssVars(baseForVars),
|
|
100
|
-
...resolveSemantic(lightSemantic)
|
|
101
|
-
},
|
|
102
|
-
dark: {
|
|
103
|
-
...flattenToCssVars(baseForVars),
|
|
104
|
-
...resolveSemantic(darkSemantic)
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|