@digdir/designsystemet 0.1.0-alpha.6 → 0.1.0-alpha.7

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.
Files changed (30) hide show
  1. package/dist/build/src/index.js +1 -0
  2. package/dist/build/src/migrations/beta-to-v1.js +3 -1
  3. package/dist/build/src/tokens/actions.js +9 -6
  4. package/dist/build/src/tokens/build.js +28 -163
  5. package/dist/build/src/tokens/configs.js +169 -0
  6. package/dist/build/src/tokens/formats/css-classes.js +53 -0
  7. package/dist/build/src/tokens/formats/css-variables.js +17 -0
  8. package/dist/build/src/tokens/formats/{groupedTokens.js → js-tokens.js} +2 -2
  9. package/dist/build/src/tokens/transformers.js +1 -1
  10. package/dist/build/tsconfig.tsbuildinfo +1 -1
  11. package/dist/types/src/index.d.ts +2 -0
  12. package/dist/types/src/index.d.ts.map +1 -0
  13. package/dist/types/src/migrations/beta-to-v1.d.ts.map +1 -1
  14. package/dist/types/src/tokens/actions.d.ts.map +1 -1
  15. package/dist/types/src/tokens/build.d.ts.map +1 -1
  16. package/dist/types/src/tokens/configs.d.ts +21 -0
  17. package/dist/types/src/tokens/configs.d.ts.map +1 -0
  18. package/dist/types/src/tokens/formats/{typographyClasses.d.ts → css-classes.d.ts} +2 -2
  19. package/dist/types/src/tokens/formats/css-classes.d.ts.map +1 -0
  20. package/dist/types/src/tokens/formats/css-variables.d.ts +3 -0
  21. package/dist/types/src/tokens/formats/css-variables.d.ts.map +1 -0
  22. package/dist/types/src/tokens/formats/{groupedTokens.d.ts → js-tokens.d.ts} +2 -2
  23. package/dist/types/src/tokens/formats/js-tokens.d.ts.map +1 -0
  24. package/package.json +3 -3
  25. package/dist/build/src/tokens/formats/scopedReferenceVariables.js +0 -51
  26. package/dist/build/src/tokens/formats/typographyClasses.js +0 -31
  27. package/dist/types/src/tokens/formats/groupedTokens.d.ts.map +0 -1
  28. package/dist/types/src/tokens/formats/scopedReferenceVariables.d.ts +0 -6
  29. package/dist/types/src/tokens/formats/scopedReferenceVariables.d.ts.map +0 -1
  30. package/dist/types/src/tokens/formats/typographyClasses.d.ts.map +0 -1
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"beta-to-v1.d.ts","sourceRoot":"","sources":["../../../../src/migrations/beta-to-v1.ts"],"names":[],"mappings":"gCAGuB,MAAM;AAA7B,wBAiVK"}
1
+ {"version":3,"file":"beta-to-v1.d.ts","sourceRoot":"","sources":["../../../../src/migrations/beta-to-v1.ts"],"names":[],"mappings":"gCAGuB,MAAM;AAA7B,wBAmVK"}
@@ -1 +1 @@
1
- {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../../src/tokens/actions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAIrD,eAAO,MAAM,aAAa,EAAE,MAY3B,CAAC"}
1
+ {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../../src/tokens/actions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAIrD,eAAO,MAAM,aAAa,EAAE,MAmB3B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../../src/tokens/build.ts"],"names":[],"mappings":"AAkKA,KAAK,OAAO,GAAG;IACb,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,8BAA8B;IAC9B,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAkCF,wBAAsB,GAAG,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAgEzD"}
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../../src/tokens/build.ts"],"names":[],"mappings":"AASA,KAAK,OAAO,GAAG;IACb,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,8BAA8B;IAC9B,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAMF,wBAAsB,GAAG,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAqEzD"}
@@ -0,0 +1,21 @@
1
+ import type { Config } from 'style-dictionary/types';
2
+ import type { ThemeObject } from '@tokens-studio/types';
3
+ export declare const permutateThemes: ($themes: ThemeObject[]) => Record<string, string[]>;
4
+ type GetConfig = (options: {
5
+ mode?: string;
6
+ theme?: string;
7
+ semantic?: string;
8
+ fontSize?: string;
9
+ typography?: string;
10
+ outPath?: string;
11
+ }) => Config;
12
+ export declare const cssVariablesConfig: GetConfig;
13
+ export declare const tsTokensConfig: GetConfig;
14
+ export declare const cssTypographyConfig: GetConfig;
15
+ type getConfigs = (getConfig: GetConfig, outPath: string, tokensDir: string, themes: Record<string, string[]>) => {
16
+ name: string;
17
+ config: Config;
18
+ }[];
19
+ export declare const getConfigs: getConfigs;
20
+ export {};
21
+ //# sourceMappingURL=configs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configs.d.ts","sourceRoot":"","sources":["../../../../src/tokens/configs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAoB,MAAM,wBAAwB,CAAC;AAEvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAuDxD,eAAO,MAAM,eAAe,YAAa,WAAW,EAAE,6BAGtB,CAAC;AAEjC,KAAK,SAAS,GAAG,CAAC,OAAO,EAAE;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,KAAK,MAAM,CAAC;AAEb,eAAO,MAAM,kBAAkB,EAAE,SAiChC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,SAqC5B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,SAoCjC,CAAC;AAEF,KAAK,UAAU,GAAG,CAChB,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,KAC7B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC;AAExC,eAAO,MAAM,UAAU,EAAE,UA2Bd,CAAC"}
@@ -2,5 +2,5 @@ import type { Format } from 'style-dictionary/types';
2
2
  /**
3
3
  * Creates CSS classes from typography tokens
4
4
  */
5
- export declare const typographyClasses: Format;
6
- //# sourceMappingURL=typographyClasses.d.ts.map
5
+ export declare const cssClassesTypography: Format;
6
+ //# sourceMappingURL=css-classes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-classes.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/formats/css-classes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAoBrD;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAiElC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Format } from 'style-dictionary/types';
2
+ export declare const cssVariables: Format;
3
+ //# sourceMappingURL=css-variables.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-variables.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/formats/css-variables.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAGrD,eAAO,MAAM,YAAY,EAAE,MAmB1B,CAAC"}
@@ -2,5 +2,5 @@ import type { Format } from 'style-dictionary/types';
2
2
  /**
3
3
  * Format for displaying tokens in storefront
4
4
  */
5
- export declare const groupedTokens: Format;
6
- //# sourceMappingURL=groupedTokens.d.ts.map
5
+ export declare const jsTokens: Format;
6
+ //# sourceMappingURL=js-tokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"js-tokens.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/formats/js-tokens.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAoB,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAYvE;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,MAyBtB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digdir/designsystemet",
3
- "version": "0.1.0-alpha.6",
3
+ "version": "0.1.0-alpha.7",
4
4
  "description": "CLI for Designsystemet",
5
5
  "author": "Designsystemet team",
6
6
  "repository": {
@@ -27,7 +27,7 @@
27
27
  "bin": "dist/build/bin/designsystemet.js",
28
28
  "dependencies": {
29
29
  "@commander-js/extra-typings": "^12.0.1",
30
- "@tokens-studio/sd-transforms": "^0.16.0",
30
+ "@tokens-studio/sd-transforms": "^0.16.1",
31
31
  "chalk": "^5.3.0",
32
32
  "commander": "^12.0.0",
33
33
  "fast-glob": "^3.3.2",
@@ -36,7 +36,7 @@
36
36
  "postcss": "^8.4.38",
37
37
  "ramda": "^0.29.1",
38
38
  "rimraf": "^5.0.5",
39
- "style-dictionary": "^4.0.0-prerelease.27",
39
+ "style-dictionary": "^4.0.0-prerelease.34",
40
40
  "tsup": "^8.0.2"
41
41
  },
42
42
  "devDependencies": {
@@ -1,51 +0,0 @@
1
- import { fileHeader, createPropertyFormatter, usesReferences, getReferences } from 'style-dictionary/utils';
2
- /**
3
- * CSS variables format with option to include source references for matched token through `options.referencesFilter`
4
- */
5
- export const scopedReferenceVariables = {
6
- name: 'css/variables-scoped-references',
7
- format: async function ({ dictionary, file, options }) {
8
- const { allTokens, unfilteredTokens } = dictionary;
9
- const { usesDtcg, outputReferences, mode } = options;
10
- const selector = `${mode === 'light' ? ':root, ' : ''}[data-ds-color-mode="${mode}"]`;
11
- const includeReferences = options.includeReferences;
12
- let referencedTokens = [];
13
- const format = createPropertyFormatter({
14
- outputReferences,
15
- dictionary,
16
- format: 'css',
17
- });
18
- const formatWithReference = createPropertyFormatter({
19
- outputReferences: true,
20
- dictionary,
21
- format: 'css',
22
- });
23
- const parseToken = (token, ignoreSource) => {
24
- const originalValue = (usesDtcg ? token.original.$value : token.original.value);
25
- if (usesReferences(originalValue) && includeReferences(token)) {
26
- const refs = getReferences(originalValue, unfilteredTokens ? unfilteredTokens : {});
27
- referencedTokens = [...referencedTokens, ...refs.filter((x) => x.isSource)];
28
- return formatWithReference(token);
29
- }
30
- if (ignoreSource && !token.isSource) {
31
- return format(token);
32
- }
33
- };
34
- const tokens = allTokens.map((t) => parseToken(t, true)).filter((x) => x);
35
- const referenceTokens = referencedTokens
36
- .reduce((acc, token) => {
37
- if (acc.find((x) => x.name === token.name)) {
38
- return acc;
39
- }
40
- return [...acc, token];
41
- }, [])
42
- .map((token) => format(token))
43
- .filter((formattedValue) => formattedValue);
44
- return fileHeader({ file }).then((fileHeaderText) => `
45
- ${fileHeaderText}
46
- ${selector} {${referenceTokens.length > 0 ? referenceTokens.join('\n') : ''}
47
- ${tokens.join('\n')}
48
- }
49
- `);
50
- },
51
- };
@@ -1,31 +0,0 @@
1
- import * as R from 'ramda';
2
- import { fileHeader } from 'style-dictionary/utils';
3
- // const isTransformedToken = (token: TransformedTokens): token is TransformedToken => token;
4
- /**
5
- * Creates CSS classes from typography tokens
6
- */
7
- export const typographyClasses = {
8
- name: 'typographyClasses',
9
- format: async function ({ dictionary, file, options, platform }) {
10
- const { usesDtcg } = options;
11
- const { basePxFontSize } = platform;
12
- const classNames = R.map((token) => {
13
- if (!Array.isArray(token)) {
14
- const typography = (usesDtcg ? token.$value : token.value);
15
- const baseFontPx = basePxFontSize || 16;
16
- const fontSize = `${parseInt(typography.fontSize) / baseFontPx}rem`;
17
- const selector = R.replace('-typography', '', token.name);
18
- const className = `
19
- .${selector} {
20
- font-size: ${fontSize};
21
- line-height: ${typography?.lineHeight};
22
- font-weight: ${typography?.fontWeight};
23
- }`;
24
- return className;
25
- }
26
- }, dictionary.allTokens);
27
- return fileHeader({ file }).then((fileHeaderText) => `${fileHeaderText}@layer ds.typography {
28
- ${classNames.join('\n')}
29
- }\n`);
30
- },
31
- };
@@ -1 +0,0 @@
1
- {"version":3,"file":"groupedTokens.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/formats/groupedTokens.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAoB,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAYvE;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,MAyB3B,CAAC"}
@@ -1,6 +0,0 @@
1
- import type { Format } from 'style-dictionary/types';
2
- /**
3
- * CSS variables format with option to include source references for matched token through `options.referencesFilter`
4
- */
5
- export declare const scopedReferenceVariables: Format;
6
- //# sourceMappingURL=scopedReferenceVariables.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scopedReferenceVariables.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/formats/scopedReferenceVariables.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoB,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAKvE;;GAEG;AACH,eAAO,MAAM,wBAAwB,EAAE,MA2DtC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"typographyClasses.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/formats/typographyClasses.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAYrD;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,MA+B/B,CAAC"}