@grucloud/bau-ui 0.21.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.
@@ -0,0 +1,100 @@
1
+ const COLORS = [
2
+ ["primary", { h: "230", s: "48%", l: "47%" }],
3
+ ["secondary", { h: "338", s: "100%", l: "48%" }],
4
+ ["success", { h: "120", s: "100%", l: "32%" }],
5
+ ["info", { h: "194", s: "80%", l: "62%" }],
6
+ ["warning", { h: "43", s: "100%", l: "50%" }],
7
+ ["danger", { h: "358", s: "95%", l: "60%" }],
8
+ ];
9
+
10
+ const SHADES_LIGHT = [
11
+ ["light", "1.15"],
12
+ ["lighter", "1.3"],
13
+ ["lightest", "1.5"],
14
+ ];
15
+ const SHADES_DARK = [
16
+ ["dark", "0.9"],
17
+ ["darker", "0.85"],
18
+ ["darkest", "0.7"],
19
+ ];
20
+
21
+ const buildGrays = () =>
22
+ new Array(10)
23
+ .fill("")
24
+ .map(
25
+ (v, index) =>
26
+ `--color-gray-${index * 100}: hsl(0, 0%, ${100 - 8 * index}%);`
27
+ )
28
+ .join("\n");
29
+
30
+ const buildEmphasis = () =>
31
+ new Array(10)
32
+ .fill("")
33
+ .map(
34
+ (v, index) =>
35
+ `--color-emphasis-${index * 100}: var(--color-gray-${index * 100});`
36
+ )
37
+ .join("\n");
38
+
39
+ const buildColor = ([color, { h, s, l }]) =>
40
+ [
41
+ `--color-${color}-h: ${h};`,
42
+ `--color-${color}-s: ${s};`,
43
+ `--color-${color}-l: ${l};`,
44
+ `--color-${color}-hsl: var(--color-${color}-h), var(--color-${color}-s), var(--color-${color}-l);`,
45
+ `--color-${color}: hsl(var(--color-${color}-hsl));`,
46
+ ...SHADES_LIGHT.map(
47
+ ([shade, value]) =>
48
+ `--color-${color}-${shade}: hsl(var(--color-${color}-h), var(--color-${color}-s), calc(var(--color-${color}-l) * ${value}));`
49
+ ),
50
+ ...SHADES_DARK.map(
51
+ ([shade, value]) =>
52
+ `--color-${color}-${shade}: hsl(var(--color-${color}-h), var(--color-${color}-s), calc(var(--color-${color}-l) * ${value}));`
53
+ ),
54
+ `--color-${color}-contrast-background: hsl(var(--color-${color}-h), var(--color-${color}-s), calc(var(--color-${color}-l) / var(--contrast-background-value)));`,
55
+ `--color-${color}-contrast-foreground: hsl(var(--color-${color}-h), var(--color-${color}-s), calc(var(--color-${color}-l) * var(--contrast-foreground-value)));`,
56
+ ].join("\n");
57
+
58
+ export function globalStyle({ createGlobalStyles }) {
59
+ createGlobalStyles`
60
+ :root {
61
+ --color-scheme: light;
62
+ --contrast-background-value: 90%;
63
+ --contrast-foreground-value: 70%;
64
+ --contrast-background-dark-value: 70%;
65
+ --contrast-foreground-dark-value: 90%;
66
+ --color-white: #fff;
67
+ --color-black: #000;
68
+ ${COLORS.map(([color, hsl]) => buildColor([color, hsl])).join("\n")}
69
+ ${buildGrays()}
70
+ ${buildEmphasis()}
71
+ --color-content: hsl(0, 0%, 10%);
72
+ --color-content-inverse: hsl(0, 0%, 90%);
73
+ --color-content-secondary: #525860;
74
+ --background-color: var(--color-white);
75
+ --background-surface-color: var(--color-content-inverse);
76
+ --global-border-width: 1px;
77
+ --global-radius: 0.4rem;
78
+ --font-color-base: var(--color-content);
79
+ --font-color-disabled: var(--color-emphasis-600);
80
+ --font-color-inverse: var(--color-content-inverse);
81
+ --font-color-secondary: var(--color-content-secondary);
82
+ --font-family: system-ui, -apple-system, Helvetica, Arial, sans-serif;
83
+ --font-family-monospace: Consolas, monospace;
84
+ --font-weight-light: 300;
85
+ --font-weight-normal: 400;
86
+ --font-weight-semibold: 500;
87
+ --font-weight-bold: 700;
88
+ --global-spacing: 1rem;
89
+ --spacing-vertical: var(--global-spacing);
90
+ --spacing-horizontal: var(--global-spacing);
91
+ --transition-fast: 200ms;
92
+ --transition-slow: 400ms;
93
+ --global-shadow-lw: 0 1px 2px 0 rgba(0, 0, 0, 0.1);
94
+ --global-shadow-md: 0 5px 40px rgba(0, 0, 0, 0.2);
95
+ --global-shadow-tl: 0 12px 28px 0 rgba(0, 0, 0, 0.2),
96
+ 0 2px 4px 0 rgba(0, 0, 0, 0.1);
97
+ }
98
+ @custom-media --narrow-window (max-width: 996px);
99
+ `;
100
+ }