@digdir/designsystemet 1.0.0-next.47 → 1.0.0-next.49
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/config.d.ts +60 -60
- package/dist/bin/config.d.ts.map +1 -1
- package/dist/bin/config.js +3 -3
- package/dist/bin/designsystemet.js +21 -17
- package/dist/config.schema.json +4 -5
- package/dist/src/colors/colorMetadata.d.ts +4 -0
- package/dist/src/colors/colorMetadata.d.ts.map +1 -0
- package/dist/src/colors/colorMetadata.js +189 -0
- package/dist/src/colors/index.d.ts +1 -0
- package/dist/src/colors/index.d.ts.map +1 -1
- package/dist/src/colors/index.js +1 -0
- package/dist/src/colors/theme.d.ts +6 -12
- package/dist/src/colors/theme.d.ts.map +1 -1
- package/dist/src/colors/theme.js +36 -47
- package/dist/src/colors/types.d.ts +18 -21
- package/dist/src/colors/types.d.ts.map +1 -1
- package/dist/src/colors/utils.d.ts +10 -23
- package/dist/src/colors/utils.d.ts.map +1 -1
- package/dist/src/colors/utils.js +7 -44
- package/dist/src/migrations/beta-to-v1.js +1 -1
- package/dist/src/migrations/codemods/css/plugins.d.ts.map +1 -1
- package/dist/src/migrations/codemods/css/plugins.js +7 -8
- package/dist/src/migrations/codemods/css/run.d.ts.map +1 -1
- package/dist/src/migrations/codemods/css/run.js +9 -1
- package/dist/src/migrations/color-rename-next49.d.ts +3 -0
- package/dist/src/migrations/color-rename-next49.d.ts.map +1 -0
- package/dist/src/migrations/color-rename-next49.js +38 -0
- package/dist/src/migrations/index.d.ts +1 -0
- package/dist/src/migrations/index.d.ts.map +1 -1
- package/dist/src/migrations/index.js +3 -1
- package/dist/src/scripts/copy-internal-tokens.d.ts +2 -0
- package/dist/src/scripts/copy-internal-tokens.d.ts.map +1 -0
- package/dist/src/scripts/copy-internal-tokens.js +28 -0
- package/dist/src/scripts/createJsonSchema.d.ts.map +1 -0
- package/dist/src/tokens/build/builtin-colors.css +20 -20
- package/dist/src/tokens/build/configs.d.ts.map +1 -1
- package/dist/src/tokens/build/configs.js +5 -41
- package/dist/src/tokens/build/types.d.ts +1 -1
- package/dist/src/tokens/build/types.d.ts.map +1 -1
- package/dist/src/tokens/build.d.ts +2 -3
- package/dist/src/tokens/build.d.ts.map +1 -1
- package/dist/src/tokens/build.js +25 -21
- package/dist/src/tokens/create.d.ts.map +1 -1
- package/dist/src/tokens/create.js +3 -17
- package/dist/src/tokens/design-tokens/default/primitives/globals.json +3 -3
- package/dist/src/tokens/design-tokens/default/primitives/modes/typography/size/large.json +9 -13
- package/dist/src/tokens/design-tokens/default/primitives/modes/typography/size/medium.json +9 -13
- package/dist/src/tokens/design-tokens/default/primitives/modes/typography/size/small.json +9 -13
- package/dist/src/tokens/design-tokens/default/semantic/style.json +25 -25
- package/dist/src/tokens/design-tokens/template/$metadata.json +1 -2
- package/dist/src/tokens/design-tokens/template/$themes.json +1315 -1295
- package/dist/src/tokens/design-tokens/template/semantic/color-base-file.json +81 -65
- package/dist/src/tokens/design-tokens/template/semantic/modes/category-color/category-color-template.json +18 -14
- package/dist/src/tokens/design-tokens/template/semantic/semantic-color-template.json +19 -15
- package/dist/src/tokens/design-tokens/template/themes/theme-color-template.json +8 -4
- package/dist/src/tokens/template.d.ts.map +1 -1
- package/dist/src/tokens/template.js +6 -7
- package/dist/src/tokens/utils.js +1 -1
- package/dist/src/tokens/write/generate$metadata.d.ts.map +1 -1
- package/dist/src/tokens/write/generate$metadata.js +1 -2
- package/dist/src/tokens/write/generate$themes.js +11 -117
- package/dist/src/tokens/write.d.ts +0 -2
- package/dist/src/tokens/write.d.ts.map +1 -1
- package/dist/src/tokens/write.js +4 -8
- package/package.json +27 -31
- package/dist/src/build-scripts/createJsonSchema.d.ts.map +0 -1
- package/dist/src/colors/luminance.d.ts +0 -54
- package/dist/src/colors/luminance.d.ts.map +0 -1
- package/dist/src/colors/luminance.js +0 -56
- package/dist/src/tokens/design-tokens/default/Figma/components.json +0 -22
- /package/dist/src/{build-scripts → scripts}/createJsonSchema.d.ts +0 -0
- /package/dist/src/{build-scripts → scripts}/createJsonSchema.js +0 -0
package/dist/bin/config.d.ts
CHANGED
|
@@ -9,58 +9,58 @@ export declare const configFileSchema: z.ZodObject<{
|
|
|
9
9
|
clean: z.ZodOptional<z.ZodBoolean>;
|
|
10
10
|
themes: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
11
11
|
colors: z.ZodObject<{
|
|
12
|
-
main: z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodString, `#${string}
|
|
13
|
-
support: z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodString, `#${string}
|
|
14
|
-
neutral: z.ZodEffects<z.ZodString, `#${string}
|
|
12
|
+
main: z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodString, `#${string}`, string>>;
|
|
13
|
+
support: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodString, `#${string}`, string>>>>;
|
|
14
|
+
neutral: z.ZodEffects<z.ZodString, `#${string}`, string>;
|
|
15
15
|
}, "strip", z.ZodTypeAny, {
|
|
16
|
-
main: Record<string, `#${string}
|
|
17
|
-
neutral: `#${string}
|
|
18
|
-
support: Record<string, `#${string}
|
|
16
|
+
main: Record<string, `#${string}`>;
|
|
17
|
+
neutral: `#${string}`;
|
|
18
|
+
support: Record<string, `#${string}`>;
|
|
19
19
|
}, {
|
|
20
20
|
main: Record<string, string>;
|
|
21
21
|
neutral: string;
|
|
22
|
-
support
|
|
22
|
+
support?: Record<string, string> | undefined;
|
|
23
23
|
}>;
|
|
24
|
-
typography: z.ZodObject<{
|
|
24
|
+
typography: z.ZodOptional<z.ZodObject<{
|
|
25
25
|
fontFamily: z.ZodString;
|
|
26
26
|
}, "strip", z.ZodTypeAny, {
|
|
27
27
|
fontFamily: string;
|
|
28
28
|
}, {
|
|
29
29
|
fontFamily: string;
|
|
30
|
-
}
|
|
31
|
-
borderRadius: z.ZodNumber
|
|
30
|
+
}>>;
|
|
31
|
+
borderRadius: z.ZodOptional<z.ZodNumber>;
|
|
32
32
|
}, "strip", z.ZodTypeAny, {
|
|
33
33
|
colors: {
|
|
34
|
-
main: Record<string, `#${string}
|
|
35
|
-
neutral: `#${string}
|
|
36
|
-
support: Record<string, `#${string}
|
|
34
|
+
main: Record<string, `#${string}`>;
|
|
35
|
+
neutral: `#${string}`;
|
|
36
|
+
support: Record<string, `#${string}`>;
|
|
37
37
|
};
|
|
38
|
-
typography
|
|
38
|
+
typography?: {
|
|
39
39
|
fontFamily: string;
|
|
40
|
-
};
|
|
41
|
-
borderRadius
|
|
40
|
+
} | undefined;
|
|
41
|
+
borderRadius?: number | undefined;
|
|
42
42
|
}, {
|
|
43
43
|
colors: {
|
|
44
44
|
main: Record<string, string>;
|
|
45
45
|
neutral: string;
|
|
46
|
-
support
|
|
46
|
+
support?: Record<string, string> | undefined;
|
|
47
47
|
};
|
|
48
|
-
typography
|
|
48
|
+
typography?: {
|
|
49
49
|
fontFamily: string;
|
|
50
|
-
};
|
|
51
|
-
borderRadius
|
|
50
|
+
} | undefined;
|
|
51
|
+
borderRadius?: number | undefined;
|
|
52
52
|
}>>;
|
|
53
53
|
}, "strip", z.ZodTypeAny, {
|
|
54
54
|
themes: Record<string, {
|
|
55
55
|
colors: {
|
|
56
|
-
main: Record<string, `#${string}
|
|
57
|
-
neutral: `#${string}
|
|
58
|
-
support: Record<string, `#${string}
|
|
56
|
+
main: Record<string, `#${string}`>;
|
|
57
|
+
neutral: `#${string}`;
|
|
58
|
+
support: Record<string, `#${string}`>;
|
|
59
59
|
};
|
|
60
|
-
typography
|
|
60
|
+
typography?: {
|
|
61
61
|
fontFamily: string;
|
|
62
|
-
};
|
|
63
|
-
borderRadius
|
|
62
|
+
} | undefined;
|
|
63
|
+
borderRadius?: number | undefined;
|
|
64
64
|
}>;
|
|
65
65
|
clean?: boolean | undefined;
|
|
66
66
|
outDir?: string | undefined;
|
|
@@ -69,12 +69,12 @@ export declare const configFileSchema: z.ZodObject<{
|
|
|
69
69
|
colors: {
|
|
70
70
|
main: Record<string, string>;
|
|
71
71
|
neutral: string;
|
|
72
|
-
support
|
|
72
|
+
support?: Record<string, string> | undefined;
|
|
73
73
|
};
|
|
74
|
-
typography
|
|
74
|
+
typography?: {
|
|
75
75
|
fontFamily: string;
|
|
76
|
-
};
|
|
77
|
-
borderRadius
|
|
76
|
+
} | undefined;
|
|
77
|
+
borderRadius?: number | undefined;
|
|
78
78
|
}>;
|
|
79
79
|
clean?: boolean | undefined;
|
|
80
80
|
outDir?: string | undefined;
|
|
@@ -88,59 +88,59 @@ export declare const combinedConfigSchema: z.ZodObject<{
|
|
|
88
88
|
clean: z.ZodBoolean;
|
|
89
89
|
themes: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
90
90
|
colors: z.ZodObject<{
|
|
91
|
-
main: z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodString, `#${string}
|
|
92
|
-
support: z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodString, `#${string}
|
|
93
|
-
neutral: z.ZodEffects<z.ZodString, `#${string}
|
|
91
|
+
main: z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodString, `#${string}`, string>>;
|
|
92
|
+
support: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodString, `#${string}`, string>>>>;
|
|
93
|
+
neutral: z.ZodEffects<z.ZodString, `#${string}`, string>;
|
|
94
94
|
}, "strip", z.ZodTypeAny, {
|
|
95
|
-
main: Record<string, `#${string}
|
|
96
|
-
neutral: `#${string}
|
|
97
|
-
support: Record<string, `#${string}
|
|
95
|
+
main: Record<string, `#${string}`>;
|
|
96
|
+
neutral: `#${string}`;
|
|
97
|
+
support: Record<string, `#${string}`>;
|
|
98
98
|
}, {
|
|
99
99
|
main: Record<string, string>;
|
|
100
100
|
neutral: string;
|
|
101
|
-
support
|
|
101
|
+
support?: Record<string, string> | undefined;
|
|
102
102
|
}>;
|
|
103
|
-
typography: z.ZodObject<{
|
|
103
|
+
typography: z.ZodOptional<z.ZodObject<{
|
|
104
104
|
fontFamily: z.ZodString;
|
|
105
105
|
}, "strip", z.ZodTypeAny, {
|
|
106
106
|
fontFamily: string;
|
|
107
107
|
}, {
|
|
108
108
|
fontFamily: string;
|
|
109
|
-
}
|
|
110
|
-
borderRadius: z.ZodNumber
|
|
109
|
+
}>>;
|
|
110
|
+
borderRadius: z.ZodOptional<z.ZodNumber>;
|
|
111
111
|
}, "strip", z.ZodTypeAny, {
|
|
112
112
|
colors: {
|
|
113
|
-
main: Record<string, `#${string}
|
|
114
|
-
neutral: `#${string}
|
|
115
|
-
support: Record<string, `#${string}
|
|
113
|
+
main: Record<string, `#${string}`>;
|
|
114
|
+
neutral: `#${string}`;
|
|
115
|
+
support: Record<string, `#${string}`>;
|
|
116
116
|
};
|
|
117
|
-
typography
|
|
117
|
+
typography?: {
|
|
118
118
|
fontFamily: string;
|
|
119
|
-
};
|
|
120
|
-
borderRadius
|
|
119
|
+
} | undefined;
|
|
120
|
+
borderRadius?: number | undefined;
|
|
121
121
|
}, {
|
|
122
122
|
colors: {
|
|
123
123
|
main: Record<string, string>;
|
|
124
124
|
neutral: string;
|
|
125
|
-
support
|
|
125
|
+
support?: Record<string, string> | undefined;
|
|
126
126
|
};
|
|
127
|
-
typography
|
|
127
|
+
typography?: {
|
|
128
128
|
fontFamily: string;
|
|
129
|
-
};
|
|
130
|
-
borderRadius
|
|
129
|
+
} | undefined;
|
|
130
|
+
borderRadius?: number | undefined;
|
|
131
131
|
}>>;
|
|
132
132
|
}, "strip", z.ZodTypeAny, {
|
|
133
133
|
clean: boolean;
|
|
134
134
|
themes: Record<string, {
|
|
135
135
|
colors: {
|
|
136
|
-
main: Record<string, `#${string}
|
|
137
|
-
neutral: `#${string}
|
|
138
|
-
support: Record<string, `#${string}
|
|
136
|
+
main: Record<string, `#${string}`>;
|
|
137
|
+
neutral: `#${string}`;
|
|
138
|
+
support: Record<string, `#${string}`>;
|
|
139
139
|
};
|
|
140
|
-
typography
|
|
140
|
+
typography?: {
|
|
141
141
|
fontFamily: string;
|
|
142
|
-
};
|
|
143
|
-
borderRadius
|
|
142
|
+
} | undefined;
|
|
143
|
+
borderRadius?: number | undefined;
|
|
144
144
|
}>;
|
|
145
145
|
outDir: string;
|
|
146
146
|
}, {
|
|
@@ -149,12 +149,12 @@ export declare const combinedConfigSchema: z.ZodObject<{
|
|
|
149
149
|
colors: {
|
|
150
150
|
main: Record<string, string>;
|
|
151
151
|
neutral: string;
|
|
152
|
-
support
|
|
152
|
+
support?: Record<string, string> | undefined;
|
|
153
153
|
};
|
|
154
|
-
typography
|
|
154
|
+
typography?: {
|
|
155
155
|
fontFamily: string;
|
|
156
|
-
};
|
|
157
|
-
borderRadius
|
|
156
|
+
} | undefined;
|
|
157
|
+
borderRadius?: number | undefined;
|
|
158
158
|
}>;
|
|
159
159
|
outDir: string;
|
|
160
160
|
}>;
|
package/dist/bin/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../bin/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,sBAQ5D;AAUD,eAAO,MAAM,UAAU,QAA2C,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../bin/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,sBAQ5D;AAUD,eAAO,MAAM,UAAU,QAA2C,CAAC;AA+BnE;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAO3B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAA8B,CAAC;AAChE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
package/dist/bin/config.js
CHANGED
|
@@ -25,7 +25,7 @@ const themeSchema = z.object(
|
|
|
25
25
|
colors: z.object(
|
|
26
26
|
{
|
|
27
27
|
main: colorCategorySchema,
|
|
28
|
-
support: colorCategorySchema,
|
|
28
|
+
support: colorCategorySchema.optional().default({}),
|
|
29
29
|
neutral: colorSchema
|
|
30
30
|
},
|
|
31
31
|
{ description: "Defines the colors for this theme" }
|
|
@@ -35,8 +35,8 @@ const themeSchema = z.object(
|
|
|
35
35
|
fontFamily: z.string({ description: "Sets the font-family for this theme" })
|
|
36
36
|
},
|
|
37
37
|
{ description: "Defines the typography for a given theme" }
|
|
38
|
-
),
|
|
39
|
-
borderRadius: z.number({ description: "Defines the border-radius for this theme" })
|
|
38
|
+
).optional(),
|
|
39
|
+
borderRadius: z.number({ description: "Defines the border-radius for this theme" }).optional()
|
|
40
40
|
},
|
|
41
41
|
{ description: "An object defining a theme. The property name holding the object becomes the theme name." }
|
|
42
42
|
);
|
|
@@ -9,9 +9,10 @@ import { convertToHex } from "../src/colors/index.js";
|
|
|
9
9
|
import migrations from "../src/migrations/index.js";
|
|
10
10
|
import { buildTokens } from "../src/tokens/build.js";
|
|
11
11
|
import { cliOptions, createTokens } from "../src/tokens/create.js";
|
|
12
|
+
import { cleanDir } from "../src/tokens/utils.js";
|
|
12
13
|
import { writeTokens } from "../src/tokens/write.js";
|
|
13
14
|
import { combinedConfigSchema, configFileSchema, mapPathToOptionName } from "./config.js";
|
|
14
|
-
import { getDefaultOrExplicitOption
|
|
15
|
+
import { getDefaultOrExplicitOption } from "./options.js";
|
|
15
16
|
program.name("designsystemet").description("CLI for working with Designsystemet").showHelpAfterError();
|
|
16
17
|
function makeTokenCommands() {
|
|
17
18
|
const tokenCmd = createCommand("tokens");
|
|
@@ -44,14 +45,14 @@ function makeTokenCommands() {
|
|
|
44
45
|
(radiusAsString) => Number(radiusAsString),
|
|
45
46
|
4
|
|
46
47
|
).option("--theme <string>", "Theme name (ignored when using JSON config file)", DEFAULT_THEME_NAME).option(
|
|
47
|
-
"--
|
|
48
|
-
`Path to
|
|
49
|
-
(value) =>
|
|
48
|
+
"--config <string>",
|
|
49
|
+
`Path to config file (default: "${DEFAULT_CONFIG_FILE}")`,
|
|
50
|
+
(value) => parseConfig(value, { allowFileNotFound: false })
|
|
50
51
|
).action(async (opts, cmd) => {
|
|
51
52
|
if (opts.dry) {
|
|
52
53
|
console.log(`Performing dry run, no files will be written`);
|
|
53
54
|
}
|
|
54
|
-
const configFile = await (opts.
|
|
55
|
+
const configFile = await (opts.config ? opts.config : parseConfig(DEFAULT_CONFIG_FILE, { allowFileNotFound: true }));
|
|
55
56
|
const propsFromJson = configFile?.config;
|
|
56
57
|
if (propsFromJson) {
|
|
57
58
|
const themeColors = Object.values(propsFromJson?.themes ?? {}).map(
|
|
@@ -60,7 +61,7 @@ function makeTokenCommands() {
|
|
|
60
61
|
if (!R.all(R.equals(R.__, themeColors[0]), themeColors)) {
|
|
61
62
|
console.error(
|
|
62
63
|
chalk.redBright(
|
|
63
|
-
`In
|
|
64
|
+
`In config ${configFile.path}, all themes must have the same custom color names, but we found:`
|
|
64
65
|
)
|
|
65
66
|
);
|
|
66
67
|
const themeNames = R.keys(propsFromJson.themes ?? {});
|
|
@@ -90,7 +91,7 @@ function makeTokenCommands() {
|
|
|
90
91
|
themes: propsFromJson?.themes ? (
|
|
91
92
|
// For each theme specified in the JSON config, we override the config values
|
|
92
93
|
// with the explicitly set options from the CLI.
|
|
93
|
-
R.map((theme) => R.mergeDeepRight(theme, getThemeOptions(
|
|
94
|
+
R.map((theme) => R.mergeDeepRight(theme, getThemeOptions(getDefaultOrExplicitOption)), propsFromJson.themes)
|
|
94
95
|
) : (
|
|
95
96
|
// If there are no themes specified in the JSON config, we use both explicit
|
|
96
97
|
// and default theme options from the CLI.
|
|
@@ -103,16 +104,19 @@ function makeTokenCommands() {
|
|
|
103
104
|
try {
|
|
104
105
|
config = combinedConfigSchema.parse(unvalidatedConfig);
|
|
105
106
|
} catch (err) {
|
|
106
|
-
console.error(chalk.redBright("Invalid config after combining
|
|
107
|
+
console.error(chalk.redBright("Invalid config after combining config file and CLI options"));
|
|
107
108
|
const validationError = makeFriendlyError(err);
|
|
108
109
|
console.error(validationError.toString());
|
|
109
110
|
process.exit(1);
|
|
110
111
|
}
|
|
111
112
|
console.log(`Creating tokens with configuration ${chalk.green(JSON.stringify(config, null, 2))}`);
|
|
113
|
+
if (config.clean) {
|
|
114
|
+
await cleanDir(config.outDir, opts.dry);
|
|
115
|
+
}
|
|
112
116
|
for (const [name, themeWithoutName] of Object.entries(config.themes)) {
|
|
113
117
|
const theme = { name, ...themeWithoutName };
|
|
114
118
|
const tokens = createTokens(theme);
|
|
115
|
-
await writeTokens({ outDir: config.outDir, tokens, theme, dry: opts.dry
|
|
119
|
+
await writeTokens({ outDir: config.outDir, tokens, theme, dry: opts.dry });
|
|
116
120
|
}
|
|
117
121
|
});
|
|
118
122
|
return tokenCmd;
|
|
@@ -137,12 +141,12 @@ program.command("migrate").description("run a Designsystemet migration").addArgu
|
|
|
137
141
|
}
|
|
138
142
|
});
|
|
139
143
|
await program.parseAsync(process.argv);
|
|
140
|
-
async function
|
|
141
|
-
const resolvedPath = path.resolve(process.cwd(),
|
|
142
|
-
let
|
|
144
|
+
async function parseConfig(configPath, options) {
|
|
145
|
+
const resolvedPath = path.resolve(process.cwd(), configPath);
|
|
146
|
+
let configFile;
|
|
143
147
|
try {
|
|
144
|
-
|
|
145
|
-
console.log(`Found
|
|
148
|
+
configFile = await fs.readFile(resolvedPath, { encoding: "utf-8" });
|
|
149
|
+
console.log(`Found config file: ${chalk.green(resolvedPath)}`);
|
|
146
150
|
} catch (err) {
|
|
147
151
|
if (err instanceof Error) {
|
|
148
152
|
const nodeErr = err;
|
|
@@ -154,11 +158,11 @@ async function parseJsonConfig(jsonPath, options) {
|
|
|
154
158
|
}
|
|
155
159
|
try {
|
|
156
160
|
return {
|
|
157
|
-
path:
|
|
158
|
-
config: await configFileSchema.parseAsync(JSON.parse(
|
|
161
|
+
path: configPath,
|
|
162
|
+
config: await configFileSchema.parseAsync(JSON.parse(configFile))
|
|
159
163
|
};
|
|
160
164
|
} catch (err) {
|
|
161
|
-
console.error(chalk.redBright(`Invalid
|
|
165
|
+
console.error(chalk.redBright(`Invalid config in ${configPath}`));
|
|
162
166
|
const validationError = makeFriendlyError(err);
|
|
163
167
|
console.error(validationError.toString());
|
|
164
168
|
process.exit(1);
|
package/dist/config.schema.json
CHANGED
|
@@ -30,7 +30,9 @@
|
|
|
30
30
|
"description": "One or more color definitions"
|
|
31
31
|
},
|
|
32
32
|
"support": {
|
|
33
|
-
"$ref": "#/properties/themes/additionalProperties/properties/colors/properties/main"
|
|
33
|
+
"$ref": "#/properties/themes/additionalProperties/properties/colors/properties/main",
|
|
34
|
+
"description": "One or more color definitions",
|
|
35
|
+
"default": {}
|
|
34
36
|
},
|
|
35
37
|
"neutral": {
|
|
36
38
|
"$ref": "#/properties/themes/additionalProperties/properties/colors/properties/main/additionalProperties"
|
|
@@ -38,7 +40,6 @@
|
|
|
38
40
|
},
|
|
39
41
|
"required": [
|
|
40
42
|
"main",
|
|
41
|
-
"support",
|
|
42
43
|
"neutral"
|
|
43
44
|
],
|
|
44
45
|
"additionalProperties": false,
|
|
@@ -64,9 +65,7 @@
|
|
|
64
65
|
}
|
|
65
66
|
},
|
|
66
67
|
"required": [
|
|
67
|
-
"colors"
|
|
68
|
-
"typography",
|
|
69
|
-
"borderRadius"
|
|
68
|
+
"colors"
|
|
70
69
|
],
|
|
71
70
|
"additionalProperties": false,
|
|
72
71
|
"description": "An object defining a theme. The property name holding the object becomes the theme name."
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colorMetadata.d.ts","sourceRoot":"","sources":["../../../src/colors/colorMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAErF,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,YAAY,EAAE,QAAQ,CAMrD,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,WAAW,EAAE,aAAa,CAsLnD,CAAC"}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
const baseColors = {
|
|
2
|
+
blue: "#0A71C0",
|
|
3
|
+
green: "#068718",
|
|
4
|
+
orange: "#EA9B1B",
|
|
5
|
+
purple: "#663299",
|
|
6
|
+
red: "#C01B1B"
|
|
7
|
+
};
|
|
8
|
+
const colorMetadata = {
|
|
9
|
+
1: {
|
|
10
|
+
name: "backgroundDefault",
|
|
11
|
+
group: "background",
|
|
12
|
+
displayName: "Background Default",
|
|
13
|
+
description: "Background Default er den mest n\xF8ytrale bakgrunnsfargen.",
|
|
14
|
+
luminance: {
|
|
15
|
+
light: 1,
|
|
16
|
+
dark: 0.011,
|
|
17
|
+
contrast: 1e-3
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
2: {
|
|
21
|
+
name: "backgroundTinted",
|
|
22
|
+
group: "background",
|
|
23
|
+
displayName: "Background Tinted",
|
|
24
|
+
description: "Background Tinted er en bakgrunnsfarge som har et hint av farge i seg.",
|
|
25
|
+
luminance: {
|
|
26
|
+
light: 0.9,
|
|
27
|
+
dark: 0.017,
|
|
28
|
+
contrast: 65e-4
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
3: {
|
|
32
|
+
name: "surfaceDefault",
|
|
33
|
+
group: "surface",
|
|
34
|
+
displayName: "Surface Default",
|
|
35
|
+
description: "Surface Default brukes p\xE5 flater som ligger opp\xE5 bakgrunnsfargene. Dette er den mest n\xF8ytrale surface fargen.",
|
|
36
|
+
luminance: {
|
|
37
|
+
light: 1,
|
|
38
|
+
dark: 0.025,
|
|
39
|
+
contrast: 0.015
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
4: {
|
|
43
|
+
name: "surfaceTinted",
|
|
44
|
+
group: "surface",
|
|
45
|
+
displayName: "Surface Tinted",
|
|
46
|
+
description: "Surface Tinted brukes p\xE5 flater som ligger opp\xE5 bakgrunnsfargene. Denne har et hint av farge i seg.",
|
|
47
|
+
luminance: {
|
|
48
|
+
light: 0.81,
|
|
49
|
+
dark: 0.035,
|
|
50
|
+
contrast: 0.015
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
5: {
|
|
54
|
+
name: "surfaceHover",
|
|
55
|
+
group: "surface",
|
|
56
|
+
displayName: "Surface Hover",
|
|
57
|
+
description: "Surface Hover brukes p\xE5 interaktive flater som ligger opp\xE5 bakgrunnsfargene i en hover state.",
|
|
58
|
+
luminance: {
|
|
59
|
+
light: 0.7,
|
|
60
|
+
dark: 0.044,
|
|
61
|
+
contrast: 0.028
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
6: {
|
|
65
|
+
name: "surfaceActive",
|
|
66
|
+
group: "surface",
|
|
67
|
+
displayName: "Surface Active",
|
|
68
|
+
description: "Surface Active brukes p\xE5 interaktive flater som ligger opp\xE5 bakgrunnsfargene i en active state.",
|
|
69
|
+
luminance: {
|
|
70
|
+
light: 0.6,
|
|
71
|
+
dark: 0.057,
|
|
72
|
+
contrast: 0.045
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
7: {
|
|
76
|
+
name: "borderSubtle",
|
|
77
|
+
group: "border",
|
|
78
|
+
displayName: "Border Subtle",
|
|
79
|
+
description: "Border Subtle er den lyseste border-fargen og brukes for \xE5 skille elementer fra hverandre.",
|
|
80
|
+
luminance: {
|
|
81
|
+
light: 0.5,
|
|
82
|
+
dark: 0.082,
|
|
83
|
+
contrast: 0.26
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
8: {
|
|
87
|
+
name: "borderDefault",
|
|
88
|
+
group: "border",
|
|
89
|
+
displayName: "Border Default",
|
|
90
|
+
description: "Border Default er en border-farge som brukes n\xE5r man \xF8nsker god kontrast mot bakgrunnsfargene.",
|
|
91
|
+
luminance: {
|
|
92
|
+
light: 0.21,
|
|
93
|
+
dark: 0.2,
|
|
94
|
+
contrast: 0.4
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
9: {
|
|
98
|
+
name: "borderStrong",
|
|
99
|
+
group: "border",
|
|
100
|
+
displayName: "Border Strong",
|
|
101
|
+
description: "Border Strong er den m\xF8rkeste border-fargen og brukes n\xE5r man \xF8nsker en veldig tydelig og sterk border.",
|
|
102
|
+
luminance: {
|
|
103
|
+
light: 0.12,
|
|
104
|
+
dark: 0.36,
|
|
105
|
+
contrast: 0.6
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
10: {
|
|
109
|
+
name: "textSubtle",
|
|
110
|
+
group: "text",
|
|
111
|
+
displayName: "Text Subtle",
|
|
112
|
+
description: "Text Subtle er den lyseste tekstfargen og brukes p\xE5 tekst som skal v\xE6re litt mindre synlig eller for \xE5 skape variasjon i typografien.",
|
|
113
|
+
luminance: {
|
|
114
|
+
light: 0.12,
|
|
115
|
+
dark: 0.36,
|
|
116
|
+
contrast: 0.57
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
11: {
|
|
120
|
+
name: "textDefault",
|
|
121
|
+
group: "text",
|
|
122
|
+
displayName: "Text Default",
|
|
123
|
+
description: "Text Default er den m\xF8rkeste tekstfargen og brukes p\xE5 tekst som skal v\xE6re mest synlig. Denne fargen b\xF8r brukes p\xE5 mesteparten av teksten p\xE5 en side.",
|
|
124
|
+
luminance: {
|
|
125
|
+
light: 0.0245,
|
|
126
|
+
dark: 0.78,
|
|
127
|
+
contrast: 0.86
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
12: {
|
|
131
|
+
name: "baseDefault",
|
|
132
|
+
group: "base",
|
|
133
|
+
displayName: "Base Default",
|
|
134
|
+
description: "Base Default fargen f\xE5r den samme hex koden som fargen som er valgt i verkt\xF8yet. Brukes ofte som farge p\xE5 viktige elementer og p\xE5 flater som skal fange brukerens oppmerksomhet.",
|
|
135
|
+
luminance: {
|
|
136
|
+
light: 1,
|
|
137
|
+
dark: 1,
|
|
138
|
+
contrast: 1
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
13: {
|
|
142
|
+
name: "baseHover",
|
|
143
|
+
group: "base",
|
|
144
|
+
displayName: "Base Hover",
|
|
145
|
+
description: "Base Hover brukes som hover farge p\xE5 elementer som bruker Base Default fargen.",
|
|
146
|
+
luminance: {
|
|
147
|
+
light: 1,
|
|
148
|
+
dark: 1,
|
|
149
|
+
contrast: 1
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
14: {
|
|
153
|
+
name: "baseActive",
|
|
154
|
+
group: "base",
|
|
155
|
+
displayName: "Base Active",
|
|
156
|
+
description: "Base Active brukes som active farge p\xE5 elementer som bruker Base Default fargen.",
|
|
157
|
+
luminance: {
|
|
158
|
+
light: 1,
|
|
159
|
+
dark: 1,
|
|
160
|
+
contrast: 1
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
15: {
|
|
164
|
+
name: "contrastSubtle",
|
|
165
|
+
group: "base",
|
|
166
|
+
displayName: "Contrast Subtle",
|
|
167
|
+
description: "Contrast Subtle brukes som en viktig meningsb\xE6rende farge opp\xE5 Base Default fargen.",
|
|
168
|
+
luminance: {
|
|
169
|
+
light: 1,
|
|
170
|
+
dark: 1,
|
|
171
|
+
contrast: 1
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
16: {
|
|
175
|
+
name: "contrastDefault",
|
|
176
|
+
group: "base",
|
|
177
|
+
displayName: "Contrast Default",
|
|
178
|
+
description: "Contrast Default brukes som en viktig meningsb\xE6rende farge opp\xE5 alle Base fargane.",
|
|
179
|
+
luminance: {
|
|
180
|
+
light: 1,
|
|
181
|
+
dark: 1,
|
|
182
|
+
contrast: 1
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
export {
|
|
187
|
+
baseColors,
|
|
188
|
+
colorMetadata
|
|
189
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/colors/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/colors/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC"}
|
package/dist/src/colors/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { CssColor } from './types.js';
|
|
2
|
-
import type { ColorInfo, ColorNumber, ColorScheme,
|
|
3
|
-
export declare const baseColors: Record<GlobalColors, CssColor>;
|
|
2
|
+
import type { ColorInfo, ColorNumber, ColorScheme, ThemeInfo } from './types.js';
|
|
4
3
|
/**
|
|
5
4
|
* Generates a color scale based on a base color and a color mode.
|
|
6
5
|
*
|
|
@@ -15,20 +14,15 @@ export declare const generateColorScale: (color: CssColor, colorScheme: ColorSch
|
|
|
15
14
|
*/
|
|
16
15
|
export declare const generateColorSchemes: (color: CssColor) => ThemeInfo;
|
|
17
16
|
/**
|
|
18
|
-
*
|
|
17
|
+
* Generates contrast color for given color
|
|
19
18
|
*
|
|
20
|
-
* @param
|
|
19
|
+
* @param color color
|
|
20
|
+
* @param type 'default' | 'subtle'
|
|
21
21
|
*/
|
|
22
|
-
export declare const
|
|
23
|
-
/**
|
|
24
|
-
* Creates the Base Contrast Subtle color
|
|
25
|
-
*
|
|
26
|
-
* @param color The base color
|
|
27
|
-
*/
|
|
28
|
-
export declare const getContrastSubtle: (color: CssColor) => CssColor;
|
|
22
|
+
export declare const generateColorContrast: (color: CssColor, type: "default" | "subtle") => CssColor;
|
|
29
23
|
/**
|
|
30
24
|
* Returns the css variable for a color.
|
|
31
|
-
*
|
|
25
|
+
* TODO: deprecate this
|
|
32
26
|
* @param colorType The type of color
|
|
33
27
|
* @param colorNumber The number of the color
|
|
34
28
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/colors/theme.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/colors/theme.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGjF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,UAAW,QAAQ,eAAe,WAAW,KAAG,SAAS,EAmBvF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,UAAW,QAAQ,KAAG,SAIrD,CAAC;AAgCH;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,UAAW,QAAQ,QAAQ,SAAS,GAAG,QAAQ,KAAG,QAgBnF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,cAAe,MAAM,eAAe,WAAW,WAEzE,CAAC"}
|