@digdir/designsystemet 1.0.2 → 1.0.4
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/dist/bin/designsystemet.js +4264 -45
- package/dist/bin/options.js +5 -4
- package/dist/src/colors/colorMetadata.d.ts.map +1 -1
- package/dist/src/colors/colorMetadata.js +84 -35
- package/dist/src/colors/index.js +470 -4
- package/dist/src/colors/theme.d.ts.map +1 -1
- package/dist/src/colors/theme.js +290 -18
- package/dist/src/colors/types.d.ts +4 -1
- package/dist/src/colors/types.d.ts.map +1 -1
- package/dist/src/colors/utils.js +16 -15
- package/dist/{bin → src}/config.d.ts +46 -1
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +377 -0
- package/dist/src/index.js +3666 -2
- package/dist/src/migrations/beta-to-v1.js +85 -4
- package/dist/src/migrations/codemods/css/plugins.js +5 -4
- package/dist/src/migrations/codemods/css/run.d.ts.map +1 -1
- package/dist/src/migrations/codemods/css/run.js +18 -4
- package/dist/src/migrations/color-rename-next49.js +77 -6
- package/dist/src/migrations/index.d.ts +0 -1
- package/dist/src/migrations/index.d.ts.map +1 -1
- package/dist/src/migrations/index.js +461 -6
- package/dist/src/scripts/createJsonSchema.js +1608 -4
- package/dist/src/scripts/update-design-tokens.d.ts +2 -0
- package/dist/src/scripts/update-design-tokens.d.ts.map +1 -0
- package/dist/src/scripts/update-design-tokens.js +36 -0
- package/dist/src/{tokens/template.d.ts → scripts/update-template.d.ts} +1 -1
- package/dist/src/scripts/update-template.d.ts.map +1 -0
- package/dist/src/scripts/update-template.js +1200 -0
- package/dist/src/tokens/build.d.ts +2 -19
- package/dist/src/tokens/build.d.ts.map +1 -1
- package/dist/src/tokens/build.js +1511 -70
- package/dist/src/tokens/create/defaults.d.ts +7 -0
- package/dist/src/tokens/create/defaults.d.ts.map +1 -0
- package/dist/src/tokens/create/defaults.js +994 -0
- package/dist/src/tokens/create/generators/$designsystemet.d.ts +5 -0
- package/dist/src/tokens/create/generators/$designsystemet.d.ts.map +1 -0
- package/dist/src/tokens/create/generators/$designsystemet.js +100 -0
- package/dist/src/tokens/create/generators/$metadata.d.ts +8 -0
- package/dist/src/tokens/create/generators/$metadata.d.ts.map +1 -0
- package/dist/src/tokens/{write/generate$metadata.js → create/generators/$metadata.js} +3 -2
- package/dist/src/tokens/create/generators/$themes.d.ts +12 -0
- package/dist/src/tokens/create/generators/$themes.d.ts.map +1 -0
- package/dist/src/tokens/create/generators/$themes.js +333 -0
- package/dist/src/tokens/create/generators/color.d.ts +5 -0
- package/dist/src/tokens/create/generators/color.d.ts.map +1 -0
- package/dist/src/tokens/create/generators/color.js +374 -0
- package/dist/src/tokens/create/generators/semantic.d.ts +296 -0
- package/dist/src/tokens/create/generators/semantic.d.ts.map +1 -0
- package/dist/src/tokens/create/generators/semantic.js +483 -0
- package/dist/src/tokens/create/generators/theme.d.ts +3 -0
- package/dist/src/tokens/create/generators/theme.d.ts.map +1 -0
- package/dist/src/tokens/create/generators/theme.js +168 -0
- package/dist/src/tokens/create/generators/typography.d.ts +3 -0
- package/dist/src/tokens/create/generators/typography.d.ts.map +1 -0
- package/dist/src/tokens/create/generators/typography.js +33 -0
- package/dist/src/tokens/{write.d.ts → create/write.d.ts} +2 -2
- package/dist/src/tokens/create/write.d.ts.map +1 -0
- package/dist/src/tokens/create/write.js +546 -0
- package/dist/src/tokens/create.d.ts +4 -2
- package/dist/src/tokens/create.d.ts.map +1 -1
- package/dist/src/tokens/create.js +2049 -59
- package/dist/src/tokens/format.d.ts +16 -0
- package/dist/src/tokens/format.d.ts.map +1 -0
- package/dist/src/tokens/format.js +3514 -0
- package/dist/src/tokens/index.d.ts +1 -0
- package/dist/src/tokens/index.d.ts.map +1 -1
- package/dist/src/tokens/index.js +3526 -2
- package/dist/src/tokens/process/configs/color.d.ts +12 -0
- package/dist/src/tokens/process/configs/color.d.ts.map +1 -0
- package/dist/src/tokens/process/configs/color.js +823 -0
- package/dist/src/tokens/process/configs/semantic.d.ts +3 -0
- package/dist/src/tokens/process/configs/semantic.d.ts.map +1 -0
- package/dist/src/tokens/process/configs/semantic.js +367 -0
- package/dist/src/tokens/process/configs/shared.d.ts +10 -0
- package/dist/src/tokens/process/configs/shared.d.ts.map +1 -0
- package/dist/src/tokens/process/configs/shared.js +99 -0
- package/dist/src/tokens/process/configs/storefront.d.ts +3 -0
- package/dist/src/tokens/process/configs/storefront.d.ts.map +1 -0
- package/dist/src/tokens/process/configs/storefront.js +220 -0
- package/dist/src/tokens/process/configs/typography.d.ts +3 -0
- package/dist/src/tokens/process/configs/typography.d.ts.map +1 -0
- package/dist/src/tokens/process/configs/typography.js +369 -0
- package/dist/src/tokens/{build → process}/configs.d.ts +3 -11
- package/dist/src/tokens/process/configs.d.ts.map +1 -0
- package/dist/src/tokens/process/configs.js +976 -0
- package/dist/src/tokens/process/formats/css/color.d.ts +4 -0
- package/dist/src/tokens/process/formats/css/color.d.ts.map +1 -0
- package/dist/src/tokens/process/formats/css/color.js +128 -0
- package/dist/src/tokens/process/formats/css/semantic.d.ts +17 -0
- package/dist/src/tokens/process/formats/css/semantic.d.ts.map +1 -0
- package/dist/src/tokens/process/formats/css/semantic.js +109 -0
- package/dist/src/tokens/process/formats/css/typography.d.ts +3 -0
- package/dist/src/tokens/process/formats/css/typography.d.ts.map +1 -0
- package/dist/src/tokens/process/formats/css/typography.js +32 -0
- package/dist/src/tokens/process/formats/css.d.ts +8 -0
- package/dist/src/tokens/process/formats/css.d.ts.map +1 -0
- package/dist/src/tokens/{build → process}/formats/css.js +94 -57
- package/dist/src/tokens/process/formats/js-tokens.d.ts.map +1 -0
- package/dist/src/tokens/process/formats/js-tokens.js +109 -0
- package/dist/src/tokens/process/platform.d.ts +87 -0
- package/dist/src/tokens/process/platform.d.ts.map +1 -0
- package/dist/src/tokens/process/platform.js +1090 -0
- package/dist/src/tokens/process/transformers.d.ts.map +1 -0
- package/dist/src/tokens/{build → process}/transformers.js +29 -6
- package/dist/src/tokens/{build → process}/utils/getMultidimensionalThemes.d.ts +3 -3
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.d.ts.map +1 -0
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +922 -0
- package/dist/src/tokens/template/design-tokens/primitives/globals.js +5 -0
- package/dist/src/tokens/template/design-tokens/primitives/modes/size/global.js +5 -0
- package/dist/src/tokens/template/design-tokens/primitives/modes/size/large.js +5 -0
- package/dist/src/tokens/template/design-tokens/primitives/modes/size/medium.js +5 -0
- package/dist/src/tokens/template/design-tokens/primitives/modes/size/small.js +5 -0
- package/dist/src/tokens/template/design-tokens/primitives/modes/typography/size/large.js +5 -0
- package/dist/src/tokens/template/design-tokens/primitives/modes/typography/size/medium.js +5 -0
- package/dist/src/tokens/template/design-tokens/primitives/modes/typography/size/small.js +5 -0
- package/dist/src/tokens/template/design-tokens/primitives/modes/typography/typography.template.js +5 -0
- package/dist/src/tokens/template/design-tokens/semantic/color.base.template.js +5 -0
- package/dist/src/tokens/template/design-tokens/semantic/color.template.js +5 -0
- package/dist/src/tokens/template/design-tokens/semantic/modes/color.template.js +5 -0
- package/dist/src/tokens/template/design-tokens/semantic/style.js +5 -0
- package/dist/src/tokens/template/design-tokens/themes/theme.base.template.js +5 -0
- package/dist/src/tokens/template/design-tokens/themes/theme.template.js +5 -0
- package/dist/src/tokens/types.d.ts +54 -38
- package/dist/src/tokens/types.d.ts.map +1 -1
- package/dist/src/tokens/types.js +8 -0
- package/dist/src/tokens/utils.d.ts +30 -5
- package/dist/src/tokens/utils.d.ts.map +1 -1
- package/dist/src/tokens/utils.js +36 -50
- package/dist/src/utils.d.ts +18 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +63 -0
- package/dist/typography.template-4N5YLH7F.json +22 -0
- package/package.json +17 -16
- package/dist/bin/config.d.ts.map +0 -1
- package/dist/bin/config.js +0 -71
- package/dist/src/migrations/codemods/jsx/classname-prefix.d.ts +0 -10
- package/dist/src/migrations/codemods/jsx/classname-prefix.d.ts.map +0 -1
- package/dist/src/migrations/codemods/jsx/classname-prefix.js +0 -64
- package/dist/src/migrations/codemods/jsx/run.d.ts +0 -7
- package/dist/src/migrations/codemods/jsx/run.d.ts.map +0 -1
- package/dist/src/migrations/codemods/jsx/run.js +0 -22
- package/dist/src/migrations/react-beta-to-v1.d.ts +0 -3
- package/dist/src/migrations/react-beta-to-v1.d.ts.map +0 -1
- package/dist/src/migrations/react-beta-to-v1.js +0 -5
- package/dist/src/scripts/copy-internal-tokens.d.ts +0 -2
- package/dist/src/scripts/copy-internal-tokens.d.ts.map +0 -1
- package/dist/src/scripts/copy-internal-tokens.js +0 -28
- package/dist/src/tokens/build/configs.d.ts.map +0 -1
- package/dist/src/tokens/build/configs.js +0 -280
- package/dist/src/tokens/build/formats/css.d.ts +0 -53
- package/dist/src/tokens/build/formats/css.d.ts.map +0 -1
- package/dist/src/tokens/build/formats/js-tokens.d.ts.map +0 -1
- package/dist/src/tokens/build/formats/js-tokens.js +0 -48
- package/dist/src/tokens/build/transformers.d.ts.map +0 -1
- package/dist/src/tokens/build/types.d.ts +0 -48
- package/dist/src/tokens/build/types.d.ts.map +0 -1
- package/dist/src/tokens/build/types.js +0 -7
- package/dist/src/tokens/build/utils/entryfile.d.ts +0 -12
- package/dist/src/tokens/build/utils/entryfile.d.ts.map +0 -1
- package/dist/src/tokens/build/utils/entryfile.js +0 -67
- package/dist/src/tokens/build/utils/getMultidimensionalThemes.d.ts.map +0 -1
- package/dist/src/tokens/build/utils/getMultidimensionalThemes.js +0 -112
- package/dist/src/tokens/design-tokens/template/$metadata.json +0 -25
- package/dist/src/tokens/design-tokens/template/$themes.json +0 -1498
- package/dist/src/tokens/template.d.ts.map +0 -1
- package/dist/src/tokens/template.js +0 -99
- package/dist/src/tokens/write/generate$metadata.d.ts +0 -9
- package/dist/src/tokens/write/generate$metadata.d.ts.map +0 -1
- package/dist/src/tokens/write/generate$themes.d.ts +0 -12
- package/dist/src/tokens/write/generate$themes.d.ts.map +0 -1
- package/dist/src/tokens/write/generate$themes.js +0 -161
- package/dist/src/tokens/write.d.ts.map +0 -1
- package/dist/src/tokens/write.js +0 -177
- /package/dist/{src/tokens/design-tokens/template/semantic/color-base-file.json → color.base.template-M7BHS4OV.json} +0 -0
- /package/dist/{src/tokens/design-tokens/template/semantic/modes/category-color/category-color-template.json → color.template-LMPUQ72A.json} +0 -0
- /package/dist/{src/tokens/design-tokens/template/semantic/semantic-color-template.json → color.template-XQNSHLTU.json} +0 -0
- /package/dist/{src/tokens/design-tokens/default/primitives/modes/size/global.json → global-XVXVBKM6.json} +0 -0
- /package/dist/{src/tokens/design-tokens/default/primitives/globals.json → globals-76VAFMDF.json} +0 -0
- /package/dist/{src/tokens/design-tokens/default/primitives/modes/typography/size/large.json → large-CIIHO7AY.json} +0 -0
- /package/dist/{src/tokens/design-tokens/default/primitives/modes/size/large.json → large-UUOZ6DYI.json} +0 -0
- /package/dist/{src/tokens/design-tokens/default/primitives/modes/size/medium.json → medium-OQ7S7P4P.json} +0 -0
- /package/dist/{src/tokens/design-tokens/default/primitives/modes/typography/size/medium.json → medium-VSB2S4X3.json} +0 -0
- /package/dist/{src/tokens/design-tokens/default/primitives/modes/typography/size/small.json → small-AEXJ6U7Z.json} +0 -0
- /package/dist/{src/tokens/design-tokens/default/primitives/modes/size/small.json → small-ZY4KOJWX.json} +0 -0
- /package/dist/src/tokens/{build → process}/formats/js-tokens.d.ts +0 -0
- /package/dist/src/tokens/{build → process}/transformers.d.ts +0 -0
- /package/dist/{src/tokens/design-tokens/default/semantic/style.json → style-FP5XVCUD.json} +0 -0
- /package/dist/{src/tokens/design-tokens/template/themes/theme-base-file.json → theme.base.template-Y4RMFBQY.json} +0 -0
- /package/dist/{src/tokens/design-tokens/template/themes/theme-color-template.json → theme.template-CTQRNOMO.json} +0 -0
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { Config as StyleDictionaryConfig, TransformedToken } from 'style-dictionary/types';
|
|
2
|
-
import type { GetStyleDictionaryConfig } from './configs.js';
|
|
3
|
-
export declare const colorCategories: {
|
|
4
|
-
readonly main: "main";
|
|
5
|
-
readonly support: "support";
|
|
6
|
-
};
|
|
7
|
-
export type ColorCategories = keyof typeof colorCategories;
|
|
8
|
-
export type BuiltInColors = 'neutral' | 'success' | 'warning' | 'danger' | 'info';
|
|
9
|
-
/**
|
|
10
|
-
* A multi-dimensional theme is a concrete permutation of the possible theme dimensions
|
|
11
|
-
*/
|
|
12
|
-
export type ThemePermutation = {
|
|
13
|
-
'color-scheme': string;
|
|
14
|
-
'main-color': string;
|
|
15
|
-
'support-color'?: string;
|
|
16
|
-
semantic: string;
|
|
17
|
-
size: string;
|
|
18
|
-
theme: string;
|
|
19
|
-
typography: string;
|
|
20
|
-
};
|
|
21
|
-
export type ThemeDimension = keyof ThemePermutation;
|
|
22
|
-
export type IsCalculatedToken = (token: TransformedToken, options?: StyleDictionaryConfig) => boolean;
|
|
23
|
-
export type GetSdConfigOptions = {
|
|
24
|
-
outPath: string;
|
|
25
|
-
tokensDir: string;
|
|
26
|
-
dry?: boolean;
|
|
27
|
-
};
|
|
28
|
-
export type BuildConfig = {
|
|
29
|
-
/** Optional name of the build config - only used in the console output */
|
|
30
|
-
name?: string;
|
|
31
|
-
/** Style Dictionary configuration creator */
|
|
32
|
-
getConfig: GetStyleDictionaryConfig;
|
|
33
|
-
/** Which theme dimensions to include. `theme` (e.g. digdir/altinn) is always included. */
|
|
34
|
-
dimensions: ThemeDimension[];
|
|
35
|
-
/** Custom options used when creating Style Dictionary configs. If not supplied, the default is used */
|
|
36
|
-
options?: Partial<GetSdConfigOptions>;
|
|
37
|
-
/** Custom build function. If not supplied, the default is used. */
|
|
38
|
-
build?: (sdConfigs: SDConfigForThemePermutation[], options: GetSdConfigOptions) => Promise<void>;
|
|
39
|
-
/** Whether the build config is enabled. @default () => true */
|
|
40
|
-
enabled?: () => boolean;
|
|
41
|
-
/** Custom log message. */
|
|
42
|
-
log?: (config: SDConfigForThemePermutation) => string;
|
|
43
|
-
};
|
|
44
|
-
export type SDConfigForThemePermutation = {
|
|
45
|
-
permutation: ThemePermutation;
|
|
46
|
-
config: StyleDictionaryConfig;
|
|
47
|
-
};
|
|
48
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/tokens/build/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAChG,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAE7D,eAAO,MAAM,eAAe;;;CAGlB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,eAAe,CAAC;AAE3D,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;AAElF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,MAAM,gBAAgB,CAAC;AAEpD,MAAM,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE,qBAAqB,KAAK,OAAO,CAAC;AAEtG,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,0EAA0E;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,SAAS,EAAE,wBAAwB,CAAC;IACpC,0FAA0F;IAC1F,UAAU,EAAE,cAAc,EAAE,CAAC;IAC7B,uGAAuG;IACvG,OAAO,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACtC,mEAAmE;IACnE,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,2BAA2B,EAAE,EAAE,OAAO,EAAE,kBAAkB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACjG,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC;IACxB,0BAA0B;IAC1B,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,2BAA2B,KAAK,MAAM,CAAC;CACvD,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IAAE,WAAW,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,qBAAqB,CAAA;CAAE,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
type EntryFile = (options: {
|
|
2
|
-
outPath: string;
|
|
3
|
-
buildPath: string;
|
|
4
|
-
theme: string;
|
|
5
|
-
dry?: boolean;
|
|
6
|
-
}) => Promise<undefined>;
|
|
7
|
-
/**
|
|
8
|
-
* Creates a CSS entry file that imports base CSS files for a theme
|
|
9
|
-
*/
|
|
10
|
-
export declare const makeEntryFile: EntryFile;
|
|
11
|
-
export {};
|
|
12
|
-
//# sourceMappingURL=entryfile.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entryfile.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/build/utils/entryfile.ts"],"names":[],"mappings":"AAmEA,KAAK,SAAS,GAAG,CAAC,OAAO,EAAE;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,OAAO,CAAC;CACf,KAAK,OAAO,CAAC,SAAS,CAAC,CAAC;AAEzB;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,SAS3B,CAAC"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import glob from "fast-glob";
|
|
3
|
-
import fs from "fs-extra";
|
|
4
|
-
import * as R from "ramda";
|
|
5
|
-
import { writeFile } from "../../utils.js";
|
|
6
|
-
const sortOrder = [
|
|
7
|
-
"color-scheme/light",
|
|
8
|
-
"typography/secondary",
|
|
9
|
-
"semantic",
|
|
10
|
-
"color-scheme/dark",
|
|
11
|
-
"color-scheme/contrast",
|
|
12
|
-
"typography/primary",
|
|
13
|
-
"color/",
|
|
14
|
-
"builtin-colors"
|
|
15
|
-
];
|
|
16
|
-
const sortByDefinedOrder = R.sortBy((fileName) => {
|
|
17
|
-
const sortIndex = sortOrder.findIndex((sortElement) => {
|
|
18
|
-
if (sortElement.endsWith("/")) {
|
|
19
|
-
return fileName.includes(sortElement);
|
|
20
|
-
}
|
|
21
|
-
return fileName.includes(`${sortElement}.css`);
|
|
22
|
-
});
|
|
23
|
-
if (sortIndex === -1) {
|
|
24
|
-
console.error(
|
|
25
|
-
chalk.yellow("WARNING: CSS section does not have a defined sort order:", fileName.replace(".css", ""))
|
|
26
|
-
);
|
|
27
|
-
console.log(
|
|
28
|
-
chalk.dim(
|
|
29
|
-
`
|
|
30
|
-
A Digdir developer should define its order in the sortOrder array in entryfile.ts.
|
|
31
|
-
The section will currently be added to the end of the entry file, but the exact
|
|
32
|
-
order may change due to nondeterminism.`.trim()
|
|
33
|
-
)
|
|
34
|
-
);
|
|
35
|
-
console.log();
|
|
36
|
-
return Infinity;
|
|
37
|
-
}
|
|
38
|
-
return sortIndex;
|
|
39
|
-
});
|
|
40
|
-
const header = `@charset "UTF-8";
|
|
41
|
-
|
|
42
|
-
@layer ds.reset, ds.theme, ds.base, ds.utilities, ds.components;
|
|
43
|
-
|
|
44
|
-
`;
|
|
45
|
-
const concat = R.pipe(
|
|
46
|
-
R.map((file) => {
|
|
47
|
-
try {
|
|
48
|
-
const content = fs.readFileSync(file, "utf-8").toString();
|
|
49
|
-
return content;
|
|
50
|
-
} catch (e) {
|
|
51
|
-
console.error(`Error reading file: ${file}`);
|
|
52
|
-
return "";
|
|
53
|
-
}
|
|
54
|
-
}),
|
|
55
|
-
R.join("\n")
|
|
56
|
-
);
|
|
57
|
-
const makeEntryFile = async ({ outPath, buildPath, theme, dry }) => {
|
|
58
|
-
const writePath = `${outPath}/${theme}.css`;
|
|
59
|
-
const files = await glob(`**/*`, { cwd: buildPath });
|
|
60
|
-
const sortAlphabetically = R.sort(R.ascend((x) => x));
|
|
61
|
-
const sortedFileNames = R.pipe(sortAlphabetically, sortByDefinedOrder)(files);
|
|
62
|
-
const content = header + concat(sortedFileNames.map((file) => `${buildPath}/${file}`));
|
|
63
|
-
await writeFile(writePath, content, dry);
|
|
64
|
-
};
|
|
65
|
-
export {
|
|
66
|
-
makeEntryFile
|
|
67
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getMultidimensionalThemes.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/build/utils/getMultidimensionalThemes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAMxD,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,yBAAyB,GAAI,QAAQ,oBAAoB,EAAE,EAAE,YAAY,cAAc,EAAE,sBAerG,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,WAAW,EAAE,gBAAgB,CAAC;CAC/B,CAAC;AAEF,QAAA,MAAM,SAAS,EAAE,OAAO,MAAsD,CAAC;AAC/E;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,WAAW,GAAG;IAAE,CAAC,SAAS,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAMvE;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,WAAW,GAAG,oBAAoB,GAAG,oBAAoB,CAUlG;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,gBAAgB,EAAE,oBAAoB,EAAE,CAAC,CAAC"}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { TokenSetStatus } from "@tokens-studio/types";
|
|
2
|
-
import chalk from "chalk";
|
|
3
|
-
import { kebabCase } from "change-case";
|
|
4
|
-
import * as R from "ramda";
|
|
5
|
-
import { buildOptions } from "../../build.js";
|
|
6
|
-
const getMultidimensionalThemes = (themes, dimensions) => {
|
|
7
|
-
const verboseLogging = buildOptions?.verbose;
|
|
8
|
-
const grouped$themes = groupThemes(themes);
|
|
9
|
-
const permutations = permutateThemes(grouped$themes);
|
|
10
|
-
const ALL_DEPENDENT_ON = ["theme"];
|
|
11
|
-
const keys = R.keys(grouped$themes);
|
|
12
|
-
const nonDependentKeys = keys.filter((x) => ![...ALL_DEPENDENT_ON, ...dimensions].includes(x));
|
|
13
|
-
if (verboseLogging) {
|
|
14
|
-
console.log(chalk.cyan(`\u{1F50E} Finding theme permutations for ${dimensions}`));
|
|
15
|
-
console.log(chalk.cyan(` (ignoring permutations for ${nonDependentKeys})`));
|
|
16
|
-
}
|
|
17
|
-
return permutations.filter((val) => {
|
|
18
|
-
const filters = nonDependentKeys.map((x) => val.permutation[x] === grouped$themes[x][0].name);
|
|
19
|
-
return filters.every((x) => x);
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
const processed = Symbol("Type brand for ProcessedThemeObject");
|
|
23
|
-
function isProcessed(theme) {
|
|
24
|
-
return Boolean(theme[processed]);
|
|
25
|
-
}
|
|
26
|
-
function processThemeObject(theme) {
|
|
27
|
-
if (isProcessed(theme)) {
|
|
28
|
-
return theme;
|
|
29
|
-
}
|
|
30
|
-
const result = { ...theme, [processed]: true };
|
|
31
|
-
if (result.group) {
|
|
32
|
-
result.group = kebabCase(result.group);
|
|
33
|
-
}
|
|
34
|
-
result.name = kebabCase(result.name);
|
|
35
|
-
return result;
|
|
36
|
-
}
|
|
37
|
-
function groupThemes(themes) {
|
|
38
|
-
const groups = {};
|
|
39
|
-
for (const rawTheme of themes) {
|
|
40
|
-
const theme = processThemeObject(rawTheme);
|
|
41
|
-
if (theme.group) {
|
|
42
|
-
const groupKey = theme.group;
|
|
43
|
-
groups[groupKey] = [...groups[groupKey] ?? [], theme];
|
|
44
|
-
} else {
|
|
45
|
-
throw new Error(
|
|
46
|
-
`Theme ${theme.name} does not have a group property, which is required for multi-dimensional theming.`
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return groups;
|
|
51
|
-
}
|
|
52
|
-
const hasUnknownProps = R.pipe(R.values, R.none(R.equals("unknown")), R.not);
|
|
53
|
-
function permutateThemes(groups) {
|
|
54
|
-
const separator = "_";
|
|
55
|
-
const permutations = cartesian(Object.values(groups));
|
|
56
|
-
const permutatedThemes = permutations.map((perm) => {
|
|
57
|
-
const permutatedTheme = perm.reduce(
|
|
58
|
-
(acc, theme) => {
|
|
59
|
-
const { group, name, selectedTokenSets } = theme;
|
|
60
|
-
let updatedPermutation = acc.permutation;
|
|
61
|
-
if (group) {
|
|
62
|
-
const groupProp = R.lensProp(group);
|
|
63
|
-
updatedPermutation = R.set(groupProp, name, updatedPermutation);
|
|
64
|
-
}
|
|
65
|
-
const updatedName = `${String(acc.name)}${acc ? separator : ""}${name}`;
|
|
66
|
-
const sets = [...acc.selectedTokenSets, ...filterTokenSets(selectedTokenSets)];
|
|
67
|
-
return {
|
|
68
|
-
permutation: updatedPermutation,
|
|
69
|
-
name: updatedName,
|
|
70
|
-
selectedTokenSets: sets
|
|
71
|
-
};
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
name: "",
|
|
75
|
-
selectedTokenSets: [],
|
|
76
|
-
permutation: {
|
|
77
|
-
"color-scheme": "unknown",
|
|
78
|
-
"main-color": "unknown",
|
|
79
|
-
"support-color": "unknown",
|
|
80
|
-
theme: "unknown",
|
|
81
|
-
semantic: "unknown",
|
|
82
|
-
size: "unknown",
|
|
83
|
-
typography: "unknown"
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
);
|
|
87
|
-
if (hasUnknownProps(permutatedTheme)) {
|
|
88
|
-
throw Error(`Theme ${permutatedTheme.name} has unknown props: ${JSON.stringify(permutatedTheme)}`);
|
|
89
|
-
}
|
|
90
|
-
const uniqueTokenSets = new Set(permutatedTheme.selectedTokenSets);
|
|
91
|
-
return { ...permutatedTheme, selectedTokenSets: Array.from(uniqueTokenSets) };
|
|
92
|
-
});
|
|
93
|
-
return permutatedThemes;
|
|
94
|
-
}
|
|
95
|
-
function filterTokenSets(tokensets) {
|
|
96
|
-
return Object.entries(tokensets).filter(([, val]) => val !== TokenSetStatus.DISABLED).sort((a, b) => {
|
|
97
|
-
if (a[1] === TokenSetStatus.SOURCE && b[1] === TokenSetStatus.ENABLED) {
|
|
98
|
-
return -1;
|
|
99
|
-
}
|
|
100
|
-
if (a[1] === TokenSetStatus.ENABLED && b[1] === TokenSetStatus.SOURCE) {
|
|
101
|
-
return 1;
|
|
102
|
-
}
|
|
103
|
-
return 0;
|
|
104
|
-
}).map((entry) => entry[0]);
|
|
105
|
-
}
|
|
106
|
-
function cartesian(a) {
|
|
107
|
-
return a.reduce((a2, b) => a2.flatMap((d) => b.map((e) => [d, e].flat())));
|
|
108
|
-
}
|
|
109
|
-
export {
|
|
110
|
-
getMultidimensionalThemes,
|
|
111
|
-
processThemeObject
|
|
112
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"tokenSetOrder": [
|
|
3
|
-
"primitives/globals",
|
|
4
|
-
"primitives/modes/size/small",
|
|
5
|
-
"primitives/modes/size/medium",
|
|
6
|
-
"primitives/modes/size/large",
|
|
7
|
-
"primitives/modes/size/global",
|
|
8
|
-
"primitives/modes/typography/size/small",
|
|
9
|
-
"primitives/modes/typography/size/medium",
|
|
10
|
-
"primitives/modes/typography/size/large",
|
|
11
|
-
"primitives/modes/typography/primary/<theme>",
|
|
12
|
-
"primitives/modes/typography/secondary/<theme>",
|
|
13
|
-
"primitives/modes/color-scheme/dark/global",
|
|
14
|
-
"primitives/modes/color-scheme/dark/<theme>",
|
|
15
|
-
"primitives/modes/color-scheme/light/global",
|
|
16
|
-
"primitives/modes/color-scheme/light/<theme>",
|
|
17
|
-
"themes/<theme>",
|
|
18
|
-
"semantic/color",
|
|
19
|
-
"semantic/modes/main-color/accent",
|
|
20
|
-
"semantic/modes/support-color/brand1",
|
|
21
|
-
"semantic/modes/support-color/brand2",
|
|
22
|
-
"semantic/modes/support-color/brand3",
|
|
23
|
-
"semantic/style"
|
|
24
|
-
]
|
|
25
|
-
}
|