@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typography.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/process/configs/typography.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkB,KAAK,wBAAwB,EAAU,MAAM,aAAa,CAAC;AAEpF,eAAO,MAAM,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"typography.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/process/configs/typography.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkB,KAAK,wBAAwB,EAAU,MAAM,aAAa,CAAC;AAEpF,eAAO,MAAM,mBAAmB,EAAE,wBAiDjC,CAAC"}
|
|
@@ -29,7 +29,10 @@ var pathStartsWithOneOf = R.curry(
|
|
|
29
29
|
return false;
|
|
30
30
|
}
|
|
31
31
|
const tokenPath = mapToLowerCase(token.path);
|
|
32
|
-
const matchPathsStartingWith = R.map((
|
|
32
|
+
const matchPathsStartingWith = R.map((pathOrString) => {
|
|
33
|
+
const path = typeof pathOrString === "string" ? [pathOrString] : pathOrString;
|
|
34
|
+
return R.startsWith(mapToLowerCase(path), tokenPath);
|
|
35
|
+
}, paths);
|
|
33
36
|
return hasAnyTruth(matchPathsStartingWith);
|
|
34
37
|
}
|
|
35
38
|
);
|
|
@@ -65,19 +68,36 @@ function inlineTokens(shouldInline, tokens) {
|
|
|
65
68
|
return tokenWithInlinedRefs;
|
|
66
69
|
});
|
|
67
70
|
}
|
|
71
|
+
var sizeMap = {
|
|
72
|
+
xsmall: "xs",
|
|
73
|
+
small: "sm",
|
|
74
|
+
medium: "md",
|
|
75
|
+
large: "lg",
|
|
76
|
+
xlarge: "xl"
|
|
77
|
+
};
|
|
78
|
+
function shortSizeName(size2) {
|
|
79
|
+
return sizeMap[size2] ?? size2;
|
|
80
|
+
}
|
|
81
|
+
var sizeComparator = (size2) => {
|
|
82
|
+
const sortIndex = Object.entries(sizeMap).findIndex(([key, val]) => key === size2 || val === size2);
|
|
83
|
+
return sortIndex ?? 0;
|
|
84
|
+
};
|
|
85
|
+
function orderBySize(sizes) {
|
|
86
|
+
return R.sortBy(sizeComparator, sizes);
|
|
87
|
+
}
|
|
68
88
|
|
|
69
89
|
// src/tokens/process/formats/css/color.ts
|
|
70
|
-
import * as
|
|
90
|
+
import * as R10 from "ramda";
|
|
71
91
|
import { createPropertyFormatter } from "style-dictionary/utils";
|
|
72
92
|
|
|
73
93
|
// src/tokens/process/platform.ts
|
|
74
94
|
import pc2 from "picocolors";
|
|
75
|
-
import * as
|
|
95
|
+
import * as R9 from "ramda";
|
|
76
96
|
import StyleDictionary2 from "style-dictionary";
|
|
77
97
|
|
|
78
98
|
// src/tokens/process/configs.ts
|
|
79
99
|
import { register } from "@tokens-studio/sd-transforms";
|
|
80
|
-
import * as
|
|
100
|
+
import * as R8 from "ramda";
|
|
81
101
|
import StyleDictionary from "style-dictionary";
|
|
82
102
|
|
|
83
103
|
// src/tokens/process/configs/color.ts
|
|
@@ -93,18 +113,22 @@ var sizeRem = {
|
|
|
93
113
|
transitive: true,
|
|
94
114
|
filter: (token) => {
|
|
95
115
|
const hasWantedType = typeEquals(["dimension", "fontsize"], token);
|
|
96
|
-
const hasWantedPath = pathStartsWithOneOf([
|
|
116
|
+
const hasWantedPath = pathStartsWithOneOf([
|
|
117
|
+
"border-radius",
|
|
118
|
+
"font-size"
|
|
119
|
+
/*, ['_size', 'mode-font-size']*/
|
|
120
|
+
], token);
|
|
97
121
|
return hasWantedType && hasWantedPath;
|
|
98
122
|
},
|
|
99
123
|
transform: (token, config) => {
|
|
100
124
|
const value = getValue(token);
|
|
101
125
|
if (isPx(value)) {
|
|
102
126
|
const baseFont = config.basePxFontSize || 16;
|
|
103
|
-
const
|
|
104
|
-
if (
|
|
127
|
+
const size2 = parseInt(value, 10);
|
|
128
|
+
if (size2 === 0) {
|
|
105
129
|
return "0";
|
|
106
130
|
}
|
|
107
|
-
return `${
|
|
131
|
+
return `${size2 / baseFont}rem`;
|
|
108
132
|
}
|
|
109
133
|
return value;
|
|
110
134
|
}
|
|
@@ -252,7 +276,10 @@ var semanticVariables = ({ theme }) => {
|
|
|
252
276
|
filter: (token) => {
|
|
253
277
|
const isUwantedToken = R4.anyPass([R4.includes("primitives/global")])(token.filePath);
|
|
254
278
|
const isPrivateToken = R4.includes("_", token.path);
|
|
255
|
-
const unwantedPaths = pathStartsWithOneOf(
|
|
279
|
+
const unwantedPaths = pathStartsWithOneOf(
|
|
280
|
+
["size", "_size", "font-size", "line-height", "letter-spacing"],
|
|
281
|
+
token
|
|
282
|
+
);
|
|
256
283
|
const unwantedTypes = typeEquals(["color", "fontWeight", "fontFamily", "typography"], token);
|
|
257
284
|
const unwantedTokens = !(unwantedPaths || unwantedTypes || isPrivateToken || isUwantedToken);
|
|
258
285
|
return unwantedTokens;
|
|
@@ -262,8 +289,48 @@ var semanticVariables = ({ theme }) => {
|
|
|
262
289
|
options: {
|
|
263
290
|
outputReferences: (token, options) => {
|
|
264
291
|
const include = pathStartsWithOneOf(["border-radius"], token);
|
|
265
|
-
|
|
266
|
-
|
|
292
|
+
return include && outputReferencesFilter(token, options);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
// src/tokens/process/configs/size.ts
|
|
301
|
+
import * as R5 from "ramda";
|
|
302
|
+
import { outputReferencesFilter as outputReferencesFilter2 } from "style-dictionary/utils";
|
|
303
|
+
var sizeVariables = ({ theme }) => {
|
|
304
|
+
const selector = `:root, [data-size]`;
|
|
305
|
+
const layer = `ds.theme.size`;
|
|
306
|
+
return {
|
|
307
|
+
preprocessors: ["tokens-studio"],
|
|
308
|
+
platforms: {
|
|
309
|
+
css: {
|
|
310
|
+
// custom
|
|
311
|
+
theme,
|
|
312
|
+
basePxFontSize,
|
|
313
|
+
selector,
|
|
314
|
+
layer,
|
|
315
|
+
//
|
|
316
|
+
prefix,
|
|
317
|
+
buildPath: `${theme}/`,
|
|
318
|
+
transforms: dsTransformers,
|
|
319
|
+
files: [
|
|
320
|
+
{
|
|
321
|
+
destination: `size.css`,
|
|
322
|
+
format: formats.size.name,
|
|
323
|
+
filter: (token) => {
|
|
324
|
+
const isUwantedToken = R5.anyPass([R5.includes("primitives/global")])(token.filePath);
|
|
325
|
+
const isPrivateToken = R5.includes("_", token.path);
|
|
326
|
+
return pathStartsWithOneOf(["size", "_size"], token) && !(isUwantedToken || isPrivateToken);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
],
|
|
330
|
+
options: {
|
|
331
|
+
outputReferences: (token, options) => {
|
|
332
|
+
const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && (isDigit(token.path[1]) || token.path[1] === "unit");
|
|
333
|
+
return isWantedSize && outputReferencesFilter2(token, options);
|
|
267
334
|
}
|
|
268
335
|
}
|
|
269
336
|
}
|
|
@@ -271,6 +338,83 @@ var semanticVariables = ({ theme }) => {
|
|
|
271
338
|
};
|
|
272
339
|
};
|
|
273
340
|
|
|
341
|
+
// src/tokens/process/configs/size-mode.ts
|
|
342
|
+
import * as R6 from "ramda";
|
|
343
|
+
var sizeModeVariables = ({ theme, size: size2 }) => {
|
|
344
|
+
const selector = `:root`;
|
|
345
|
+
const layer = `ds.theme.size-mode`;
|
|
346
|
+
return {
|
|
347
|
+
preprocessors: ["tokens-studio"],
|
|
348
|
+
platforms: {
|
|
349
|
+
css: {
|
|
350
|
+
// custom
|
|
351
|
+
size: size2,
|
|
352
|
+
theme,
|
|
353
|
+
basePxFontSize,
|
|
354
|
+
selector,
|
|
355
|
+
layer,
|
|
356
|
+
//
|
|
357
|
+
prefix,
|
|
358
|
+
buildPath: `${theme}/`,
|
|
359
|
+
transforms: dsTransformers,
|
|
360
|
+
files: [
|
|
361
|
+
{
|
|
362
|
+
destination: `size-mode/${size2}.css`,
|
|
363
|
+
format: formats.sizeMode.name,
|
|
364
|
+
filter: (token) => {
|
|
365
|
+
return R6.equals(["_size", "mode-font-size"], token.path);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
]
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
// src/tokens/process/configs/type-scale.ts
|
|
375
|
+
var typeScaleVariables = ({ theme, size: size2 }) => {
|
|
376
|
+
const selector = ":root, [data-size]";
|
|
377
|
+
const layer = `ds.theme.type-scale`;
|
|
378
|
+
return {
|
|
379
|
+
usesDtcg: true,
|
|
380
|
+
preprocessors: ["tokens-studio"],
|
|
381
|
+
expand: {
|
|
382
|
+
include: ["typography"]
|
|
383
|
+
},
|
|
384
|
+
platforms: {
|
|
385
|
+
css: {
|
|
386
|
+
prefix,
|
|
387
|
+
selector,
|
|
388
|
+
layer,
|
|
389
|
+
buildPath: `${theme}/`,
|
|
390
|
+
basePxFontSize,
|
|
391
|
+
transforms: [
|
|
392
|
+
"name/kebab",
|
|
393
|
+
"ts/size/px",
|
|
394
|
+
sizeRem.name,
|
|
395
|
+
"ts/size/lineheight",
|
|
396
|
+
"ts/typography/fontWeight",
|
|
397
|
+
typographyName.name
|
|
398
|
+
],
|
|
399
|
+
files: [
|
|
400
|
+
{
|
|
401
|
+
destination: `type-scale.css`,
|
|
402
|
+
format: formats.typeScale.name,
|
|
403
|
+
filter: (token) => {
|
|
404
|
+
const included = typeEquals(["typography", "dimension", "fontsize"], token);
|
|
405
|
+
if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
|
|
406
|
+
return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "border-width", "border-radius"], token) && (pathStartsWithOneOf(["font-size"], token) || token.path.includes("fontSize"));
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
],
|
|
410
|
+
options: {
|
|
411
|
+
outputReferences: (token) => pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize")
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
};
|
|
417
|
+
|
|
274
418
|
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js
|
|
275
419
|
var BoxShadowTypes;
|
|
276
420
|
(function(BoxShadowTypes2) {
|
|
@@ -437,9 +581,9 @@ var TypographyValues;
|
|
|
437
581
|
// src/tokens/process/utils/getMultidimensionalThemes.ts
|
|
438
582
|
import { kebabCase } from "change-case";
|
|
439
583
|
import pc from "picocolors";
|
|
440
|
-
import * as
|
|
584
|
+
import * as R7 from "ramda";
|
|
441
585
|
var processed = Symbol("Type brand for ProcessedThemeObject");
|
|
442
|
-
var hasUnknownProps =
|
|
586
|
+
var hasUnknownProps = R7.pipe(R7.values, R7.none(R7.equals("unknown")), R7.not);
|
|
443
587
|
|
|
444
588
|
// src/tokens/process/configs.ts
|
|
445
589
|
void register(StyleDictionary, { withSDBuiltins: false });
|
|
@@ -459,7 +603,10 @@ var configs = {
|
|
|
459
603
|
dangerColorVariables: colorCategoryVariables({ category: "builtin", color: "danger" }),
|
|
460
604
|
warningColorVariables: colorCategoryVariables({ category: "builtin", color: "warning" }),
|
|
461
605
|
infoColorVariables: colorCategoryVariables({ category: "builtin", color: "info" }),
|
|
606
|
+
sizeModeVariables,
|
|
607
|
+
sizeVariables,
|
|
462
608
|
typographyVariables,
|
|
609
|
+
typeScaleVariables,
|
|
463
610
|
semanticVariables
|
|
464
611
|
};
|
|
465
612
|
|
|
@@ -472,6 +619,9 @@ var buildOptions = {
|
|
|
472
619
|
var sd = new StyleDictionary2();
|
|
473
620
|
var buildConfigs = {
|
|
474
621
|
typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
|
|
622
|
+
sizeMode: { getConfig: configs.sizeModeVariables, dimensions: ["size"] },
|
|
623
|
+
size: { getConfig: configs.sizeVariables, dimensions: ["semantic"] },
|
|
624
|
+
typeScale: { getConfig: configs.typeScaleVariables, dimensions: ["semantic"] },
|
|
475
625
|
"color-scheme": { getConfig: configs.colorSchemeVariables, dimensions: ["color-scheme"] },
|
|
476
626
|
"main-color": { getConfig: configs.mainColorVariables, dimensions: ["main-color"] },
|
|
477
627
|
"support-color": { getConfig: configs.supportColorVariables, dimensions: ["support-color"] },
|
|
@@ -526,8 +676,8 @@ var colorScheme = {
|
|
|
526
676
|
color-scheme: ${colorScheme_};
|
|
527
677
|
` : "";
|
|
528
678
|
const filteredAllTokens = allTokens.filter(
|
|
529
|
-
|
|
530
|
-
|
|
679
|
+
R10.allPass([
|
|
680
|
+
R10.anyPass([
|
|
531
681
|
// Include semantic tokens in the output
|
|
532
682
|
isSemanticToken,
|
|
533
683
|
// Include global color tokens
|
|
@@ -541,13 +691,13 @@ var colorScheme = {
|
|
|
541
691
|
token,
|
|
542
692
|
formatted: format(token)
|
|
543
693
|
}));
|
|
544
|
-
const formattedTokens = formattedMap.map(
|
|
694
|
+
const formattedTokens = formattedMap.map(R10.view(R10.lensProp("formatted"))).join("\n");
|
|
545
695
|
const content = `{
|
|
546
696
|
${formattedTokens}
|
|
547
697
|
${colorSchemeProperty}}
|
|
548
698
|
`;
|
|
549
699
|
const autoSelectorContent = ["light", "dark"].includes(colorScheme_) ? prefersColorScheme(colorScheme_, content) : "";
|
|
550
|
-
const body =
|
|
700
|
+
const body = R10.isNotNil(layer) ? `@layer ${layer} {
|
|
551
701
|
${selector} ${content} ${autoSelectorContent}
|
|
552
702
|
}
|
|
553
703
|
` : `${selector} ${content} ${autoSelectorContent}
|
|
@@ -557,11 +707,11 @@ ${selector} ${content} ${autoSelectorContent}
|
|
|
557
707
|
};
|
|
558
708
|
var colorCategory = {
|
|
559
709
|
name: "ds/css-colorcategory",
|
|
560
|
-
format: async ({ dictionary, options, platform }) => {
|
|
710
|
+
format: async ({ dictionary, file, options, platform }) => {
|
|
561
711
|
const { outputReferences, usesDtcg } = options;
|
|
562
|
-
const { selector, layer
|
|
563
|
-
const destination =
|
|
564
|
-
const format =
|
|
712
|
+
const { selector, layer } = platform;
|
|
713
|
+
const destination = file.destination;
|
|
714
|
+
const format = R10.compose(
|
|
565
715
|
createPropertyFormatter({
|
|
566
716
|
outputReferences,
|
|
567
717
|
dictionary,
|
|
@@ -582,12 +732,12 @@ var colorCategory = {
|
|
|
582
732
|
formatted: format(token)
|
|
583
733
|
}));
|
|
584
734
|
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
585
|
-
const formattedTokens = formattedMap.map(
|
|
735
|
+
const formattedTokens = formattedMap.map(R10.view(R10.lensProp("formatted"))).join("\n");
|
|
586
736
|
const content = `{
|
|
587
737
|
${formattedTokens}
|
|
588
738
|
}
|
|
589
739
|
`;
|
|
590
|
-
const body =
|
|
740
|
+
const body = R10.isNotNil(layer) ? `@layer ${layer} {
|
|
591
741
|
${selector} ${content}
|
|
592
742
|
}
|
|
593
743
|
` : `${selector} ${content}
|
|
@@ -597,23 +747,35 @@ ${selector} ${content}
|
|
|
597
747
|
};
|
|
598
748
|
|
|
599
749
|
// src/tokens/process/formats/css/semantic.ts
|
|
600
|
-
import * as
|
|
750
|
+
import * as R12 from "ramda";
|
|
751
|
+
import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
|
|
752
|
+
|
|
753
|
+
// src/tokens/process/formats/css/size.ts
|
|
754
|
+
import * as R11 from "ramda";
|
|
601
755
|
import { createPropertyFormatter as createPropertyFormatter2 } from "style-dictionary/utils";
|
|
602
756
|
var isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
|
|
603
757
|
var isNumericSizeToken = (t) => pathStartsWithOneOf(["size"], t) && isDigit(t.path[1]);
|
|
604
758
|
var isSizeToken = (t) => pathStartsWithOneOf(["size"], t);
|
|
605
|
-
var isInlineTokens =
|
|
759
|
+
var isInlineTokens = R11.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
|
|
606
760
|
var overrideSizingFormula = (format, token) => {
|
|
607
|
-
const [name, value] = format(token).split(":");
|
|
608
|
-
|
|
609
|
-
|
|
761
|
+
const [name, value] = format(token).replace(/;$/, "").split(": ");
|
|
762
|
+
let calc;
|
|
763
|
+
let round;
|
|
764
|
+
if (token.path[1] === "unit") {
|
|
765
|
+
calc = `calc(1rem * ${value})`;
|
|
766
|
+
} else if (value.startsWith("floor")) {
|
|
767
|
+
calc = value.replace(/^floor\((.*)\)$/, "calc($1)");
|
|
768
|
+
round = `round(down, ${calc}, 1px)`;
|
|
769
|
+
} else {
|
|
770
|
+
calc = value.includes("*") ? `calc(${value})` : value;
|
|
771
|
+
}
|
|
610
772
|
return {
|
|
611
773
|
name,
|
|
612
|
-
round,
|
|
774
|
+
round: round ?? calc,
|
|
613
775
|
calc
|
|
614
776
|
};
|
|
615
777
|
};
|
|
616
|
-
var formatSizingTokens = (format, tokens) =>
|
|
778
|
+
var formatSizingTokens = (format, tokens) => R11.reduce(
|
|
617
779
|
(acc, token) => {
|
|
618
780
|
const { round, calc, name } = overrideSizingFormula(format, token);
|
|
619
781
|
return {
|
|
@@ -625,18 +787,21 @@ var formatSizingTokens = (format, tokens) => R9.reduce(
|
|
|
625
787
|
{ tokens: [], round: [], calc: [] },
|
|
626
788
|
tokens
|
|
627
789
|
);
|
|
628
|
-
var sizingTemplate = ({ round, calc }) =>
|
|
790
|
+
var sizingTemplate = ({ round, calc }) => {
|
|
791
|
+
const usesRounding = round.filter((val, i) => val !== calc[i]);
|
|
792
|
+
return `
|
|
629
793
|
${calc.join("\n")}
|
|
630
794
|
|
|
631
795
|
@supports (width: round(down, .1em, 1px)) {
|
|
632
|
-
${
|
|
796
|
+
${usesRounding.join("\n ")}
|
|
633
797
|
}`;
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
798
|
+
};
|
|
799
|
+
var size = {
|
|
800
|
+
name: "ds/css-size",
|
|
801
|
+
format: async ({ dictionary, file, options, platform }) => {
|
|
637
802
|
const { outputReferences, usesDtcg } = options;
|
|
638
|
-
const { selector, layer
|
|
639
|
-
const destination =
|
|
803
|
+
const { selector, layer } = platform;
|
|
804
|
+
const destination = file.destination;
|
|
640
805
|
const format = createPropertyFormatter2({
|
|
641
806
|
outputReferences,
|
|
642
807
|
dictionary,
|
|
@@ -644,9 +809,9 @@ var semantic = {
|
|
|
644
809
|
usesDtcg
|
|
645
810
|
});
|
|
646
811
|
const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
|
|
647
|
-
const filteredTokens =
|
|
648
|
-
const [sizingTokens, restTokens] =
|
|
649
|
-
(t) => pathStartsWithOneOf(["_size"], t) && isDigit(t.path[1]),
|
|
812
|
+
const filteredTokens = R11.reject((token) => R11.equals(["_size", "mode-font-size"], token.path), tokens);
|
|
813
|
+
const [sizingTokens, restTokens] = R11.partition(
|
|
814
|
+
(t) => pathStartsWithOneOf(["_size"], t) && (isDigit(t.path[1]) || t.path[1] === "unit"),
|
|
650
815
|
filteredTokens
|
|
651
816
|
);
|
|
652
817
|
const formattedSizingTokens = formatSizingTokens(format, sizingTokens);
|
|
@@ -659,51 +824,186 @@ var semantic = {
|
|
|
659
824
|
formatted: t
|
|
660
825
|
}));
|
|
661
826
|
buildOptions.buildTokenFormats[destination] = [...formattedMap, ...formattedSizingMap];
|
|
662
|
-
const
|
|
663
|
-
const
|
|
664
|
-
const content = `{
|
|
827
|
+
const formattedTokens = [formattedMap.map(R11.prop("formatted")).join("\n"), sizingTemplate(formattedSizingTokens)];
|
|
828
|
+
const content = `${selector} {
|
|
665
829
|
${formattedTokens.join("\n")}
|
|
666
830
|
}
|
|
667
831
|
`;
|
|
668
|
-
const body =
|
|
669
|
-
${
|
|
832
|
+
const body = R11.isNotNil(layer) ? `@layer ${layer} {
|
|
833
|
+
${content}
|
|
670
834
|
}
|
|
671
|
-
` : `${
|
|
835
|
+
` : `${content}
|
|
672
836
|
`;
|
|
673
837
|
return body;
|
|
674
838
|
}
|
|
675
839
|
};
|
|
676
840
|
|
|
841
|
+
// src/tokens/process/formats/css/semantic.ts
|
|
842
|
+
var semantic = {
|
|
843
|
+
name: "ds/css-semantic",
|
|
844
|
+
format: async ({ dictionary, file, options, platform }) => {
|
|
845
|
+
const { outputReferences, usesDtcg } = options;
|
|
846
|
+
const { selector, layer } = platform;
|
|
847
|
+
const destination = file.destination;
|
|
848
|
+
const format = createPropertyFormatter3({
|
|
849
|
+
outputReferences,
|
|
850
|
+
dictionary,
|
|
851
|
+
format: "css",
|
|
852
|
+
usesDtcg
|
|
853
|
+
});
|
|
854
|
+
const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
|
|
855
|
+
const formattedMap = tokens.map((token) => ({
|
|
856
|
+
token,
|
|
857
|
+
formatted: format(token)
|
|
858
|
+
}));
|
|
859
|
+
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
860
|
+
const formattedTokens = formattedMap.map(R12.prop("formatted")).join("\n");
|
|
861
|
+
const content = `${selector} {
|
|
862
|
+
${formattedTokens}
|
|
863
|
+
}
|
|
864
|
+
`;
|
|
865
|
+
const body = R12.isNotNil(layer) ? `@layer ${layer} {
|
|
866
|
+
${content}
|
|
867
|
+
}
|
|
868
|
+
` : `${content}
|
|
869
|
+
`;
|
|
870
|
+
return body;
|
|
871
|
+
}
|
|
872
|
+
};
|
|
873
|
+
|
|
874
|
+
// src/tokens/process/formats/css/size-mode.ts
|
|
875
|
+
import * as R13 from "ramda";
|
|
876
|
+
import { createPropertyFormatter as createPropertyFormatter4 } from "style-dictionary/utils";
|
|
877
|
+
var formatBaseSizeToken = (size2) => (token) => ({
|
|
878
|
+
...token,
|
|
879
|
+
originalName: token.name,
|
|
880
|
+
name: `${token.name}--${shortSizeName(size2)}`,
|
|
881
|
+
$value: token.$value / basePxFontSize
|
|
882
|
+
});
|
|
883
|
+
var sizeMode = {
|
|
884
|
+
name: "ds/css-size-mode",
|
|
885
|
+
format: async ({ dictionary, file, options, platform }) => {
|
|
886
|
+
const { outputReferences, usesDtcg } = options;
|
|
887
|
+
const { selector, layer, size: size2 } = platform;
|
|
888
|
+
const destination = file.destination;
|
|
889
|
+
const format = createPropertyFormatter4({
|
|
890
|
+
outputReferences,
|
|
891
|
+
dictionary,
|
|
892
|
+
format: "css",
|
|
893
|
+
usesDtcg
|
|
894
|
+
});
|
|
895
|
+
const sizeSpecificTokens = dictionary.allTokens.map(formatBaseSizeToken(size2));
|
|
896
|
+
const sizeSpecificVariables = sizeSpecificTokens.map(format).join("\n");
|
|
897
|
+
const formattedMap = sizeSpecificTokens.map((token) => ({
|
|
898
|
+
token,
|
|
899
|
+
formatted: format({
|
|
900
|
+
...token,
|
|
901
|
+
// Remove the `--<size>` suffix for the token listing, since that is the only token we actually use
|
|
902
|
+
name: token.originalName
|
|
903
|
+
})
|
|
904
|
+
}));
|
|
905
|
+
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
906
|
+
const content = `${selector} /* ${size2} */ {
|
|
907
|
+
${sizeSpecificVariables}
|
|
908
|
+
}`;
|
|
909
|
+
const body = wrapInLayer(content, layer);
|
|
910
|
+
const sizes = orderBySize(buildOptions?.sizeModes ?? []).map(shortSizeName);
|
|
911
|
+
const defaultSize = shortSizeName(buildOptions?.defaultSize ?? "");
|
|
912
|
+
const sizingToggles = `:root, [data-size] {
|
|
913
|
+
--ds-size: var(--ds-size--${defaultSize});
|
|
914
|
+
${sizes.map((size3) => ` --ds-size--${size3}: var(--ds-size,);`).join("\n")}
|
|
915
|
+
--ds-size-mode-font-size:
|
|
916
|
+
${sizes.map((size3) => ` var(--ds-size--${size3}, var(--ds-size-mode-font-size--${size3}))`).join("\n")};
|
|
917
|
+
}`;
|
|
918
|
+
const sizingHelpers = sizes.map((size3) => `[data-size='${size3}'] { --ds-size: var(--ds-size--${size3}); }`).join("\n");
|
|
919
|
+
const sharedContent = `${sizingToggles}
|
|
920
|
+
|
|
921
|
+
${sizingHelpers}`;
|
|
922
|
+
const sharedBody = shortSizeName(size2) === R13.last(sizes) ? `
|
|
923
|
+
${wrapInLayer(sharedContent, layer)}` : "";
|
|
924
|
+
return body + sharedBody;
|
|
925
|
+
}
|
|
926
|
+
};
|
|
927
|
+
function wrapInLayer(content, layer) {
|
|
928
|
+
return R13.isNotNil(layer) ? `@layer ${layer} {
|
|
929
|
+
${content}
|
|
930
|
+
}
|
|
931
|
+
` : `${content}
|
|
932
|
+
`;
|
|
933
|
+
}
|
|
934
|
+
|
|
677
935
|
// src/tokens/process/formats/css/typography.ts
|
|
678
|
-
import * as
|
|
679
|
-
import { createPropertyFormatter as
|
|
680
|
-
var typographyFontFamilyPredicate =
|
|
681
|
-
|
|
682
|
-
|
|
936
|
+
import * as R14 from "ramda";
|
|
937
|
+
import { createPropertyFormatter as createPropertyFormatter5 } from "style-dictionary/utils";
|
|
938
|
+
var typographyFontFamilyPredicate = R14.allPass([
|
|
939
|
+
R14.pathSatisfies(R14.includes("typography"), ["path"]),
|
|
940
|
+
R14.pathSatisfies(R14.includes("fontFamily"), ["path"])
|
|
683
941
|
]);
|
|
684
942
|
var typography = {
|
|
685
943
|
name: "ds/css-typography",
|
|
686
|
-
format: async ({ dictionary, options, platform }) => {
|
|
944
|
+
format: async ({ dictionary, file, options, platform }) => {
|
|
687
945
|
const { outputReferences, usesDtcg } = options;
|
|
688
|
-
const { selector, layer
|
|
689
|
-
const destination =
|
|
690
|
-
const format =
|
|
946
|
+
const { selector, layer } = platform;
|
|
947
|
+
const destination = file.destination;
|
|
948
|
+
const format = createPropertyFormatter5({
|
|
691
949
|
outputReferences,
|
|
692
950
|
dictionary,
|
|
693
951
|
format: "css",
|
|
694
952
|
usesDtcg
|
|
695
953
|
});
|
|
696
|
-
const filteredTokens =
|
|
954
|
+
const filteredTokens = R14.reject(typographyFontFamilyPredicate, dictionary.allTokens);
|
|
697
955
|
const formattedMap = filteredTokens.map((token) => ({
|
|
698
956
|
token,
|
|
699
957
|
formatted: format(token)
|
|
700
958
|
}));
|
|
701
959
|
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
702
|
-
const formattedTokens = formattedMap.map(
|
|
960
|
+
const formattedTokens = formattedMap.map(R14.view(R14.lensProp("formatted"))).join("\n");
|
|
703
961
|
const content = selector ? `${selector} {
|
|
704
962
|
${formattedTokens}
|
|
705
963
|
}` : formattedTokens;
|
|
706
|
-
const body =
|
|
964
|
+
const body = R14.isNotNil(layer) ? `@layer ${layer} {
|
|
965
|
+
${content}
|
|
966
|
+
}` : content;
|
|
967
|
+
return body;
|
|
968
|
+
}
|
|
969
|
+
};
|
|
970
|
+
|
|
971
|
+
// src/tokens/process/formats/css/type-scale.ts
|
|
972
|
+
import * as R15 from "ramda";
|
|
973
|
+
import { createPropertyFormatter as createPropertyFormatter6 } from "style-dictionary/utils";
|
|
974
|
+
var typographyFontFamilyPredicate2 = R15.allPass([
|
|
975
|
+
R15.pathSatisfies(R15.includes("typography"), ["path"]),
|
|
976
|
+
R15.pathSatisfies(R15.includes("fontFamily"), ["path"])
|
|
977
|
+
]);
|
|
978
|
+
function formatTypographySizeToken(token) {
|
|
979
|
+
return { ...token, $value: `calc(${token.$value} * var(--_ds-font-size-factor))` };
|
|
980
|
+
}
|
|
981
|
+
var typeScale = {
|
|
982
|
+
name: "ds/css-type-scale",
|
|
983
|
+
format: async ({ dictionary, file, options, platform }) => {
|
|
984
|
+
const { outputReferences, usesDtcg } = options;
|
|
985
|
+
const { selector, layer } = platform;
|
|
986
|
+
const destination = file.destination;
|
|
987
|
+
const format = createPropertyFormatter6({
|
|
988
|
+
outputReferences,
|
|
989
|
+
dictionary,
|
|
990
|
+
format: "css",
|
|
991
|
+
usesDtcg
|
|
992
|
+
});
|
|
993
|
+
const filteredTokens = R15.reject(typographyFontFamilyPredicate2, dictionary.allTokens);
|
|
994
|
+
const tokens = R15.map(formatTypographySizeToken, filteredTokens);
|
|
995
|
+
const formattedMap = tokens.map((token) => ({
|
|
996
|
+
token,
|
|
997
|
+
formatted: format(token)
|
|
998
|
+
}));
|
|
999
|
+
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
1000
|
+
const formattedTokens = formattedMap.map(R15.prop("formatted")).join("\n");
|
|
1001
|
+
const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
|
|
1002
|
+
const content = `${selector} {
|
|
1003
|
+
${sizeFactor}
|
|
1004
|
+
${formattedTokens}
|
|
1005
|
+
}`;
|
|
1006
|
+
const body = R15.isNotNil(layer) ? `@layer ${layer} {
|
|
707
1007
|
${content}
|
|
708
1008
|
}` : content;
|
|
709
1009
|
return body;
|
|
@@ -715,7 +1015,10 @@ var formats = {
|
|
|
715
1015
|
colorScheme,
|
|
716
1016
|
colorCategory,
|
|
717
1017
|
semantic,
|
|
718
|
-
|
|
1018
|
+
sizeMode,
|
|
1019
|
+
size,
|
|
1020
|
+
typography,
|
|
1021
|
+
typeScale
|
|
719
1022
|
};
|
|
720
1023
|
|
|
721
1024
|
// src/tokens/process/configs/typography.ts
|
|
@@ -751,12 +1054,9 @@ var typographyVariables = ({ theme, typography: typography2 }) => {
|
|
|
751
1054
|
destination: `typography/${typography2}.css`,
|
|
752
1055
|
format: formats.typography.name,
|
|
753
1056
|
filter: (token) => {
|
|
754
|
-
const included = typeEquals(
|
|
755
|
-
["typography", "fontweight", "fontFamily", "lineHeight", "dimension", "font", "fontsize"],
|
|
756
|
-
token
|
|
757
|
-
);
|
|
1057
|
+
const included = typeEquals(["fontweight", "fontFamily", "lineHeight", "dimension"], token);
|
|
758
1058
|
if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
|
|
759
|
-
return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "_size", "border-width", "border-radius"], token);
|
|
1059
|
+
return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "_size", "border-width", "border-radius"], token) && !(pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize"));
|
|
760
1060
|
}
|
|
761
1061
|
}
|
|
762
1062
|
]
|
|
@@ -10,7 +10,10 @@ export declare const configs: {
|
|
|
10
10
|
dangerColorVariables: GetStyleDictionaryConfig;
|
|
11
11
|
warningColorVariables: GetStyleDictionaryConfig;
|
|
12
12
|
infoColorVariables: GetStyleDictionaryConfig;
|
|
13
|
+
sizeModeVariables: GetStyleDictionaryConfig;
|
|
14
|
+
sizeVariables: GetStyleDictionaryConfig;
|
|
13
15
|
typographyVariables: GetStyleDictionaryConfig;
|
|
16
|
+
typeScaleVariables: GetStyleDictionaryConfig;
|
|
14
17
|
semanticVariables: GetStyleDictionaryConfig;
|
|
15
18
|
};
|
|
16
19
|
export declare const getConfigsForThemeDimensions: (getConfig: GetStyleDictionaryConfig, processed$themes: ProcessedThemeObject[], dimensions: ThemeDimension[], options: GetSDConfigOptions) => SDConfigForThemePermutation[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configs.d.ts","sourceRoot":"","sources":["../../../../src/tokens/process/configs.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAInG,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"configs.d.ts","sourceRoot":"","sources":["../../../../src/tokens/process/configs.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAInG,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAQpE,OAAO,EAA6B,KAAK,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAa5G,eAAO,MAAM,OAAO;;;;;;;;;;;;;;CAcnB,CAAC;AAEF,eAAO,MAAM,4BAA4B,GACvC,WAAW,wBAAwB,EACnC,kBAAkB,oBAAoB,EAAE,EACxC,YAAY,cAAc,EAAE,EAC5B,SAAS,kBAAkB,KAC1B,2BAA2B,EAoD7B,CAAC"}
|