@digdir/designsystemet 1.5.0 → 1.6.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/test-tokens.config.json +15 -1
- package/dist/bin/config.js +14 -3
- package/dist/bin/designsystemet.js +105 -43
- package/dist/config.schema.json +52 -0
- package/dist/src/colors/colorMetadata.d.ts +1 -0
- package/dist/src/colors/colorMetadata.d.ts.map +1 -1
- package/dist/src/colors/colorMetadata.js +2 -0
- package/dist/src/colors/index.js +2 -0
- package/dist/src/colors/theme.js +1 -0
- package/dist/src/config.d.ts +70 -0
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +12 -1
- package/dist/src/index.js +90 -37
- package/dist/src/scripts/createJsonSchema.js +12 -1
- package/dist/src/scripts/update-preview-tokens.js +80 -28
- package/dist/src/tokens/build.js +45 -27
- package/dist/src/tokens/create/generators/$designsystemet.js +9 -9
- package/dist/src/tokens/create/generators/color.d.ts +2 -1
- package/dist/src/tokens/create/generators/color.d.ts.map +1 -1
- package/dist/src/tokens/create/generators/color.js +40 -6
- package/dist/src/tokens/create/write.js +9 -9
- package/dist/src/tokens/create.js +44 -10
- package/dist/src/tokens/format.js +89 -37
- package/dist/src/tokens/index.js +89 -37
- package/dist/src/tokens/process/configs/color.js +31 -13
- package/dist/src/tokens/process/configs/semantic.js +31 -13
- package/dist/src/tokens/process/configs/size-mode.js +31 -13
- package/dist/src/tokens/process/configs/size.js +31 -13
- package/dist/src/tokens/process/configs/type-scale.js +31 -13
- package/dist/src/tokens/process/configs/typography.js +31 -13
- package/dist/src/tokens/process/configs.js +36 -18
- package/dist/src/tokens/process/formats/css/color.js +31 -13
- package/dist/src/tokens/process/formats/css/semantic.js +31 -13
- package/dist/src/tokens/process/formats/css/size-mode.js +31 -13
- package/dist/src/tokens/process/formats/css/size.d.ts +4 -0
- package/dist/src/tokens/process/formats/css/size.d.ts.map +1 -1
- package/dist/src/tokens/process/formats/css/size.js +33 -14
- package/dist/src/tokens/process/formats/css/type-scale.d.ts.map +1 -1
- package/dist/src/tokens/process/formats/css/type-scale.js +31 -13
- package/dist/src/tokens/process/formats/css/typography.js +33 -15
- package/dist/src/tokens/process/formats/css.js +31 -13
- package/dist/src/tokens/process/output/declarations.js +40 -22
- package/dist/src/tokens/process/output/theme.js +9 -9
- package/dist/src/tokens/process/platform.js +36 -18
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +31 -13
- package/dist/src/tokens/types.d.ts +1 -1
- package/dist/src/tokens/types.d.ts.map +1 -1
- package/package.json +9 -9
package/dist/src/tokens/index.js
CHANGED
|
@@ -1248,6 +1248,7 @@ var colorMetadata = {
|
|
|
1248
1248
|
}
|
|
1249
1249
|
};
|
|
1250
1250
|
var colorMetadataByNumber = R2.indexBy((metadata) => metadata.number, Object.values(colorMetadata));
|
|
1251
|
+
var colorNames = Object.keys(colorMetadata);
|
|
1251
1252
|
|
|
1252
1253
|
// src/colors/theme.ts
|
|
1253
1254
|
import chroma2 from "chroma-js";
|
|
@@ -1328,18 +1329,51 @@ var generateColorContrast = (color, type) => {
|
|
|
1328
1329
|
};
|
|
1329
1330
|
|
|
1330
1331
|
// src/tokens/create/generators/color.ts
|
|
1331
|
-
var generateColor = (colorArray) => {
|
|
1332
|
+
var generateColor = (colorArray, overrides) => {
|
|
1332
1333
|
const obj = {};
|
|
1333
1334
|
const $type = "color";
|
|
1334
1335
|
for (const index in colorArray) {
|
|
1335
|
-
|
|
1336
|
+
const position = Number(index) + 1;
|
|
1337
|
+
const overrideValue = overrides?.[position];
|
|
1338
|
+
obj[position] = {
|
|
1339
|
+
$type,
|
|
1340
|
+
$value: overrideValue || colorArray[index].hex
|
|
1341
|
+
};
|
|
1336
1342
|
}
|
|
1337
1343
|
return obj;
|
|
1338
1344
|
};
|
|
1339
|
-
var generateColorScheme = (themeName, colorScheme2, colors) => {
|
|
1340
|
-
const
|
|
1341
|
-
|
|
1342
|
-
|
|
1345
|
+
var generateColorScheme = (themeName, colorScheme2, colors, overrides) => {
|
|
1346
|
+
const createColorOverrides = (colorName) => {
|
|
1347
|
+
if (!overrides?.colors || !(colorName in overrides.colors)) {
|
|
1348
|
+
return void 0;
|
|
1349
|
+
}
|
|
1350
|
+
const colorOverrides = overrides.colors[colorName];
|
|
1351
|
+
const positionOverrides = {};
|
|
1352
|
+
Object.entries(colorOverrides).forEach(([semanticTokenName, modeOverrides]) => {
|
|
1353
|
+
const position = colorMetadata[semanticTokenName].number;
|
|
1354
|
+
if (position) {
|
|
1355
|
+
let overrideValue;
|
|
1356
|
+
if (colorScheme2 === "light" && modeOverrides.light) {
|
|
1357
|
+
overrideValue = modeOverrides.light;
|
|
1358
|
+
} else if (colorScheme2 === "dark" && modeOverrides.dark) {
|
|
1359
|
+
overrideValue = modeOverrides.dark;
|
|
1360
|
+
}
|
|
1361
|
+
if (overrideValue) {
|
|
1362
|
+
positionOverrides[position] = overrideValue;
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
});
|
|
1366
|
+
return Object.keys(positionOverrides).length > 0 ? positionOverrides : void 0;
|
|
1367
|
+
};
|
|
1368
|
+
const main = R4.mapObjIndexed(
|
|
1369
|
+
(color, colorName) => generateColor(generateColorScale(color, colorScheme2), createColorOverrides(colorName)),
|
|
1370
|
+
colors.main
|
|
1371
|
+
);
|
|
1372
|
+
const support = R4.mapObjIndexed(
|
|
1373
|
+
(color, colorName) => generateColor(generateColorScale(color, colorScheme2), createColorOverrides(colorName)),
|
|
1374
|
+
colors.support
|
|
1375
|
+
);
|
|
1376
|
+
const neutral = generateColor(generateColorScale(colors.neutral, colorScheme2), createColorOverrides("neutral"));
|
|
1343
1377
|
return {
|
|
1344
1378
|
[themeName]: {
|
|
1345
1379
|
...main,
|
|
@@ -1804,8 +1838,8 @@ var generateSemantic = (colors) => {
|
|
|
1804
1838
|
["main-color", mainColorNames],
|
|
1805
1839
|
["support-color", supportColorNames]
|
|
1806
1840
|
];
|
|
1807
|
-
for (const [colorCategory2,
|
|
1808
|
-
for (const colorName of
|
|
1841
|
+
for (const [colorCategory2, colorNames2] of categories) {
|
|
1842
|
+
for (const colorName of colorNames2) {
|
|
1809
1843
|
const category = colorCategory2.replace("-color", "");
|
|
1810
1844
|
const customColorTokens = {
|
|
1811
1845
|
color: {
|
|
@@ -2061,7 +2095,7 @@ var cliOptions = {
|
|
|
2061
2095
|
}
|
|
2062
2096
|
};
|
|
2063
2097
|
var createTokens = async (opts) => {
|
|
2064
|
-
const { colors, typography: typography2, name, borderRadius } = opts;
|
|
2098
|
+
const { colors, typography: typography2, name, borderRadius, overrides } = opts;
|
|
2065
2099
|
const colorSchemes = ["light", "dark"];
|
|
2066
2100
|
const semantic2 = generateSemantic(colors);
|
|
2067
2101
|
const tokenSets = new Map([
|
|
@@ -2079,7 +2113,7 @@ var createTokens = async (opts) => {
|
|
|
2079
2113
|
[`primitives/modes/typography/secondary/${name}`, generateTypography(name, typography2)],
|
|
2080
2114
|
...colorSchemes.flatMap((scheme) => [
|
|
2081
2115
|
[`primitives/modes/color-scheme/${scheme}/global`, generateColorGlobal(scheme)],
|
|
2082
|
-
[`primitives/modes/color-scheme/${scheme}/${name}`, generateColorScheme(name, scheme, colors)]
|
|
2116
|
+
[`primitives/modes/color-scheme/${scheme}/${name}`, generateColorScheme(name, scheme, colors, overrides)]
|
|
2083
2117
|
]),
|
|
2084
2118
|
[`themes/${name}`, generateTheme(colors, name, borderRadius)],
|
|
2085
2119
|
["semantic/color", semantic2.color],
|
|
@@ -2433,11 +2467,11 @@ import * as R8 from "ramda";
|
|
|
2433
2467
|
// package.json
|
|
2434
2468
|
var package_default = {
|
|
2435
2469
|
name: "@digdir/designsystemet",
|
|
2436
|
-
version: "1.
|
|
2470
|
+
version: "1.6.0",
|
|
2437
2471
|
description: "CLI for Designsystemet",
|
|
2438
2472
|
author: "Designsystemet team",
|
|
2439
2473
|
engines: {
|
|
2440
|
-
node: ">=
|
|
2474
|
+
node: ">=20 <25"
|
|
2441
2475
|
},
|
|
2442
2476
|
repository: {
|
|
2443
2477
|
type: "git",
|
|
@@ -2485,7 +2519,7 @@ var package_default = {
|
|
|
2485
2519
|
"test:tokens-build-config-tailwind": "pnpm run designsystemet tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean --experimental-tailwind",
|
|
2486
2520
|
"test:tokens-create-and-build-options": "pnpm test:tokens-create-options && pnpm test:tokens-build",
|
|
2487
2521
|
"test:tokens-create-and-build-config": "pnpm test:tokens-create-config && pnpm test:tokens-build-config",
|
|
2488
|
-
test: "pnpm test:tokens-create-and-build-options && pnpm test:tokens-create-and-build-config",
|
|
2522
|
+
test: "node -v && pnpm test:tokens-create-and-build-options && pnpm test:tokens-create-and-build-config",
|
|
2489
2523
|
"digdir:tokens-build": "pnpm run designsystemet tokens build -t ../../internal/design-tokens -o ../../packages/theme/brand --clean --experimental-tailwind",
|
|
2490
2524
|
"digdir:tokens-create": "pnpm run designsystemet tokens create --config ./configs/digdir.config.json",
|
|
2491
2525
|
"update:template": "tsx ./src/scripts/update-template.ts",
|
|
@@ -2500,7 +2534,7 @@ var package_default = {
|
|
|
2500
2534
|
"change-case": "^5.4.4",
|
|
2501
2535
|
"chroma-js": "^3.1.2",
|
|
2502
2536
|
"colorjs.io": "^0.6.0-alpha.1",
|
|
2503
|
-
commander: "^14.0.
|
|
2537
|
+
commander: "^14.0.1",
|
|
2504
2538
|
"fast-glob": "^3.3.3",
|
|
2505
2539
|
hsluv: "^1.0.1",
|
|
2506
2540
|
"object-hash": "^3.0.0",
|
|
@@ -2508,18 +2542,18 @@ var package_default = {
|
|
|
2508
2542
|
postcss: "^8.5.6",
|
|
2509
2543
|
ramda: "^0.31.3",
|
|
2510
2544
|
"style-dictionary": "^5.0.4",
|
|
2511
|
-
zod: "^4.1.
|
|
2512
|
-
"zod-validation-error": "^4.0.
|
|
2545
|
+
zod: "^4.1.11",
|
|
2546
|
+
"zod-validation-error": "^4.0.2"
|
|
2513
2547
|
},
|
|
2514
2548
|
devDependencies: {
|
|
2515
2549
|
"@tokens-studio/types": "0.5.2",
|
|
2516
2550
|
"@types/apca-w3": "^0.1.3",
|
|
2517
2551
|
"@types/chroma-js": "^3.1.1",
|
|
2518
2552
|
"@types/fs-extra": "^11.0.4",
|
|
2519
|
-
"@types/node": "^22.18.
|
|
2553
|
+
"@types/node": "^22.18.6",
|
|
2520
2554
|
"@types/object-hash": "^3.0.6",
|
|
2521
|
-
"@types/ramda": "^0.31.
|
|
2522
|
-
"fs-extra": "^11.3.
|
|
2555
|
+
"@types/ramda": "^0.31.1",
|
|
2556
|
+
"fs-extra": "^11.3.2",
|
|
2523
2557
|
tslib: "^2.8.1",
|
|
2524
2558
|
tsup: "^8.5.0",
|
|
2525
2559
|
tsx: "^4.20.5",
|
|
@@ -2582,11 +2616,11 @@ function isColorCategoryToken(token, category) {
|
|
|
2582
2616
|
var isDigit = (s) => /^\d+$/.test(s);
|
|
2583
2617
|
function traverseObj(obj, fn) {
|
|
2584
2618
|
for (const key in obj) {
|
|
2585
|
-
const
|
|
2586
|
-
if (
|
|
2587
|
-
fn.apply(null, [obj, key,
|
|
2588
|
-
if (typeof
|
|
2589
|
-
traverseObj(
|
|
2619
|
+
const prop3 = obj[key];
|
|
2620
|
+
if (prop3 != null) {
|
|
2621
|
+
fn.apply(null, [obj, key, prop3]);
|
|
2622
|
+
if (typeof prop3 === "object") {
|
|
2623
|
+
traverseObj(prop3, fn);
|
|
2590
2624
|
}
|
|
2591
2625
|
}
|
|
2592
2626
|
}
|
|
@@ -3117,13 +3151,33 @@ ${content}
|
|
|
3117
3151
|
// src/tokens/process/formats/css/type-scale.ts
|
|
3118
3152
|
import * as R15 from "ramda";
|
|
3119
3153
|
import { createPropertyFormatter as createPropertyFormatter6 } from "style-dictionary/utils";
|
|
3120
|
-
var
|
|
3154
|
+
var isTypographyFontFamilyToken = R15.allPass([
|
|
3121
3155
|
R15.pathSatisfies(R15.includes("typography"), ["path"]),
|
|
3122
3156
|
R15.pathSatisfies(R15.includes("fontFamily"), ["path"])
|
|
3123
3157
|
]);
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3158
|
+
var formatTypographySizeToken = (format, token) => {
|
|
3159
|
+
const [name, value] = format(token).replace(/;$/, "").split(": ");
|
|
3160
|
+
let calc;
|
|
3161
|
+
let round;
|
|
3162
|
+
if (R15.startsWith(["font-size"], token.path)) {
|
|
3163
|
+
calc = `calc(${value} * var(--_ds-font-size-factor))`;
|
|
3164
|
+
round = `round(${calc}, 1px)`;
|
|
3165
|
+
} else {
|
|
3166
|
+
calc = value;
|
|
3167
|
+
}
|
|
3168
|
+
return { name, calc, round: round ?? calc };
|
|
3169
|
+
};
|
|
3170
|
+
var formatTypographySizeTokens = (format, tokens) => R15.reduce(
|
|
3171
|
+
(acc, token) => {
|
|
3172
|
+
const { name, calc, round } = formatTypographySizeToken(format, token);
|
|
3173
|
+
acc.tokens.push(token);
|
|
3174
|
+
acc.calc.push(`${name}: ${calc};`);
|
|
3175
|
+
acc.round.push(`${name}: ${round};`);
|
|
3176
|
+
return acc;
|
|
3177
|
+
},
|
|
3178
|
+
{ tokens: [], calc: [], round: [] },
|
|
3179
|
+
tokens
|
|
3180
|
+
);
|
|
3127
3181
|
var typeScale = {
|
|
3128
3182
|
name: "ds/css-type-scale",
|
|
3129
3183
|
format: async ({ dictionary, file, options, platform }) => {
|
|
@@ -3136,18 +3190,16 @@ var typeScale = {
|
|
|
3136
3190
|
format: "css",
|
|
3137
3191
|
usesDtcg
|
|
3138
3192
|
});
|
|
3139
|
-
const filteredTokens = R15.reject(
|
|
3140
|
-
const
|
|
3141
|
-
const formattedMap =
|
|
3142
|
-
token,
|
|
3143
|
-
formatted:
|
|
3193
|
+
const filteredTokens = R15.reject(R15.anyPass([isTypographyFontFamilyToken]), dictionary.allTokens);
|
|
3194
|
+
const formattedTokens = formatTypographySizeTokens(format, filteredTokens);
|
|
3195
|
+
const formattedMap = formattedTokens.round.map((t, i) => ({
|
|
3196
|
+
token: formattedTokens.tokens[i],
|
|
3197
|
+
formatted: t
|
|
3144
3198
|
}));
|
|
3145
3199
|
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
3146
|
-
const formattedTokens = formattedMap.map(R15.prop("formatted")).join("\n");
|
|
3147
3200
|
const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
|
|
3148
3201
|
const content = `${selector} {
|
|
3149
|
-
${sizeFactor}
|
|
3150
|
-
${formattedTokens}
|
|
3202
|
+
${sizeFactor}${sizingTemplate(formattedTokens)}
|
|
3151
3203
|
}`;
|
|
3152
3204
|
const body = R15.isNotNil(layer) ? `@layer ${layer} {
|
|
3153
3205
|
${content}
|
|
@@ -3360,7 +3412,7 @@ var sizeModeVariables = ({ theme, size: size2 }) => {
|
|
|
3360
3412
|
};
|
|
3361
3413
|
|
|
3362
3414
|
// src/tokens/process/configs/type-scale.ts
|
|
3363
|
-
var typeScaleVariables = ({ theme
|
|
3415
|
+
var typeScaleVariables = ({ theme }) => {
|
|
3364
3416
|
const selector = ":root, [data-size]";
|
|
3365
3417
|
const layer = `ds.theme.type-scale`;
|
|
3366
3418
|
return {
|
|
@@ -300,7 +300,7 @@ var sizeModeVariables = ({ theme, size: size2 }) => {
|
|
|
300
300
|
};
|
|
301
301
|
|
|
302
302
|
// src/tokens/process/configs/type-scale.ts
|
|
303
|
-
var typeScaleVariables = ({ theme
|
|
303
|
+
var typeScaleVariables = ({ theme }) => {
|
|
304
304
|
const selector = ":root, [data-size]";
|
|
305
305
|
const layer = `ds.theme.type-scale`;
|
|
306
306
|
return {
|
|
@@ -944,13 +944,33 @@ ${content}
|
|
|
944
944
|
// src/tokens/process/formats/css/type-scale.ts
|
|
945
945
|
import * as R14 from "ramda";
|
|
946
946
|
import { createPropertyFormatter as createPropertyFormatter6 } from "style-dictionary/utils";
|
|
947
|
-
var
|
|
947
|
+
var isTypographyFontFamilyToken = R14.allPass([
|
|
948
948
|
R14.pathSatisfies(R14.includes("typography"), ["path"]),
|
|
949
949
|
R14.pathSatisfies(R14.includes("fontFamily"), ["path"])
|
|
950
950
|
]);
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
951
|
+
var formatTypographySizeToken = (format, token) => {
|
|
952
|
+
const [name, value] = format(token).replace(/;$/, "").split(": ");
|
|
953
|
+
let calc;
|
|
954
|
+
let round;
|
|
955
|
+
if (R14.startsWith(["font-size"], token.path)) {
|
|
956
|
+
calc = `calc(${value} * var(--_ds-font-size-factor))`;
|
|
957
|
+
round = `round(${calc}, 1px)`;
|
|
958
|
+
} else {
|
|
959
|
+
calc = value;
|
|
960
|
+
}
|
|
961
|
+
return { name, calc, round: round ?? calc };
|
|
962
|
+
};
|
|
963
|
+
var formatTypographySizeTokens = (format, tokens) => R14.reduce(
|
|
964
|
+
(acc, token) => {
|
|
965
|
+
const { name, calc, round } = formatTypographySizeToken(format, token);
|
|
966
|
+
acc.tokens.push(token);
|
|
967
|
+
acc.calc.push(`${name}: ${calc};`);
|
|
968
|
+
acc.round.push(`${name}: ${round};`);
|
|
969
|
+
return acc;
|
|
970
|
+
},
|
|
971
|
+
{ tokens: [], calc: [], round: [] },
|
|
972
|
+
tokens
|
|
973
|
+
);
|
|
954
974
|
var typeScale = {
|
|
955
975
|
name: "ds/css-type-scale",
|
|
956
976
|
format: async ({ dictionary, file, options, platform }) => {
|
|
@@ -963,18 +983,16 @@ var typeScale = {
|
|
|
963
983
|
format: "css",
|
|
964
984
|
usesDtcg
|
|
965
985
|
});
|
|
966
|
-
const filteredTokens = R14.reject(
|
|
967
|
-
const
|
|
968
|
-
const formattedMap =
|
|
969
|
-
token,
|
|
970
|
-
formatted:
|
|
986
|
+
const filteredTokens = R14.reject(R14.anyPass([isTypographyFontFamilyToken]), dictionary.allTokens);
|
|
987
|
+
const formattedTokens = formatTypographySizeTokens(format, filteredTokens);
|
|
988
|
+
const formattedMap = formattedTokens.round.map((t, i) => ({
|
|
989
|
+
token: formattedTokens.tokens[i],
|
|
990
|
+
formatted: t
|
|
971
991
|
}));
|
|
972
992
|
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
973
|
-
const formattedTokens = formattedMap.map(R14.prop("formatted")).join("\n");
|
|
974
993
|
const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
|
|
975
994
|
const content = `${selector} {
|
|
976
|
-
${sizeFactor}
|
|
977
|
-
${formattedTokens}
|
|
995
|
+
${sizeFactor}${sizingTemplate(formattedTokens)}
|
|
978
996
|
}`;
|
|
979
997
|
const body = R14.isNotNil(layer) ? `@layer ${layer} {
|
|
980
998
|
${content}
|
|
@@ -326,7 +326,7 @@ var sizeModeVariables = ({ theme, size: size2 }) => {
|
|
|
326
326
|
};
|
|
327
327
|
|
|
328
328
|
// src/tokens/process/configs/type-scale.ts
|
|
329
|
-
var typeScaleVariables = ({ theme
|
|
329
|
+
var typeScaleVariables = ({ theme }) => {
|
|
330
330
|
const selector = ":root, [data-size]";
|
|
331
331
|
const layer = `ds.theme.type-scale`;
|
|
332
332
|
return {
|
|
@@ -970,13 +970,33 @@ ${content}
|
|
|
970
970
|
// src/tokens/process/formats/css/type-scale.ts
|
|
971
971
|
import * as R14 from "ramda";
|
|
972
972
|
import { createPropertyFormatter as createPropertyFormatter6 } from "style-dictionary/utils";
|
|
973
|
-
var
|
|
973
|
+
var isTypographyFontFamilyToken = R14.allPass([
|
|
974
974
|
R14.pathSatisfies(R14.includes("typography"), ["path"]),
|
|
975
975
|
R14.pathSatisfies(R14.includes("fontFamily"), ["path"])
|
|
976
976
|
]);
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
977
|
+
var formatTypographySizeToken = (format, token) => {
|
|
978
|
+
const [name, value] = format(token).replace(/;$/, "").split(": ");
|
|
979
|
+
let calc;
|
|
980
|
+
let round;
|
|
981
|
+
if (R14.startsWith(["font-size"], token.path)) {
|
|
982
|
+
calc = `calc(${value} * var(--_ds-font-size-factor))`;
|
|
983
|
+
round = `round(${calc}, 1px)`;
|
|
984
|
+
} else {
|
|
985
|
+
calc = value;
|
|
986
|
+
}
|
|
987
|
+
return { name, calc, round: round ?? calc };
|
|
988
|
+
};
|
|
989
|
+
var formatTypographySizeTokens = (format, tokens) => R14.reduce(
|
|
990
|
+
(acc, token) => {
|
|
991
|
+
const { name, calc, round } = formatTypographySizeToken(format, token);
|
|
992
|
+
acc.tokens.push(token);
|
|
993
|
+
acc.calc.push(`${name}: ${calc};`);
|
|
994
|
+
acc.round.push(`${name}: ${round};`);
|
|
995
|
+
return acc;
|
|
996
|
+
},
|
|
997
|
+
{ tokens: [], calc: [], round: [] },
|
|
998
|
+
tokens
|
|
999
|
+
);
|
|
980
1000
|
var typeScale = {
|
|
981
1001
|
name: "ds/css-type-scale",
|
|
982
1002
|
format: async ({ dictionary, file, options, platform }) => {
|
|
@@ -989,18 +1009,16 @@ var typeScale = {
|
|
|
989
1009
|
format: "css",
|
|
990
1010
|
usesDtcg
|
|
991
1011
|
});
|
|
992
|
-
const filteredTokens = R14.reject(
|
|
993
|
-
const
|
|
994
|
-
const formattedMap =
|
|
995
|
-
token,
|
|
996
|
-
formatted:
|
|
1012
|
+
const filteredTokens = R14.reject(R14.anyPass([isTypographyFontFamilyToken]), dictionary.allTokens);
|
|
1013
|
+
const formattedTokens = formatTypographySizeTokens(format, filteredTokens);
|
|
1014
|
+
const formattedMap = formattedTokens.round.map((t, i) => ({
|
|
1015
|
+
token: formattedTokens.tokens[i],
|
|
1016
|
+
formatted: t
|
|
997
1017
|
}));
|
|
998
1018
|
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
999
|
-
const formattedTokens = formattedMap.map(R14.prop("formatted")).join("\n");
|
|
1000
1019
|
const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
|
|
1001
1020
|
const content = `${selector} {
|
|
1002
|
-
${sizeFactor}
|
|
1003
|
-
${formattedTokens}
|
|
1021
|
+
${sizeFactor}${sizingTemplate(formattedTokens)}
|
|
1004
1022
|
}`;
|
|
1005
1023
|
const body = R14.isNotNil(layer) ? `@layer ${layer} {
|
|
1006
1024
|
${content}
|
|
@@ -337,7 +337,7 @@ var sizeVariables = ({ theme }) => {
|
|
|
337
337
|
};
|
|
338
338
|
|
|
339
339
|
// src/tokens/process/configs/type-scale.ts
|
|
340
|
-
var typeScaleVariables = ({ theme
|
|
340
|
+
var typeScaleVariables = ({ theme }) => {
|
|
341
341
|
const selector = ":root, [data-size]";
|
|
342
342
|
const layer = `ds.theme.type-scale`;
|
|
343
343
|
return {
|
|
@@ -981,13 +981,33 @@ ${content}
|
|
|
981
981
|
// src/tokens/process/formats/css/type-scale.ts
|
|
982
982
|
import * as R14 from "ramda";
|
|
983
983
|
import { createPropertyFormatter as createPropertyFormatter6 } from "style-dictionary/utils";
|
|
984
|
-
var
|
|
984
|
+
var isTypographyFontFamilyToken = R14.allPass([
|
|
985
985
|
R14.pathSatisfies(R14.includes("typography"), ["path"]),
|
|
986
986
|
R14.pathSatisfies(R14.includes("fontFamily"), ["path"])
|
|
987
987
|
]);
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
988
|
+
var formatTypographySizeToken = (format, token) => {
|
|
989
|
+
const [name, value] = format(token).replace(/;$/, "").split(": ");
|
|
990
|
+
let calc;
|
|
991
|
+
let round;
|
|
992
|
+
if (R14.startsWith(["font-size"], token.path)) {
|
|
993
|
+
calc = `calc(${value} * var(--_ds-font-size-factor))`;
|
|
994
|
+
round = `round(${calc}, 1px)`;
|
|
995
|
+
} else {
|
|
996
|
+
calc = value;
|
|
997
|
+
}
|
|
998
|
+
return { name, calc, round: round ?? calc };
|
|
999
|
+
};
|
|
1000
|
+
var formatTypographySizeTokens = (format, tokens) => R14.reduce(
|
|
1001
|
+
(acc, token) => {
|
|
1002
|
+
const { name, calc, round } = formatTypographySizeToken(format, token);
|
|
1003
|
+
acc.tokens.push(token);
|
|
1004
|
+
acc.calc.push(`${name}: ${calc};`);
|
|
1005
|
+
acc.round.push(`${name}: ${round};`);
|
|
1006
|
+
return acc;
|
|
1007
|
+
},
|
|
1008
|
+
{ tokens: [], calc: [], round: [] },
|
|
1009
|
+
tokens
|
|
1010
|
+
);
|
|
991
1011
|
var typeScale = {
|
|
992
1012
|
name: "ds/css-type-scale",
|
|
993
1013
|
format: async ({ dictionary, file, options, platform }) => {
|
|
@@ -1000,18 +1020,16 @@ var typeScale = {
|
|
|
1000
1020
|
format: "css",
|
|
1001
1021
|
usesDtcg
|
|
1002
1022
|
});
|
|
1003
|
-
const filteredTokens = R14.reject(
|
|
1004
|
-
const
|
|
1005
|
-
const formattedMap =
|
|
1006
|
-
token,
|
|
1007
|
-
formatted:
|
|
1023
|
+
const filteredTokens = R14.reject(R14.anyPass([isTypographyFontFamilyToken]), dictionary.allTokens);
|
|
1024
|
+
const formattedTokens = formatTypographySizeTokens(format, filteredTokens);
|
|
1025
|
+
const formattedMap = formattedTokens.round.map((t, i) => ({
|
|
1026
|
+
token: formattedTokens.tokens[i],
|
|
1027
|
+
formatted: t
|
|
1008
1028
|
}));
|
|
1009
1029
|
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
1010
|
-
const formattedTokens = formattedMap.map(R14.prop("formatted")).join("\n");
|
|
1011
1030
|
const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
|
|
1012
1031
|
const content = `${selector} {
|
|
1013
|
-
${sizeFactor}
|
|
1014
|
-
${formattedTokens}
|
|
1032
|
+
${sizeFactor}${sizingTemplate(formattedTokens)}
|
|
1015
1033
|
}`;
|
|
1016
1034
|
const body = R14.isNotNil(layer) ? `@layer ${layer} {
|
|
1017
1035
|
${content}
|
|
@@ -332,7 +332,7 @@ var sizeModeVariables = ({ theme, size: size2 }) => {
|
|
|
332
332
|
};
|
|
333
333
|
|
|
334
334
|
// src/tokens/process/configs/type-scale.ts
|
|
335
|
-
var typeScaleVariables = ({ theme
|
|
335
|
+
var typeScaleVariables = ({ theme }) => {
|
|
336
336
|
const selector = ":root, [data-size]";
|
|
337
337
|
const layer = `ds.theme.type-scale`;
|
|
338
338
|
return {
|
|
@@ -976,13 +976,33 @@ ${content}
|
|
|
976
976
|
// src/tokens/process/formats/css/type-scale.ts
|
|
977
977
|
import * as R14 from "ramda";
|
|
978
978
|
import { createPropertyFormatter as createPropertyFormatter6 } from "style-dictionary/utils";
|
|
979
|
-
var
|
|
979
|
+
var isTypographyFontFamilyToken = R14.allPass([
|
|
980
980
|
R14.pathSatisfies(R14.includes("typography"), ["path"]),
|
|
981
981
|
R14.pathSatisfies(R14.includes("fontFamily"), ["path"])
|
|
982
982
|
]);
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
983
|
+
var formatTypographySizeToken = (format, token) => {
|
|
984
|
+
const [name, value] = format(token).replace(/;$/, "").split(": ");
|
|
985
|
+
let calc;
|
|
986
|
+
let round;
|
|
987
|
+
if (R14.startsWith(["font-size"], token.path)) {
|
|
988
|
+
calc = `calc(${value} * var(--_ds-font-size-factor))`;
|
|
989
|
+
round = `round(${calc}, 1px)`;
|
|
990
|
+
} else {
|
|
991
|
+
calc = value;
|
|
992
|
+
}
|
|
993
|
+
return { name, calc, round: round ?? calc };
|
|
994
|
+
};
|
|
995
|
+
var formatTypographySizeTokens = (format, tokens) => R14.reduce(
|
|
996
|
+
(acc, token) => {
|
|
997
|
+
const { name, calc, round } = formatTypographySizeToken(format, token);
|
|
998
|
+
acc.tokens.push(token);
|
|
999
|
+
acc.calc.push(`${name}: ${calc};`);
|
|
1000
|
+
acc.round.push(`${name}: ${round};`);
|
|
1001
|
+
return acc;
|
|
1002
|
+
},
|
|
1003
|
+
{ tokens: [], calc: [], round: [] },
|
|
1004
|
+
tokens
|
|
1005
|
+
);
|
|
986
1006
|
var typeScale = {
|
|
987
1007
|
name: "ds/css-type-scale",
|
|
988
1008
|
format: async ({ dictionary, file, options, platform }) => {
|
|
@@ -995,18 +1015,16 @@ var typeScale = {
|
|
|
995
1015
|
format: "css",
|
|
996
1016
|
usesDtcg
|
|
997
1017
|
});
|
|
998
|
-
const filteredTokens = R14.reject(
|
|
999
|
-
const
|
|
1000
|
-
const formattedMap =
|
|
1001
|
-
token,
|
|
1002
|
-
formatted:
|
|
1018
|
+
const filteredTokens = R14.reject(R14.anyPass([isTypographyFontFamilyToken]), dictionary.allTokens);
|
|
1019
|
+
const formattedTokens = formatTypographySizeTokens(format, filteredTokens);
|
|
1020
|
+
const formattedMap = formattedTokens.round.map((t, i) => ({
|
|
1021
|
+
token: formattedTokens.tokens[i],
|
|
1022
|
+
formatted: t
|
|
1003
1023
|
}));
|
|
1004
1024
|
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
1005
|
-
const formattedTokens = formattedMap.map(R14.prop("formatted")).join("\n");
|
|
1006
1025
|
const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
|
|
1007
1026
|
const content = `${selector} {
|
|
1008
|
-
${sizeFactor}
|
|
1009
|
-
${formattedTokens}
|
|
1027
|
+
${sizeFactor}${sizingTemplate(formattedTokens)}
|
|
1010
1028
|
}`;
|
|
1011
1029
|
const body = R14.isNotNil(layer) ? `@layer ${layer} {
|
|
1012
1030
|
${content}
|
|
@@ -969,13 +969,33 @@ ${content}
|
|
|
969
969
|
// src/tokens/process/formats/css/type-scale.ts
|
|
970
970
|
import * as R15 from "ramda";
|
|
971
971
|
import { createPropertyFormatter as createPropertyFormatter6 } from "style-dictionary/utils";
|
|
972
|
-
var
|
|
972
|
+
var isTypographyFontFamilyToken = R15.allPass([
|
|
973
973
|
R15.pathSatisfies(R15.includes("typography"), ["path"]),
|
|
974
974
|
R15.pathSatisfies(R15.includes("fontFamily"), ["path"])
|
|
975
975
|
]);
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
976
|
+
var formatTypographySizeToken = (format, token) => {
|
|
977
|
+
const [name, value] = format(token).replace(/;$/, "").split(": ");
|
|
978
|
+
let calc;
|
|
979
|
+
let round;
|
|
980
|
+
if (R15.startsWith(["font-size"], token.path)) {
|
|
981
|
+
calc = `calc(${value} * var(--_ds-font-size-factor))`;
|
|
982
|
+
round = `round(${calc}, 1px)`;
|
|
983
|
+
} else {
|
|
984
|
+
calc = value;
|
|
985
|
+
}
|
|
986
|
+
return { name, calc, round: round ?? calc };
|
|
987
|
+
};
|
|
988
|
+
var formatTypographySizeTokens = (format, tokens) => R15.reduce(
|
|
989
|
+
(acc, token) => {
|
|
990
|
+
const { name, calc, round } = formatTypographySizeToken(format, token);
|
|
991
|
+
acc.tokens.push(token);
|
|
992
|
+
acc.calc.push(`${name}: ${calc};`);
|
|
993
|
+
acc.round.push(`${name}: ${round};`);
|
|
994
|
+
return acc;
|
|
995
|
+
},
|
|
996
|
+
{ tokens: [], calc: [], round: [] },
|
|
997
|
+
tokens
|
|
998
|
+
);
|
|
979
999
|
var typeScale = {
|
|
980
1000
|
name: "ds/css-type-scale",
|
|
981
1001
|
format: async ({ dictionary, file, options, platform }) => {
|
|
@@ -988,18 +1008,16 @@ var typeScale = {
|
|
|
988
1008
|
format: "css",
|
|
989
1009
|
usesDtcg
|
|
990
1010
|
});
|
|
991
|
-
const filteredTokens = R15.reject(
|
|
992
|
-
const
|
|
993
|
-
const formattedMap =
|
|
994
|
-
token,
|
|
995
|
-
formatted:
|
|
1011
|
+
const filteredTokens = R15.reject(R15.anyPass([isTypographyFontFamilyToken]), dictionary.allTokens);
|
|
1012
|
+
const formattedTokens = formatTypographySizeTokens(format, filteredTokens);
|
|
1013
|
+
const formattedMap = formattedTokens.round.map((t, i) => ({
|
|
1014
|
+
token: formattedTokens.tokens[i],
|
|
1015
|
+
formatted: t
|
|
996
1016
|
}));
|
|
997
1017
|
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
998
|
-
const formattedTokens = formattedMap.map(R15.prop("formatted")).join("\n");
|
|
999
1018
|
const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
|
|
1000
1019
|
const content = `${selector} {
|
|
1001
|
-
${sizeFactor}
|
|
1002
|
-
${formattedTokens}
|
|
1020
|
+
${sizeFactor}${sizingTemplate(formattedTokens)}
|
|
1003
1021
|
}`;
|
|
1004
1022
|
const body = R15.isNotNil(layer) ? `@layer ${layer} {
|
|
1005
1023
|
${content}
|
|
@@ -1020,7 +1038,7 @@ var formats = {
|
|
|
1020
1038
|
};
|
|
1021
1039
|
|
|
1022
1040
|
// src/tokens/process/configs/type-scale.ts
|
|
1023
|
-
var typeScaleVariables = ({ theme
|
|
1041
|
+
var typeScaleVariables = ({ theme }) => {
|
|
1024
1042
|
const selector = ":root, [data-size]";
|
|
1025
1043
|
const layer = `ds.theme.type-scale`;
|
|
1026
1044
|
return {
|