@digdir/designsystemet 0.1.0-next.28 → 0.1.0-next.30
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 +3 -3
- package/dist/src/colors/theme.js +1 -1
- package/dist/src/tokens/create/index.js +11 -12
- package/dist/types/src/colors/theme.d.ts +1 -1
- package/dist/types/src/colors/theme.d.ts.map +1 -1
- package/dist/types/src/tokens/create/index.d.ts +1 -1
- package/dist/types/src/tokens/create/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -16,10 +16,10 @@ function makeTokenCommands() {
|
|
|
16
16
|
console.log(`Bulding tokens in ${chalk.green(tokens)}`);
|
|
17
17
|
return buildTokens({ tokens, out, preview });
|
|
18
18
|
});
|
|
19
|
-
tokenCmd.command("create").description("Create Designsystemet tokens").option("-w, --write [string]", `Output directory for created ${chalk.blue("design-tokens")}
|
|
19
|
+
tokenCmd.command("create").description("Create Designsystemet tokens").option("-w, --write [string]", `Output directory for created ${chalk.blue("design-tokens")}`).option("-a, --accent <number>", `Accent hex color`).option("-n, --neutral <number>", `Neutral hex color`).option("-b1, --brand1 <number>", `Brand1 hex color`).option("-b2, --brand2 <number>", `Brand2 hex color`).option("-b3, --brand3 <number>", `Brand3 hex color`).option("-f, --font-family <string>", `Font family`).action(async (opts) => {
|
|
20
20
|
console.log(`Creating tokens with options ${chalk.green(JSON.stringify(opts))}`);
|
|
21
|
-
const outPath = typeof opts.write === "string" ? opts.write : "./design-tokens";
|
|
22
21
|
const family = typeof opts.fontFamily === "string" ? opts.fontFamily : "Inter";
|
|
22
|
+
const write2 = typeof opts.write === "boolean" ? "./design-tokens" : opts.write;
|
|
23
23
|
const props = {
|
|
24
24
|
colors: {
|
|
25
25
|
accent: convertToHex(opts.accent),
|
|
@@ -31,7 +31,7 @@ function makeTokenCommands() {
|
|
|
31
31
|
typography: {
|
|
32
32
|
family
|
|
33
33
|
},
|
|
34
|
-
|
|
34
|
+
write: write2
|
|
35
35
|
};
|
|
36
36
|
await createTokens(props);
|
|
37
37
|
});
|
package/dist/src/colors/theme.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BackgroundColor, Color, Theme } from "@adobe/leonardo-contrast-colors";
|
|
2
2
|
import { Hsluv } from "hsluv";
|
|
3
|
-
import { getContrastFromHex, getContrastFromLightness, getLightnessFromHex } from "./utils";
|
|
3
|
+
import { getContrastFromHex, getContrastFromLightness, getLightnessFromHex } from "./utils.js";
|
|
4
4
|
const baseColors = {
|
|
5
5
|
blue: "#0A71C0",
|
|
6
6
|
green: "#078D19",
|
|
@@ -101,7 +101,7 @@ const generateGlobalTokens = (theme) => {
|
|
|
101
101
|
};
|
|
102
102
|
};
|
|
103
103
|
const createTokens = async (opts) => {
|
|
104
|
-
const { colors,
|
|
104
|
+
const { colors, write, typography } = opts;
|
|
105
105
|
const tokens = {
|
|
106
106
|
colors: {
|
|
107
107
|
light: {
|
|
@@ -115,9 +115,8 @@ const createTokens = async (opts) => {
|
|
|
115
115
|
primary: generateTypographyTokens(typography)
|
|
116
116
|
}
|
|
117
117
|
};
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const targetDir = path.resolve(process.cwd(), outPath);
|
|
118
|
+
if (R.isNotNil(write)) {
|
|
119
|
+
const targetDir = path.resolve(process.cwd(), String(write));
|
|
121
120
|
await fs.mkdir(targetDir, { recursive: true });
|
|
122
121
|
console.log("Generating metadata and themes files");
|
|
123
122
|
const $theme = generateThemesJson(["Light", "Dark", "Contrast"], ["theme"]);
|
|
@@ -129,14 +128,14 @@ const createTokens = async (opts) => {
|
|
|
129
128
|
recursive: true
|
|
130
129
|
});
|
|
131
130
|
const files = [
|
|
132
|
-
generateColorModeFile("light", "theme", tokens.colors.light.theme,
|
|
133
|
-
generateColorModeFile("light", "global", tokens.colors.light.global,
|
|
134
|
-
generateColorModeFile("dark", "theme", tokens.colors.dark.theme,
|
|
135
|
-
generateColorModeFile("dark", "global", tokens.colors.dark.global,
|
|
136
|
-
generateColorModeFile("contrast", "theme", tokens.colors.contrast.theme,
|
|
137
|
-
generateColorModeFile("contrast", "global", tokens.colors.contrast.global,
|
|
138
|
-
generateTypographyFile("primary", "theme", tokens.typography.primary,
|
|
139
|
-
generateTypographyFile("secondary", "theme", tokens.typography.primary,
|
|
131
|
+
generateColorModeFile("light", "theme", tokens.colors.light.theme, targetDir),
|
|
132
|
+
generateColorModeFile("light", "global", tokens.colors.light.global, targetDir),
|
|
133
|
+
generateColorModeFile("dark", "theme", tokens.colors.dark.theme, targetDir),
|
|
134
|
+
generateColorModeFile("dark", "global", tokens.colors.dark.global, targetDir),
|
|
135
|
+
generateColorModeFile("contrast", "theme", tokens.colors.contrast.theme, targetDir),
|
|
136
|
+
generateColorModeFile("contrast", "global", tokens.colors.contrast.global, targetDir),
|
|
137
|
+
generateTypographyFile("primary", "theme", tokens.typography.primary, targetDir),
|
|
138
|
+
generateTypographyFile("secondary", "theme", tokens.typography.primary, targetDir)
|
|
140
139
|
];
|
|
141
140
|
for (const file of files) {
|
|
142
141
|
const path_ = path.resolve(file.path);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CssColor } from '@adobe/leonardo-contrast-colors';
|
|
2
|
-
import type { ColorInfo, ColorMode, ColorNumber, ContrastMode, GlobalColors, ThemeColors, ThemeInfo } from './types';
|
|
2
|
+
import type { ColorInfo, ColorMode, ColorNumber, ContrastMode, GlobalColors, ThemeColors, ThemeInfo } from './types.js';
|
|
3
3
|
export declare const baseColors: Record<GlobalColors, CssColor>;
|
|
4
4
|
type Colors = Record<ThemeColors, CssColor>;
|
|
5
5
|
export type ColorError = 'none' | 'decorative' | 'interaction';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../src/colors/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAIhE,OAAO,KAAK,EAAE,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H,eAAO,MAAM,yBAAyB,cAAe,QAAQ,0BAO5D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,UAAW,QAAQ,aAaxD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,qBAAsB,QAAQ,mBAAmB,QAAQ,YAe1F,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,UAAW,QAAQ,aAAa,MAAM,aAkB1E,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,SAAU,MAAM,KAAG,WAmBrD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,WAAY,WAAW,KAAG,MAmB5D,CAAC;AAEF,eAAO,MAAM,YAAY,UAAW,QAAQ,KAQvB,QACpB,CAAC;AAEF,eAAO,MAAM,cAAc,cAAe,MAAM,eAAe,WAAW,WAEzE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/create/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAGhE,OAAO,KAAK,EAAwB,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAI/E,KAAK,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;AAC5C,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAGzC,KAAK,YAAY,GAAG;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,UAAU,CAAC;IACvB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/create/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAGhE,OAAO,KAAK,EAAwB,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAI/E,KAAK,MAAM,GA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