@digdir/designsystemet 1.3.0 → 1.5.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/configs/digdir.config.json +4 -0
- package/dist/bin/designsystemet.js +488 -166
- package/dist/global-Y35YADVH.json +100 -0
- package/dist/src/index.js +527 -203
- package/dist/src/scripts/update-preview-tokens.js +478 -128
- package/dist/src/tokens/build.js +429 -111
- package/dist/src/tokens/create/defaults.js +27 -23
- package/dist/src/tokens/create/generators/$designsystemet.js +6 -6
- package/dist/src/tokens/create/write.js +6 -6
- package/dist/src/tokens/create.js +27 -23
- package/dist/src/tokens/format.js +527 -203
- package/dist/src/tokens/index.js +527 -203
- package/dist/src/tokens/process/configs/color.js +366 -66
- package/dist/src/tokens/process/configs/semantic.d.ts.map +1 -1
- package/dist/src/tokens/process/configs/semantic.js +368 -68
- package/dist/src/tokens/process/configs/shared.js +9 -2
- package/dist/src/tokens/process/configs/size-mode.d.ts +3 -0
- package/dist/src/tokens/process/configs/size-mode.d.ts.map +1 -0
- package/dist/src/tokens/process/configs/size-mode.js +1067 -0
- package/dist/src/tokens/process/configs/size.d.ts +3 -0
- package/dist/src/tokens/process/configs/size.d.ts.map +1 -0
- package/dist/src/tokens/process/configs/size.js +1069 -0
- package/dist/src/tokens/process/configs/type-scale.d.ts +3 -0
- package/dist/src/tokens/process/configs/type-scale.d.ts.map +1 -0
- package/dist/src/tokens/process/configs/type-scale.js +1067 -0
- package/dist/src/tokens/process/configs/typography.d.ts.map +1 -1
- package/dist/src/tokens/process/configs/typography.js +364 -64
- package/dist/src/tokens/process/configs.d.ts +3 -0
- package/dist/src/tokens/process/configs.d.ts.map +1 -1
- package/dist/src/tokens/process/configs.js +373 -71
- package/dist/src/tokens/process/formats/css/color.js +381 -79
- package/dist/src/tokens/process/formats/css/semantic.d.ts +0 -14
- package/dist/src/tokens/process/formats/css/semantic.d.ts.map +1 -1
- package/dist/src/tokens/process/formats/css/semantic.js +407 -109
- package/dist/src/tokens/process/formats/css/size-mode.d.ts +4 -0
- package/dist/src/tokens/process/formats/css/size-mode.d.ts.map +1 -0
- package/dist/src/tokens/process/formats/css/size-mode.js +1068 -0
- package/dist/src/tokens/process/formats/css/size.d.ts +17 -0
- package/dist/src/tokens/process/formats/css/size.d.ts.map +1 -0
- package/dist/src/tokens/process/formats/css/size.js +1069 -0
- package/dist/src/tokens/process/formats/css/type-scale.d.ts +3 -0
- package/dist/src/tokens/process/formats/css/type-scale.d.ts.map +1 -0
- package/dist/src/tokens/process/formats/css/type-scale.js +1069 -0
- package/dist/src/tokens/process/formats/css/typography.js +365 -63
- package/dist/src/tokens/process/formats/css.d.ts +3 -0
- package/dist/src/tokens/process/formats/css.d.ts.map +1 -1
- package/dist/src/tokens/process/formats/css.js +364 -64
- package/dist/src/tokens/process/output/declarations.js +376 -74
- package/dist/src/tokens/process/output/theme.d.ts.map +1 -1
- package/dist/src/tokens/process/output/theme.js +63 -14
- package/dist/src/tokens/process/platform.d.ts +16 -0
- package/dist/src/tokens/process/platform.d.ts.map +1 -1
- package/dist/src/tokens/process/platform.js +402 -95
- package/dist/src/tokens/process/transformers.js +9 -2
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +373 -71
- package/dist/src/tokens/template/design-tokens/primitives/modes/size/global.js +1 -1
- package/dist/src/tokens/utils.d.ts +4 -1
- package/dist/src/tokens/utils.d.ts.map +1 -1
- package/dist/src/tokens/utils.js +24 -1
- package/package.json +6 -6
- package/dist/global-XVXVBKM6.json +0 -96
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/tokens/process/formats/css/color.ts
|
|
2
|
-
import * as
|
|
3
|
-
import { createPropertyFormatter as
|
|
2
|
+
import * as R15 from "ramda";
|
|
3
|
+
import { createPropertyFormatter as createPropertyFormatter6 } from "style-dictionary/utils";
|
|
4
4
|
|
|
5
5
|
// src/tokens/types.ts
|
|
6
6
|
var colorCategories = {
|
|
@@ -28,7 +28,10 @@ var pathStartsWithOneOf = R.curry(
|
|
|
28
28
|
return false;
|
|
29
29
|
}
|
|
30
30
|
const tokenPath = mapToLowerCase(token.path);
|
|
31
|
-
const matchPathsStartingWith = R.map((
|
|
31
|
+
const matchPathsStartingWith = R.map((pathOrString) => {
|
|
32
|
+
const path = typeof pathOrString === "string" ? [pathOrString] : pathOrString;
|
|
33
|
+
return R.startsWith(mapToLowerCase(path), tokenPath);
|
|
34
|
+
}, paths);
|
|
32
35
|
return hasAnyTruth(matchPathsStartingWith);
|
|
33
36
|
}
|
|
34
37
|
);
|
|
@@ -64,21 +67,42 @@ function inlineTokens(shouldInline, tokens) {
|
|
|
64
67
|
return tokenWithInlinedRefs;
|
|
65
68
|
});
|
|
66
69
|
}
|
|
70
|
+
var sizeMap = {
|
|
71
|
+
xsmall: "xs",
|
|
72
|
+
small: "sm",
|
|
73
|
+
medium: "md",
|
|
74
|
+
large: "lg",
|
|
75
|
+
xlarge: "xl"
|
|
76
|
+
};
|
|
77
|
+
function shortSizeName(size2) {
|
|
78
|
+
return sizeMap[size2] ?? size2;
|
|
79
|
+
}
|
|
80
|
+
var sizeComparator = (size2) => {
|
|
81
|
+
const sortIndex = Object.entries(sizeMap).findIndex(([key, val]) => key === size2 || val === size2);
|
|
82
|
+
return sortIndex ?? 0;
|
|
83
|
+
};
|
|
84
|
+
function orderBySize(sizes) {
|
|
85
|
+
return R.sortBy(sizeComparator, sizes);
|
|
86
|
+
}
|
|
67
87
|
|
|
68
88
|
// src/tokens/process/platform.ts
|
|
69
89
|
import pc2 from "picocolors";
|
|
70
|
-
import * as
|
|
90
|
+
import * as R14 from "ramda";
|
|
71
91
|
import StyleDictionary2 from "style-dictionary";
|
|
72
92
|
|
|
73
93
|
// src/tokens/process/configs.ts
|
|
74
94
|
import { register } from "@tokens-studio/sd-transforms";
|
|
75
|
-
import * as
|
|
95
|
+
import * as R13 from "ramda";
|
|
76
96
|
import StyleDictionary from "style-dictionary";
|
|
77
97
|
|
|
78
98
|
// src/tokens/process/configs/color.ts
|
|
79
|
-
import * as
|
|
99
|
+
import * as R8 from "ramda";
|
|
80
100
|
|
|
81
101
|
// src/tokens/process/formats/css/semantic.ts
|
|
102
|
+
import * as R3 from "ramda";
|
|
103
|
+
import { createPropertyFormatter as createPropertyFormatter2 } from "style-dictionary/utils";
|
|
104
|
+
|
|
105
|
+
// src/tokens/process/formats/css/size.ts
|
|
82
106
|
import * as R2 from "ramda";
|
|
83
107
|
import { createPropertyFormatter } from "style-dictionary/utils";
|
|
84
108
|
var isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
|
|
@@ -86,12 +110,20 @@ var isNumericSizeToken = (t) => pathStartsWithOneOf(["size"], t) && isDigit(t.pa
|
|
|
86
110
|
var isSizeToken = (t) => pathStartsWithOneOf(["size"], t);
|
|
87
111
|
var isInlineTokens = R2.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
|
|
88
112
|
var overrideSizingFormula = (format, token) => {
|
|
89
|
-
const [name, value] = format(token).split(":");
|
|
90
|
-
|
|
91
|
-
|
|
113
|
+
const [name, value] = format(token).replace(/;$/, "").split(": ");
|
|
114
|
+
let calc;
|
|
115
|
+
let round;
|
|
116
|
+
if (token.path[1] === "unit") {
|
|
117
|
+
calc = `calc(1rem * ${value})`;
|
|
118
|
+
} else if (value.startsWith("floor")) {
|
|
119
|
+
calc = value.replace(/^floor\((.*)\)$/, "calc($1)");
|
|
120
|
+
round = `round(down, ${calc}, 1px)`;
|
|
121
|
+
} else {
|
|
122
|
+
calc = value.includes("*") ? `calc(${value})` : value;
|
|
123
|
+
}
|
|
92
124
|
return {
|
|
93
125
|
name,
|
|
94
|
-
round,
|
|
126
|
+
round: round ?? calc,
|
|
95
127
|
calc
|
|
96
128
|
};
|
|
97
129
|
};
|
|
@@ -107,18 +139,21 @@ var formatSizingTokens = (format, tokens) => R2.reduce(
|
|
|
107
139
|
{ tokens: [], round: [], calc: [] },
|
|
108
140
|
tokens
|
|
109
141
|
);
|
|
110
|
-
var sizingTemplate = ({ round, calc }) =>
|
|
142
|
+
var sizingTemplate = ({ round, calc }) => {
|
|
143
|
+
const usesRounding = round.filter((val, i) => val !== calc[i]);
|
|
144
|
+
return `
|
|
111
145
|
${calc.join("\n")}
|
|
112
146
|
|
|
113
147
|
@supports (width: round(down, .1em, 1px)) {
|
|
114
|
-
${
|
|
148
|
+
${usesRounding.join("\n ")}
|
|
115
149
|
}`;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
150
|
+
};
|
|
151
|
+
var size = {
|
|
152
|
+
name: "ds/css-size",
|
|
153
|
+
format: async ({ dictionary, file, options, platform }) => {
|
|
119
154
|
const { outputReferences, usesDtcg } = options;
|
|
120
|
-
const { selector, layer
|
|
121
|
-
const destination =
|
|
155
|
+
const { selector, layer } = platform;
|
|
156
|
+
const destination = file.destination;
|
|
122
157
|
const format = createPropertyFormatter({
|
|
123
158
|
outputReferences,
|
|
124
159
|
dictionary,
|
|
@@ -126,9 +161,9 @@ var semantic = {
|
|
|
126
161
|
usesDtcg
|
|
127
162
|
});
|
|
128
163
|
const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
|
|
129
|
-
const filteredTokens = R2.reject((token) =>
|
|
164
|
+
const filteredTokens = R2.reject((token) => R2.equals(["_size", "mode-font-size"], token.path), tokens);
|
|
130
165
|
const [sizingTokens, restTokens] = R2.partition(
|
|
131
|
-
(t) => pathStartsWithOneOf(["_size"], t) && isDigit(t.path[1]),
|
|
166
|
+
(t) => pathStartsWithOneOf(["_size"], t) && (isDigit(t.path[1]) || t.path[1] === "unit"),
|
|
132
167
|
filteredTokens
|
|
133
168
|
);
|
|
134
169
|
const formattedSizingTokens = formatSizingTokens(format, sizingTokens);
|
|
@@ -141,64 +176,56 @@ var semantic = {
|
|
|
141
176
|
formatted: t
|
|
142
177
|
}));
|
|
143
178
|
buildOptions.buildTokenFormats[destination] = [...formattedMap, ...formattedSizingMap];
|
|
144
|
-
const
|
|
145
|
-
const
|
|
146
|
-
const content = `{
|
|
179
|
+
const formattedTokens = [formattedMap.map(R2.prop("formatted")).join("\n"), sizingTemplate(formattedSizingTokens)];
|
|
180
|
+
const content = `${selector} {
|
|
147
181
|
${formattedTokens.join("\n")}
|
|
148
182
|
}
|
|
149
183
|
`;
|
|
150
184
|
const body = R2.isNotNil(layer) ? `@layer ${layer} {
|
|
151
|
-
${
|
|
185
|
+
${content}
|
|
152
186
|
}
|
|
153
|
-
` : `${
|
|
187
|
+
` : `${content}
|
|
154
188
|
`;
|
|
155
189
|
return body;
|
|
156
190
|
}
|
|
157
191
|
};
|
|
158
192
|
|
|
159
|
-
// src/tokens/process/formats/css/
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
R3.pathSatisfies(R3.includes("typography"), ["path"]),
|
|
164
|
-
R3.pathSatisfies(R3.includes("fontFamily"), ["path"])
|
|
165
|
-
]);
|
|
166
|
-
var typography = {
|
|
167
|
-
name: "ds/css-typography",
|
|
168
|
-
format: async ({ dictionary, options, platform }) => {
|
|
193
|
+
// src/tokens/process/formats/css/semantic.ts
|
|
194
|
+
var semantic = {
|
|
195
|
+
name: "ds/css-semantic",
|
|
196
|
+
format: async ({ dictionary, file, options, platform }) => {
|
|
169
197
|
const { outputReferences, usesDtcg } = options;
|
|
170
|
-
const { selector, layer
|
|
171
|
-
const destination =
|
|
198
|
+
const { selector, layer } = platform;
|
|
199
|
+
const destination = file.destination;
|
|
172
200
|
const format = createPropertyFormatter2({
|
|
173
201
|
outputReferences,
|
|
174
202
|
dictionary,
|
|
175
203
|
format: "css",
|
|
176
204
|
usesDtcg
|
|
177
205
|
});
|
|
178
|
-
const
|
|
179
|
-
const formattedMap =
|
|
206
|
+
const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
|
|
207
|
+
const formattedMap = tokens.map((token) => ({
|
|
180
208
|
token,
|
|
181
209
|
formatted: format(token)
|
|
182
210
|
}));
|
|
183
211
|
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
184
|
-
const formattedTokens = formattedMap.map(R3.
|
|
185
|
-
const content =
|
|
212
|
+
const formattedTokens = formattedMap.map(R3.prop("formatted")).join("\n");
|
|
213
|
+
const content = `${selector} {
|
|
186
214
|
${formattedTokens}
|
|
187
|
-
}
|
|
215
|
+
}
|
|
216
|
+
`;
|
|
188
217
|
const body = R3.isNotNil(layer) ? `@layer ${layer} {
|
|
189
218
|
${content}
|
|
190
|
-
}
|
|
219
|
+
}
|
|
220
|
+
` : `${content}
|
|
221
|
+
`;
|
|
191
222
|
return body;
|
|
192
223
|
}
|
|
193
224
|
};
|
|
194
225
|
|
|
195
|
-
// src/tokens/process/formats/css.ts
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
colorCategory,
|
|
199
|
-
semantic,
|
|
200
|
-
typography
|
|
201
|
-
};
|
|
226
|
+
// src/tokens/process/formats/css/size-mode.ts
|
|
227
|
+
import * as R5 from "ramda";
|
|
228
|
+
import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
|
|
202
229
|
|
|
203
230
|
// src/tokens/process/transformers.ts
|
|
204
231
|
import { checkAndEvaluateMath } from "@tokens-studio/sd-transforms";
|
|
@@ -210,18 +237,22 @@ var sizeRem = {
|
|
|
210
237
|
transitive: true,
|
|
211
238
|
filter: (token) => {
|
|
212
239
|
const hasWantedType = typeEquals(["dimension", "fontsize"], token);
|
|
213
|
-
const hasWantedPath = pathStartsWithOneOf([
|
|
240
|
+
const hasWantedPath = pathStartsWithOneOf([
|
|
241
|
+
"border-radius",
|
|
242
|
+
"font-size"
|
|
243
|
+
/*, ['_size', 'mode-font-size']*/
|
|
244
|
+
], token);
|
|
214
245
|
return hasWantedType && hasWantedPath;
|
|
215
246
|
},
|
|
216
247
|
transform: (token, config) => {
|
|
217
248
|
const value = getValue(token);
|
|
218
249
|
if (isPx(value)) {
|
|
219
250
|
const baseFont = config.basePxFontSize || 16;
|
|
220
|
-
const
|
|
221
|
-
if (
|
|
251
|
+
const size2 = parseInt(value, 10);
|
|
252
|
+
if (size2 === 0) {
|
|
222
253
|
return "0";
|
|
223
254
|
}
|
|
224
|
-
return `${
|
|
255
|
+
return `${size2 / baseFont}rem`;
|
|
225
256
|
}
|
|
226
257
|
return value;
|
|
227
258
|
}
|
|
@@ -272,6 +303,154 @@ var dsTransformers = [
|
|
|
272
303
|
"shadow/css/shorthand"
|
|
273
304
|
];
|
|
274
305
|
|
|
306
|
+
// src/tokens/process/formats/css/size-mode.ts
|
|
307
|
+
var formatBaseSizeToken = (size2) => (token) => ({
|
|
308
|
+
...token,
|
|
309
|
+
originalName: token.name,
|
|
310
|
+
name: `${token.name}--${shortSizeName(size2)}`,
|
|
311
|
+
$value: token.$value / basePxFontSize
|
|
312
|
+
});
|
|
313
|
+
var sizeMode = {
|
|
314
|
+
name: "ds/css-size-mode",
|
|
315
|
+
format: async ({ dictionary, file, options, platform }) => {
|
|
316
|
+
const { outputReferences, usesDtcg } = options;
|
|
317
|
+
const { selector, layer, size: size2 } = platform;
|
|
318
|
+
const destination = file.destination;
|
|
319
|
+
const format = createPropertyFormatter3({
|
|
320
|
+
outputReferences,
|
|
321
|
+
dictionary,
|
|
322
|
+
format: "css",
|
|
323
|
+
usesDtcg
|
|
324
|
+
});
|
|
325
|
+
const sizeSpecificTokens = dictionary.allTokens.map(formatBaseSizeToken(size2));
|
|
326
|
+
const sizeSpecificVariables = sizeSpecificTokens.map(format).join("\n");
|
|
327
|
+
const formattedMap = sizeSpecificTokens.map((token) => ({
|
|
328
|
+
token,
|
|
329
|
+
formatted: format({
|
|
330
|
+
...token,
|
|
331
|
+
// Remove the `--<size>` suffix for the token listing, since that is the only token we actually use
|
|
332
|
+
name: token.originalName
|
|
333
|
+
})
|
|
334
|
+
}));
|
|
335
|
+
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
336
|
+
const content = `${selector} /* ${size2} */ {
|
|
337
|
+
${sizeSpecificVariables}
|
|
338
|
+
}`;
|
|
339
|
+
const body = wrapInLayer(content, layer);
|
|
340
|
+
const sizes = orderBySize(buildOptions?.sizeModes ?? []).map(shortSizeName);
|
|
341
|
+
const defaultSize = shortSizeName(buildOptions?.defaultSize ?? "");
|
|
342
|
+
const sizingToggles = `:root, [data-size] {
|
|
343
|
+
--ds-size: var(--ds-size--${defaultSize});
|
|
344
|
+
${sizes.map((size3) => ` --ds-size--${size3}: var(--ds-size,);`).join("\n")}
|
|
345
|
+
--ds-size-mode-font-size:
|
|
346
|
+
${sizes.map((size3) => ` var(--ds-size--${size3}, var(--ds-size-mode-font-size--${size3}))`).join("\n")};
|
|
347
|
+
}`;
|
|
348
|
+
const sizingHelpers = sizes.map((size3) => `[data-size='${size3}'] { --ds-size: var(--ds-size--${size3}); }`).join("\n");
|
|
349
|
+
const sharedContent = `${sizingToggles}
|
|
350
|
+
|
|
351
|
+
${sizingHelpers}`;
|
|
352
|
+
const sharedBody = shortSizeName(size2) === R5.last(sizes) ? `
|
|
353
|
+
${wrapInLayer(sharedContent, layer)}` : "";
|
|
354
|
+
return body + sharedBody;
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
function wrapInLayer(content, layer) {
|
|
358
|
+
return R5.isNotNil(layer) ? `@layer ${layer} {
|
|
359
|
+
${content}
|
|
360
|
+
}
|
|
361
|
+
` : `${content}
|
|
362
|
+
`;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// src/tokens/process/formats/css/typography.ts
|
|
366
|
+
import * as R6 from "ramda";
|
|
367
|
+
import { createPropertyFormatter as createPropertyFormatter4 } from "style-dictionary/utils";
|
|
368
|
+
var typographyFontFamilyPredicate = R6.allPass([
|
|
369
|
+
R6.pathSatisfies(R6.includes("typography"), ["path"]),
|
|
370
|
+
R6.pathSatisfies(R6.includes("fontFamily"), ["path"])
|
|
371
|
+
]);
|
|
372
|
+
var typography = {
|
|
373
|
+
name: "ds/css-typography",
|
|
374
|
+
format: async ({ dictionary, file, options, platform }) => {
|
|
375
|
+
const { outputReferences, usesDtcg } = options;
|
|
376
|
+
const { selector, layer } = platform;
|
|
377
|
+
const destination = file.destination;
|
|
378
|
+
const format = createPropertyFormatter4({
|
|
379
|
+
outputReferences,
|
|
380
|
+
dictionary,
|
|
381
|
+
format: "css",
|
|
382
|
+
usesDtcg
|
|
383
|
+
});
|
|
384
|
+
const filteredTokens = R6.reject(typographyFontFamilyPredicate, dictionary.allTokens);
|
|
385
|
+
const formattedMap = filteredTokens.map((token) => ({
|
|
386
|
+
token,
|
|
387
|
+
formatted: format(token)
|
|
388
|
+
}));
|
|
389
|
+
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
390
|
+
const formattedTokens = formattedMap.map(R6.view(R6.lensProp("formatted"))).join("\n");
|
|
391
|
+
const content = selector ? `${selector} {
|
|
392
|
+
${formattedTokens}
|
|
393
|
+
}` : formattedTokens;
|
|
394
|
+
const body = R6.isNotNil(layer) ? `@layer ${layer} {
|
|
395
|
+
${content}
|
|
396
|
+
}` : content;
|
|
397
|
+
return body;
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
// src/tokens/process/formats/css/type-scale.ts
|
|
402
|
+
import * as R7 from "ramda";
|
|
403
|
+
import { createPropertyFormatter as createPropertyFormatter5 } from "style-dictionary/utils";
|
|
404
|
+
var typographyFontFamilyPredicate2 = R7.allPass([
|
|
405
|
+
R7.pathSatisfies(R7.includes("typography"), ["path"]),
|
|
406
|
+
R7.pathSatisfies(R7.includes("fontFamily"), ["path"])
|
|
407
|
+
]);
|
|
408
|
+
function formatTypographySizeToken(token) {
|
|
409
|
+
return { ...token, $value: `calc(${token.$value} * var(--_ds-font-size-factor))` };
|
|
410
|
+
}
|
|
411
|
+
var typeScale = {
|
|
412
|
+
name: "ds/css-type-scale",
|
|
413
|
+
format: async ({ dictionary, file, options, platform }) => {
|
|
414
|
+
const { outputReferences, usesDtcg } = options;
|
|
415
|
+
const { selector, layer } = platform;
|
|
416
|
+
const destination = file.destination;
|
|
417
|
+
const format = createPropertyFormatter5({
|
|
418
|
+
outputReferences,
|
|
419
|
+
dictionary,
|
|
420
|
+
format: "css",
|
|
421
|
+
usesDtcg
|
|
422
|
+
});
|
|
423
|
+
const filteredTokens = R7.reject(typographyFontFamilyPredicate2, dictionary.allTokens);
|
|
424
|
+
const tokens = R7.map(formatTypographySizeToken, filteredTokens);
|
|
425
|
+
const formattedMap = tokens.map((token) => ({
|
|
426
|
+
token,
|
|
427
|
+
formatted: format(token)
|
|
428
|
+
}));
|
|
429
|
+
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
430
|
+
const formattedTokens = formattedMap.map(R7.prop("formatted")).join("\n");
|
|
431
|
+
const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
|
|
432
|
+
const content = `${selector} {
|
|
433
|
+
${sizeFactor}
|
|
434
|
+
${formattedTokens}
|
|
435
|
+
}`;
|
|
436
|
+
const body = R7.isNotNil(layer) ? `@layer ${layer} {
|
|
437
|
+
${content}
|
|
438
|
+
}` : content;
|
|
439
|
+
return body;
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
// src/tokens/process/formats/css.ts
|
|
444
|
+
var formats = {
|
|
445
|
+
colorScheme,
|
|
446
|
+
colorCategory,
|
|
447
|
+
semantic,
|
|
448
|
+
sizeMode,
|
|
449
|
+
size,
|
|
450
|
+
typography,
|
|
451
|
+
typeScale
|
|
452
|
+
};
|
|
453
|
+
|
|
275
454
|
// src/tokens/process/configs/color.ts
|
|
276
455
|
var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) => {
|
|
277
456
|
const selector = `${colorScheme2 === "light" ? ":root, " : ""}[data-color-scheme="${colorScheme2}"]`;
|
|
@@ -293,7 +472,7 @@ var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) =
|
|
|
293
472
|
{
|
|
294
473
|
destination: `color-scheme/${colorScheme2}.css`,
|
|
295
474
|
format: formats.colorScheme.name,
|
|
296
|
-
filter: (token) => typeEquals("color", token) && !
|
|
475
|
+
filter: (token) => typeEquals("color", token) && !R8.startsWith(["global"], token.path)
|
|
297
476
|
}
|
|
298
477
|
],
|
|
299
478
|
options: {
|
|
@@ -344,7 +523,7 @@ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, .
|
|
|
344
523
|
};
|
|
345
524
|
|
|
346
525
|
// src/tokens/process/configs/semantic.ts
|
|
347
|
-
import * as
|
|
526
|
+
import * as R9 from "ramda";
|
|
348
527
|
import { outputReferencesFilter } from "style-dictionary/utils";
|
|
349
528
|
var semanticVariables = ({ theme }) => {
|
|
350
529
|
const selector = `:root`;
|
|
@@ -367,9 +546,12 @@ var semanticVariables = ({ theme }) => {
|
|
|
367
546
|
destination: `semantic.css`,
|
|
368
547
|
format: formats.semantic.name,
|
|
369
548
|
filter: (token) => {
|
|
370
|
-
const isUwantedToken =
|
|
371
|
-
const isPrivateToken =
|
|
372
|
-
const unwantedPaths = pathStartsWithOneOf(
|
|
549
|
+
const isUwantedToken = R9.anyPass([R9.includes("primitives/global")])(token.filePath);
|
|
550
|
+
const isPrivateToken = R9.includes("_", token.path);
|
|
551
|
+
const unwantedPaths = pathStartsWithOneOf(
|
|
552
|
+
["size", "_size", "font-size", "line-height", "letter-spacing"],
|
|
553
|
+
token
|
|
554
|
+
);
|
|
373
555
|
const unwantedTypes = typeEquals(["color", "fontWeight", "fontFamily", "typography"], token);
|
|
374
556
|
const unwantedTokens = !(unwantedPaths || unwantedTypes || isPrivateToken || isUwantedToken);
|
|
375
557
|
return unwantedTokens;
|
|
@@ -379,8 +561,7 @@ var semanticVariables = ({ theme }) => {
|
|
|
379
561
|
options: {
|
|
380
562
|
outputReferences: (token, options) => {
|
|
381
563
|
const include = pathStartsWithOneOf(["border-radius"], token);
|
|
382
|
-
|
|
383
|
-
return (include || isWantedSize) && outputReferencesFilter(token, options);
|
|
564
|
+
return include && outputReferencesFilter(token, options);
|
|
384
565
|
}
|
|
385
566
|
}
|
|
386
567
|
}
|
|
@@ -388,6 +569,124 @@ var semanticVariables = ({ theme }) => {
|
|
|
388
569
|
};
|
|
389
570
|
};
|
|
390
571
|
|
|
572
|
+
// src/tokens/process/configs/size.ts
|
|
573
|
+
import * as R10 from "ramda";
|
|
574
|
+
import { outputReferencesFilter as outputReferencesFilter2 } from "style-dictionary/utils";
|
|
575
|
+
var sizeVariables = ({ theme }) => {
|
|
576
|
+
const selector = `:root, [data-size]`;
|
|
577
|
+
const layer = `ds.theme.size`;
|
|
578
|
+
return {
|
|
579
|
+
preprocessors: ["tokens-studio"],
|
|
580
|
+
platforms: {
|
|
581
|
+
css: {
|
|
582
|
+
// custom
|
|
583
|
+
theme,
|
|
584
|
+
basePxFontSize,
|
|
585
|
+
selector,
|
|
586
|
+
layer,
|
|
587
|
+
//
|
|
588
|
+
prefix,
|
|
589
|
+
buildPath: `${theme}/`,
|
|
590
|
+
transforms: dsTransformers,
|
|
591
|
+
files: [
|
|
592
|
+
{
|
|
593
|
+
destination: `size.css`,
|
|
594
|
+
format: formats.size.name,
|
|
595
|
+
filter: (token) => {
|
|
596
|
+
const isUwantedToken = R10.anyPass([R10.includes("primitives/global")])(token.filePath);
|
|
597
|
+
const isPrivateToken = R10.includes("_", token.path);
|
|
598
|
+
return pathStartsWithOneOf(["size", "_size"], token) && !(isUwantedToken || isPrivateToken);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
],
|
|
602
|
+
options: {
|
|
603
|
+
outputReferences: (token, options) => {
|
|
604
|
+
const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && (isDigit(token.path[1]) || token.path[1] === "unit");
|
|
605
|
+
return isWantedSize && outputReferencesFilter2(token, options);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
};
|
|
612
|
+
|
|
613
|
+
// src/tokens/process/configs/size-mode.ts
|
|
614
|
+
import * as R11 from "ramda";
|
|
615
|
+
var sizeModeVariables = ({ theme, size: size2 }) => {
|
|
616
|
+
const selector = `:root`;
|
|
617
|
+
const layer = `ds.theme.size-mode`;
|
|
618
|
+
return {
|
|
619
|
+
preprocessors: ["tokens-studio"],
|
|
620
|
+
platforms: {
|
|
621
|
+
css: {
|
|
622
|
+
// custom
|
|
623
|
+
size: size2,
|
|
624
|
+
theme,
|
|
625
|
+
basePxFontSize,
|
|
626
|
+
selector,
|
|
627
|
+
layer,
|
|
628
|
+
//
|
|
629
|
+
prefix,
|
|
630
|
+
buildPath: `${theme}/`,
|
|
631
|
+
transforms: dsTransformers,
|
|
632
|
+
files: [
|
|
633
|
+
{
|
|
634
|
+
destination: `size-mode/${size2}.css`,
|
|
635
|
+
format: formats.sizeMode.name,
|
|
636
|
+
filter: (token) => {
|
|
637
|
+
return R11.equals(["_size", "mode-font-size"], token.path);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
]
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
};
|
|
644
|
+
};
|
|
645
|
+
|
|
646
|
+
// src/tokens/process/configs/type-scale.ts
|
|
647
|
+
var typeScaleVariables = ({ theme, size: size2 }) => {
|
|
648
|
+
const selector = ":root, [data-size]";
|
|
649
|
+
const layer = `ds.theme.type-scale`;
|
|
650
|
+
return {
|
|
651
|
+
usesDtcg: true,
|
|
652
|
+
preprocessors: ["tokens-studio"],
|
|
653
|
+
expand: {
|
|
654
|
+
include: ["typography"]
|
|
655
|
+
},
|
|
656
|
+
platforms: {
|
|
657
|
+
css: {
|
|
658
|
+
prefix,
|
|
659
|
+
selector,
|
|
660
|
+
layer,
|
|
661
|
+
buildPath: `${theme}/`,
|
|
662
|
+
basePxFontSize,
|
|
663
|
+
transforms: [
|
|
664
|
+
"name/kebab",
|
|
665
|
+
"ts/size/px",
|
|
666
|
+
sizeRem.name,
|
|
667
|
+
"ts/size/lineheight",
|
|
668
|
+
"ts/typography/fontWeight",
|
|
669
|
+
typographyName.name
|
|
670
|
+
],
|
|
671
|
+
files: [
|
|
672
|
+
{
|
|
673
|
+
destination: `type-scale.css`,
|
|
674
|
+
format: formats.typeScale.name,
|
|
675
|
+
filter: (token) => {
|
|
676
|
+
const included = typeEquals(["typography", "dimension", "fontsize"], token);
|
|
677
|
+
if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
|
|
678
|
+
return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "border-width", "border-radius"], token) && (pathStartsWithOneOf(["font-size"], token) || token.path.includes("fontSize"));
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
],
|
|
682
|
+
options: {
|
|
683
|
+
outputReferences: (token) => pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize")
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
};
|
|
688
|
+
};
|
|
689
|
+
|
|
391
690
|
// src/tokens/process/configs/typography.ts
|
|
392
691
|
import { expandTypesMap } from "@tokens-studio/sd-transforms";
|
|
393
692
|
var typographyVariables = ({ theme, typography: typography2 }) => {
|
|
@@ -422,12 +721,9 @@ var typographyVariables = ({ theme, typography: typography2 }) => {
|
|
|
422
721
|
destination: `typography/${typography2}.css`,
|
|
423
722
|
format: formats.typography.name,
|
|
424
723
|
filter: (token) => {
|
|
425
|
-
const included = typeEquals(
|
|
426
|
-
["typography", "fontweight", "fontFamily", "lineHeight", "dimension", "font", "fontsize"],
|
|
427
|
-
token
|
|
428
|
-
);
|
|
724
|
+
const included = typeEquals(["fontweight", "fontFamily", "lineHeight", "dimension"], token);
|
|
429
725
|
if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
|
|
430
|
-
return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "_size", "border-width", "border-radius"], token);
|
|
726
|
+
return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "_size", "border-width", "border-radius"], token) && !(pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize"));
|
|
431
727
|
}
|
|
432
728
|
}
|
|
433
729
|
]
|
|
@@ -602,9 +898,9 @@ var TypographyValues;
|
|
|
602
898
|
// src/tokens/process/utils/getMultidimensionalThemes.ts
|
|
603
899
|
import { kebabCase } from "change-case";
|
|
604
900
|
import pc from "picocolors";
|
|
605
|
-
import * as
|
|
901
|
+
import * as R12 from "ramda";
|
|
606
902
|
var processed = Symbol("Type brand for ProcessedThemeObject");
|
|
607
|
-
var hasUnknownProps =
|
|
903
|
+
var hasUnknownProps = R12.pipe(R12.values, R12.none(R12.equals("unknown")), R12.not);
|
|
608
904
|
|
|
609
905
|
// src/tokens/process/configs.ts
|
|
610
906
|
void register(StyleDictionary, { withSDBuiltins: false });
|
|
@@ -624,7 +920,10 @@ var configs = {
|
|
|
624
920
|
dangerColorVariables: colorCategoryVariables({ category: "builtin", color: "danger" }),
|
|
625
921
|
warningColorVariables: colorCategoryVariables({ category: "builtin", color: "warning" }),
|
|
626
922
|
infoColorVariables: colorCategoryVariables({ category: "builtin", color: "info" }),
|
|
923
|
+
sizeModeVariables,
|
|
924
|
+
sizeVariables,
|
|
627
925
|
typographyVariables,
|
|
926
|
+
typeScaleVariables,
|
|
628
927
|
semanticVariables
|
|
629
928
|
};
|
|
630
929
|
|
|
@@ -637,6 +936,9 @@ var buildOptions = {
|
|
|
637
936
|
var sd = new StyleDictionary2();
|
|
638
937
|
var buildConfigs = {
|
|
639
938
|
typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
|
|
939
|
+
sizeMode: { getConfig: configs.sizeModeVariables, dimensions: ["size"] },
|
|
940
|
+
size: { getConfig: configs.sizeVariables, dimensions: ["semantic"] },
|
|
941
|
+
typeScale: { getConfig: configs.typeScaleVariables, dimensions: ["semantic"] },
|
|
640
942
|
"color-scheme": { getConfig: configs.colorSchemeVariables, dimensions: ["color-scheme"] },
|
|
641
943
|
"main-color": { getConfig: configs.mainColorVariables, dimensions: ["main-color"] },
|
|
642
944
|
"support-color": { getConfig: configs.supportColorVariables, dimensions: ["support-color"] },
|
|
@@ -681,7 +983,7 @@ var colorScheme = {
|
|
|
681
983
|
const { outputReferences, usesDtcg } = options;
|
|
682
984
|
const { selector, colorScheme: colorScheme2, layer } = platform;
|
|
683
985
|
const colorScheme_ = colorScheme2;
|
|
684
|
-
const format =
|
|
986
|
+
const format = createPropertyFormatter6({
|
|
685
987
|
outputReferences,
|
|
686
988
|
dictionary,
|
|
687
989
|
format: "css",
|
|
@@ -691,8 +993,8 @@ var colorScheme = {
|
|
|
691
993
|
color-scheme: ${colorScheme_};
|
|
692
994
|
` : "";
|
|
693
995
|
const filteredAllTokens = allTokens.filter(
|
|
694
|
-
|
|
695
|
-
|
|
996
|
+
R15.allPass([
|
|
997
|
+
R15.anyPass([
|
|
696
998
|
// Include semantic tokens in the output
|
|
697
999
|
isSemanticToken,
|
|
698
1000
|
// Include global color tokens
|
|
@@ -706,13 +1008,13 @@ var colorScheme = {
|
|
|
706
1008
|
token,
|
|
707
1009
|
formatted: format(token)
|
|
708
1010
|
}));
|
|
709
|
-
const formattedTokens = formattedMap.map(
|
|
1011
|
+
const formattedTokens = formattedMap.map(R15.view(R15.lensProp("formatted"))).join("\n");
|
|
710
1012
|
const content = `{
|
|
711
1013
|
${formattedTokens}
|
|
712
1014
|
${colorSchemeProperty}}
|
|
713
1015
|
`;
|
|
714
1016
|
const autoSelectorContent = ["light", "dark"].includes(colorScheme_) ? prefersColorScheme(colorScheme_, content) : "";
|
|
715
|
-
const body =
|
|
1017
|
+
const body = R15.isNotNil(layer) ? `@layer ${layer} {
|
|
716
1018
|
${selector} ${content} ${autoSelectorContent}
|
|
717
1019
|
}
|
|
718
1020
|
` : `${selector} ${content} ${autoSelectorContent}
|
|
@@ -722,12 +1024,12 @@ ${selector} ${content} ${autoSelectorContent}
|
|
|
722
1024
|
};
|
|
723
1025
|
var colorCategory = {
|
|
724
1026
|
name: "ds/css-colorcategory",
|
|
725
|
-
format: async ({ dictionary, options, platform }) => {
|
|
1027
|
+
format: async ({ dictionary, file, options, platform }) => {
|
|
726
1028
|
const { outputReferences, usesDtcg } = options;
|
|
727
|
-
const { selector, layer
|
|
728
|
-
const destination =
|
|
729
|
-
const format =
|
|
730
|
-
|
|
1029
|
+
const { selector, layer } = platform;
|
|
1030
|
+
const destination = file.destination;
|
|
1031
|
+
const format = R15.compose(
|
|
1032
|
+
createPropertyFormatter6({
|
|
731
1033
|
outputReferences,
|
|
732
1034
|
dictionary,
|
|
733
1035
|
format: "css",
|
|
@@ -747,12 +1049,12 @@ var colorCategory = {
|
|
|
747
1049
|
formatted: format(token)
|
|
748
1050
|
}));
|
|
749
1051
|
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
750
|
-
const formattedTokens = formattedMap.map(
|
|
1052
|
+
const formattedTokens = formattedMap.map(R15.view(R15.lensProp("formatted"))).join("\n");
|
|
751
1053
|
const content = `{
|
|
752
1054
|
${formattedTokens}
|
|
753
1055
|
}
|
|
754
1056
|
`;
|
|
755
|
-
const body =
|
|
1057
|
+
const body = R15.isNotNil(layer) ? `@layer ${layer} {
|
|
756
1058
|
${selector} ${content}
|
|
757
1059
|
}
|
|
758
1060
|
` : `${selector} ${content}
|