@digdir/designsystemet 1.0.0-next.50 → 1.0.0
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/README.md +94 -3
- package/dist/bin/config.d.ts +16 -16
- package/dist/bin/config.d.ts.map +1 -1
- package/dist/bin/config.js +17 -2
- package/dist/bin/designsystemet.js +10 -10
- package/dist/bin/options.d.ts +9 -4
- package/dist/bin/options.d.ts.map +1 -1
- package/dist/bin/options.js +6 -4
- package/dist/config.schema.json +4 -2
- package/dist/src/colors/colorMetadata.d.ts +51 -2
- package/dist/src/colors/colorMetadata.d.ts.map +1 -1
- package/dist/src/colors/colorMetadata.js +55 -33
- package/dist/src/colors/theme.d.ts +3 -2
- package/dist/src/colors/theme.d.ts.map +1 -1
- package/dist/src/colors/theme.js +29 -11
- package/dist/src/colors/types.d.ts +36 -7
- package/dist/src/colors/types.d.ts.map +1 -1
- package/dist/src/colors/utils.d.ts +1 -2
- package/dist/src/colors/utils.d.ts.map +1 -1
- package/dist/src/colors/utils.js +0 -5
- package/dist/src/migrations/beta-to-v1.js +1 -1
- package/dist/src/tokens/build/configs.js +1 -1
- package/dist/src/tokens/create.d.ts.map +1 -1
- package/dist/src/tokens/create.js +14 -12
- package/dist/src/tokens/design-tokens/default/primitives/globals.json +1 -1
- package/dist/src/tokens/design-tokens/default/primitives/modes/typography/size/large.json +1 -1
- package/dist/src/tokens/design-tokens/default/primitives/modes/typography/size/medium.json +1 -1
- package/dist/src/tokens/design-tokens/default/primitives/modes/typography/size/small.json +1 -1
- package/dist/src/tokens/design-tokens/default/semantic/style.json +25 -25
- package/dist/src/tokens/design-tokens/template/$themes.json +20 -20
- package/dist/src/tokens/design-tokens/template/semantic/color-base-file.json +8 -0
- package/dist/src/tokens/design-tokens/template/themes/theme-base-file.json +6 -8
- package/dist/src/tokens/template.d.ts.map +1 -1
- package/dist/src/tokens/template.js +1 -0
- package/dist/src/tokens/types.d.ts +3 -4
- package/dist/src/tokens/types.d.ts.map +1 -1
- package/dist/src/tokens/write.d.ts.map +1 -1
- package/dist/src/tokens/write.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,7 +10,98 @@ Read the Designsystemet [README](https://github.com/digdir/designsystemet) to ge
|
|
|
10
10
|
## Usage
|
|
11
11
|
|
|
12
12
|
### Create tokens
|
|
13
|
-
We recommend using the [Designsystemet theme-builder](https://theme.designsystemet.no/) for generating options and commandline snippet.
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
Use `npx @digdir/designsystemet tokens create <options>` to create design tokens for use with Designsystemet.
|
|
15
|
+
|
|
16
|
+
This allows you to define themes including custom colors, font-family, and border-radius.
|
|
17
|
+
We recommend using the [Designsystemet theme builder](https://theme.designsystemet.no/) for generating a valid command with correct options.
|
|
18
|
+
|
|
19
|
+
#### Update tokens
|
|
20
|
+
|
|
21
|
+
Whenever a new version of the CLI is released, or you have done changes, we recommend to update design tokens with the `--clean` option to potentially remove any changes deprecated files or unneeded files.
|
|
22
|
+
|
|
23
|
+
To update design tokens, re-run `npx @digdir/designsystemet tokens create <options> --clean`.
|
|
24
|
+
If a [config file](#using-a-config-file) you can also re-run with `"clean": true`.
|
|
25
|
+
|
|
26
|
+
> ⚠️ **WARNING** ⚠️
|
|
27
|
+
> The design tokens created by this tool are considered an implementation detail, and is subject
|
|
28
|
+
> to change at any time without being considered a breaking change. We **only** support customisations
|
|
29
|
+
> done through the CLI options. Direct editing of the design tokens are **not** supported.
|
|
30
|
+
>
|
|
31
|
+
> Since tokens may be added or removed at any time, it is necessary to routinely re-run this
|
|
32
|
+
> command when upgrading the libraries. This will remove any direct edits to the design tokens.
|
|
33
|
+
|
|
34
|
+
### Build CSS from tokens
|
|
35
|
+
|
|
36
|
+
Use `npx @digdir/designsystemet tokens build <options>` to build CSS from design tokens generated in the previous step.
|
|
37
|
+
|
|
38
|
+
> ⚠️ **WARNING** ⚠️
|
|
39
|
+
> The CSS files from created by this tool are considered build artifacts. They should **not** be
|
|
40
|
+
> edited directly. While the CSS will not change unexpectedly, new variables may be added at any
|
|
41
|
+
> time. Therefore, it is necessary to routinely re-run this command when upgrading the libraries.
|
|
42
|
+
> This will remove any direct edits to the CSS.
|
|
43
|
+
|
|
44
|
+
#### Update built CSS
|
|
45
|
+
|
|
46
|
+
Whenever a new version of the CLI is released, or you have done changes, we recommend to build a new set of CSS from design tokens with the `--clean` option to potentially remove any changes deprecated files or unneeded files.
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
### Using a config file
|
|
50
|
+
|
|
51
|
+
> ⚠️ **WARNING** ⚠️
|
|
52
|
+
> This feature is experimental. The config schema may change at any time.
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
The `tokens create` command supports a config file. It will auto-detect a `designsystemet.config.json` file in the current directory. You can also use the `--config <path>` option to supply a different config name and location.
|
|
56
|
+
|
|
57
|
+
The main advantage of using a config file is for automation in scenarios with multiple themes.
|
|
58
|
+
|
|
59
|
+
To get started, use this template for a `designsystemet.config.json` file:
|
|
60
|
+
|
|
61
|
+
```jsonc
|
|
62
|
+
{
|
|
63
|
+
"$schema": "node_modules/@digdir/designsystemet/dist/config.schema.json",
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
In editors which support JSON Schema, the `$schema` will then give you editor hints for the structure of the file.
|
|
68
|
+
|
|
69
|
+
#### Minimal config example
|
|
70
|
+
As a minimal example, the following CLI snippet from the theme builder
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
npx @digdir/designsystemet tokens create \
|
|
74
|
+
--main-colors "primary:#0062BA" "accent:#1E98F5" \
|
|
75
|
+
--neutral-color "#1E2B3C" \
|
|
76
|
+
--support-colors "extra1:#F45F63" "extra2:#E5AA20" \
|
|
77
|
+
--border-radius 4 \
|
|
78
|
+
--theme "theme"
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
...is equivalent to this `designsystemet.config.json` file
|
|
82
|
+
```jsonc
|
|
83
|
+
{
|
|
84
|
+
"$schema": "./node_modules/@digdir/designsystemet/dist/config.schema.json",
|
|
85
|
+
"outDir": "../path/to/design-tokens",
|
|
86
|
+
"themes": {
|
|
87
|
+
"theme": {
|
|
88
|
+
"colors": {
|
|
89
|
+
"main": { "primary": "#0062BA", "accent": "#1E98F5" },
|
|
90
|
+
"neutral": "#1E2B3C",
|
|
91
|
+
"support": { "extra1": "#F45F63", "extra2": "#E5AA20" }
|
|
92
|
+
},
|
|
93
|
+
"borderRadius": 4
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
To generate new design tokens and CSS files, you would then run.
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
npx @digdir/designsystemet tokens create
|
|
102
|
+
npx @digdir/designsystemet tokens build
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
#### Complex config example
|
|
106
|
+
|
|
107
|
+
Have a look at the `*.config.json` files under the `packages/cli` in the Github repo for more complex examples.
|
package/dist/bin/config.d.ts
CHANGED
|
@@ -9,16 +9,16 @@ 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}`, string>>;
|
|
13
|
-
support: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodString, `#${string}`, string>>>>;
|
|
12
|
+
main: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodString, `#${string}`, string>>, Record<string, `#${string}`>, Record<string, string>>;
|
|
13
|
+
support: z.ZodDefault<z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodString, `#${string}`, string>>, Record<string, `#${string}`>, Record<string, string>>>>;
|
|
14
14
|
neutral: z.ZodEffects<z.ZodString, `#${string}`, string>;
|
|
15
15
|
}, "strip", z.ZodTypeAny, {
|
|
16
|
-
main: Record<string, `#${string}`>;
|
|
17
16
|
neutral: `#${string}`;
|
|
17
|
+
main: Record<string, `#${string}`>;
|
|
18
18
|
support: Record<string, `#${string}`>;
|
|
19
19
|
}, {
|
|
20
|
-
main: Record<string, string>;
|
|
21
20
|
neutral: string;
|
|
21
|
+
main: Record<string, string>;
|
|
22
22
|
support?: Record<string, string> | undefined;
|
|
23
23
|
}>;
|
|
24
24
|
typography: z.ZodOptional<z.ZodObject<{
|
|
@@ -31,8 +31,8 @@ export declare const configFileSchema: z.ZodObject<{
|
|
|
31
31
|
borderRadius: z.ZodOptional<z.ZodNumber>;
|
|
32
32
|
}, "strip", z.ZodTypeAny, {
|
|
33
33
|
colors: {
|
|
34
|
-
main: Record<string, `#${string}`>;
|
|
35
34
|
neutral: `#${string}`;
|
|
35
|
+
main: Record<string, `#${string}`>;
|
|
36
36
|
support: Record<string, `#${string}`>;
|
|
37
37
|
};
|
|
38
38
|
typography?: {
|
|
@@ -41,8 +41,8 @@ export declare const configFileSchema: z.ZodObject<{
|
|
|
41
41
|
borderRadius?: number | undefined;
|
|
42
42
|
}, {
|
|
43
43
|
colors: {
|
|
44
|
-
main: Record<string, string>;
|
|
45
44
|
neutral: string;
|
|
45
|
+
main: Record<string, string>;
|
|
46
46
|
support?: Record<string, string> | undefined;
|
|
47
47
|
};
|
|
48
48
|
typography?: {
|
|
@@ -53,8 +53,8 @@ export declare const configFileSchema: z.ZodObject<{
|
|
|
53
53
|
}, "strip", z.ZodTypeAny, {
|
|
54
54
|
themes: Record<string, {
|
|
55
55
|
colors: {
|
|
56
|
-
main: Record<string, `#${string}`>;
|
|
57
56
|
neutral: `#${string}`;
|
|
57
|
+
main: Record<string, `#${string}`>;
|
|
58
58
|
support: Record<string, `#${string}`>;
|
|
59
59
|
};
|
|
60
60
|
typography?: {
|
|
@@ -67,8 +67,8 @@ export declare const configFileSchema: z.ZodObject<{
|
|
|
67
67
|
}, {
|
|
68
68
|
themes: Record<string, {
|
|
69
69
|
colors: {
|
|
70
|
-
main: Record<string, string>;
|
|
71
70
|
neutral: string;
|
|
71
|
+
main: Record<string, string>;
|
|
72
72
|
support?: Record<string, string> | undefined;
|
|
73
73
|
};
|
|
74
74
|
typography?: {
|
|
@@ -88,16 +88,16 @@ 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}`, string>>;
|
|
92
|
-
support: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodString, `#${string}`, string>>>>;
|
|
91
|
+
main: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodString, `#${string}`, string>>, Record<string, `#${string}`>, Record<string, string>>;
|
|
92
|
+
support: z.ZodDefault<z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodString, `#${string}`, string>>, Record<string, `#${string}`>, Record<string, string>>>>;
|
|
93
93
|
neutral: z.ZodEffects<z.ZodString, `#${string}`, string>;
|
|
94
94
|
}, "strip", z.ZodTypeAny, {
|
|
95
|
-
main: Record<string, `#${string}`>;
|
|
96
95
|
neutral: `#${string}`;
|
|
96
|
+
main: Record<string, `#${string}`>;
|
|
97
97
|
support: Record<string, `#${string}`>;
|
|
98
98
|
}, {
|
|
99
|
-
main: Record<string, string>;
|
|
100
99
|
neutral: string;
|
|
100
|
+
main: Record<string, string>;
|
|
101
101
|
support?: Record<string, string> | undefined;
|
|
102
102
|
}>;
|
|
103
103
|
typography: z.ZodOptional<z.ZodObject<{
|
|
@@ -110,8 +110,8 @@ export declare const combinedConfigSchema: z.ZodObject<{
|
|
|
110
110
|
borderRadius: z.ZodOptional<z.ZodNumber>;
|
|
111
111
|
}, "strip", z.ZodTypeAny, {
|
|
112
112
|
colors: {
|
|
113
|
-
main: Record<string, `#${string}`>;
|
|
114
113
|
neutral: `#${string}`;
|
|
114
|
+
main: Record<string, `#${string}`>;
|
|
115
115
|
support: Record<string, `#${string}`>;
|
|
116
116
|
};
|
|
117
117
|
typography?: {
|
|
@@ -120,8 +120,8 @@ export declare const combinedConfigSchema: z.ZodObject<{
|
|
|
120
120
|
borderRadius?: number | undefined;
|
|
121
121
|
}, {
|
|
122
122
|
colors: {
|
|
123
|
-
main: Record<string, string>;
|
|
124
123
|
neutral: string;
|
|
124
|
+
main: Record<string, string>;
|
|
125
125
|
support?: Record<string, string> | undefined;
|
|
126
126
|
};
|
|
127
127
|
typography?: {
|
|
@@ -133,8 +133,8 @@ export declare const combinedConfigSchema: z.ZodObject<{
|
|
|
133
133
|
clean: boolean;
|
|
134
134
|
themes: Record<string, {
|
|
135
135
|
colors: {
|
|
136
|
-
main: Record<string, `#${string}`>;
|
|
137
136
|
neutral: `#${string}`;
|
|
137
|
+
main: Record<string, `#${string}`>;
|
|
138
138
|
support: Record<string, `#${string}`>;
|
|
139
139
|
};
|
|
140
140
|
typography?: {
|
|
@@ -147,8 +147,8 @@ export declare const combinedConfigSchema: z.ZodObject<{
|
|
|
147
147
|
clean: boolean;
|
|
148
148
|
themes: Record<string, {
|
|
149
149
|
colors: {
|
|
150
|
-
main: Record<string, string>;
|
|
151
150
|
neutral: string;
|
|
151
|
+
main: Record<string, string>;
|
|
152
152
|
support?: Record<string, string> | undefined;
|
|
153
153
|
};
|
|
154
154
|
typography?: {
|
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;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../bin/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,sBAQ5D;AAWD,eAAO,MAAM,UAAU,QAA2C,CAAC;AA+CnE;;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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as R from "ramda";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { convertToHex } from "../src/colors/index.js";
|
|
4
|
+
import { RESERVED_COLORS } from "../src/colors/theme.js";
|
|
4
5
|
import { cliOptions } from "../src/tokens/create.js";
|
|
5
6
|
function mapPathToOptionName(path) {
|
|
6
7
|
const normalisedPath = path[0] === "themes" ? ["theme", ...R.drop(2, path)] : path;
|
|
@@ -17,9 +18,23 @@ const hexPatterns = [
|
|
|
17
18
|
`#[0-9a-fA-F]{6}`,
|
|
18
19
|
`#[0-9a-fA-F]{8}`
|
|
19
20
|
];
|
|
21
|
+
const reservedColorsPattern = `^(?!(?:${RESERVED_COLORS.join("|")})$)`;
|
|
20
22
|
const colorRegex = new RegExp(`^${hexPatterns.join("|")}$`);
|
|
21
|
-
const colorSchema = z.string({
|
|
22
|
-
|
|
23
|
+
const colorSchema = z.string({
|
|
24
|
+
description: `A hex color, which is used for creating a color scale. Invalid color names: ${RESERVED_COLORS.join(", ")}`
|
|
25
|
+
}).regex(colorRegex).transform(convertToHex);
|
|
26
|
+
const colorCategorySchema = z.record(
|
|
27
|
+
z.string().regex(new RegExp(reservedColorsPattern, "i"), {
|
|
28
|
+
message: `Color names cannot include reserved names: ${RESERVED_COLORS.join(", ")}`
|
|
29
|
+
}),
|
|
30
|
+
colorSchema,
|
|
31
|
+
{
|
|
32
|
+
description: "One or more color definitions",
|
|
33
|
+
invalid_type_error: "Color definitions must be hex color values"
|
|
34
|
+
}
|
|
35
|
+
).refine((colors) => !Object.keys(colors).some((key) => RESERVED_COLORS.includes(key.toLowerCase())), {
|
|
36
|
+
message: `Color names cannot include reserved names: ${RESERVED_COLORS.join(", ")}`
|
|
37
|
+
});
|
|
23
38
|
const themeSchema = z.object(
|
|
24
39
|
{
|
|
25
40
|
colors: z.object(
|
|
@@ -12,7 +12,7 @@ import { cliOptions, createTokens } from "../src/tokens/create.js";
|
|
|
12
12
|
import { cleanDir } from "../src/tokens/utils.js";
|
|
13
13
|
import { writeTokens } from "../src/tokens/write.js";
|
|
14
14
|
import { combinedConfigSchema, configFileSchema, mapPathToOptionName } from "./config.js";
|
|
15
|
-
import {
|
|
15
|
+
import { getCliOption, getDefaultCliOption, getSuppliedCliOption } from "./options.js";
|
|
16
16
|
program.name("designsystemet").description("CLI for working with Designsystemet").showHelpAfterError();
|
|
17
17
|
function makeTokenCommands() {
|
|
18
18
|
const tokenCmd = createCommand("tokens");
|
|
@@ -39,7 +39,7 @@ function makeTokenCommands() {
|
|
|
39
39
|
`-o, --${cliOptions.outDir} <string>`,
|
|
40
40
|
`Output directory for created ${chalk.blue("design-tokens")}`,
|
|
41
41
|
DEFAULT_TOKENS_CREATE_DIR
|
|
42
|
-
).option(`--${cliOptions.clean} [boolean]`, "Clean output directory before creating tokens", parseBoolean, false).option("--dry [boolean]", `Dry run for created ${chalk.blue("design-tokens")}`, parseBoolean, false).option(`-f, --${cliOptions.theme.typography.fontFamily} <string>`, `Font family`, DEFAULT_FONT).option(
|
|
42
|
+
).option(`--${cliOptions.clean} [boolean]`, "Clean output directory before creating tokens", parseBoolean, false).option("--dry [boolean]", `Dry run for created ${chalk.blue("design-tokens")}`, parseBoolean, false).option(`-f, --${cliOptions.theme.typography.fontFamily} <string>`, `Font family (experimental)`, DEFAULT_FONT).option(
|
|
43
43
|
`-b, --${cliOptions.theme.borderRadius} <number>`,
|
|
44
44
|
`Unitless base border-radius in px`,
|
|
45
45
|
(radiusAsString) => Number(radiusAsString),
|
|
@@ -86,17 +86,17 @@ function makeTokenCommands() {
|
|
|
86
86
|
borderRadius: optionGetter(cmd, "borderRadius")
|
|
87
87
|
});
|
|
88
88
|
const unvalidatedConfig = noUndefined({
|
|
89
|
-
outDir: propsFromJson?.outDir ??
|
|
90
|
-
clean: propsFromJson?.clean ??
|
|
91
|
-
themes: propsFromJson?.themes ? (
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
R.
|
|
95
|
-
) : (
|
|
89
|
+
outDir: propsFromJson?.outDir ?? getCliOption(cmd, "outDir"),
|
|
90
|
+
clean: propsFromJson?.clean ?? getCliOption(cmd, "clean"),
|
|
91
|
+
themes: propsFromJson?.themes ? R.map((jsonThemeValues) => {
|
|
92
|
+
const defaultThemeValues = getThemeOptions(getDefaultCliOption);
|
|
93
|
+
const cliThemeValues = getThemeOptions(getSuppliedCliOption);
|
|
94
|
+
return R.mergeDeepRight(defaultThemeValues, R.mergeDeepRight(jsonThemeValues, cliThemeValues));
|
|
95
|
+
}, propsFromJson.themes) : (
|
|
96
96
|
// If there are no themes specified in the JSON config, we use both explicit
|
|
97
97
|
// and default theme options from the CLI.
|
|
98
98
|
{
|
|
99
|
-
[opts.theme]: getThemeOptions(
|
|
99
|
+
[opts.theme]: getThemeOptions(getCliOption)
|
|
100
100
|
}
|
|
101
101
|
)
|
|
102
102
|
});
|
package/dist/bin/options.d.ts
CHANGED
|
@@ -6,11 +6,16 @@ export type OptionGetter = ReturnType<typeof getOptionIfMatchingSource>;
|
|
|
6
6
|
* The difference between this and using the option directly is that we return undefined
|
|
7
7
|
* instead of the default value if the option was not explicitly set.
|
|
8
8
|
*/
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const getSuppliedCliOption: <Args extends unknown[], Opts extends OptionValues, K extends keyof Opts>(command: Command<Args, Opts>, option: K) => Opts[K] | undefined;
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* Get the default value specified for a CLI command option.
|
|
12
|
+
* Mostly useful for getting values which may later be overridden.
|
|
13
13
|
*/
|
|
14
|
-
export declare const
|
|
14
|
+
export declare const getDefaultCliOption: <Args extends unknown[], Opts extends OptionValues, K extends keyof Opts>(command: Command<Args, Opts>, option: K) => Opts[K] | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Try to get the explicitly supplied CLI option, and fall back to the default value
|
|
17
|
+
* for the option as defined in the {@link Command}
|
|
18
|
+
*/
|
|
19
|
+
export declare const getCliOption: <Args extends unknown[], Opts extends OptionValues, K extends keyof Opts>(command: Command<Args, Opts>, option: K) => Opts[K] | undefined;
|
|
15
20
|
export {};
|
|
16
21
|
//# sourceMappingURL=options.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../bin/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE5F,QAAA,MAAM,yBAAyB,eAChB,iBAAiB,EAAE,MAC/B,IAAI,SAAS,OAAO,EAAE,EAAE,IAAI,SAAS,YAAY,EAAE,CAAC,SAAS,MAAM,IAAI,WAC7D,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,UACpB,CAAC,wBAMV,CAAC;AAEJ,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAExE;;;;GAIG;AACH,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../bin/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE5F,QAAA,MAAM,yBAAyB,eAChB,iBAAiB,EAAE,MAC/B,IAAI,SAAS,OAAO,EAAE,EAAE,IAAI,SAAS,YAAY,EAAE,CAAC,SAAS,MAAM,IAAI,WAC7D,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,UACpB,CAAC,wBAMV,CAAC;AAEJ,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAExE;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAjB9B,IAAI,SAAS,OAAO,EAAE,EAAE,IAAI,SAAS,YAAY,EAAE,CAAC,SAAS,MAAM,IAAI,WAC7D,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,UACpB,CAAC,wBAeuD,CAAC;AAErE;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAvB7B,IAAI,SAAS,OAAO,EAAE,EAAE,IAAI,SAAS,YAAY,EAAE,CAAC,SAAS,MAAM,IAAI,WAC7D,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,UACpB,CAAC,wBAqB0D,CAAC;AAExE;;;GAGG;AACH,eAAO,MAAM,YAAY,GA7BtB,IAAI,SAAS,OAAO,EAAE,EAAE,IAAI,SAAS,YAAY,EAAE,CAAC,SAAS,MAAM,IAAI,WAC7D,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,UACpB,CAAC,wBA2B0D,CAAC"}
|
package/dist/bin/options.js
CHANGED
|
@@ -4,9 +4,11 @@ const getOptionIfMatchingSource = (...sources) => (command, option) => {
|
|
|
4
4
|
return command.getOptionValue(option);
|
|
5
5
|
}
|
|
6
6
|
};
|
|
7
|
-
const
|
|
8
|
-
const
|
|
7
|
+
const getSuppliedCliOption = getOptionIfMatchingSource("cli");
|
|
8
|
+
const getDefaultCliOption = getOptionIfMatchingSource("default");
|
|
9
|
+
const getCliOption = getOptionIfMatchingSource("cli", "default");
|
|
9
10
|
export {
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
getCliOption,
|
|
12
|
+
getDefaultCliOption,
|
|
13
|
+
getSuppliedCliOption
|
|
12
14
|
};
|
package/dist/config.schema.json
CHANGED
|
@@ -25,13 +25,15 @@
|
|
|
25
25
|
"additionalProperties": {
|
|
26
26
|
"type": "string",
|
|
27
27
|
"pattern": "^#[0-9a-fA-F]{3}|#[0-9a-fA-F]{4}|#[0-9a-fA-F]{6}|#[0-9a-fA-F]{8}$",
|
|
28
|
-
"description": "A hex color, which is used for creating a color scale"
|
|
28
|
+
"description": "A hex color, which is used for creating a color scale. Invalid color names: neutral, success, warning, danger, info, blue, green, orange, purple, red"
|
|
29
|
+
},
|
|
30
|
+
"propertyNames": {
|
|
31
|
+
"pattern": "^(?!(?:neutral|success|warning|danger|info|blue|green|orange|purple|red)$)"
|
|
29
32
|
},
|
|
30
33
|
"description": "One or more color definitions"
|
|
31
34
|
},
|
|
32
35
|
"support": {
|
|
33
36
|
"$ref": "#/properties/themes/additionalProperties/properties/colors/properties/main",
|
|
34
|
-
"description": "One or more color definitions",
|
|
35
37
|
"default": {}
|
|
36
38
|
},
|
|
37
39
|
"neutral": {
|
|
@@ -1,4 +1,53 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ColorMetadataByName, ColorNumber, CssColor, GlobalColors } from './types.js';
|
|
2
2
|
export declare const baseColors: Record<GlobalColors, CssColor>;
|
|
3
|
-
export declare const colorMetadata:
|
|
3
|
+
export declare const colorMetadata: ColorMetadataByName;
|
|
4
|
+
export declare const getColorMetadataByNumber: (number: ColorNumber) => ({
|
|
5
|
+
name: "background-default";
|
|
6
|
+
number: 1;
|
|
7
|
+
} & import("./types.js").ColorMetadata) | ({
|
|
8
|
+
name: "background-tinted";
|
|
9
|
+
number: 2;
|
|
10
|
+
} & import("./types.js").ColorMetadata) | ({
|
|
11
|
+
name: "surface-default";
|
|
12
|
+
number: 3;
|
|
13
|
+
} & import("./types.js").ColorMetadata) | ({
|
|
14
|
+
name: "surface-tinted";
|
|
15
|
+
number: 4;
|
|
16
|
+
} & import("./types.js").ColorMetadata) | ({
|
|
17
|
+
name: "surface-hover";
|
|
18
|
+
number: 5;
|
|
19
|
+
} & import("./types.js").ColorMetadata) | ({
|
|
20
|
+
name: "surface-active";
|
|
21
|
+
number: 6;
|
|
22
|
+
} & import("./types.js").ColorMetadata) | ({
|
|
23
|
+
name: "border-subtle";
|
|
24
|
+
number: 7;
|
|
25
|
+
} & import("./types.js").ColorMetadata) | ({
|
|
26
|
+
name: "border-default";
|
|
27
|
+
number: 8;
|
|
28
|
+
} & import("./types.js").ColorMetadata) | ({
|
|
29
|
+
name: "border-strong";
|
|
30
|
+
number: 9;
|
|
31
|
+
} & import("./types.js").ColorMetadata) | ({
|
|
32
|
+
name: "text-subtle";
|
|
33
|
+
number: 10;
|
|
34
|
+
} & import("./types.js").ColorMetadata) | ({
|
|
35
|
+
name: "text-default";
|
|
36
|
+
number: 11;
|
|
37
|
+
} & import("./types.js").ColorMetadata) | ({
|
|
38
|
+
name: "base-default";
|
|
39
|
+
number: 12;
|
|
40
|
+
} & import("./types.js").ColorMetadata) | ({
|
|
41
|
+
name: "base-hover";
|
|
42
|
+
number: 13;
|
|
43
|
+
} & import("./types.js").ColorMetadata) | ({
|
|
44
|
+
name: "base-active";
|
|
45
|
+
number: 14;
|
|
46
|
+
} & import("./types.js").ColorMetadata) | ({
|
|
47
|
+
name: "base-contrast-subtle";
|
|
48
|
+
number: 15;
|
|
49
|
+
} & import("./types.js").ColorMetadata) | ({
|
|
50
|
+
name: "base-contrast-default";
|
|
51
|
+
number: 16;
|
|
52
|
+
} & import("./types.js").ColorMetadata);
|
|
4
53
|
//# sourceMappingURL=colorMetadata.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colorMetadata.d.ts","sourceRoot":"","sources":["../../../src/colors/colorMetadata.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"colorMetadata.d.ts","sourceRoot":"","sources":["../../../src/colors/colorMetadata.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE3F,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,YAAY,EAAE,QAAQ,CAMrD,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,mBAsM3B,CAAC;AAIF,eAAO,MAAM,wBAAwB,WAAY,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uCAE3D,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as R from "ramda";
|
|
1
2
|
const baseColors = {
|
|
2
3
|
blue: "#0A71C0",
|
|
3
4
|
green: "#068718",
|
|
@@ -6,8 +7,9 @@ const baseColors = {
|
|
|
6
7
|
red: "#C01B1B"
|
|
7
8
|
};
|
|
8
9
|
const colorMetadata = {
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
"background-default": {
|
|
11
|
+
number: 1,
|
|
12
|
+
name: "background-default",
|
|
11
13
|
group: "background",
|
|
12
14
|
displayName: "Background Default",
|
|
13
15
|
description: "Background Default er den mest n\xF8ytrale bakgrunnsfargen.",
|
|
@@ -17,8 +19,9 @@ const colorMetadata = {
|
|
|
17
19
|
contrast: 1e-3
|
|
18
20
|
}
|
|
19
21
|
},
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
"background-tinted": {
|
|
23
|
+
number: 2,
|
|
24
|
+
name: "background-tinted",
|
|
22
25
|
group: "background",
|
|
23
26
|
displayName: "Background Tinted",
|
|
24
27
|
description: "Background Tinted er en bakgrunnsfarge som har et hint av farge i seg.",
|
|
@@ -28,8 +31,9 @@ const colorMetadata = {
|
|
|
28
31
|
contrast: 65e-4
|
|
29
32
|
}
|
|
30
33
|
},
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
"surface-default": {
|
|
35
|
+
number: 3,
|
|
36
|
+
name: "surface-default",
|
|
33
37
|
group: "surface",
|
|
34
38
|
displayName: "Surface Default",
|
|
35
39
|
description: "Surface Default brukes p\xE5 flater som ligger opp\xE5 bakgrunnsfargene. Dette er den mest n\xF8ytrale surface fargen.",
|
|
@@ -39,8 +43,9 @@ const colorMetadata = {
|
|
|
39
43
|
contrast: 0.015
|
|
40
44
|
}
|
|
41
45
|
},
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
"surface-tinted": {
|
|
47
|
+
number: 4,
|
|
48
|
+
name: "surface-tinted",
|
|
44
49
|
group: "surface",
|
|
45
50
|
displayName: "Surface Tinted",
|
|
46
51
|
description: "Surface Tinted brukes p\xE5 flater som ligger opp\xE5 bakgrunnsfargene. Denne har et hint av farge i seg.",
|
|
@@ -50,8 +55,9 @@ const colorMetadata = {
|
|
|
50
55
|
contrast: 0.015
|
|
51
56
|
}
|
|
52
57
|
},
|
|
53
|
-
|
|
54
|
-
|
|
58
|
+
"surface-hover": {
|
|
59
|
+
number: 5,
|
|
60
|
+
name: "surface-hover",
|
|
55
61
|
group: "surface",
|
|
56
62
|
displayName: "Surface Hover",
|
|
57
63
|
description: "Surface Hover brukes p\xE5 interaktive flater som ligger opp\xE5 bakgrunnsfargene i en hover state.",
|
|
@@ -61,8 +67,9 @@ const colorMetadata = {
|
|
|
61
67
|
contrast: 0.028
|
|
62
68
|
}
|
|
63
69
|
},
|
|
64
|
-
|
|
65
|
-
|
|
70
|
+
"surface-active": {
|
|
71
|
+
number: 6,
|
|
72
|
+
name: "surface-active",
|
|
66
73
|
group: "surface",
|
|
67
74
|
displayName: "Surface Active",
|
|
68
75
|
description: "Surface Active brukes p\xE5 interaktive flater som ligger opp\xE5 bakgrunnsfargene i en active state.",
|
|
@@ -72,8 +79,9 @@ const colorMetadata = {
|
|
|
72
79
|
contrast: 0.045
|
|
73
80
|
}
|
|
74
81
|
},
|
|
75
|
-
|
|
76
|
-
|
|
82
|
+
"border-subtle": {
|
|
83
|
+
number: 7,
|
|
84
|
+
name: "border-subtle",
|
|
77
85
|
group: "border",
|
|
78
86
|
displayName: "Border Subtle",
|
|
79
87
|
description: "Border Subtle er den lyseste border-fargen og brukes for \xE5 skille elementer fra hverandre.",
|
|
@@ -83,8 +91,9 @@ const colorMetadata = {
|
|
|
83
91
|
contrast: 0.26
|
|
84
92
|
}
|
|
85
93
|
},
|
|
86
|
-
|
|
87
|
-
|
|
94
|
+
"border-default": {
|
|
95
|
+
number: 8,
|
|
96
|
+
name: "border-default",
|
|
88
97
|
group: "border",
|
|
89
98
|
displayName: "Border Default",
|
|
90
99
|
description: "Border Default er en border-farge som brukes n\xE5r man \xF8nsker god kontrast mot bakgrunnsfargene.",
|
|
@@ -94,8 +103,9 @@ const colorMetadata = {
|
|
|
94
103
|
contrast: 0.4
|
|
95
104
|
}
|
|
96
105
|
},
|
|
97
|
-
|
|
98
|
-
|
|
106
|
+
"border-strong": {
|
|
107
|
+
number: 9,
|
|
108
|
+
name: "border-strong",
|
|
99
109
|
group: "border",
|
|
100
110
|
displayName: "Border Strong",
|
|
101
111
|
description: "Border Strong er den m\xF8rkeste border-fargen og brukes n\xE5r man \xF8nsker en veldig tydelig og sterk border.",
|
|
@@ -105,8 +115,9 @@ const colorMetadata = {
|
|
|
105
115
|
contrast: 0.6
|
|
106
116
|
}
|
|
107
117
|
},
|
|
108
|
-
|
|
109
|
-
|
|
118
|
+
"text-subtle": {
|
|
119
|
+
number: 10,
|
|
120
|
+
name: "text-subtle",
|
|
110
121
|
group: "text",
|
|
111
122
|
displayName: "Text Subtle",
|
|
112
123
|
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.",
|
|
@@ -116,8 +127,9 @@ const colorMetadata = {
|
|
|
116
127
|
contrast: 0.57
|
|
117
128
|
}
|
|
118
129
|
},
|
|
119
|
-
|
|
120
|
-
|
|
130
|
+
"text-default": {
|
|
131
|
+
number: 11,
|
|
132
|
+
name: "text-default",
|
|
121
133
|
group: "text",
|
|
122
134
|
displayName: "Text Default",
|
|
123
135
|
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.",
|
|
@@ -127,8 +139,9 @@ const colorMetadata = {
|
|
|
127
139
|
contrast: 0.86
|
|
128
140
|
}
|
|
129
141
|
},
|
|
130
|
-
|
|
131
|
-
|
|
142
|
+
"base-default": {
|
|
143
|
+
number: 12,
|
|
144
|
+
name: "base-default",
|
|
132
145
|
group: "base",
|
|
133
146
|
displayName: "Base Default",
|
|
134
147
|
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.",
|
|
@@ -138,8 +151,9 @@ const colorMetadata = {
|
|
|
138
151
|
contrast: 1
|
|
139
152
|
}
|
|
140
153
|
},
|
|
141
|
-
|
|
142
|
-
|
|
154
|
+
"base-hover": {
|
|
155
|
+
number: 13,
|
|
156
|
+
name: "base-hover",
|
|
143
157
|
group: "base",
|
|
144
158
|
displayName: "Base Hover",
|
|
145
159
|
description: "Base Hover brukes som hover farge p\xE5 elementer som bruker Base Default fargen.",
|
|
@@ -149,8 +163,9 @@ const colorMetadata = {
|
|
|
149
163
|
contrast: 1
|
|
150
164
|
}
|
|
151
165
|
},
|
|
152
|
-
|
|
153
|
-
|
|
166
|
+
"base-active": {
|
|
167
|
+
number: 14,
|
|
168
|
+
name: "base-active",
|
|
154
169
|
group: "base",
|
|
155
170
|
displayName: "Base Active",
|
|
156
171
|
description: "Base Active brukes som active farge p\xE5 elementer som bruker Base Default fargen.",
|
|
@@ -160,8 +175,9 @@ const colorMetadata = {
|
|
|
160
175
|
contrast: 1
|
|
161
176
|
}
|
|
162
177
|
},
|
|
163
|
-
|
|
164
|
-
|
|
178
|
+
"base-contrast-subtle": {
|
|
179
|
+
number: 15,
|
|
180
|
+
name: "base-contrast-subtle",
|
|
165
181
|
group: "base",
|
|
166
182
|
displayName: "Contrast Subtle",
|
|
167
183
|
description: "Contrast Subtle brukes som en viktig meningsb\xE6rende farge opp\xE5 Base Default fargen.",
|
|
@@ -171,8 +187,9 @@ const colorMetadata = {
|
|
|
171
187
|
contrast: 1
|
|
172
188
|
}
|
|
173
189
|
},
|
|
174
|
-
|
|
175
|
-
|
|
190
|
+
"base-contrast-default": {
|
|
191
|
+
number: 16,
|
|
192
|
+
name: "base-contrast-default",
|
|
176
193
|
group: "base",
|
|
177
194
|
displayName: "Contrast Default",
|
|
178
195
|
description: "Contrast Default brukes som en viktig meningsb\xE6rende farge opp\xE5 alle Base fargane.",
|
|
@@ -183,7 +200,12 @@ const colorMetadata = {
|
|
|
183
200
|
}
|
|
184
201
|
}
|
|
185
202
|
};
|
|
203
|
+
const colorMetadataByNumber = R.indexBy((metadata) => metadata.number, Object.values(colorMetadata));
|
|
204
|
+
const getColorMetadataByNumber = (number) => {
|
|
205
|
+
return colorMetadataByNumber[number];
|
|
206
|
+
};
|
|
186
207
|
export {
|
|
187
208
|
baseColors,
|
|
188
|
-
colorMetadata
|
|
209
|
+
colorMetadata,
|
|
210
|
+
getColorMetadataByNumber
|
|
189
211
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { CssColor } from './types.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Color, ColorNumber, ColorScheme, ThemeInfo } from './types.js';
|
|
3
|
+
export declare const RESERVED_COLORS: string[];
|
|
3
4
|
/**
|
|
4
5
|
* Generates a color scale based on a base color and a color mode.
|
|
5
6
|
*
|
|
6
7
|
* @param color The base color that is used to generate the color scale
|
|
7
8
|
* @param colorScheme The color scheme to generate a scale for
|
|
8
9
|
*/
|
|
9
|
-
export declare const generateColorScale: (color: CssColor, colorScheme: ColorScheme) =>
|
|
10
|
+
export declare const generateColorScale: (color: CssColor, colorScheme: ColorScheme) => Color[];
|
|
10
11
|
/**
|
|
11
12
|
* Generates color schemes based on a base color. Light, Dark and Contrast scales are included.
|
|
12
13
|
*
|