lapikit 0.0.0-insiders.22823e3 → 0.0.0-insiders.4b1dc48
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.
|
@@ -23,7 +23,9 @@ export const processCSS = async (minified, normalize) => {
|
|
|
23
23
|
let styles = `${_variables}\n`;
|
|
24
24
|
if (normalize)
|
|
25
25
|
styles += `${_normalize}\n`;
|
|
26
|
-
colors();
|
|
26
|
+
const colorScheme = colors();
|
|
27
|
+
styles += `${colorScheme.root}\n`;
|
|
28
|
+
styles += `${colorScheme.className}\n`;
|
|
27
29
|
if (fs.existsSync(__components) && fs.statSync(__components).isDirectory()) {
|
|
28
30
|
const tresholds = {
|
|
29
31
|
_default: '',
|
|
@@ -36,11 +36,59 @@ export const colors = () => {
|
|
|
36
36
|
schemes['dark'][property] = parseColor(values.dark);
|
|
37
37
|
}
|
|
38
38
|
else {
|
|
39
|
-
const _refColor = 'dark' in values ? parseColor(values
|
|
39
|
+
const _refColor = 'dark' in values ? parseColor(values['dark']) : parseColor(values['light']);
|
|
40
40
|
schemes['light'][property] = _refColor;
|
|
41
41
|
schemes['dark'][property] = _refColor;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
const theming = 'mixed';
|
|
46
|
+
// css variables
|
|
47
|
+
let cssVariables = '';
|
|
48
|
+
if (theming === 'mixed') {
|
|
49
|
+
for (const [themeName, colors] of Object.entries(schemes)) {
|
|
50
|
+
const used = themeName;
|
|
51
|
+
const inversed = used === 'light' ? 'dark' : 'light';
|
|
52
|
+
cssVariables += `@media (prefers-color-scheme: ${used}) {\n`;
|
|
53
|
+
cssVariables += `:root, .${used} {\n`;
|
|
54
|
+
cssVariables += `color-scheme: ${used};\n`;
|
|
55
|
+
for (const [colorName, colorValue] of Object.entries(colors)) {
|
|
56
|
+
cssVariables += `--${colorName}: ${colorValue};\n`;
|
|
57
|
+
}
|
|
58
|
+
cssVariables += `}\n`;
|
|
59
|
+
cssVariables += `.${inversed} {\n`;
|
|
60
|
+
cssVariables += `color-scheme: ${used};\n`;
|
|
61
|
+
for (const [colorName, colorValue] of Object.entries(schemes[inversed])) {
|
|
62
|
+
cssVariables += `--${colorName}: ${colorValue};\n`;
|
|
63
|
+
}
|
|
64
|
+
cssVariables += `}\n`;
|
|
65
|
+
cssVariables += `}\n`;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
const used = theming;
|
|
70
|
+
const inversed = theming === 'light' ? 'dark' : 'light';
|
|
71
|
+
cssVariables += `:root, .${used} {\n`;
|
|
72
|
+
for (const [colorName, colorValue] of Object.entries(schemes[used])) {
|
|
73
|
+
cssVariables += `--${colorName}: ${colorValue};\n`;
|
|
74
|
+
}
|
|
75
|
+
cssVariables += `}\n`;
|
|
76
|
+
cssVariables += `.${inversed} {\n`;
|
|
77
|
+
for (const [colorName, colorValue] of Object.entries(schemes[inversed])) {
|
|
78
|
+
cssVariables += `--${colorName}: ${colorValue};\n`;
|
|
79
|
+
}
|
|
80
|
+
cssVariables += `}\n`;
|
|
81
|
+
}
|
|
82
|
+
// class
|
|
83
|
+
let classStyles = '';
|
|
84
|
+
for (const [property] of Object.entries(schemes.light)) {
|
|
85
|
+
classStyles += `.${property} {\n`;
|
|
86
|
+
classStyles += `--background-color: var(--${property});\n`;
|
|
87
|
+
classStyles += `--color: var(--${property});\n`;
|
|
88
|
+
classStyles += `}\n`;
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
root: cssVariables,
|
|
92
|
+
className: classStyles
|
|
93
|
+
};
|
|
46
94
|
};
|