@digdir/designsystemet 0.1.0-next.30 → 0.1.0-next.31
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/src/colors/theme.js
CHANGED
|
@@ -3,8 +3,8 @@ import { Hsluv } from "hsluv";
|
|
|
3
3
|
import { getContrastFromHex, getContrastFromLightness, getLightnessFromHex } from "./utils.js";
|
|
4
4
|
const baseColors = {
|
|
5
5
|
blue: "#0A71C0",
|
|
6
|
-
green: "#
|
|
7
|
-
orange: "#
|
|
6
|
+
green: "#068718",
|
|
7
|
+
orange: "#B8581D",
|
|
8
8
|
purple: "#663299",
|
|
9
9
|
red: "#C01B1B",
|
|
10
10
|
yellow: "#EABF28"
|
|
@@ -2,7 +2,7 @@ import { normalizeTokenSetName } from "./utils.js";
|
|
|
2
2
|
function generateMetadataJson(modes, themes) {
|
|
3
3
|
return {
|
|
4
4
|
tokenSetOrder: [
|
|
5
|
-
"primitives/
|
|
5
|
+
"primitives/globals",
|
|
6
6
|
"primitives/size/default",
|
|
7
7
|
"primitives/modes/typography/primary/theme",
|
|
8
8
|
"primitives/modes/typography/secondary/theme",
|
|
@@ -67,8 +67,7 @@ const generateThemeTokens = (theme, colors) => {
|
|
|
67
67
|
const generateColorModeFile = (folder, name, tokens, outPath) => {
|
|
68
68
|
const path2 = `${outPath}/primitives/modes/colors/${folder}`;
|
|
69
69
|
return {
|
|
70
|
-
data:
|
|
71
|
-
`,
|
|
70
|
+
data: JSON.stringify(tokens, null, 2),
|
|
72
71
|
path: path2,
|
|
73
72
|
filePath: `${path2}/${name}.json`
|
|
74
73
|
};
|
|
@@ -76,8 +75,7 @@ const generateColorModeFile = (folder, name, tokens, outPath) => {
|
|
|
76
75
|
const generateTypographyFile = (folder, name, tokens, outPath) => {
|
|
77
76
|
const path2 = `${outPath}/primitives/modes/typography/${folder}`;
|
|
78
77
|
return {
|
|
79
|
-
data:
|
|
80
|
-
`,
|
|
78
|
+
data: JSON.stringify(tokens, null, 2),
|
|
81
79
|
path: path2,
|
|
82
80
|
filePath: `${path2}/${name}.json`
|
|
83
81
|
};
|
|
@@ -123,7 +121,7 @@ const createTokens = async (opts) => {
|
|
|
123
121
|
const $metadata = generateMetadataJson(["Light", "Dark", "Contrast"], ["theme"]);
|
|
124
122
|
await fs.writeFile(path.join(targetDir, "$themes.json"), JSON.stringify($theme, null, 2));
|
|
125
123
|
await fs.writeFile(path.join(targetDir, "$metadata.json"), JSON.stringify($metadata, null, 2));
|
|
126
|
-
console.log(`
|
|
124
|
+
console.log(`Copying default files to ${targetDir}`);
|
|
127
125
|
await fs.cp(DEFAULT_FILES_PATH, targetDir, {
|
|
128
126
|
recursive: true
|
|
129
127
|
});
|
|
@@ -138,10 +136,10 @@ const createTokens = async (opts) => {
|
|
|
138
136
|
generateTypographyFile("secondary", "theme", tokens.typography.primary, targetDir)
|
|
139
137
|
];
|
|
140
138
|
for (const file of files) {
|
|
141
|
-
const
|
|
139
|
+
const dirPath = path.resolve(file.path);
|
|
142
140
|
const filePath = path.resolve(file.filePath);
|
|
143
141
|
console.log(`Writing file ${filePath}`);
|
|
144
|
-
await fs.mkdir(
|
|
142
|
+
await fs.mkdir(dirPath, { recursive: true });
|
|
145
143
|
await fs.writeFile(filePath, file.data, { encoding: "utf-8" });
|
|
146
144
|
}
|
|
147
145
|
}
|