@baloise/ds-tokens 19.10.2 → 20.0.0-next.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/LICENSE +11 -2
  2. package/dist/css/base.override.css +2351 -0
  3. package/dist/css/base.tokens.css +2354 -0
  4. package/dist/css/erv.override.css +2351 -0
  5. package/dist/css/erv.tokens.css +2351 -0
  6. package/dist/css/tcs.override.css +2351 -0
  7. package/dist/css/tcs.tokens.css +2351 -0
  8. package/dist/docs/base.tokens.json +80732 -0
  9. package/dist/js/base.tokens.js +1992 -0
  10. package/dist/out-tsc/config.base.js +210 -0
  11. package/dist/out-tsc/config.brand.js +92 -0
  12. package/dist/out-tsc/css-naming.js +26 -0
  13. package/dist/out-tsc/css-preview.js +8 -0
  14. package/dist/out-tsc/css-value.js +301 -0
  15. package/dist/out-tsc/formatter.js +517 -0
  16. package/dist/out-tsc/index.js +46 -0
  17. package/dist/out-tsc/transformers.js +196 -0
  18. package/dist/sass/base.tokens.scss +17 -0
  19. package/dist/web/base.tokens.json +1990 -0
  20. package/package.json +31 -9
  21. package/sbom.cdx.json +76462 -0
  22. package/README.md +0 -37
  23. package/dist/deprecated/tokens.css +0 -119
  24. package/dist/deprecated/tokens.css.scss +0 -119
  25. package/dist/deprecated/tokens.docs.json +0 -2764
  26. package/dist/deprecated/tokens.json +0 -114
  27. package/dist/deprecated/tokens.less +0 -116
  28. package/dist/deprecated/tokens.scss +0 -116
  29. package/dist/figma/color.json +0 -606
  30. package/dist/figma/size.json +0 -232
  31. package/dist/tokens.css +0 -270
  32. package/dist/tokens.css.scss +0 -270
  33. package/dist/tokens.docs.json +0 -5853
  34. package/dist/tokens.esm.js +0 -268
  35. package/dist/tokens.js +0 -270
  36. package/dist/tokens.json +0 -265
  37. package/dist/tokens.less +0 -267
  38. package/dist/tokens.scss +0 -267
  39. package/dist/types/tokens.d.ts +0 -350
@@ -0,0 +1,196 @@
1
+ import { borderValueToCss, colorValueToCss, dimensionValueToCss, fontFamilyValueToCss, numberValueToCssSize, roundNumberValue, shadowValueToCss, typographyValueToCss, } from './css-value.js';
2
+ import { tokenNameToCssVar } from './css-naming.js';
3
+ export const registerCustomTransformers = (sd) => {
4
+ /**
5
+ * Transform color tokens with hex and alpha properties to rgba() format
6
+ */
7
+ sd.registerTransform({
8
+ type: `value`,
9
+ transitive: true,
10
+ name: `ds/color/rgba`,
11
+ filter: token => token.$type === 'color',
12
+ transform: token => {
13
+ const value = token.$value ?? token.value;
14
+ return colorValueToCss(value) ?? value;
15
+ },
16
+ });
17
+ /**
18
+ * Transform color tokens with hex
19
+ */
20
+ sd.registerTransform({
21
+ type: `value`,
22
+ transitive: true,
23
+ name: `ds/color/hex`,
24
+ filter: token => token.$type === 'color',
25
+ transform: token => {
26
+ const value = token.$value ?? token.value;
27
+ // Handle object values with hex and alpha properties
28
+ if (typeof value === 'object' && value !== null && 'hex' in value && 'alpha' in value) {
29
+ return value.hex;
30
+ }
31
+ return value;
32
+ },
33
+ });
34
+ /**
35
+ * Transform token names for CSS usage
36
+ */
37
+ sd.registerTransform({
38
+ type: `name`,
39
+ transitive: true,
40
+ name: `ds/css/name`,
41
+ transform: (token, config) => tokenNameToCssVar(token.path, config.prefix ?? 'ds'),
42
+ });
43
+ /**
44
+ * Transform token names for CSS usage
45
+ */
46
+ sd.registerTransform({
47
+ type: `name`,
48
+ transitive: true,
49
+ name: `ds/js/name`,
50
+ transform: token => {
51
+ let tokenName = token.name;
52
+ tokenName = tokenName.replace('Primitive', 'Global');
53
+ tokenName = tokenName.replace('Semantic', 'Alias');
54
+ return tokenName;
55
+ },
56
+ });
57
+ /**
58
+ * Transform size tokens from px to rem
59
+ */
60
+ sd.registerTransform({
61
+ type: `value`,
62
+ transitive: true,
63
+ name: `ds/size/rem`,
64
+ filter: token => token.$type === 'number',
65
+ transform: token => numberValueToCssSize(token.$value, token.path),
66
+ });
67
+ sd.registerTransform({
68
+ type: `value`,
69
+ transitive: true,
70
+ name: `ds/size/round`,
71
+ filter: token => token.$type === 'number',
72
+ transform: token => {
73
+ const value = token.$value ?? token.value;
74
+ const name = token.name;
75
+ const tokenName = Array.isArray(name) ? name.join('-') : String(name ?? '');
76
+ return roundNumberValue(value, tokenName);
77
+ },
78
+ });
79
+ /**
80
+ * Transform fontWeight tokens to a bare CSS number (e.g. 700), never rem/px-converted
81
+ */
82
+ sd.registerTransform({
83
+ type: `value`,
84
+ transitive: true,
85
+ name: `ds/font-weight`,
86
+ filter: token => token.$type === 'fontWeight',
87
+ transform: token => Number(token.$value ?? token.value),
88
+ });
89
+ /**
90
+ * Transform fontFamily tokens (an array of font names) into a CSS-ready, comma-joined
91
+ * font-family declaration, quoting only entries that need it.
92
+ */
93
+ sd.registerTransform({
94
+ type: `value`,
95
+ transitive: true,
96
+ name: `ds/font-family`,
97
+ filter: token => token.$type === 'fontFamily',
98
+ transform: token => fontFamilyValueToCss(token.$value ?? token.value),
99
+ });
100
+ /**
101
+ * Transform dimension tokens ({value, unit}) into a CSS-ready size, e.g. '1.5rem'.
102
+ *
103
+ * NOT needed on the 'css'/'scss'/'javascript' platforms — their transformGroups already include
104
+ * Style Dictionary's own built-in 'size/rem', which correctly preserves whichever unit our
105
+ * $value carries; adding this transform there too would double-process it (the same trap
106
+ * 'ds/font-family' hit — see docs/plans/font-family-token-type-plan.md's addendum).
107
+ *
108
+ * IS needed on 'web'/'docs' (config.base.ts) and the brand css platform (config.brand.ts) —
109
+ * 'web'/'docs' use the 'web' transformGroup, which includes Style Dictionary's built-in
110
+ * 'size/px' instead of 'size/rem'; unlike 'size/rem', 'size/px' unconditionally forces a "px"
111
+ * suffix onto the number *without* converting it (a 1.5rem token would come out "1.5px" — wrong
112
+ * unit label AND physically 24x smaller than intended). Re-registering a transform under the
113
+ * name 'size/px' to override that behavior was tried and didn't take effect — Style Dictionary
114
+ * appears to re-establish its own built-ins on instance construction, after this module's
115
+ * static-level registration — so 'web'/'docs' drop `transformGroup: 'web'` entirely instead and
116
+ * list their transforms explicitly (see config.base.ts), which is why this transform has to be
117
+ * in that explicit list. The brand css platform has no transformGroup at all, so it always
118
+ * needed this explicitly regardless.
119
+ */
120
+ sd.registerTransform({
121
+ type: `value`,
122
+ transitive: true,
123
+ name: `ds/dimension`,
124
+ filter: token => token.$type === 'dimension',
125
+ transform: token => {
126
+ const value = token.$value ?? token.value;
127
+ // Already a string when 'size/rem' ran first (needed on 'web'/'docs' so a border
128
+ // composite token's referenced Width sub-value resolves correctly — see 'web'/'docs'
129
+ // platform comment in config.base.ts). Pass through rather than re-parse.
130
+ return typeof value === 'string' ? value : dimensionValueToCss(value);
131
+ },
132
+ });
133
+ /**
134
+ * Transform shadow tokens (a shadow object, or an array of them) into a CSS-ready box-shadow
135
+ * value. Not relying on Style Dictionary's own built-in 'shadow/css/shorthand' — verified its
136
+ * color output ('rgb(0% 0% 0% / 0.25)', colorjs.io's default) doesn't match this codebase's
137
+ * '#hex'/'rgba(...)' convention. See docs/plans/shadow-token-type-plan.md.
138
+ */
139
+ /**
140
+ * Transform dimension tokens for JS consumption: px stays a bare number (e.g. 769, not "769px")
141
+ * so it's directly usable in JS logic (media-query math, comparisons); rem stays a string, since
142
+ * it's only meaningful as a CSS value. Runs after the 'js' transformGroup's built-in 'size/rem',
143
+ * which has already turned the {value, unit} object into a "769px"/"1rem" string.
144
+ */
145
+ sd.registerTransform({
146
+ type: `value`,
147
+ transitive: true,
148
+ name: `ds/dimension/js`,
149
+ filter: token => token.$type === 'dimension',
150
+ transform: token => {
151
+ const value = token.$value ?? token.value;
152
+ if (typeof value === 'string' && value.endsWith('px')) {
153
+ return Number(value.slice(0, -2));
154
+ }
155
+ return value;
156
+ },
157
+ });
158
+ sd.registerTransform({
159
+ type: `value`,
160
+ transitive: true,
161
+ name: `ds/shadow`,
162
+ filter: token => token.$type === 'shadow',
163
+ transform: token => shadowValueToCss(token.$value ?? token.value, token.path),
164
+ });
165
+ /**
166
+ * Transform border tokens ({color, width, style}) into a CSS-ready border shorthand value. Not
167
+ * relying on Style Dictionary's own built-in 'border/css/shorthand' — verified it renders each
168
+ * sub-value as a `var(--ds-*)` reference to its sibling custom property instead of a resolved
169
+ * literal, diverging from this codebase's convention. See docs/plans/border-token-type-plan.md.
170
+ */
171
+ sd.registerTransform({
172
+ type: `value`,
173
+ transitive: true,
174
+ name: `ds/border`,
175
+ filter: token => token.$type === 'border',
176
+ transform: token => borderValueToCss(token.$value ?? token.value),
177
+ });
178
+ /**
179
+ * Transform typography tokens ({fontFamily, fontSize, fontWeight, lineHeight}) into their 4
180
+ * CSS-ready sub-strings. Unlike every transform above, this doesn't produce the token's final
181
+ * `.value` directly usable by Style Dictionary's stock `css`/`variables` formatter — a typography
182
+ * token maps to 4 separate custom properties, not 1 (docs/plans/typography-token-type-plan.md
183
+ * decision 5). The `ds/css/variables-*` formatters (`formatter.ts`) expand each
184
+ * `$type: "typography"` token's `{fontFamily, fontSize, fontWeight, lineHeight}` value (the
185
+ * object this transform produces) into 4 token entries before handing off to
186
+ * `formattedVariables` — this transform's only job is getting each sub-value from "maybe still a
187
+ * reference / raw DTCG shape" to "final CSS string" first, same as ds/shadow/ds/border.
188
+ */
189
+ sd.registerTransform({
190
+ type: `value`,
191
+ transitive: true,
192
+ name: `ds/typography`,
193
+ filter: token => token.$type === 'typography',
194
+ transform: token => typographyValueToCss(token.$value ?? token.value),
195
+ });
196
+ };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Do not edit directly, this file was auto-generated.
3
+ */
4
+
5
+ /* Global tokens */
6
+ $ds-global-dimension-breakpoint-1: 769px;
7
+ $ds-global-dimension-breakpoint-2: 1024px;
8
+ $ds-global-dimension-breakpoint-3: 1280px;
9
+ $ds-global-dimension-breakpoint-4: 1440px;
10
+ $ds-global-dimension-breakpoint-5: 1920px;
11
+
12
+ /* Alias tokens */
13
+ $ds-alias-breakpoint-tablet: $ds-global-dimension-breakpoint-1;
14
+ $ds-alias-breakpoint-desktop: $ds-global-dimension-breakpoint-2;
15
+ $ds-alias-breakpoint-desktop-lg: $ds-global-dimension-breakpoint-3; // HighDefinition
16
+ $ds-alias-breakpoint-desktop-xl: $ds-global-dimension-breakpoint-4; // Widescreen
17
+ $ds-alias-breakpoint-desktop-2xl: $ds-global-dimension-breakpoint-5; // FullHD