@digdir/designsystemet 1.0.0-next.48 → 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 +54 -54
- package/dist/bin/config.d.ts.map +1 -1
- package/dist/bin/config.js +2 -2
- package/dist/bin/designsystemet.js +7 -3
- package/dist/config.schema.json +1 -3
- 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 +2 -15
- package/dist/src/tokens/build.js +2 -2
- 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/$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.js +6 -6
- 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 +4 -7
- 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/{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.ZodDefault<z.ZodOptional<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
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
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;
|
|
@@ -71,10 +71,10 @@ export declare const configFileSchema: z.ZodObject<{
|
|
|
71
71
|
neutral: string;
|
|
72
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.ZodDefault<z.ZodOptional<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
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
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
|
}, {
|
|
@@ -151,10 +151,10 @@ export declare const combinedConfigSchema: z.ZodObject<{
|
|
|
151
151
|
neutral: string;
|
|
152
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
|
@@ -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");
|
|
@@ -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.
|
|
@@ -109,10 +110,13 @@ function makeTokenCommands() {
|
|
|
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;
|
package/dist/config.schema.json
CHANGED
|
@@ -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"}
|
package/dist/src/colors/theme.js
CHANGED
|
@@ -1,44 +1,30 @@
|
|
|
1
1
|
import chroma from "chroma-js";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
blue: "#0A71C0",
|
|
6
|
-
green: "#068718",
|
|
7
|
-
orange: "#B8581D",
|
|
8
|
-
purple: "#663299",
|
|
9
|
-
red: "#C01B1B",
|
|
10
|
-
yellow: "#D4B12F"
|
|
11
|
-
};
|
|
2
|
+
import * as R from "ramda";
|
|
3
|
+
import { colorMetadata } from "./colorMetadata.js";
|
|
4
|
+
import { getColorInfoFromPosition, getLightnessFromHex, getLuminanceFromLightness } from "./utils.js";
|
|
12
5
|
const generateColorScale = (color, colorScheme) => {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}));
|
|
20
|
-
const specialColors = [
|
|
21
|
-
{ hex: baseColors2.baseDefault, number: 9 },
|
|
22
|
-
{ hex: baseColors2.baseHover, number: 10 },
|
|
23
|
-
{ hex: baseColors2.baseActive, number: 11 },
|
|
24
|
-
{ hex: getContrastDefault(baseColors2.baseDefault), number: 14 },
|
|
25
|
-
{ hex: getContrastSubtle(baseColors2.baseDefault), number: 15 }
|
|
26
|
-
];
|
|
27
|
-
for (const { hex, number } of specialColors) {
|
|
28
|
-
outputArray[number - 1] = {
|
|
29
|
-
hex,
|
|
30
|
-
number,
|
|
31
|
-
name: getColorNameFromNumber(number)
|
|
6
|
+
const colors = R.mapObjIndexed((colorData, key) => {
|
|
7
|
+
const luminance = colorData.luminance[colorScheme];
|
|
8
|
+
return {
|
|
9
|
+
...colorData,
|
|
10
|
+
hex: chroma(color).luminance(luminance).hex(),
|
|
11
|
+
number: parseInt(key)
|
|
32
12
|
};
|
|
33
|
-
}
|
|
34
|
-
|
|
13
|
+
}, colorMetadata);
|
|
14
|
+
const baseColors = generateBaseColors(color, colorScheme);
|
|
15
|
+
colors["12"] = { ...colors["12"], hex: baseColors.default };
|
|
16
|
+
colors["13"] = { ...colors["13"], hex: baseColors.hover };
|
|
17
|
+
colors["14"] = { ...colors["14"], hex: baseColors.active };
|
|
18
|
+
colors["15"] = { ...colors["15"], hex: generateColorContrast(baseColors.default, "subtle") };
|
|
19
|
+
colors["16"] = { ...colors["16"], hex: generateColorContrast(baseColors.default, "default") };
|
|
20
|
+
return Object.values(colors);
|
|
35
21
|
};
|
|
36
22
|
const generateColorSchemes = (color) => ({
|
|
37
23
|
light: generateColorScale(color, "light"),
|
|
38
24
|
dark: generateColorScale(color, "dark"),
|
|
39
25
|
contrast: generateColorScale(color, "contrast")
|
|
40
26
|
});
|
|
41
|
-
const
|
|
27
|
+
const generateBaseColors = (color, colorScheme) => {
|
|
42
28
|
let colorLightness = getLightnessFromHex(color);
|
|
43
29
|
if (colorScheme !== "light") {
|
|
44
30
|
colorLightness = colorLightness <= 30 ? 70 : 100 - colorLightness;
|
|
@@ -46,28 +32,31 @@ const getBaseColors = (color, colorScheme) => {
|
|
|
46
32
|
const modifier = colorLightness <= 30 || colorLightness >= 49 && colorLightness <= 65 ? -8 : 8;
|
|
47
33
|
const calculateLightness = (base, mod) => base - mod;
|
|
48
34
|
return {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
35
|
+
default: colorScheme === "light" ? color : chroma(color).luminance(getLuminanceFromLightness(colorLightness)).hex(),
|
|
36
|
+
hover: chroma(color).luminance(getLuminanceFromLightness(calculateLightness(colorLightness, modifier))).hex(),
|
|
37
|
+
active: chroma(color).luminance(getLuminanceFromLightness(calculateLightness(colorLightness, modifier * 2))).hex()
|
|
52
38
|
};
|
|
53
39
|
};
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
40
|
+
const generateColorContrast = (color, type) => {
|
|
41
|
+
if (type === "default") {
|
|
42
|
+
return chroma.contrast(color, "#ffffff") >= chroma.contrast(color, "#000000") ? "#ffffff" : "#000000";
|
|
43
|
+
}
|
|
44
|
+
if (type === "subtle") {
|
|
45
|
+
const contrastWhite = chroma.contrast(color, "#ffffff");
|
|
46
|
+
const contrastBlack = chroma.contrast(color, "#000000");
|
|
47
|
+
const lightness = getLightnessFromHex(color);
|
|
48
|
+
const modifier = lightness <= 40 || lightness >= 60 ? 60 : 50;
|
|
49
|
+
const targetLightness = contrastWhite >= contrastBlack ? lightness + modifier : lightness - modifier;
|
|
50
|
+
return chroma(color).luminance(getLuminanceFromLightness(targetLightness)).hex();
|
|
51
|
+
}
|
|
52
|
+
return color;
|
|
62
53
|
};
|
|
63
54
|
const getCssVariable = (colorType, colorNumber) => {
|
|
64
|
-
return `--ds-color-${colorType}-${
|
|
55
|
+
return `--ds-color-${colorType}-${getColorInfoFromPosition(colorNumber).displayName.toLowerCase().replace(/\s/g, "-")}`;
|
|
65
56
|
};
|
|
66
57
|
export {
|
|
67
|
-
|
|
58
|
+
generateColorContrast,
|
|
68
59
|
generateColorScale,
|
|
69
60
|
generateColorSchemes,
|
|
70
|
-
getContrastDefault,
|
|
71
|
-
getContrastSubtle,
|
|
72
61
|
getCssVariable
|
|
73
62
|
};
|