@symbo.ls/scratch 3.8.9 → 3.14.1

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.
Files changed (119) hide show
  1. package/README.md +2 -2
  2. package/dist/cjs/defaultConfig/animation.js +4 -2
  3. package/dist/cjs/defaultConfig/cases.js +4 -2
  4. package/dist/cjs/defaultConfig/class.js +4 -2
  5. package/dist/cjs/defaultConfig/color.js +6 -9
  6. package/dist/cjs/defaultConfig/document.js +4 -2
  7. package/dist/cjs/defaultConfig/font-family.js +8 -12
  8. package/dist/cjs/defaultConfig/font.js +4 -11
  9. package/dist/cjs/defaultConfig/grid.js +5 -3
  10. package/dist/cjs/defaultConfig/icons.js +6 -4
  11. package/dist/cjs/defaultConfig/index.js +200 -24
  12. package/dist/cjs/defaultConfig/media.js +4 -2
  13. package/dist/cjs/defaultConfig/responsive.js +6 -4
  14. package/dist/cjs/defaultConfig/sequence.js +4 -2
  15. package/dist/cjs/defaultConfig/shadow.js +4 -2
  16. package/dist/cjs/defaultConfig/spacing.js +56 -7
  17. package/dist/cjs/defaultConfig/svg.js +6 -4
  18. package/dist/cjs/defaultConfig/templates.js +4 -2
  19. package/dist/cjs/defaultConfig/theme.js +4 -14
  20. package/dist/cjs/defaultConfig/timing.js +36 -5
  21. package/dist/cjs/defaultConfig/typography.js +36 -5
  22. package/dist/cjs/defaultConfig/unit.js +4 -2
  23. package/dist/cjs/factory.js +341 -40
  24. package/dist/cjs/index.js +6333 -11
  25. package/dist/cjs/package.json +4 -0
  26. package/dist/cjs/set.js +5614 -158
  27. package/dist/cjs/system/color.js +4481 -104
  28. package/dist/cjs/system/document.js +4371 -11
  29. package/dist/cjs/system/font.js +4401 -28
  30. package/dist/cjs/system/index.js +5748 -11
  31. package/dist/cjs/system/reset.js +4445 -21
  32. package/dist/cjs/system/shadow.js +4832 -41
  33. package/dist/cjs/system/spacing.js +4752 -39
  34. package/dist/cjs/system/svg.js +4437 -47
  35. package/dist/cjs/system/theme.js +4526 -335
  36. package/dist/cjs/system/timing.js +4695 -19
  37. package/dist/cjs/system/typography.js +4755 -33
  38. package/dist/cjs/tests/index.js +4 -2
  39. package/dist/cjs/transforms/index.js +5019 -134
  40. package/dist/cjs/utils/color.js +47 -66
  41. package/dist/cjs/utils/font.js +25 -46
  42. package/dist/cjs/utils/index.js +5068 -8
  43. package/dist/cjs/utils/sequence.js +4423 -35
  44. package/dist/cjs/utils/sprite.js +353 -12
  45. package/dist/cjs/utils/theme.js +3 -1
  46. package/dist/cjs/utils/unit.js +4 -2
  47. package/dist/cjs/utils/var.js +4390 -42
  48. package/index.js +1 -0
  49. package/package.json +11 -14
  50. package/src/defaultConfig/class.js +2 -1
  51. package/src/defaultConfig/font-family.js +3 -3
  52. package/src/defaultConfig/icons.js +1 -1
  53. package/src/defaultConfig/svg.js +1 -1
  54. package/src/defaultConfig/timing.js +1 -1
  55. package/src/factory.js +85 -13
  56. package/src/index.js +16 -5
  57. package/src/set.js +156 -63
  58. package/src/system/color.js +113 -12
  59. package/src/system/document.js +3 -3
  60. package/src/system/font.js +5 -5
  61. package/src/system/reset.js +41 -8
  62. package/src/system/shadow.js +4 -3
  63. package/src/system/spacing.js +3 -3
  64. package/src/system/svg.js +42 -5
  65. package/src/system/theme.js +87 -64
  66. package/src/system/timing.js +2 -2
  67. package/src/system/typography.js +12 -3
  68. package/src/transforms/index.js +4 -4
  69. package/src/utils/color.js +2 -1
  70. package/src/utils/font.js +7 -1
  71. package/src/utils/sequence.js +46 -29
  72. package/src/utils/sprite.js +44 -16
  73. package/src/utils/var.js +27 -9
  74. package/dist/esm/defaultConfig/animation.js +0 -4
  75. package/dist/esm/defaultConfig/cases.js +0 -4
  76. package/dist/esm/defaultConfig/class.js +0 -5
  77. package/dist/esm/defaultConfig/color.js +0 -11
  78. package/dist/esm/defaultConfig/document.js +0 -4
  79. package/dist/esm/defaultConfig/font-family.js +0 -18
  80. package/dist/esm/defaultConfig/font.js +0 -13
  81. package/dist/esm/defaultConfig/grid.js +0 -5
  82. package/dist/esm/defaultConfig/icons.js +0 -6
  83. package/dist/esm/defaultConfig/index.js +0 -25
  84. package/dist/esm/defaultConfig/media.js +0 -9
  85. package/dist/esm/defaultConfig/responsive.js +0 -30
  86. package/dist/esm/defaultConfig/sequence.js +0 -29
  87. package/dist/esm/defaultConfig/shadow.js +0 -4
  88. package/dist/esm/defaultConfig/spacing.js +0 -18
  89. package/dist/esm/defaultConfig/svg.js +0 -6
  90. package/dist/esm/defaultConfig/templates.js +0 -4
  91. package/dist/esm/defaultConfig/theme.js +0 -16
  92. package/dist/esm/defaultConfig/timing.js +0 -17
  93. package/dist/esm/defaultConfig/typography.js +0 -21
  94. package/dist/esm/defaultConfig/unit.js +0 -6
  95. package/dist/esm/factory.js +0 -60
  96. package/dist/esm/index.js +0 -12
  97. package/dist/esm/set.js +0 -219
  98. package/dist/esm/system/color.js +0 -193
  99. package/dist/esm/system/document.js +0 -16
  100. package/dist/esm/system/font.js +0 -58
  101. package/dist/esm/system/index.js +0 -10
  102. package/dist/esm/system/reset.js +0 -67
  103. package/dist/esm/system/shadow.js +0 -91
  104. package/dist/esm/system/spacing.js +0 -121
  105. package/dist/esm/system/svg.js +0 -86
  106. package/dist/esm/system/theme.js +0 -480
  107. package/dist/esm/system/timing.js +0 -32
  108. package/dist/esm/system/typography.js +0 -85
  109. package/dist/esm/tests/index.js +0 -8
  110. package/dist/esm/transforms/index.js +0 -216
  111. package/dist/esm/utils/color.js +0 -192
  112. package/dist/esm/utils/font.js +0 -92
  113. package/dist/esm/utils/index.js +0 -7
  114. package/dist/esm/utils/sequence.js +0 -303
  115. package/dist/esm/utils/sprite.js +0 -65
  116. package/dist/esm/utils/theme.js +0 -9
  117. package/dist/esm/utils/unit.js +0 -59
  118. package/dist/esm/utils/var.js +0 -82
  119. package/dist/iife/index.js +0 -3204
@@ -1,480 +0,0 @@
1
- import { getColor } from "./color";
2
- import { getActiveConfig } from "../factory.js";
3
- import { isCSSVar } from "../utils/color.js";
4
- import {
5
- isObject,
6
- isString,
7
- isObjectLike,
8
- isArray
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
- ]);
167
- const setThemeValue = (theme) => {
168
- const value = {};
169
- const { state, media, helpers, ...rest } = theme;
170
- const keys = Object.keys(rest);
171
- keys.map((key) => {
172
- const conditions = ["color", "Color", "background", "border"];
173
- const isColor = conditions.some((k) => key.includes(k));
174
- return value[key] = isColor ? getColor(theme[key]) : theme[key];
175
- });
176
- return value;
177
- };
178
- const getThemeValue = (theme) => {
179
- if (theme.value) return theme.value;
180
- theme.value = setThemeValue(theme);
181
- return theme.value;
182
- };
183
- const getTheme = (value, modifier) => {
184
- const CONFIG = getActiveConfig();
185
- if (CONFIG.useVariable) return getMediaTheme(value, modifier);
186
- const THEME = CONFIG.theme;
187
- if (isString(value)) {
188
- const [theme, subtheme] = value.split(" ");
189
- const isOurTheme = THEME[theme];
190
- if (isOurTheme) {
191
- if (!subtheme && !modifier) return getThemeValue(isOurTheme);
192
- value = [theme, subtheme || modifier];
193
- }
194
- }
195
- if (isObjectLike(value) && value[1]) {
196
- const themeName = value[0];
197
- const subThemeName = value[1];
198
- const { helpers, media, state } = THEME[themeName];
199
- if (media && media[subThemeName]) return getThemeValue(media[subThemeName]);
200
- if (helpers && helpers[subThemeName]) return getThemeValue(helpers[subThemeName]);
201
- if (state && state[subThemeName]) return getThemeValue(state[subThemeName]);
202
- } else if (isObject(value)) return setThemeValue(value);
203
- };
204
- const setInverseTheme = (theme, variant, value) => {
205
- if (isObject(variant)) {
206
- theme.variants.inverse.value = setThemeValue(variant);
207
- } else if (variant === true) {
208
- const { color, background } = value;
209
- theme.variants.inverse = {
210
- value: {
211
- color: background,
212
- background: color
213
- }
214
- };
215
- }
216
- };
217
- const setPseudo = (theme, key, variant, themeValue) => {
218
- const result = getTheme(variant);
219
- themeValue[`&:${key}`] = result;
220
- if (isObject(variant) && !variant.value) variant.value = result;
221
- };
222
- const setSelectors = (theme, value) => {
223
- const { state } = theme;
224
- if (!state) return;
225
- const keys = Object.keys(state);
226
- keys.map((key) => {
227
- const variant = state[key];
228
- setPseudo(theme, key, variant, value);
229
- return theme;
230
- });
231
- return theme;
232
- };
233
- const setPrefersScheme = (theme, key, variant, themeValue) => {
234
- const result = getTheme(variant);
235
- themeValue[`@media (prefers-color-scheme: ${key})`] = result;
236
- if (isObject(variant) && !variant.value) variant.value = result;
237
- };
238
- const setMedia = (theme, value) => {
239
- const { media } = theme;
240
- if (!media) return;
241
- const keys = Object.keys(media);
242
- keys.map((key) => {
243
- const variant = media[key];
244
- if (key === "dark" || key === "light") setPrefersScheme(theme, key, variant, value);
245
- if (key === "inverse") setInverseTheme(theme, variant, value);
246
- return theme;
247
- });
248
- return theme;
249
- };
250
- const setHelpers = (theme, value) => {
251
- const CONFIG = getActiveConfig();
252
- const { helpers } = theme;
253
- if (!helpers) return;
254
- const keys = Object.keys(helpers);
255
- keys.map((key) => {
256
- const helper = helpers[key];
257
- if (isString(helper)) helpers[key] = CONFIG.theme[helper];
258
- else getThemeValue(helpers[key]);
259
- return theme;
260
- });
261
- return theme;
262
- };
263
- const setTheme = (val, key) => {
264
- const CONFIG = getActiveConfig();
265
- if (CONFIG.useVariable) return setMediaTheme(val, key);
266
- const { state, media, helpers } = val;
267
- const value = setThemeValue(val, key);
268
- const CSSvar = `--theme-${key}`;
269
- setSelectors(val, value);
270
- setMedia(val, value);
271
- setHelpers(val, value);
272
- return { var: CSSvar, value, state, media, helpers };
273
- };
274
- const keySetters = {
275
- // eslint-disable-line
276
- "@": (theme, value) => setMedia(theme, value),
277
- ":": (theme, value) => setSelectors(theme, value),
278
- ".": (theme, value) => setHelpers(theme, value)
279
- };
280
- const generateAutoVars = (schemes, varPrefix, CONFIG) => {
281
- const { CSS_VARS } = CONFIG;
282
- if (!CONFIG.CSS_MEDIA_VARS) CONFIG.CSS_MEDIA_VARS = {};
283
- const MEDIA_VARS = CONFIG.CSS_MEDIA_VARS;
284
- const globalTheme = CONFIG.globalTheme !== void 0 ? CONFIG.globalTheme : "auto";
285
- const result = {};
286
- const allKeys = /* @__PURE__ */ new Set();
287
- for (const scheme in schemes) {
288
- if (schemes[scheme]) for (const k of Object.keys(schemes[scheme])) allKeys.add(k);
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
- }
307
- for (const param of allKeys) {
308
- const symb = param.slice(0, 1);
309
- const hasObject = Object.values(schemes).some((s) => isObjectLike(s?.[param]));
310
- if (symb === "." && hasObject) {
311
- const helperName = param.slice(1);
312
- const subSchemes = {};
313
- for (const scheme in schemes) {
314
- if (isObjectLike(schemes[scheme]?.[param])) subSchemes[scheme] = schemes[scheme][param];
315
- }
316
- result[param] = generateAutoVars(subSchemes, `${varPrefix}-${helperName}`, CONFIG);
317
- } else if (symb === ":" && hasObject) {
318
- const pseudoName = param.replace(/^:+/, "");
319
- const subSchemes = {};
320
- for (const scheme in schemes) {
321
- if (isObjectLike(schemes[scheme]?.[param])) subSchemes[scheme] = schemes[scheme][param];
322
- }
323
- result[param] = generateAutoVars(subSchemes, `${varPrefix}-${pseudoName}`, CONFIG);
324
- } else if (symb !== "@" && symb !== "." && symb !== ":") {
325
- const autoVar = `--theme-${varPrefix}-${param}`;
326
- if (globalTheme === "auto") {
327
- let fallbackColor;
328
- for (const scheme in schemes) {
329
- if (brokenSchemes.has(scheme)) continue;
330
- const val = schemes[scheme]?.[param];
331
- if (val === void 0) continue;
332
- const color = getColor(val, `@${scheme}`);
333
- if (color === void 0) continue;
334
- if (scheme === "light" || fallbackColor === void 0) {
335
- fallbackColor = color;
336
- }
337
- const selector = `[data-theme="${scheme}"]`;
338
- if (!MEDIA_VARS[selector]) MEDIA_VARS[selector] = {};
339
- MEDIA_VARS[selector][autoVar] = color;
340
- if (scheme === "dark" || scheme === "light") {
341
- const mq = `@media (prefers-color-scheme: ${scheme})`;
342
- if (!MEDIA_VARS[mq]) MEDIA_VARS[mq] = {};
343
- MEDIA_VARS[mq][autoVar] = color;
344
- }
345
- }
346
- if (fallbackColor !== void 0) {
347
- CSS_VARS[autoVar] = fallbackColor;
348
- }
349
- } else {
350
- const forced = String(globalTheme).replace(/^'|'$/g, "");
351
- const source = schemes[forced]?.[param];
352
- if (source !== void 0) {
353
- const color = getColor(source, `@${forced}`);
354
- if (color !== void 0) CSS_VARS[autoVar] = color;
355
- }
356
- }
357
- result[param] = `var(${autoVar})`;
358
- result[`.${param}`] = { [param]: result[param] };
359
- }
360
- }
361
- if (result.background || result.color || result.backgroundColor) {
362
- result[".inversed"] = {
363
- color: result.background || result.backgroundColor,
364
- background: result.color
365
- };
366
- }
367
- return result;
368
- };
369
- const setMediaTheme = (val, key, suffix, prefers) => {
370
- const CONFIG = getActiveConfig();
371
- const { CSS_VARS } = CONFIG;
372
- const theme = { value: val };
373
- const isTopLevel = !suffix && !prefers;
374
- if (isObjectLike(val)) {
375
- if (isTopLevel && CONFIG.useVariable) {
376
- const schemes = {};
377
- for (const param in val) {
378
- if (param.startsWith("@") && isObjectLike(val[param])) {
379
- schemes[param.slice(1)] = val[param];
380
- }
381
- }
382
- if (Object.keys(schemes).length) {
383
- const autoResult = generateAutoVars(schemes, key, CONFIG);
384
- Object.assign(theme, autoResult);
385
- }
386
- }
387
- for (const param in val) {
388
- const symb = param.slice(0, 1);
389
- const value = val[param];
390
- if (symb === "@" || symb === ":" || symb === ".") {
391
- const hasPrefers = symb === "@" && param;
392
- theme[param] = setMediaTheme(value, key, param, prefers || hasPrefers);
393
- } else if (!isTopLevel) {
394
- const color = getColor(value, prefers);
395
- const metaSuffixes = [...new Set([prefers, suffix].filter((v) => v).map((v) => v.slice(1)))];
396
- const varmetaSuffixName = metaSuffixes.length ? "-" + metaSuffixes.join("-") : "";
397
- const CSSVar = `--theme-${key}${varmetaSuffixName}-${param}`;
398
- if (CONFIG.useVariable) {
399
- if (CONFIG.useThemeSuffixedVars) CSS_VARS[CSSVar] = color;
400
- theme[param] = `var(${CSSVar})`;
401
- } else {
402
- theme[param] = color;
403
- }
404
- theme[`.${param}`] = { [param]: theme[param] };
405
- }
406
- }
407
- if (!theme[".inversed"] && (theme.background || theme.color || theme.backgroundColor)) {
408
- theme[".inversed"] = {
409
- color: theme.background || theme.backgroundColor,
410
- background: theme.color
411
- };
412
- }
413
- }
414
- if (isString(val) && isCSSVar(val)) {
415
- const THEME = CONFIG.theme;
416
- const value = THEME[val.slice(2)];
417
- const getReferenced = getMediaTheme(value, prefers);
418
- return getReferenced;
419
- }
420
- return theme;
421
- };
422
- const recursiveTheme = (val) => {
423
- const CONFIG = getActiveConfig();
424
- const obj = {};
425
- for (const param in val) {
426
- const symb = param.slice(0, 1);
427
- if (isObjectLike(val[param])) {
428
- if (symb === "@") {
429
- continue;
430
- } else if (symb === ":") {
431
- obj[`&${param}`] = recursiveTheme(val[param]);
432
- } else if (symb === ".") {
433
- obj[`&${param}`] = recursiveTheme(val[param]);
434
- }
435
- } else obj[param] = val[param];
436
- }
437
- return obj;
438
- };
439
- const findModifierFromArray = (val, modifierArray) => {
440
- const currentMod = modifierArray.shift();
441
- if (val[currentMod]) return findModifierFromArray(val[currentMod], modifierArray);
442
- return val;
443
- };
444
- const findModifier = (val, modifier) => {
445
- if (isArray(modifier)) return findModifierFromArray(val, modifier);
446
- else if (isString(modifier) && val[modifier]) return val[modifier];
447
- else return val;
448
- };
449
- const checkForReference = (val, callback) => {
450
- if (isString(val) && isCSSVar(val)) return getMediaTheme(val.slice(2));
451
- return val;
452
- };
453
- const checkThemeReference = (val) => checkForReference(val, checkThemeReference);
454
- const getMediaTheme = (value, modifier) => {
455
- const activeConfig = getActiveConfig();
456
- if (isString(value) && isCSSVar(value)) {
457
- value = getMediaTheme(value.slice(2));
458
- }
459
- if (!value || !isString(value)) {
460
- if (activeConfig.verbose) {
461
- console.warn(`${value} - Theme is not a string`);
462
- }
463
- return;
464
- }
465
- const [themeName, ...themeModifiers] = isArray(value) ? value : value.split(" ");
466
- let themeValue = activeConfig.theme[themeName];
467
- if (themeValue && themeModifiers.length) {
468
- themeValue = findModifier(themeValue, themeModifiers);
469
- } else if (themeValue && modifier) {
470
- themeValue = findModifier(themeValue, modifier);
471
- }
472
- const resolvedTheme = recursiveTheme(themeValue);
473
- return resolvedTheme;
474
- };
475
- export {
476
- getMediaTheme,
477
- getTheme,
478
- setMediaTheme,
479
- setTheme
480
- };
@@ -1,32 +0,0 @@
1
- import { toCamelCase } from "@symbo.ls/smbls-utils";
2
- import { getActiveConfig } from "../factory.js";
3
- import {
4
- applySequenceVars,
5
- generateSequence,
6
- getSequenceValuePropertyPair
7
- } from "../utils";
8
- const applyTimingSequence = () => {
9
- const CONFIG = getActiveConfig();
10
- const { timing: TIMING } = CONFIG;
11
- generateSequence(TIMING);
12
- applySequenceVars(TIMING);
13
- };
14
- const getTimingFunction = (value) => {
15
- const CONFIG = getActiveConfig();
16
- const { timing: TIMING } = CONFIG;
17
- return TIMING[value] || TIMING[toCamelCase(value)] || value;
18
- };
19
- const getTimingByKey = (value, property = "timing") => {
20
- const CONFIG = getActiveConfig();
21
- const { timing: TIMING } = CONFIG;
22
- return getSequenceValuePropertyPair(
23
- value,
24
- property,
25
- TIMING
26
- );
27
- };
28
- export {
29
- applyTimingSequence,
30
- getTimingByKey,
31
- getTimingFunction
32
- };
@@ -1,85 +0,0 @@
1
- import { merge } from "@domql/utils";
2
- import { getActiveConfig } from "../factory.js";
3
- import {
4
- applyMediaSequenceVars,
5
- applySequenceVars,
6
- findHeadings,
7
- generateSequence,
8
- getSequenceValuePropertyPair
9
- } from "../utils";
10
- const runThroughMedia = (FACTORY) => {
11
- const CONFIG = getActiveConfig();
12
- const { typography: TYPOGRAPHY, media: MEDIA } = CONFIG;
13
- for (const prop in FACTORY) {
14
- const isPropMedia = prop.slice(0, 1) === "@";
15
- const mediaValue = FACTORY[prop];
16
- if (!isPropMedia) continue;
17
- const { mediaRegenerate } = FACTORY;
18
- const mediaName = prop.slice(1);
19
- const { type, base, ratio, range, subSequence, h1Matches, unit } = FACTORY;
20
- merge(mediaValue, {
21
- type,
22
- base,
23
- ratio,
24
- range,
25
- subSequence,
26
- h1Matches,
27
- unit
28
- });
29
- const query = MEDIA[mediaName];
30
- const media = "@media " + (query === "print" ? `${query}` : `screen and ${query}`);
31
- TYPOGRAPHY.templates[media] = {
32
- fontSize: mediaValue.base / TYPOGRAPHY.browserDefault + unit
33
- };
34
- if (!mediaRegenerate) {
35
- applyMediaSequenceVars(FACTORY, prop);
36
- continue;
37
- }
38
- merge(mediaValue, {
39
- sequence: {},
40
- scales: {},
41
- templates: {},
42
- vars: {}
43
- });
44
- generateSequence(mediaValue);
45
- applyMediaSequenceVars(FACTORY, prop);
46
- }
47
- };
48
- const applyHeadings = (props) => {
49
- const CONFIG = getActiveConfig();
50
- if (props.h1Matches) {
51
- const unit = props.unit;
52
- const HEADINGS = findHeadings(props);
53
- const { templates } = props;
54
- for (const k in HEADINGS) {
55
- const headerName = `h${parseInt(k) + 1}`;
56
- const headerStyle = templates[headerName];
57
- templates[headerName] = {
58
- fontSize: CONFIG.useVariable ? `var(${HEADINGS[k]?.variable})` : `${HEADINGS[k]?.scaling}${unit}`,
59
- margin: headerStyle ? headerStyle.margin : 0,
60
- lineHeight: headerStyle ? headerStyle.lineHeight : props.lineHeight,
61
- letterSpacing: headerStyle ? headerStyle.letterSpacing : props.letterSpacing,
62
- fontWeight: headerStyle ? headerStyle.fontWeight : 900 - k * 100
63
- };
64
- }
65
- }
66
- };
67
- const applyTypographySequence = () => {
68
- const CONFIG = getActiveConfig();
69
- const { typography: TYPOGRAPHY } = CONFIG;
70
- generateSequence(TYPOGRAPHY);
71
- applyHeadings(TYPOGRAPHY);
72
- applySequenceVars(TYPOGRAPHY);
73
- runThroughMedia(TYPOGRAPHY);
74
- };
75
- const getFontSizeByKey = (value) => {
76
- const CONFIG = getActiveConfig();
77
- const { typography: TYPOGRAPHY } = CONFIG;
78
- return getSequenceValuePropertyPair(value, "fontSize", TYPOGRAPHY);
79
- };
80
- export {
81
- applyHeadings,
82
- applyTypographySequence,
83
- getFontSizeByKey,
84
- runThroughMedia
85
- };
@@ -1,8 +0,0 @@
1
- const testWCAGAA = (colorA, colorB) => {
2
- };
3
- const testWCAGAAA = (colorA, colorB) => {
4
- };
5
- export {
6
- testWCAGAA,
7
- testWCAGAAA
8
- };