@digdir/designsystemet 1.5.1 → 1.6.1
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 +106 -44
- 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 +91 -38
- package/dist/src/scripts/createJsonSchema.js +12 -1
- package/dist/src/scripts/update-preview-tokens.js +79 -27
- package/dist/src/tokens/build.js +46 -28
- package/dist/src/tokens/create/generators/$designsystemet.js +11 -11
- 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 +11 -11
- package/dist/src/tokens/create.js +44 -10
- package/dist/src/tokens/format.js +90 -38
- package/dist/src/tokens/index.js +90 -38
- package/dist/src/tokens/process/configs/color.js +30 -12
- package/dist/src/tokens/process/configs/semantic.js +30 -12
- package/dist/src/tokens/process/configs/size-mode.js +30 -12
- package/dist/src/tokens/process/configs/size.js +30 -12
- package/dist/src/tokens/process/configs/type-scale.js +30 -12
- package/dist/src/tokens/process/configs/typography.js +30 -12
- package/dist/src/tokens/process/configs.js +35 -17
- package/dist/src/tokens/process/formats/css/color.js +30 -12
- package/dist/src/tokens/process/formats/css/semantic.js +30 -12
- package/dist/src/tokens/process/formats/css/size-mode.js +30 -12
- 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 +32 -13
- package/dist/src/tokens/process/formats/css/type-scale.d.ts.map +1 -1
- package/dist/src/tokens/process/formats/css/type-scale.js +30 -12
- package/dist/src/tokens/process/formats/css/typography.js +32 -14
- package/dist/src/tokens/process/formats/css.js +30 -12
- package/dist/src/tokens/process/output/declarations.js +41 -23
- package/dist/src/tokens/process/output/theme.js +11 -11
- package/dist/src/tokens/process/platform.js +35 -17
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +30 -12
- package/dist/src/tokens/types.d.ts +1 -1
- package/dist/src/tokens/types.d.ts.map +1 -1
- package/package.json +11 -11
|
@@ -58,11 +58,11 @@ function isColorCategoryToken(token, category) {
|
|
|
58
58
|
var isDigit = (s) => /^\d+$/.test(s);
|
|
59
59
|
function traverseObj(obj, fn) {
|
|
60
60
|
for (const key in obj) {
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
63
|
-
fn.apply(null, [obj, key,
|
|
64
|
-
if (typeof
|
|
65
|
-
traverseObj(
|
|
61
|
+
const prop3 = obj[key];
|
|
62
|
+
if (prop3 != null) {
|
|
63
|
+
fn.apply(null, [obj, key, prop3]);
|
|
64
|
+
if (typeof prop3 === "object") {
|
|
65
|
+
traverseObj(prop3, fn);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
}
|
|
@@ -807,13 +807,33 @@ ${content}
|
|
|
807
807
|
// src/tokens/process/formats/css/type-scale.ts
|
|
808
808
|
import * as R10 from "ramda";
|
|
809
809
|
import { createPropertyFormatter as createPropertyFormatter6 } from "style-dictionary/utils";
|
|
810
|
-
var
|
|
810
|
+
var isTypographyFontFamilyToken = R10.allPass([
|
|
811
811
|
R10.pathSatisfies(R10.includes("typography"), ["path"]),
|
|
812
812
|
R10.pathSatisfies(R10.includes("fontFamily"), ["path"])
|
|
813
813
|
]);
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
814
|
+
var formatTypographySizeToken = (format, token) => {
|
|
815
|
+
const [name, value] = format(token).replace(/;$/, "").split(": ");
|
|
816
|
+
let calc;
|
|
817
|
+
let round;
|
|
818
|
+
if (R10.startsWith(["font-size"], token.path)) {
|
|
819
|
+
calc = `calc(${value} * var(--_ds-font-size-factor))`;
|
|
820
|
+
round = `round(${calc}, 1px)`;
|
|
821
|
+
} else {
|
|
822
|
+
calc = value;
|
|
823
|
+
}
|
|
824
|
+
return { name, calc, round: round ?? calc };
|
|
825
|
+
};
|
|
826
|
+
var formatTypographySizeTokens = (format, tokens) => R10.reduce(
|
|
827
|
+
(acc, token) => {
|
|
828
|
+
const { name, calc, round } = formatTypographySizeToken(format, token);
|
|
829
|
+
acc.tokens.push(token);
|
|
830
|
+
acc.calc.push(`${name}: ${calc};`);
|
|
831
|
+
acc.round.push(`${name}: ${round};`);
|
|
832
|
+
return acc;
|
|
833
|
+
},
|
|
834
|
+
{ tokens: [], calc: [], round: [] },
|
|
835
|
+
tokens
|
|
836
|
+
);
|
|
817
837
|
var typeScale = {
|
|
818
838
|
name: "ds/css-type-scale",
|
|
819
839
|
format: async ({ dictionary, file, options, platform }) => {
|
|
@@ -826,18 +846,16 @@ var typeScale = {
|
|
|
826
846
|
format: "css",
|
|
827
847
|
usesDtcg
|
|
828
848
|
});
|
|
829
|
-
const filteredTokens = R10.reject(
|
|
830
|
-
const
|
|
831
|
-
const formattedMap =
|
|
832
|
-
token,
|
|
833
|
-
formatted:
|
|
849
|
+
const filteredTokens = R10.reject(R10.anyPass([isTypographyFontFamilyToken]), dictionary.allTokens);
|
|
850
|
+
const formattedTokens = formatTypographySizeTokens(format, filteredTokens);
|
|
851
|
+
const formattedMap = formattedTokens.round.map((t, i) => ({
|
|
852
|
+
token: formattedTokens.tokens[i],
|
|
853
|
+
formatted: t
|
|
834
854
|
}));
|
|
835
855
|
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
836
|
-
const formattedTokens = formattedMap.map(R10.prop("formatted")).join("\n");
|
|
837
856
|
const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
|
|
838
857
|
const content = `${selector} {
|
|
839
|
-
${sizeFactor}
|
|
840
|
-
${formattedTokens}
|
|
858
|
+
${sizeFactor}${sizingTemplate(formattedTokens)}
|
|
841
859
|
}`;
|
|
842
860
|
const body = R10.isNotNil(layer) ? `@layer ${layer} {
|
|
843
861
|
${content}
|
|
@@ -401,13 +401,33 @@ ${content}
|
|
|
401
401
|
// src/tokens/process/formats/css/type-scale.ts
|
|
402
402
|
import * as R7 from "ramda";
|
|
403
403
|
import { createPropertyFormatter as createPropertyFormatter5 } from "style-dictionary/utils";
|
|
404
|
-
var
|
|
404
|
+
var isTypographyFontFamilyToken = R7.allPass([
|
|
405
405
|
R7.pathSatisfies(R7.includes("typography"), ["path"]),
|
|
406
406
|
R7.pathSatisfies(R7.includes("fontFamily"), ["path"])
|
|
407
407
|
]);
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
408
|
+
var formatTypographySizeToken = (format, token) => {
|
|
409
|
+
const [name, value] = format(token).replace(/;$/, "").split(": ");
|
|
410
|
+
let calc;
|
|
411
|
+
let round;
|
|
412
|
+
if (R7.startsWith(["font-size"], token.path)) {
|
|
413
|
+
calc = `calc(${value} * var(--_ds-font-size-factor))`;
|
|
414
|
+
round = `round(${calc}, 1px)`;
|
|
415
|
+
} else {
|
|
416
|
+
calc = value;
|
|
417
|
+
}
|
|
418
|
+
return { name, calc, round: round ?? calc };
|
|
419
|
+
};
|
|
420
|
+
var formatTypographySizeTokens = (format, tokens) => R7.reduce(
|
|
421
|
+
(acc, token) => {
|
|
422
|
+
const { name, calc, round } = formatTypographySizeToken(format, token);
|
|
423
|
+
acc.tokens.push(token);
|
|
424
|
+
acc.calc.push(`${name}: ${calc};`);
|
|
425
|
+
acc.round.push(`${name}: ${round};`);
|
|
426
|
+
return acc;
|
|
427
|
+
},
|
|
428
|
+
{ tokens: [], calc: [], round: [] },
|
|
429
|
+
tokens
|
|
430
|
+
);
|
|
411
431
|
var typeScale = {
|
|
412
432
|
name: "ds/css-type-scale",
|
|
413
433
|
format: async ({ dictionary, file, options, platform }) => {
|
|
@@ -420,18 +440,16 @@ var typeScale = {
|
|
|
420
440
|
format: "css",
|
|
421
441
|
usesDtcg
|
|
422
442
|
});
|
|
423
|
-
const filteredTokens = R7.reject(
|
|
424
|
-
const
|
|
425
|
-
const formattedMap =
|
|
426
|
-
token,
|
|
427
|
-
formatted:
|
|
443
|
+
const filteredTokens = R7.reject(R7.anyPass([isTypographyFontFamilyToken]), dictionary.allTokens);
|
|
444
|
+
const formattedTokens = formatTypographySizeTokens(format, filteredTokens);
|
|
445
|
+
const formattedMap = formattedTokens.round.map((t, i) => ({
|
|
446
|
+
token: formattedTokens.tokens[i],
|
|
447
|
+
formatted: t
|
|
428
448
|
}));
|
|
429
449
|
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
430
|
-
const formattedTokens = formattedMap.map(R7.prop("formatted")).join("\n");
|
|
431
450
|
const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
|
|
432
451
|
const content = `${selector} {
|
|
433
|
-
${sizeFactor}
|
|
434
|
-
${formattedTokens}
|
|
452
|
+
${sizeFactor}${sizingTemplate(formattedTokens)}
|
|
435
453
|
}`;
|
|
436
454
|
const body = R7.isNotNil(layer) ? `@layer ${layer} {
|
|
437
455
|
${content}
|
|
@@ -461,13 +461,33 @@ ${content}
|
|
|
461
461
|
// src/tokens/process/formats/css/type-scale.ts
|
|
462
462
|
import * as R7 from "ramda";
|
|
463
463
|
import { createPropertyFormatter as createPropertyFormatter5 } from "style-dictionary/utils";
|
|
464
|
-
var
|
|
464
|
+
var isTypographyFontFamilyToken = R7.allPass([
|
|
465
465
|
R7.pathSatisfies(R7.includes("typography"), ["path"]),
|
|
466
466
|
R7.pathSatisfies(R7.includes("fontFamily"), ["path"])
|
|
467
467
|
]);
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
468
|
+
var formatTypographySizeToken = (format, token) => {
|
|
469
|
+
const [name, value] = format(token).replace(/;$/, "").split(": ");
|
|
470
|
+
let calc;
|
|
471
|
+
let round;
|
|
472
|
+
if (R7.startsWith(["font-size"], token.path)) {
|
|
473
|
+
calc = `calc(${value} * var(--_ds-font-size-factor))`;
|
|
474
|
+
round = `round(${calc}, 1px)`;
|
|
475
|
+
} else {
|
|
476
|
+
calc = value;
|
|
477
|
+
}
|
|
478
|
+
return { name, calc, round: round ?? calc };
|
|
479
|
+
};
|
|
480
|
+
var formatTypographySizeTokens = (format, tokens) => R7.reduce(
|
|
481
|
+
(acc, token) => {
|
|
482
|
+
const { name, calc, round } = formatTypographySizeToken(format, token);
|
|
483
|
+
acc.tokens.push(token);
|
|
484
|
+
acc.calc.push(`${name}: ${calc};`);
|
|
485
|
+
acc.round.push(`${name}: ${round};`);
|
|
486
|
+
return acc;
|
|
487
|
+
},
|
|
488
|
+
{ tokens: [], calc: [], round: [] },
|
|
489
|
+
tokens
|
|
490
|
+
);
|
|
471
491
|
var typeScale = {
|
|
472
492
|
name: "ds/css-type-scale",
|
|
473
493
|
format: async ({ dictionary, file, options, platform }) => {
|
|
@@ -480,18 +500,16 @@ var typeScale = {
|
|
|
480
500
|
format: "css",
|
|
481
501
|
usesDtcg
|
|
482
502
|
});
|
|
483
|
-
const filteredTokens = R7.reject(
|
|
484
|
-
const
|
|
485
|
-
const formattedMap =
|
|
486
|
-
token,
|
|
487
|
-
formatted:
|
|
503
|
+
const filteredTokens = R7.reject(R7.anyPass([isTypographyFontFamilyToken]), dictionary.allTokens);
|
|
504
|
+
const formattedTokens = formatTypographySizeTokens(format, filteredTokens);
|
|
505
|
+
const formattedMap = formattedTokens.round.map((t, i) => ({
|
|
506
|
+
token: formattedTokens.tokens[i],
|
|
507
|
+
formatted: t
|
|
488
508
|
}));
|
|
489
509
|
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
490
|
-
const formattedTokens = formattedMap.map(R7.prop("formatted")).join("\n");
|
|
491
510
|
const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
|
|
492
511
|
const content = `${selector} {
|
|
493
|
-
${sizeFactor}
|
|
494
|
-
${formattedTokens}
|
|
512
|
+
${sizeFactor}${sizingTemplate(formattedTokens)}
|
|
495
513
|
}`;
|
|
496
514
|
const body = R7.isNotNil(layer) ? `@layer ${layer} {
|
|
497
515
|
${content}
|
|
@@ -435,13 +435,33 @@ ${content}
|
|
|
435
435
|
// src/tokens/process/formats/css/type-scale.ts
|
|
436
436
|
import * as R7 from "ramda";
|
|
437
437
|
import { createPropertyFormatter as createPropertyFormatter5 } from "style-dictionary/utils";
|
|
438
|
-
var
|
|
438
|
+
var isTypographyFontFamilyToken = R7.allPass([
|
|
439
439
|
R7.pathSatisfies(R7.includes("typography"), ["path"]),
|
|
440
440
|
R7.pathSatisfies(R7.includes("fontFamily"), ["path"])
|
|
441
441
|
]);
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
442
|
+
var formatTypographySizeToken = (format, token) => {
|
|
443
|
+
const [name, value] = format(token).replace(/;$/, "").split(": ");
|
|
444
|
+
let calc;
|
|
445
|
+
let round;
|
|
446
|
+
if (R7.startsWith(["font-size"], token.path)) {
|
|
447
|
+
calc = `calc(${value} * var(--_ds-font-size-factor))`;
|
|
448
|
+
round = `round(${calc}, 1px)`;
|
|
449
|
+
} else {
|
|
450
|
+
calc = value;
|
|
451
|
+
}
|
|
452
|
+
return { name, calc, round: round ?? calc };
|
|
453
|
+
};
|
|
454
|
+
var formatTypographySizeTokens = (format, tokens) => R7.reduce(
|
|
455
|
+
(acc, token) => {
|
|
456
|
+
const { name, calc, round } = formatTypographySizeToken(format, token);
|
|
457
|
+
acc.tokens.push(token);
|
|
458
|
+
acc.calc.push(`${name}: ${calc};`);
|
|
459
|
+
acc.round.push(`${name}: ${round};`);
|
|
460
|
+
return acc;
|
|
461
|
+
},
|
|
462
|
+
{ tokens: [], calc: [], round: [] },
|
|
463
|
+
tokens
|
|
464
|
+
);
|
|
445
465
|
var typeScale = {
|
|
446
466
|
name: "ds/css-type-scale",
|
|
447
467
|
format: async ({ dictionary, file, options, platform }) => {
|
|
@@ -454,18 +474,16 @@ var typeScale = {
|
|
|
454
474
|
format: "css",
|
|
455
475
|
usesDtcg
|
|
456
476
|
});
|
|
457
|
-
const filteredTokens = R7.reject(
|
|
458
|
-
const
|
|
459
|
-
const formattedMap =
|
|
460
|
-
token,
|
|
461
|
-
formatted:
|
|
477
|
+
const filteredTokens = R7.reject(R7.anyPass([isTypographyFontFamilyToken]), dictionary.allTokens);
|
|
478
|
+
const formattedTokens = formatTypographySizeTokens(format, filteredTokens);
|
|
479
|
+
const formattedMap = formattedTokens.round.map((t, i) => ({
|
|
480
|
+
token: formattedTokens.tokens[i],
|
|
481
|
+
formatted: t
|
|
462
482
|
}));
|
|
463
483
|
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
464
|
-
const formattedTokens = formattedMap.map(R7.prop("formatted")).join("\n");
|
|
465
484
|
const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
|
|
466
485
|
const content = `${selector} {
|
|
467
|
-
${sizeFactor}
|
|
468
|
-
${formattedTokens}
|
|
486
|
+
${sizeFactor}${sizingTemplate(formattedTokens)}
|
|
469
487
|
}`;
|
|
470
488
|
const body = R7.isNotNil(layer) ? `@layer ${layer} {
|
|
471
489
|
${content}
|
|
@@ -13,5 +13,9 @@ export declare const overrideSizingFormula: (format: (t: TransformedToken) => st
|
|
|
13
13
|
round: string;
|
|
14
14
|
calc: string;
|
|
15
15
|
};
|
|
16
|
+
export declare const sizingTemplate: ({ round, calc }: {
|
|
17
|
+
round: string[];
|
|
18
|
+
calc: string[];
|
|
19
|
+
}) => string;
|
|
16
20
|
export declare const size: Format;
|
|
17
21
|
//# sourceMappingURL=size.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"size.d.ts","sourceRoot":"","sources":["../../../../../../src/tokens/process/formats/css/size.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AASrD,eAAO,MAAM,cAAc,MAJY,gBAAgB,YAI+C,CAAC;AAEvG;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,GAAI,QAAQ,CAAC,CAAC,EAAE,gBAAgB,KAAK,MAAM,EAAE,OAAO,gBAAgB;;;;CAmBrG,CAAC;
|
|
1
|
+
{"version":3,"file":"size.d.ts","sourceRoot":"","sources":["../../../../../../src/tokens/process/formats/css/size.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AASrD,eAAO,MAAM,cAAc,MAJY,gBAAgB,YAI+C,CAAC;AAEvG;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,GAAI,QAAQ,CAAC,CAAC,EAAE,gBAAgB,KAAK,MAAM,EAAE,OAAO,gBAAgB;;;;CAmBrG,CAAC;AAwBF,eAAO,MAAM,cAAc,GAAI,iBAAiB;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,WAOlF,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,MAyClB,CAAC"}
|
|
@@ -408,13 +408,33 @@ ${content}
|
|
|
408
408
|
// src/tokens/process/formats/css/type-scale.ts
|
|
409
409
|
import * as R7 from "ramda";
|
|
410
410
|
import { createPropertyFormatter as createPropertyFormatter5 } from "style-dictionary/utils";
|
|
411
|
-
var
|
|
411
|
+
var isTypographyFontFamilyToken = R7.allPass([
|
|
412
412
|
R7.pathSatisfies(R7.includes("typography"), ["path"]),
|
|
413
413
|
R7.pathSatisfies(R7.includes("fontFamily"), ["path"])
|
|
414
414
|
]);
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
415
|
+
var formatTypographySizeToken = (format, token) => {
|
|
416
|
+
const [name, value] = format(token).replace(/;$/, "").split(": ");
|
|
417
|
+
let calc;
|
|
418
|
+
let round;
|
|
419
|
+
if (R7.startsWith(["font-size"], token.path)) {
|
|
420
|
+
calc = `calc(${value} * var(--_ds-font-size-factor))`;
|
|
421
|
+
round = `round(${calc}, 1px)`;
|
|
422
|
+
} else {
|
|
423
|
+
calc = value;
|
|
424
|
+
}
|
|
425
|
+
return { name, calc, round: round ?? calc };
|
|
426
|
+
};
|
|
427
|
+
var formatTypographySizeTokens = (format, tokens) => R7.reduce(
|
|
428
|
+
(acc, token) => {
|
|
429
|
+
const { name, calc, round } = formatTypographySizeToken(format, token);
|
|
430
|
+
acc.tokens.push(token);
|
|
431
|
+
acc.calc.push(`${name}: ${calc};`);
|
|
432
|
+
acc.round.push(`${name}: ${round};`);
|
|
433
|
+
return acc;
|
|
434
|
+
},
|
|
435
|
+
{ tokens: [], calc: [], round: [] },
|
|
436
|
+
tokens
|
|
437
|
+
);
|
|
418
438
|
var typeScale = {
|
|
419
439
|
name: "ds/css-type-scale",
|
|
420
440
|
format: async ({ dictionary, file, options, platform }) => {
|
|
@@ -427,18 +447,16 @@ var typeScale = {
|
|
|
427
447
|
format: "css",
|
|
428
448
|
usesDtcg
|
|
429
449
|
});
|
|
430
|
-
const filteredTokens = R7.reject(
|
|
431
|
-
const
|
|
432
|
-
const formattedMap =
|
|
433
|
-
token,
|
|
434
|
-
formatted:
|
|
450
|
+
const filteredTokens = R7.reject(R7.anyPass([isTypographyFontFamilyToken]), dictionary.allTokens);
|
|
451
|
+
const formattedTokens = formatTypographySizeTokens(format, filteredTokens);
|
|
452
|
+
const formattedMap = formattedTokens.round.map((t, i) => ({
|
|
453
|
+
token: formattedTokens.tokens[i],
|
|
454
|
+
formatted: t
|
|
435
455
|
}));
|
|
436
456
|
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
437
|
-
const formattedTokens = formattedMap.map(R7.prop("formatted")).join("\n");
|
|
438
457
|
const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
|
|
439
458
|
const content = `${selector} {
|
|
440
|
-
${sizeFactor}
|
|
441
|
-
${formattedTokens}
|
|
459
|
+
${sizeFactor}${sizingTemplate(formattedTokens)}
|
|
442
460
|
}`;
|
|
443
461
|
const body = R7.isNotNil(layer) ? `@layer ${layer} {
|
|
444
462
|
${content}
|
|
@@ -1065,5 +1083,6 @@ ${content}
|
|
|
1065
1083
|
export {
|
|
1066
1084
|
isInlineTokens,
|
|
1067
1085
|
overrideSizingFormula,
|
|
1068
|
-
size
|
|
1086
|
+
size,
|
|
1087
|
+
sizingTemplate
|
|
1069
1088
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-scale.d.ts","sourceRoot":"","sources":["../../../../../../src/tokens/process/formats/css/type-scale.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAoB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"type-scale.d.ts","sourceRoot":"","sources":["../../../../../../src/tokens/process/formats/css/type-scale.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAoB,MAAM,wBAAwB,CAAC;AA2CvE,eAAO,MAAM,SAAS,EAAE,MA8BvB,CAAC"}
|
|
@@ -1026,13 +1026,33 @@ var buildConfigs = {
|
|
|
1026
1026
|
};
|
|
1027
1027
|
|
|
1028
1028
|
// src/tokens/process/formats/css/type-scale.ts
|
|
1029
|
-
var
|
|
1029
|
+
var isTypographyFontFamilyToken = R15.allPass([
|
|
1030
1030
|
R15.pathSatisfies(R15.includes("typography"), ["path"]),
|
|
1031
1031
|
R15.pathSatisfies(R15.includes("fontFamily"), ["path"])
|
|
1032
1032
|
]);
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1033
|
+
var formatTypographySizeToken = (format, token) => {
|
|
1034
|
+
const [name, value] = format(token).replace(/;$/, "").split(": ");
|
|
1035
|
+
let calc;
|
|
1036
|
+
let round;
|
|
1037
|
+
if (R15.startsWith(["font-size"], token.path)) {
|
|
1038
|
+
calc = `calc(${value} * var(--_ds-font-size-factor))`;
|
|
1039
|
+
round = `round(${calc}, 1px)`;
|
|
1040
|
+
} else {
|
|
1041
|
+
calc = value;
|
|
1042
|
+
}
|
|
1043
|
+
return { name, calc, round: round ?? calc };
|
|
1044
|
+
};
|
|
1045
|
+
var formatTypographySizeTokens = (format, tokens) => R15.reduce(
|
|
1046
|
+
(acc, token) => {
|
|
1047
|
+
const { name, calc, round } = formatTypographySizeToken(format, token);
|
|
1048
|
+
acc.tokens.push(token);
|
|
1049
|
+
acc.calc.push(`${name}: ${calc};`);
|
|
1050
|
+
acc.round.push(`${name}: ${round};`);
|
|
1051
|
+
return acc;
|
|
1052
|
+
},
|
|
1053
|
+
{ tokens: [], calc: [], round: [] },
|
|
1054
|
+
tokens
|
|
1055
|
+
);
|
|
1036
1056
|
var typeScale = {
|
|
1037
1057
|
name: "ds/css-type-scale",
|
|
1038
1058
|
format: async ({ dictionary, file, options, platform }) => {
|
|
@@ -1045,18 +1065,16 @@ var typeScale = {
|
|
|
1045
1065
|
format: "css",
|
|
1046
1066
|
usesDtcg
|
|
1047
1067
|
});
|
|
1048
|
-
const filteredTokens = R15.reject(
|
|
1049
|
-
const
|
|
1050
|
-
const formattedMap =
|
|
1051
|
-
token,
|
|
1052
|
-
formatted:
|
|
1068
|
+
const filteredTokens = R15.reject(R15.anyPass([isTypographyFontFamilyToken]), dictionary.allTokens);
|
|
1069
|
+
const formattedTokens = formatTypographySizeTokens(format, filteredTokens);
|
|
1070
|
+
const formattedMap = formattedTokens.round.map((t, i) => ({
|
|
1071
|
+
token: formattedTokens.tokens[i],
|
|
1072
|
+
formatted: t
|
|
1053
1073
|
}));
|
|
1054
1074
|
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
1055
|
-
const formattedTokens = formattedMap.map(R15.prop("formatted")).join("\n");
|
|
1056
1075
|
const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
|
|
1057
1076
|
const content = `${selector} {
|
|
1058
|
-
${sizeFactor}
|
|
1059
|
-
${formattedTokens}
|
|
1077
|
+
${sizeFactor}${sizingTemplate(formattedTokens)}
|
|
1060
1078
|
}`;
|
|
1061
1079
|
const body = R15.isNotNil(layer) ? `@layer ${layer} {
|
|
1062
1080
|
${content}
|
|
@@ -460,13 +460,33 @@ ${content}
|
|
|
460
460
|
// src/tokens/process/formats/css/type-scale.ts
|
|
461
461
|
import * as R7 from "ramda";
|
|
462
462
|
import { createPropertyFormatter as createPropertyFormatter5 } from "style-dictionary/utils";
|
|
463
|
-
var
|
|
463
|
+
var isTypographyFontFamilyToken = R7.allPass([
|
|
464
464
|
R7.pathSatisfies(R7.includes("typography"), ["path"]),
|
|
465
465
|
R7.pathSatisfies(R7.includes("fontFamily"), ["path"])
|
|
466
466
|
]);
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
467
|
+
var formatTypographySizeToken = (format, token) => {
|
|
468
|
+
const [name, value] = format(token).replace(/;$/, "").split(": ");
|
|
469
|
+
let calc;
|
|
470
|
+
let round;
|
|
471
|
+
if (R7.startsWith(["font-size"], token.path)) {
|
|
472
|
+
calc = `calc(${value} * var(--_ds-font-size-factor))`;
|
|
473
|
+
round = `round(${calc}, 1px)`;
|
|
474
|
+
} else {
|
|
475
|
+
calc = value;
|
|
476
|
+
}
|
|
477
|
+
return { name, calc, round: round ?? calc };
|
|
478
|
+
};
|
|
479
|
+
var formatTypographySizeTokens = (format, tokens) => R7.reduce(
|
|
480
|
+
(acc, token) => {
|
|
481
|
+
const { name, calc, round } = formatTypographySizeToken(format, token);
|
|
482
|
+
acc.tokens.push(token);
|
|
483
|
+
acc.calc.push(`${name}: ${calc};`);
|
|
484
|
+
acc.round.push(`${name}: ${round};`);
|
|
485
|
+
return acc;
|
|
486
|
+
},
|
|
487
|
+
{ tokens: [], calc: [], round: [] },
|
|
488
|
+
tokens
|
|
489
|
+
);
|
|
470
490
|
var typeScale = {
|
|
471
491
|
name: "ds/css-type-scale",
|
|
472
492
|
format: async ({ dictionary, file, options, platform }) => {
|
|
@@ -479,18 +499,16 @@ var typeScale = {
|
|
|
479
499
|
format: "css",
|
|
480
500
|
usesDtcg
|
|
481
501
|
});
|
|
482
|
-
const filteredTokens = R7.reject(
|
|
483
|
-
const
|
|
484
|
-
const formattedMap =
|
|
485
|
-
token,
|
|
486
|
-
formatted:
|
|
502
|
+
const filteredTokens = R7.reject(R7.anyPass([isTypographyFontFamilyToken]), dictionary.allTokens);
|
|
503
|
+
const formattedTokens = formatTypographySizeTokens(format, filteredTokens);
|
|
504
|
+
const formattedMap = formattedTokens.round.map((t, i) => ({
|
|
505
|
+
token: formattedTokens.tokens[i],
|
|
506
|
+
formatted: t
|
|
487
507
|
}));
|
|
488
508
|
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
489
|
-
const formattedTokens = formattedMap.map(R7.prop("formatted")).join("\n");
|
|
490
509
|
const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
|
|
491
510
|
const content = `${selector} {
|
|
492
|
-
${sizeFactor}
|
|
493
|
-
${formattedTokens}
|
|
511
|
+
${sizeFactor}${sizingTemplate(formattedTokens)}
|
|
494
512
|
}`;
|
|
495
513
|
const body = R7.isNotNil(layer) ? `@layer ${layer} {
|
|
496
514
|
${content}
|
|
@@ -1030,7 +1048,7 @@ var buildConfigs = {
|
|
|
1030
1048
|
};
|
|
1031
1049
|
|
|
1032
1050
|
// src/tokens/process/formats/css/typography.ts
|
|
1033
|
-
var
|
|
1051
|
+
var typographyFontFamilyPredicate = R15.allPass([
|
|
1034
1052
|
R15.pathSatisfies(R15.includes("typography"), ["path"]),
|
|
1035
1053
|
R15.pathSatisfies(R15.includes("fontFamily"), ["path"])
|
|
1036
1054
|
]);
|
|
@@ -1046,7 +1064,7 @@ var typography = {
|
|
|
1046
1064
|
format: "css",
|
|
1047
1065
|
usesDtcg
|
|
1048
1066
|
});
|
|
1049
|
-
const filteredTokens = R15.reject(
|
|
1067
|
+
const filteredTokens = R15.reject(typographyFontFamilyPredicate, dictionary.allTokens);
|
|
1050
1068
|
const formattedMap = filteredTokens.map((token) => ({
|
|
1051
1069
|
token,
|
|
1052
1070
|
formatted: format(token)
|
|
@@ -1011,13 +1011,33 @@ ${content}
|
|
|
1011
1011
|
// src/tokens/process/formats/css/type-scale.ts
|
|
1012
1012
|
import * as R15 from "ramda";
|
|
1013
1013
|
import { createPropertyFormatter as createPropertyFormatter6 } from "style-dictionary/utils";
|
|
1014
|
-
var
|
|
1014
|
+
var isTypographyFontFamilyToken = R15.allPass([
|
|
1015
1015
|
R15.pathSatisfies(R15.includes("typography"), ["path"]),
|
|
1016
1016
|
R15.pathSatisfies(R15.includes("fontFamily"), ["path"])
|
|
1017
1017
|
]);
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1018
|
+
var formatTypographySizeToken = (format, token) => {
|
|
1019
|
+
const [name, value] = format(token).replace(/;$/, "").split(": ");
|
|
1020
|
+
let calc;
|
|
1021
|
+
let round;
|
|
1022
|
+
if (R15.startsWith(["font-size"], token.path)) {
|
|
1023
|
+
calc = `calc(${value} * var(--_ds-font-size-factor))`;
|
|
1024
|
+
round = `round(${calc}, 1px)`;
|
|
1025
|
+
} else {
|
|
1026
|
+
calc = value;
|
|
1027
|
+
}
|
|
1028
|
+
return { name, calc, round: round ?? calc };
|
|
1029
|
+
};
|
|
1030
|
+
var formatTypographySizeTokens = (format, tokens) => R15.reduce(
|
|
1031
|
+
(acc, token) => {
|
|
1032
|
+
const { name, calc, round } = formatTypographySizeToken(format, token);
|
|
1033
|
+
acc.tokens.push(token);
|
|
1034
|
+
acc.calc.push(`${name}: ${calc};`);
|
|
1035
|
+
acc.round.push(`${name}: ${round};`);
|
|
1036
|
+
return acc;
|
|
1037
|
+
},
|
|
1038
|
+
{ tokens: [], calc: [], round: [] },
|
|
1039
|
+
tokens
|
|
1040
|
+
);
|
|
1021
1041
|
var typeScale = {
|
|
1022
1042
|
name: "ds/css-type-scale",
|
|
1023
1043
|
format: async ({ dictionary, file, options, platform }) => {
|
|
@@ -1030,18 +1050,16 @@ var typeScale = {
|
|
|
1030
1050
|
format: "css",
|
|
1031
1051
|
usesDtcg
|
|
1032
1052
|
});
|
|
1033
|
-
const filteredTokens = R15.reject(
|
|
1034
|
-
const
|
|
1035
|
-
const formattedMap =
|
|
1036
|
-
token,
|
|
1037
|
-
formatted:
|
|
1053
|
+
const filteredTokens = R15.reject(R15.anyPass([isTypographyFontFamilyToken]), dictionary.allTokens);
|
|
1054
|
+
const formattedTokens = formatTypographySizeTokens(format, filteredTokens);
|
|
1055
|
+
const formattedMap = formattedTokens.round.map((t, i) => ({
|
|
1056
|
+
token: formattedTokens.tokens[i],
|
|
1057
|
+
formatted: t
|
|
1038
1058
|
}));
|
|
1039
1059
|
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
1040
|
-
const formattedTokens = formattedMap.map(R15.prop("formatted")).join("\n");
|
|
1041
1060
|
const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
|
|
1042
1061
|
const content = `${selector} {
|
|
1043
|
-
${sizeFactor}
|
|
1044
|
-
${formattedTokens}
|
|
1062
|
+
${sizeFactor}${sizingTemplate(formattedTokens)}
|
|
1045
1063
|
}`;
|
|
1046
1064
|
const body = R15.isNotNil(layer) ? `@layer ${layer} {
|
|
1047
1065
|
${content}
|