@symbo.ls/scratch 3.8.0 → 3.8.6
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 +50 -1
- package/dist/cjs/defaultConfig/index.js +3 -2
- package/dist/cjs/set.js +35 -20
- package/dist/cjs/system/color.js +6 -1
- package/dist/cjs/system/font.js +6 -2
- package/dist/cjs/system/theme.js +184 -0
- package/dist/cjs/utils/font.js +17 -9
- package/dist/esm/defaultConfig/index.js +3 -2
- package/dist/esm/set.js +36 -21
- package/dist/esm/system/color.js +6 -1
- package/dist/esm/system/font.js +6 -2
- package/dist/esm/system/theme.js +184 -0
- package/dist/esm/utils/font.js +17 -9
- package/dist/iife/index.js +273 -47
- package/package.json +3 -3
- package/src/defaultConfig/index.js +1 -1
- package/src/set.js +50 -30
- package/src/system/color.js +7 -1
- package/src/system/font.js +8 -2
- package/src/system/theme.js +68 -0
- package/src/utils/font.js +22 -10
package/dist/esm/system/theme.js
CHANGED
|
@@ -7,6 +7,163 @@ import {
|
|
|
7
7
|
isObjectLike,
|
|
8
8
|
isArray
|
|
9
9
|
} from "@domql/utils";
|
|
10
|
+
const CSS_NAMED_COLORS = /* @__PURE__ */ new Set([
|
|
11
|
+
"black",
|
|
12
|
+
"white",
|
|
13
|
+
"red",
|
|
14
|
+
"green",
|
|
15
|
+
"blue",
|
|
16
|
+
"yellow",
|
|
17
|
+
"orange",
|
|
18
|
+
"purple",
|
|
19
|
+
"pink",
|
|
20
|
+
"brown",
|
|
21
|
+
"gray",
|
|
22
|
+
"grey",
|
|
23
|
+
"cyan",
|
|
24
|
+
"magenta",
|
|
25
|
+
"lime",
|
|
26
|
+
"olive",
|
|
27
|
+
"navy",
|
|
28
|
+
"teal",
|
|
29
|
+
"aqua",
|
|
30
|
+
"maroon",
|
|
31
|
+
"silver",
|
|
32
|
+
"fuchsia",
|
|
33
|
+
"transparent",
|
|
34
|
+
"currentColor",
|
|
35
|
+
"currentcolor",
|
|
36
|
+
"inherit",
|
|
37
|
+
"initial",
|
|
38
|
+
"unset",
|
|
39
|
+
"none",
|
|
40
|
+
"aliceblue",
|
|
41
|
+
"antiquewhite",
|
|
42
|
+
"aquamarine",
|
|
43
|
+
"azure",
|
|
44
|
+
"beige",
|
|
45
|
+
"bisque",
|
|
46
|
+
"blanchedalmond",
|
|
47
|
+
"blueviolet",
|
|
48
|
+
"burlywood",
|
|
49
|
+
"cadetblue",
|
|
50
|
+
"chartreuse",
|
|
51
|
+
"chocolate",
|
|
52
|
+
"coral",
|
|
53
|
+
"cornflowerblue",
|
|
54
|
+
"cornsilk",
|
|
55
|
+
"crimson",
|
|
56
|
+
"darkblue",
|
|
57
|
+
"darkcyan",
|
|
58
|
+
"darkgoldenrod",
|
|
59
|
+
"darkgray",
|
|
60
|
+
"darkgreen",
|
|
61
|
+
"darkgrey",
|
|
62
|
+
"darkkhaki",
|
|
63
|
+
"darkmagenta",
|
|
64
|
+
"darkolivegreen",
|
|
65
|
+
"darkorange",
|
|
66
|
+
"darkorchid",
|
|
67
|
+
"darkred",
|
|
68
|
+
"darksalmon",
|
|
69
|
+
"darkseagreen",
|
|
70
|
+
"darkslateblue",
|
|
71
|
+
"darkslategray",
|
|
72
|
+
"darkslategrey",
|
|
73
|
+
"darkturquoise",
|
|
74
|
+
"darkviolet",
|
|
75
|
+
"deeppink",
|
|
76
|
+
"deepskyblue",
|
|
77
|
+
"dimgray",
|
|
78
|
+
"dimgrey",
|
|
79
|
+
"dodgerblue",
|
|
80
|
+
"firebrick",
|
|
81
|
+
"floralwhite",
|
|
82
|
+
"forestgreen",
|
|
83
|
+
"gainsboro",
|
|
84
|
+
"ghostwhite",
|
|
85
|
+
"gold",
|
|
86
|
+
"goldenrod",
|
|
87
|
+
"greenyellow",
|
|
88
|
+
"honeydew",
|
|
89
|
+
"hotpink",
|
|
90
|
+
"indianred",
|
|
91
|
+
"indigo",
|
|
92
|
+
"ivory",
|
|
93
|
+
"khaki",
|
|
94
|
+
"lavender",
|
|
95
|
+
"lavenderblush",
|
|
96
|
+
"lawngreen",
|
|
97
|
+
"lemonchiffon",
|
|
98
|
+
"lightblue",
|
|
99
|
+
"lightcoral",
|
|
100
|
+
"lightcyan",
|
|
101
|
+
"lightgoldenrodyellow",
|
|
102
|
+
"lightgray",
|
|
103
|
+
"lightgreen",
|
|
104
|
+
"lightgrey",
|
|
105
|
+
"lightpink",
|
|
106
|
+
"lightsalmon",
|
|
107
|
+
"lightseagreen",
|
|
108
|
+
"lightskyblue",
|
|
109
|
+
"lightslategray",
|
|
110
|
+
"lightslategrey",
|
|
111
|
+
"lightsteelblue",
|
|
112
|
+
"lightyellow",
|
|
113
|
+
"limegreen",
|
|
114
|
+
"linen",
|
|
115
|
+
"mediumaquamarine",
|
|
116
|
+
"mediumblue",
|
|
117
|
+
"mediumorchid",
|
|
118
|
+
"mediumpurple",
|
|
119
|
+
"mediumseagreen",
|
|
120
|
+
"mediumslateblue",
|
|
121
|
+
"mediumspringgreen",
|
|
122
|
+
"mediumturquoise",
|
|
123
|
+
"mediumvioletred",
|
|
124
|
+
"midnightblue",
|
|
125
|
+
"mintcream",
|
|
126
|
+
"mistyrose",
|
|
127
|
+
"moccasin",
|
|
128
|
+
"navajowhite",
|
|
129
|
+
"oldlace",
|
|
130
|
+
"olivedrab",
|
|
131
|
+
"orangered",
|
|
132
|
+
"orchid",
|
|
133
|
+
"palegoldenrod",
|
|
134
|
+
"palegreen",
|
|
135
|
+
"paleturquoise",
|
|
136
|
+
"palevioletred",
|
|
137
|
+
"papayawhip",
|
|
138
|
+
"peachpuff",
|
|
139
|
+
"peru",
|
|
140
|
+
"plum",
|
|
141
|
+
"powderblue",
|
|
142
|
+
"rosybrown",
|
|
143
|
+
"royalblue",
|
|
144
|
+
"saddlebrown",
|
|
145
|
+
"salmon",
|
|
146
|
+
"sandybrown",
|
|
147
|
+
"seagreen",
|
|
148
|
+
"seashell",
|
|
149
|
+
"sienna",
|
|
150
|
+
"skyblue",
|
|
151
|
+
"slateblue",
|
|
152
|
+
"slategray",
|
|
153
|
+
"slategrey",
|
|
154
|
+
"snow",
|
|
155
|
+
"springgreen",
|
|
156
|
+
"steelblue",
|
|
157
|
+
"tan",
|
|
158
|
+
"thistle",
|
|
159
|
+
"tomato",
|
|
160
|
+
"turquoise",
|
|
161
|
+
"violet",
|
|
162
|
+
"wheat",
|
|
163
|
+
"whitesmoke",
|
|
164
|
+
"yellowgreen",
|
|
165
|
+
"rebeccapurple"
|
|
166
|
+
]);
|
|
10
167
|
const setThemeValue = (theme) => {
|
|
11
168
|
const value = {};
|
|
12
169
|
const { state, media, helpers, ...rest } = theme;
|
|
@@ -130,6 +287,23 @@ const generateAutoVars = (schemes, varPrefix, CONFIG) => {
|
|
|
130
287
|
for (const scheme in schemes) {
|
|
131
288
|
if (schemes[scheme]) for (const k of Object.keys(schemes[scheme])) allKeys.add(k);
|
|
132
289
|
}
|
|
290
|
+
const brokenSchemes = /* @__PURE__ */ new Set();
|
|
291
|
+
if (globalTheme === "auto") {
|
|
292
|
+
for (const param of allKeys) {
|
|
293
|
+
const symb = param.slice(0, 1);
|
|
294
|
+
if (symb === "@" || symb === "." || symb === ":") continue;
|
|
295
|
+
for (const scheme in schemes) {
|
|
296
|
+
if (brokenSchemes.has(scheme)) continue;
|
|
297
|
+
const val = schemes[scheme]?.[param];
|
|
298
|
+
if (val === void 0) continue;
|
|
299
|
+
const color = getColor(val, `@${scheme}`);
|
|
300
|
+
if (color === void 0) continue;
|
|
301
|
+
if (isString(color) && /^[a-z][a-zA-Z]+$/.test(color) && !CSS_NAMED_COLORS.has(color)) {
|
|
302
|
+
brokenSchemes.add(scheme);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
133
307
|
for (const param of allKeys) {
|
|
134
308
|
const symb = param.slice(0, 1);
|
|
135
309
|
const hasObject = Object.values(schemes).some((s) => isObjectLike(s?.[param]));
|
|
@@ -150,11 +324,16 @@ const generateAutoVars = (schemes, varPrefix, CONFIG) => {
|
|
|
150
324
|
} else if (symb !== "@" && symb !== "." && symb !== ":") {
|
|
151
325
|
const autoVar = `--theme-${varPrefix}-${param}`;
|
|
152
326
|
if (globalTheme === "auto") {
|
|
327
|
+
let fallbackColor;
|
|
153
328
|
for (const scheme in schemes) {
|
|
329
|
+
if (brokenSchemes.has(scheme)) continue;
|
|
154
330
|
const val = schemes[scheme]?.[param];
|
|
155
331
|
if (val === void 0) continue;
|
|
156
332
|
const color = getColor(val, `@${scheme}`);
|
|
157
333
|
if (color === void 0) continue;
|
|
334
|
+
if (scheme === "light" || fallbackColor === void 0) {
|
|
335
|
+
fallbackColor = color;
|
|
336
|
+
}
|
|
158
337
|
const selector = `[data-theme="${scheme}"]`;
|
|
159
338
|
if (!MEDIA_VARS[selector]) MEDIA_VARS[selector] = {};
|
|
160
339
|
MEDIA_VARS[selector][autoVar] = color;
|
|
@@ -164,6 +343,9 @@ const generateAutoVars = (schemes, varPrefix, CONFIG) => {
|
|
|
164
343
|
MEDIA_VARS[mq][autoVar] = color;
|
|
165
344
|
}
|
|
166
345
|
}
|
|
346
|
+
if (fallbackColor !== void 0) {
|
|
347
|
+
CSS_VARS[autoVar] = fallbackColor;
|
|
348
|
+
}
|
|
167
349
|
} else {
|
|
168
350
|
const forced = String(globalTheme).replace(/^'|'$/g, "");
|
|
169
351
|
const source = schemes[forced]?.[param];
|
|
@@ -247,6 +429,8 @@ const recursiveTheme = (val) => {
|
|
|
247
429
|
continue;
|
|
248
430
|
} else if (symb === ":") {
|
|
249
431
|
obj[`&${param}`] = recursiveTheme(val[param]);
|
|
432
|
+
} else if (symb === ".") {
|
|
433
|
+
obj[`&${param}`] = recursiveTheme(val[param]);
|
|
250
434
|
}
|
|
251
435
|
} else obj[param] = val[param];
|
|
252
436
|
}
|
package/dist/esm/utils/font.js
CHANGED
|
@@ -24,24 +24,28 @@ const isGoogleFontsUrl = (url) => url && (url.includes("fonts.googleapis.com") |
|
|
|
24
24
|
const setFontImport = (url) => `@import url('${url}');`;
|
|
25
25
|
const setInCustomFontMedia = (str) => `@font-face { ${str} }`;
|
|
26
26
|
const setCustomFont = (name, url, weight, options = {}) => {
|
|
27
|
-
const
|
|
28
|
-
const
|
|
27
|
+
const urls = Array.isArray(url) ? url : [url];
|
|
28
|
+
const srcList = urls.map((u) => {
|
|
29
|
+
const format = getFontFormat(u);
|
|
30
|
+
const formatStr = format ? ` format('${format}')` : "";
|
|
31
|
+
return `url('${u}')${formatStr}`;
|
|
32
|
+
}).join(",\n ");
|
|
29
33
|
return `
|
|
30
34
|
font-family: '${name}';
|
|
31
|
-
font-style: normal;${weight ? `
|
|
35
|
+
font-style: ${options.fontStyle || "normal"};${weight ? `
|
|
32
36
|
font-weight: ${weight};` : ""}${options.fontStretch ? `
|
|
33
37
|
font-stretch: ${options.fontStretch};` : ""}${options.fontDisplay ? `
|
|
34
38
|
font-display: ${options.fontDisplay};` : ""}
|
|
35
|
-
src:
|
|
39
|
+
src: ${srcList};`;
|
|
36
40
|
};
|
|
37
41
|
const setCustomFontMedia = (name, url, weight, options) => `@font-face {${setCustomFont(name, url, weight, options)}
|
|
38
42
|
}`;
|
|
39
43
|
const getFontFaceEach = (name, weights, files) => {
|
|
40
44
|
const keys = Object.keys(weights);
|
|
41
45
|
return keys.map((key) => {
|
|
42
|
-
const { url, fontWeight } = weights[key];
|
|
43
|
-
const resolvedUrl = resolveFileUrl(url, files) || url;
|
|
44
|
-
return setCustomFont(name, resolvedUrl, fontWeight);
|
|
46
|
+
const { url, fontWeight, fontStyle, fontDisplay, fontStretch } = weights[key];
|
|
47
|
+
const resolvedUrl = Array.isArray(url) ? url.map((u) => resolveFileUrl(u, files) || u) : resolveFileUrl(url, files) || url;
|
|
48
|
+
return setCustomFont(name, resolvedUrl, fontWeight, { fontStyle, fontDisplay, fontStretch });
|
|
45
49
|
});
|
|
46
50
|
};
|
|
47
51
|
const getFontFace = (LIBRARY) => {
|
|
@@ -61,8 +65,12 @@ const getFontFaceEachString = (name, weights, files) => {
|
|
|
61
65
|
}
|
|
62
66
|
const isArr = weights[0];
|
|
63
67
|
if (isArr) return getFontFaceEach(name, weights, files).map(setInCustomFontMedia);
|
|
64
|
-
const url = resolveFileUrl(weights.url, files) || weights.url;
|
|
65
|
-
return setCustomFontMedia(name, url
|
|
68
|
+
const url = Array.isArray(weights.url) ? weights.url.map((u) => resolveFileUrl(u, files) || u) : resolveFileUrl(weights.url, files) || weights.url;
|
|
69
|
+
return setCustomFontMedia(name, url, weights.fontWeight, {
|
|
70
|
+
fontStyle: weights.fontStyle,
|
|
71
|
+
fontDisplay: weights.fontDisplay,
|
|
72
|
+
fontStretch: weights.fontStretch
|
|
73
|
+
});
|
|
66
74
|
};
|
|
67
75
|
const getFontFaceString = (LIBRARY, files) => {
|
|
68
76
|
const keys = Object.keys(LIBRARY);
|