@digdir/designsystemet 0.1.0-alpha.12 → 0.1.0-alpha.14
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/LICENSE +7 -0
- package/dist/bin/designsystemet.js +178 -121
- package/dist/bin/designsystemet.js.map +1 -1
- package/dist/src/colors/colorUtils.js +156 -2
- package/dist/src/colors/colorUtils.js.map +1 -1
- package/dist/src/colors/index.js +166 -10
- package/dist/src/colors/index.js.map +1 -1
- package/dist/src/colors/themeUtils.js +62 -8
- package/dist/src/colors/themeUtils.js.map +1 -1
- package/dist/src/tokens/actions.js +7 -1
- package/dist/src/tokens/actions.js.map +1 -1
- package/dist/src/tokens/build.js +178 -121
- package/dist/src/tokens/build.js.map +1 -1
- package/dist/src/tokens/configs.js +163 -102
- package/dist/src/tokens/configs.js.map +1 -1
- package/dist/src/tokens/formats/{css-classes.js → css.js} +123 -89
- package/dist/src/tokens/formats/css.js.map +1 -0
- package/dist/src/tokens/formats/js-tokens.js +6 -0
- package/dist/src/tokens/formats/js-tokens.js.map +1 -1
- package/dist/src/tokens/transformers.js +2 -2
- package/dist/src/tokens/transformers.js.map +1 -1
- package/dist/src/tokens/utils/permutateThemes.js +41 -29
- package/dist/src/tokens/utils/permutateThemes.js.map +1 -1
- package/dist/src/tokens/utils/utils.js +2 -2
- package/dist/src/tokens/utils/utils.js.map +1 -1
- package/package.json +10 -7
- package/dist/src/tokens/formats/css-classes.js.map +0 -1
- package/dist/src/tokens/formats/css-variables.js +0 -50
- package/dist/src/tokens/formats/css-variables.js.map +0 -1
|
@@ -2154,6 +2154,9 @@ import StyleDictionary from "style-dictionary";
|
|
|
2154
2154
|
import { outputReferencesFilter } from "style-dictionary/utils";
|
|
2155
2155
|
import * as R7 from "ramda";
|
|
2156
2156
|
|
|
2157
|
+
// src/tokens/utils/permutateThemes.ts
|
|
2158
|
+
import * as R from "ramda";
|
|
2159
|
+
|
|
2157
2160
|
// ../../node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js
|
|
2158
2161
|
var BoxShadowTypes;
|
|
2159
2162
|
(function(BoxShadowTypes2) {
|
|
@@ -2319,40 +2322,49 @@ var TypographyValues;
|
|
|
2319
2322
|
|
|
2320
2323
|
// src/tokens/utils/permutateThemes.ts
|
|
2321
2324
|
function mapThemesToSetsObject(themes) {
|
|
2322
|
-
return
|
|
2325
|
+
return themes.map((theme) => ({ name: theme.name, selectedTokenSets: filterTokenSets(theme.selectedTokenSets) }));
|
|
2323
2326
|
}
|
|
2324
2327
|
function permutateThemes(themes, { separator: separator2 = "-" } = {}) {
|
|
2325
|
-
if (themes.some((theme) => theme.group)) {
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
const permutations = cartesian(Object.values(groups));
|
|
2340
|
-
return Object.fromEntries(
|
|
2341
|
-
permutations.map((perm) => {
|
|
2342
|
-
const reduced = perm.reduce(
|
|
2343
|
-
(acc, curr) => [
|
|
2344
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
2345
|
-
`${acc[0]}${acc[0] ? separator2 : ""}${curr.name}`,
|
|
2346
|
-
[...acc[1], ...filterTokenSets(curr.selectedTokenSets)]
|
|
2347
|
-
],
|
|
2348
|
-
["", []]
|
|
2349
|
-
);
|
|
2350
|
-
return [reduced[0], [...new Set(reduced[1])]];
|
|
2351
|
-
})
|
|
2352
|
-
);
|
|
2353
|
-
} else {
|
|
2328
|
+
if (!themes.some((theme) => theme.group)) {
|
|
2329
|
+
return mapThemesToSetsObject(themes);
|
|
2330
|
+
}
|
|
2331
|
+
const groups = {};
|
|
2332
|
+
themes.forEach((theme) => {
|
|
2333
|
+
if (theme.group) {
|
|
2334
|
+
groups[theme.group] = [...groups[theme.group] ?? [], theme];
|
|
2335
|
+
} else {
|
|
2336
|
+
throw new Error(
|
|
2337
|
+
`Theme ${theme.name} does not have a group property, which is required for multi-dimensional theming.`
|
|
2338
|
+
);
|
|
2339
|
+
}
|
|
2340
|
+
});
|
|
2341
|
+
if (Object.keys(groups).length <= 1) {
|
|
2354
2342
|
return mapThemesToSetsObject(themes);
|
|
2355
2343
|
}
|
|
2344
|
+
const permutations = cartesian(Object.values(groups));
|
|
2345
|
+
const permutatedThemes = permutations.map((perm) => {
|
|
2346
|
+
const permutatedTheme = perm.reduce(
|
|
2347
|
+
(acc, theme) => {
|
|
2348
|
+
const { group, name, selectedTokenSets } = theme;
|
|
2349
|
+
let updatedPermutatedTheme = acc;
|
|
2350
|
+
if (group) {
|
|
2351
|
+
const groupProp = R.lensProp(group.toLowerCase());
|
|
2352
|
+
updatedPermutatedTheme = R.set(groupProp, name.toLowerCase(), updatedPermutatedTheme);
|
|
2353
|
+
}
|
|
2354
|
+
const updatedName = `${String(acc.name)}${acc ? separator2 : ""}${name}`;
|
|
2355
|
+
const sets = [...updatedPermutatedTheme.selectedTokenSets, ...filterTokenSets(selectedTokenSets)];
|
|
2356
|
+
return {
|
|
2357
|
+
...updatedPermutatedTheme,
|
|
2358
|
+
name: updatedName,
|
|
2359
|
+
selectedTokenSets: sets
|
|
2360
|
+
};
|
|
2361
|
+
},
|
|
2362
|
+
{ name: "", selectedTokenSets: [] }
|
|
2363
|
+
);
|
|
2364
|
+
const uniqueTokenSets = new Set(permutatedTheme.selectedTokenSets);
|
|
2365
|
+
return { ...permutatedTheme, selectedTokenSets: Array.from(uniqueTokenSets) };
|
|
2366
|
+
});
|
|
2367
|
+
return permutatedThemes;
|
|
2356
2368
|
}
|
|
2357
2369
|
function filterTokenSets(tokensets) {
|
|
2358
2370
|
return Object.entries(tokensets).filter(([, val]) => val !== TokenSetStatus.DISABLED).sort((a, b) => {
|
|
@@ -2369,7 +2381,7 @@ function cartesian(a) {
|
|
|
2369
2381
|
}
|
|
2370
2382
|
|
|
2371
2383
|
// src/tokens/transformers.ts
|
|
2372
|
-
import * as
|
|
2384
|
+
import * as R3 from "ramda";
|
|
2373
2385
|
|
|
2374
2386
|
// src/tokens/utils/noCase.ts
|
|
2375
2387
|
var lowerCase = (text = "") => text.toLowerCase();
|
|
@@ -2399,18 +2411,18 @@ function replace(input, re, value) {
|
|
|
2399
2411
|
}
|
|
2400
2412
|
|
|
2401
2413
|
// src/tokens/utils/utils.ts
|
|
2402
|
-
import * as
|
|
2414
|
+
import * as R2 from "ramda";
|
|
2403
2415
|
var getType = (token) => (token.$type ?? token.type) || "";
|
|
2404
2416
|
var getValue = (token) => token.$value ?? token.value;
|
|
2405
|
-
var typeEquals = (types, token) => {
|
|
2406
|
-
if (
|
|
2417
|
+
var typeEquals = R2.curry((types, token) => {
|
|
2418
|
+
if (R2.isNil(token)) {
|
|
2407
2419
|
return false;
|
|
2408
2420
|
}
|
|
2409
|
-
return
|
|
2410
|
-
};
|
|
2421
|
+
return R2.includes(R2.toLower(getType(token)), R2.map(R2.toLower, Array.isArray(types) ? types : [types]));
|
|
2422
|
+
});
|
|
2411
2423
|
|
|
2412
2424
|
// src/tokens/transformers.ts
|
|
2413
|
-
var isPx =
|
|
2425
|
+
var isPx = R3.test(/\b\d+px\b/g);
|
|
2414
2426
|
var sizeRem = {
|
|
2415
2427
|
name: "ds/size/toRem",
|
|
2416
2428
|
type: "value",
|
|
@@ -2445,19 +2457,19 @@ var typographyShorthand = {
|
|
|
2445
2457
|
transitive: true,
|
|
2446
2458
|
filter: (token) => token.type === "typography",
|
|
2447
2459
|
transform: (token) => {
|
|
2448
|
-
const
|
|
2449
|
-
return `${
|
|
2460
|
+
const typography2 = getValue(token);
|
|
2461
|
+
return `${typography2.fontWeight} ${typography2.fontSize}/${typography2.lineHeight} '${typography2.fontFamily}'`;
|
|
2450
2462
|
}
|
|
2451
2463
|
};
|
|
2452
2464
|
|
|
2453
2465
|
// src/tokens/formats/js-tokens.ts
|
|
2454
|
-
import * as
|
|
2466
|
+
import * as R4 from "ramda";
|
|
2455
2467
|
import { fileHeader, createPropertyFormatter } from "style-dictionary/utils";
|
|
2456
|
-
var groupByType =
|
|
2457
|
-
var removeUnwatedTokens =
|
|
2468
|
+
var groupByType = R4.groupBy((token) => getType(token));
|
|
2469
|
+
var removeUnwatedTokens = R4.filter(
|
|
2458
2470
|
(token) => !["fds-base_spacing", "fds-base_sizing"].includes(token.name)
|
|
2459
2471
|
);
|
|
2460
|
-
var toCssVarName =
|
|
2472
|
+
var toCssVarName = R4.pipe(R4.split(":"), R4.head, R4.trim);
|
|
2461
2473
|
var jsTokens = {
|
|
2462
2474
|
name: "ds/js-tokens",
|
|
2463
2475
|
format: async function({ dictionary, file }) {
|
|
@@ -2465,11 +2477,11 @@ var jsTokens = {
|
|
|
2465
2477
|
dictionary,
|
|
2466
2478
|
format: "css"
|
|
2467
2479
|
});
|
|
2468
|
-
const formatTokens =
|
|
2480
|
+
const formatTokens = R4.map((token) => ({
|
|
2469
2481
|
...token,
|
|
2470
2482
|
name: toCssVarName(format(token))
|
|
2471
2483
|
}));
|
|
2472
|
-
const processTokens =
|
|
2484
|
+
const processTokens = R4.pipe(removeUnwatedTokens, formatTokens, groupByType);
|
|
2473
2485
|
const tokens = processTokens(dictionary.allTokens);
|
|
2474
2486
|
const content = Object.entries(tokens).map(
|
|
2475
2487
|
([name, token]) => `export const ${name} = ${JSON.stringify(token, null, 2).replace(/"([^"]+)":/g, "$1:")}
|
|
@@ -2479,21 +2491,20 @@ var jsTokens = {
|
|
|
2479
2491
|
}
|
|
2480
2492
|
};
|
|
2481
2493
|
|
|
2482
|
-
// src/tokens/formats/css
|
|
2483
|
-
import * as
|
|
2484
|
-
import { fileHeader as fileHeader2, createPropertyFormatter as createPropertyFormatter2, usesReferences } from "style-dictionary/utils";
|
|
2485
|
-
var calculatedVariable = R4.pipe(R4.split(/:(.*?);/g), (split5) => `${split5[0]}: calc(${R4.trim(split5[1])});`);
|
|
2494
|
+
// src/tokens/formats/css.ts
|
|
2495
|
+
import * as R5 from "ramda";
|
|
2496
|
+
import { fileHeader as fileHeader2, createPropertyFormatter as createPropertyFormatter2, usesReferences, getReferences } from "style-dictionary/utils";
|
|
2486
2497
|
var prefersColorScheme = (mode, content) => `
|
|
2487
2498
|
@media (prefers-color-scheme: ${mode}) {
|
|
2488
2499
|
[data-ds-color-mode="auto"] ${content}
|
|
2489
2500
|
}
|
|
2490
2501
|
`;
|
|
2491
|
-
var
|
|
2492
|
-
name: "ds/css-
|
|
2502
|
+
var colormode = {
|
|
2503
|
+
name: "ds/css-colormode",
|
|
2493
2504
|
format: async function({ dictionary, file, options, platform }) {
|
|
2494
2505
|
const { allTokens } = dictionary;
|
|
2495
2506
|
const { outputReferences } = options;
|
|
2496
|
-
const { selector,
|
|
2507
|
+
const { selector, mode, layer } = platform;
|
|
2497
2508
|
const mode_ = mode;
|
|
2498
2509
|
const header = await fileHeader2({ file });
|
|
2499
2510
|
const format = createPropertyFormatter2({
|
|
@@ -2501,7 +2512,31 @@ var cssVariables = {
|
|
|
2501
2512
|
dictionary,
|
|
2502
2513
|
format: "css"
|
|
2503
2514
|
});
|
|
2504
|
-
const
|
|
2515
|
+
const content = `{
|
|
2516
|
+
${allTokens.map(format).join("\n")}
|
|
2517
|
+
}
|
|
2518
|
+
`;
|
|
2519
|
+
const autoSelectorContent = ["light", "dark"].includes(mode_) ? prefersColorScheme(mode_, content) : "";
|
|
2520
|
+
return header + `@layer ${layer} {
|
|
2521
|
+
${selector} ${content} ${autoSelectorContent}
|
|
2522
|
+
}
|
|
2523
|
+
`;
|
|
2524
|
+
}
|
|
2525
|
+
};
|
|
2526
|
+
var calculatedVariable = R5.pipe(R5.split(/:(.*?);/g), (split3) => `${split3[0]}: calc(${R5.trim(split3[1])});`);
|
|
2527
|
+
var semantic = {
|
|
2528
|
+
name: "ds/css-semantic",
|
|
2529
|
+
format: async function({ dictionary, file, options, platform }) {
|
|
2530
|
+
const { allTokens } = dictionary;
|
|
2531
|
+
const { outputReferences } = options;
|
|
2532
|
+
const { selector, isCalculatedToken, layer } = platform;
|
|
2533
|
+
const header = await fileHeader2({ file });
|
|
2534
|
+
const format = createPropertyFormatter2({
|
|
2535
|
+
outputReferences,
|
|
2536
|
+
dictionary,
|
|
2537
|
+
format: "css"
|
|
2538
|
+
});
|
|
2539
|
+
const formatTokens = R5.map((token) => {
|
|
2505
2540
|
const originalValue = getValue(token.original);
|
|
2506
2541
|
if (usesReferences(originalValue) && typeof outputReferences === "function" && outputReferences?.(token, { dictionary })) {
|
|
2507
2542
|
if (isCalculatedToken?.(token, options)) {
|
|
@@ -2515,14 +2550,12 @@ var cssVariables = {
|
|
|
2515
2550
|
${formattedVariables.join("\n")}
|
|
2516
2551
|
}
|
|
2517
2552
|
`;
|
|
2518
|
-
|
|
2519
|
-
|
|
2553
|
+
return header + `@layer ${layer} {
|
|
2554
|
+
${selector} ${content}
|
|
2555
|
+
}
|
|
2556
|
+
`;
|
|
2520
2557
|
}
|
|
2521
2558
|
};
|
|
2522
|
-
|
|
2523
|
-
// src/tokens/formats/css-classes.ts
|
|
2524
|
-
import * as R5 from "ramda";
|
|
2525
|
-
import { fileHeader as fileHeader3, createPropertyFormatter as createPropertyFormatter3, getReferences } from "style-dictionary/utils";
|
|
2526
2559
|
var sortByType = R5.sortBy((token) => token?.type === "typography");
|
|
2527
2560
|
var getVariableName = R5.pipe(
|
|
2528
2561
|
R5.split(":"),
|
|
@@ -2536,21 +2569,23 @@ var bemify = R5.pipe(
|
|
|
2536
2569
|
const filteredPath = path.filter((p) => p !== "typography");
|
|
2537
2570
|
const withPrefix = R5.concat([prefix], R5.remove(0, 0, filteredPath));
|
|
2538
2571
|
const [rest, last] = R5.splitAt(-1, withPrefix);
|
|
2539
|
-
|
|
2572
|
+
const className = `${rest.join("-")}--${R5.head(last)}`;
|
|
2573
|
+
return className;
|
|
2540
2574
|
},
|
|
2541
2575
|
R5.trim,
|
|
2542
2576
|
R5.toLower
|
|
2543
2577
|
);
|
|
2544
2578
|
var classSelector = R5.pipe(R5.prop("path"), bemify);
|
|
2545
|
-
var
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2579
|
+
var sortTypographyLast = R5.sortWith([
|
|
2580
|
+
R5.ascend((token) => typeEquals("typography")(token) ? 1 : 0)
|
|
2581
|
+
]);
|
|
2582
|
+
var typography = {
|
|
2583
|
+
name: "ds/css-typography",
|
|
2549
2584
|
format: async function({ dictionary, file, options, platform }) {
|
|
2550
2585
|
const { outputReferences } = options;
|
|
2551
|
-
const { selector } = platform;
|
|
2552
|
-
const header = await
|
|
2553
|
-
const format =
|
|
2586
|
+
const { selector, layer } = platform;
|
|
2587
|
+
const header = await fileHeader2({ file });
|
|
2588
|
+
const format = createPropertyFormatter2({
|
|
2554
2589
|
outputReferences,
|
|
2555
2590
|
dictionary,
|
|
2556
2591
|
format: "css"
|
|
@@ -2584,17 +2619,20 @@ var cssClassesTypography = {
|
|
|
2584
2619
|
}
|
|
2585
2620
|
if (typeEquals("typography", token)) {
|
|
2586
2621
|
const references = getReferences(getValue(token.original), dictionary.tokens);
|
|
2587
|
-
const fontweight = R5.find(
|
|
2588
|
-
const lineheight = R5.find(
|
|
2589
|
-
const fontsize = R5.find(
|
|
2622
|
+
const fontweight = R5.find(typeEquals(["fontweights"]))(references);
|
|
2623
|
+
const lineheight = R5.find(typeEquals(["lineheights"]))(references);
|
|
2624
|
+
const fontsize = R5.find(typeEquals(["fontsizes"]))(references);
|
|
2625
|
+
const letterSpacing = R5.find(typeEquals(["letterSpacing"]))(references);
|
|
2590
2626
|
const fontSizeVar = fontsize ? getVariableName(format(fontsize)) : null;
|
|
2591
2627
|
const fontWeightVar = fontweight ? getVariableName(format(fontweight)) : null;
|
|
2592
2628
|
const lineheightVar = lineheight ? getVariableName(format(lineheight)) : null;
|
|
2629
|
+
const letterSpacingVar = letterSpacing ? getVariableName(format(letterSpacing)) : null;
|
|
2593
2630
|
const className = `
|
|
2594
2631
|
.${classSelector(token)} {
|
|
2595
2632
|
${fontSizeVar && `font-size: ${fontSizeVar};`}
|
|
2596
2633
|
${lineheightVar && `line-height: ${lineheightVar};`}
|
|
2597
2634
|
${fontWeightVar && `font-weight: ${fontWeightVar};`}
|
|
2635
|
+
${letterSpacingVar && `letter-spacing: ${letterSpacingVar};`}
|
|
2598
2636
|
}`;
|
|
2599
2637
|
return { ...acc, classes: [className, ...acc.classes] };
|
|
2600
2638
|
}
|
|
@@ -2605,15 +2643,11 @@ var cssClassesTypography = {
|
|
|
2605
2643
|
)(sortedTokens);
|
|
2606
2644
|
const classes = formattedTokens.classes.join("\n");
|
|
2607
2645
|
const variables = formattedTokens.variables.join("\n");
|
|
2608
|
-
const variables_ = `:root {
|
|
2609
|
-
${variables}
|
|
2610
|
-
}
|
|
2611
|
-
`;
|
|
2612
2646
|
const content = selector ? `${selector} {
|
|
2647
|
+
${variables}
|
|
2613
2648
|
${classes}
|
|
2614
2649
|
}` : classes;
|
|
2615
|
-
return header + `@layer
|
|
2616
|
-
${variables_}
|
|
2650
|
+
return header + `@layer ${layer} {
|
|
2617
2651
|
${content}
|
|
2618
2652
|
}
|
|
2619
2653
|
`;
|
|
@@ -2625,6 +2659,7 @@ var import_fs_extra = __toESM(require_lib(), 1);
|
|
|
2625
2659
|
import glob from "fast-glob";
|
|
2626
2660
|
import chalk from "chalk";
|
|
2627
2661
|
import * as R6 from "ramda";
|
|
2662
|
+
var sortLightmodeFirst = R6.sortWith([R6.descend(R6.includes("light")), R6.descend(R6.includes("secondary"))]);
|
|
2628
2663
|
var makeEntryFile = {
|
|
2629
2664
|
name: "make_entryfile",
|
|
2630
2665
|
do: async function(dictionary, platform) {
|
|
@@ -2633,8 +2668,13 @@ var makeEntryFile = {
|
|
|
2633
2668
|
if (log?.verbosity !== "silent") {
|
|
2634
2669
|
console.log(chalk.green(`Creating entry file: ${writePath}`));
|
|
2635
2670
|
}
|
|
2671
|
+
const generateImportUrls = R6.pipe(
|
|
2672
|
+
sortLightmodeFirst,
|
|
2673
|
+
R6.map((file) => `@import url('./${theme}/${file.toString()}');`),
|
|
2674
|
+
R6.join("\n")
|
|
2675
|
+
);
|
|
2636
2676
|
const files = await glob(`**/*`, { cwd: platform.buildPath });
|
|
2637
|
-
const content =
|
|
2677
|
+
const content = generateImportUrls(files);
|
|
2638
2678
|
await import_fs_extra.default.writeFile(writePath, content);
|
|
2639
2679
|
},
|
|
2640
2680
|
undo: async function noOp() {
|
|
@@ -2646,13 +2686,14 @@ void tokenStudio.registerTransforms(StyleDictionary);
|
|
|
2646
2686
|
var prefix = "ds";
|
|
2647
2687
|
var basePxFontSize = 16;
|
|
2648
2688
|
var separator = "_";
|
|
2649
|
-
var
|
|
2689
|
+
var fileHeader3 = () => [`These files are generated from design tokens defind using Token Studio`];
|
|
2650
2690
|
StyleDictionary.registerTransform(sizeRem);
|
|
2651
2691
|
StyleDictionary.registerTransform(nameKebab);
|
|
2652
2692
|
StyleDictionary.registerTransform(typographyShorthand);
|
|
2653
2693
|
StyleDictionary.registerFormat(jsTokens);
|
|
2654
|
-
StyleDictionary.registerFormat(
|
|
2655
|
-
StyleDictionary.registerFormat(
|
|
2694
|
+
StyleDictionary.registerFormat(colormode);
|
|
2695
|
+
StyleDictionary.registerFormat(semantic);
|
|
2696
|
+
StyleDictionary.registerFormat(typography);
|
|
2656
2697
|
StyleDictionary.registerAction(makeEntryFile);
|
|
2657
2698
|
var dsTransformers = [
|
|
2658
2699
|
nameKebab.name,
|
|
@@ -2666,7 +2707,8 @@ var dsTransformers = [
|
|
|
2666
2707
|
"ts/size/lineheight",
|
|
2667
2708
|
"ts/shadow/css/shorthand"
|
|
2668
2709
|
];
|
|
2669
|
-
var
|
|
2710
|
+
var paritionPrimitives = R7.partition(R7.test(/(?!.*global\.json).*primitives.*/));
|
|
2711
|
+
var hasUnknownProps = R7.pipe(R7.values, R7.none(R7.equals("unknown")), R7.not);
|
|
2670
2712
|
var outputColorReferences = (token) => {
|
|
2671
2713
|
if (R7.test(/accent|neutral|brand1|brand2|brand3|success|danger|warning/, token.name) && R7.includes("semantic/color", token.filePath)) {
|
|
2672
2714
|
return true;
|
|
@@ -2678,6 +2720,7 @@ var permutateThemes2 = ($themes) => permutateThemes($themes, {
|
|
|
2678
2720
|
});
|
|
2679
2721
|
var colorModeVariables = ({ mode = "light", outPath, theme }) => {
|
|
2680
2722
|
const selector = `${mode === "light" ? ":root, " : ""}[data-ds-color-mode="${mode}"]`;
|
|
2723
|
+
const layer = `ds.theme.color-mode.${mode}`;
|
|
2681
2724
|
return {
|
|
2682
2725
|
log: { verbosity: "silent" },
|
|
2683
2726
|
preprocessors: ["tokens-studio"],
|
|
@@ -2688,6 +2731,7 @@ var colorModeVariables = ({ mode = "light", outPath, theme }) => {
|
|
|
2688
2731
|
mode,
|
|
2689
2732
|
theme,
|
|
2690
2733
|
selector,
|
|
2734
|
+
layer,
|
|
2691
2735
|
//
|
|
2692
2736
|
prefix,
|
|
2693
2737
|
buildPath: `${outPath}/${theme}/`,
|
|
@@ -2696,12 +2740,12 @@ var colorModeVariables = ({ mode = "light", outPath, theme }) => {
|
|
|
2696
2740
|
files: [
|
|
2697
2741
|
{
|
|
2698
2742
|
destination: `color-mode/${mode}.css`,
|
|
2699
|
-
format:
|
|
2743
|
+
format: colormode.name,
|
|
2700
2744
|
filter: (token) => !token.isSource && typeEquals("color", token)
|
|
2701
2745
|
}
|
|
2702
2746
|
],
|
|
2703
2747
|
options: {
|
|
2704
|
-
fileHeader:
|
|
2748
|
+
fileHeader: fileHeader3,
|
|
2705
2749
|
outputReferences: (token, options) => outputColorReferences(token) && outputReferencesFilter(token, options)
|
|
2706
2750
|
}
|
|
2707
2751
|
}
|
|
@@ -2710,6 +2754,7 @@ var colorModeVariables = ({ mode = "light", outPath, theme }) => {
|
|
|
2710
2754
|
};
|
|
2711
2755
|
var semanticVariables = ({ outPath, theme }) => {
|
|
2712
2756
|
const selector = `:root`;
|
|
2757
|
+
const layer = `ds.theme.semantic`;
|
|
2713
2758
|
const isCalculatedToken = (token) => typeEquals(["spacing", "sizing", "borderRadius"], token);
|
|
2714
2759
|
return {
|
|
2715
2760
|
log: { verbosity: "silent" },
|
|
@@ -2722,6 +2767,7 @@ var semanticVariables = ({ outPath, theme }) => {
|
|
|
2722
2767
|
basePxFontSize,
|
|
2723
2768
|
isCalculatedToken,
|
|
2724
2769
|
selector,
|
|
2770
|
+
layer,
|
|
2725
2771
|
//
|
|
2726
2772
|
prefix,
|
|
2727
2773
|
buildPath: `${outPath}/${theme}/`,
|
|
@@ -2730,12 +2776,12 @@ var semanticVariables = ({ outPath, theme }) => {
|
|
|
2730
2776
|
files: [
|
|
2731
2777
|
{
|
|
2732
2778
|
destination: `semantic.css`,
|
|
2733
|
-
format:
|
|
2779
|
+
format: semantic.name,
|
|
2734
2780
|
filter: (token) => (!token.isSource || isCalculatedToken(token)) && !typeEquals(["color", "fontWeights", "fontFamilies"], token)
|
|
2735
2781
|
}
|
|
2736
2782
|
],
|
|
2737
2783
|
options: {
|
|
2738
|
-
fileHeader:
|
|
2784
|
+
fileHeader: fileHeader3,
|
|
2739
2785
|
outputReferences: (token, options) => isCalculatedToken(token) && outputReferencesFilter(token, options)
|
|
2740
2786
|
}
|
|
2741
2787
|
}
|
|
@@ -2769,59 +2815,74 @@ var typescriptTokens = ({ mode = "unknown", outPath, theme }) => {
|
|
|
2769
2815
|
}
|
|
2770
2816
|
],
|
|
2771
2817
|
options: {
|
|
2772
|
-
fileHeader:
|
|
2818
|
+
fileHeader: fileHeader3
|
|
2773
2819
|
}
|
|
2774
2820
|
}
|
|
2775
2821
|
}
|
|
2776
2822
|
};
|
|
2777
2823
|
};
|
|
2778
|
-
var typographyCSS = ({ outPath, theme, typography }) => {
|
|
2824
|
+
var typographyCSS = ({ outPath, theme, typography: typography2 }) => {
|
|
2825
|
+
const selector = `${typography2 === "primary" ? ":root, " : ""}[data-ds-typography="${typography2}"]`;
|
|
2826
|
+
const layer = `ds.theme.typography.${typography2}`;
|
|
2779
2827
|
return {
|
|
2780
2828
|
log: { verbosity: "silent" },
|
|
2781
2829
|
preprocessors: ["tokens-studio"],
|
|
2782
2830
|
platforms: {
|
|
2783
2831
|
css: {
|
|
2784
2832
|
prefix,
|
|
2785
|
-
typography,
|
|
2786
|
-
|
|
2833
|
+
typography: typography2,
|
|
2834
|
+
selector,
|
|
2835
|
+
layer,
|
|
2787
2836
|
buildPath: `${outPath}/${theme}/`,
|
|
2788
2837
|
basePxFontSize,
|
|
2789
2838
|
transforms: [nameKebab.name, "ts/size/px", sizeRem.name, "ts/size/lineheight", "ts/typography/fontWeight"],
|
|
2790
2839
|
files: [
|
|
2791
2840
|
{
|
|
2792
|
-
destination: `typography.css`,
|
|
2793
|
-
format:
|
|
2841
|
+
destination: `typography/${typography2}.css`,
|
|
2842
|
+
format: typography.name,
|
|
2794
2843
|
filter: (token) => {
|
|
2795
|
-
return typeEquals(
|
|
2844
|
+
return typeEquals(
|
|
2845
|
+
["typography", "fontweights", "fontfamilies", "lineheights", "fontsizes", "letterSpacing"],
|
|
2846
|
+
token
|
|
2847
|
+
) && !(token.path[0] || "").startsWith("theme");
|
|
2796
2848
|
}
|
|
2797
2849
|
}
|
|
2798
2850
|
],
|
|
2799
2851
|
options: {
|
|
2800
|
-
fileHeader:
|
|
2852
|
+
fileHeader: fileHeader3
|
|
2801
2853
|
}
|
|
2802
2854
|
}
|
|
2803
2855
|
}
|
|
2804
2856
|
};
|
|
2805
2857
|
};
|
|
2806
|
-
var getConfigs = (getConfig, outPath, tokensDir,
|
|
2807
|
-
const
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2858
|
+
var getConfigs = (getConfig, outPath, tokensDir, permutatedThemes) => permutatedThemes.map((permutatedTheme) => {
|
|
2859
|
+
const {
|
|
2860
|
+
selectedTokenSets = [],
|
|
2861
|
+
mode = "unknown",
|
|
2862
|
+
theme = "unknown",
|
|
2863
|
+
semantic: semantic2 = "unknown",
|
|
2864
|
+
size = "unknown",
|
|
2865
|
+
typography: typography2 = "unknown"
|
|
2866
|
+
} = permutatedTheme;
|
|
2867
|
+
if (hasUnknownProps(permutatedTheme)) {
|
|
2868
|
+
throw Error(`Theme ${permutatedTheme.name} has unknown props: ${JSON.stringify(permutatedTheme)}`);
|
|
2869
|
+
}
|
|
2870
|
+
const setsWithPaths = selectedTokenSets.map((x) => `${tokensDir}/${x}.json`);
|
|
2871
|
+
const [source, include] = paritionPrimitives(setsWithPaths);
|
|
2811
2872
|
const config_ = getConfig({
|
|
2812
2873
|
outPath,
|
|
2813
2874
|
theme,
|
|
2814
2875
|
mode,
|
|
2815
|
-
semantic,
|
|
2816
|
-
|
|
2817
|
-
typography
|
|
2876
|
+
semantic: semantic2,
|
|
2877
|
+
size,
|
|
2878
|
+
typography: typography2
|
|
2818
2879
|
});
|
|
2819
2880
|
const config = {
|
|
2820
2881
|
...config_,
|
|
2821
2882
|
source,
|
|
2822
2883
|
include
|
|
2823
2884
|
};
|
|
2824
|
-
return {
|
|
2885
|
+
return { mode, theme, semantic: semantic2, size, typography: typography2, config };
|
|
2825
2886
|
}).sort();
|
|
2826
2887
|
export {
|
|
2827
2888
|
basePxFontSize,
|