@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 CHANGED
@@ -29,7 +29,8 @@ set({
29
29
  font: {},
30
30
  font_family: {},
31
31
  timing: {},
32
- reset: {}
32
+ reset: {},
33
+ vars: {}
33
34
  }, {
34
35
  // options
35
36
  })
@@ -86,6 +87,54 @@ Generated CSS:
86
87
 
87
88
  When `true`, also generates suffixed variables like `--theme-document-dark-background` alongside the non-suffixed `--theme-document-background`. Disabled by default to reduce CSS variable count.
88
89
 
90
+ ## CSS Custom Properties (vars)
91
+
92
+ Define initial CSS custom properties in the design system:
93
+
94
+ ```javascript
95
+ set({
96
+ vars: {
97
+ '--header-height': '60px',
98
+ 'sidebar-width': '280px', // auto-prefixed to --sidebar-width
99
+ 'gap': '1rem' // becomes --gap
100
+ }
101
+ })
102
+ ```
103
+
104
+ Each entry is written to `:root` CSS custom properties. Keys without `--` prefix get it added automatically. Values can be referenced in component props: `padding: '--gap'` → `var(--gap)`.
105
+
106
+ ## Font — Array URL Support
107
+
108
+ Font definitions support array URLs for multiple format fallbacks:
109
+
110
+ ```javascript
111
+ set({
112
+ font: {
113
+ Exo2: [
114
+ {
115
+ url: ['Exo2-Medium.woff2', 'Exo2-Medium.woff'],
116
+ fontWeight: '500',
117
+ fontStyle: 'normal',
118
+ fontDisplay: 'swap'
119
+ }
120
+ ]
121
+ }
122
+ })
123
+ ```
124
+
125
+ Generates comma-separated `src` with auto-detected formats:
126
+
127
+ ```css
128
+ @font-face {
129
+ font-family: 'Exo2';
130
+ font-style: normal;
131
+ font-weight: 500;
132
+ font-display: swap;
133
+ src: url('Exo2-Medium.woff2') format('woff2'),
134
+ url('Exo2-Medium.woff') format('woff');
135
+ }
136
+ ```
137
+
89
138
  Read more at [docs](https://www.symbols.app/developersdesign-system)
90
139
 
91
140
  ### TODO:
@@ -19,7 +19,8 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
19
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
20
  var defaultConfig_exports = {};
21
21
  __export(defaultConfig_exports, {
22
- reset: () => reset
22
+ reset: () => reset,
23
+ vars: () => vars
23
24
  });
24
25
  module.exports = __toCommonJS(defaultConfig_exports);
25
26
  __reExport(defaultConfig_exports, require("./sequence.js"), module.exports);
@@ -36,10 +37,10 @@ __reExport(defaultConfig_exports, require("./icons.js"), module.exports);
36
37
  __reExport(defaultConfig_exports, require("./timing.js"), module.exports);
37
38
  __reExport(defaultConfig_exports, require("./document.js"), module.exports);
38
39
  __reExport(defaultConfig_exports, require("./responsive.js"), module.exports);
39
- __reExport(defaultConfig_exports, require("./cases.js"), module.exports);
40
40
  __reExport(defaultConfig_exports, require("./animation.js"), module.exports);
41
41
  __reExport(defaultConfig_exports, require("./svg.js"), module.exports);
42
42
  __reExport(defaultConfig_exports, require("./templates.js"), module.exports);
43
43
  __reExport(defaultConfig_exports, require("./grid.js"), module.exports);
44
44
  __reExport(defaultConfig_exports, require("./class.js"), module.exports);
45
45
  const reset = {};
46
+ const vars = {};
package/dist/cjs/set.js CHANGED
@@ -28,11 +28,14 @@ module.exports = __toCommonJS(set_exports);
28
28
  var import_factory = require("./factory.js");
29
29
  var import_system = require("./system");
30
30
  var import_utils = require("@domql/utils");
31
- const setCases = (val, key) => {
32
- if ((0, import_utils.isFunction)(val)) return val();
31
+ const setVars = (val, key) => {
32
+ const CONFIG = (0, import_factory.getActiveConfig)();
33
+ const { CSS_VARS } = CONFIG;
34
+ const varName = key.startsWith("--") ? key : `--${key}`;
35
+ CSS_VARS[varName] = val;
33
36
  return val;
34
37
  };
35
- const setSameValue = (val, key) => val;
38
+ const asIs = (val) => val;
36
39
  const VALUE_TRANSFORMERS = {
37
40
  color: import_system.setColor,
38
41
  gradient: import_system.setGradient,
@@ -41,21 +44,21 @@ const VALUE_TRANSFORMERS = {
41
44
  fontfamily: import_system.setFontFamily,
42
45
  theme: import_system.setTheme,
43
46
  icons: import_system.setSvgIcon,
44
- semantic_icons: setSameValue,
45
- semanticicons: setSameValue,
47
+ semantic_icons: asIs,
48
+ semanticicons: asIs,
46
49
  svg: import_system.setSVG,
47
- svg_data: setSameValue,
48
- typography: setSameValue,
49
- cases: setCases,
50
+ svg_data: asIs,
51
+ typography: asIs,
50
52
  shadow: import_system.setShadow,
51
- spacing: setSameValue,
52
- media: setSameValue,
53
- grid: setSameValue,
54
- class: setSameValue,
55
- timing: setSameValue,
56
- reset: setSameValue,
57
- unit: setSameValue,
58
- animation: setSameValue
53
+ spacing: asIs,
54
+ media: asIs,
55
+ grid: asIs,
56
+ class: asIs,
57
+ timing: asIs,
58
+ reset: asIs,
59
+ unit: asIs,
60
+ animation: asIs,
61
+ vars: setVars
59
62
  };
60
63
  const setValue = (factoryName, value, key) => {
61
64
  const CONFIG = (0, import_factory.getActiveConfig)();
@@ -67,10 +70,12 @@ const setValue = (factoryName, value, key) => {
67
70
  FACTORY2[key] = result;
68
71
  return FACTORY2;
69
72
  } catch (error) {
70
- if (CONFIG.verbose) console.warn("Error setting", lowerName, "value", value, key, error);
73
+ if (CONFIG.verbose)
74
+ console.warn("Error setting", lowerName, "value", value, key, error);
71
75
  }
72
76
  }
73
- if (CONFIG.verbose) console.warn("Can not find", lowerName, "method in scratch");
77
+ if (CONFIG.verbose)
78
+ console.warn("Can not find", lowerName, "method in scratch");
74
79
  };
75
80
  const setEach = (factoryName, props) => {
76
81
  const CONFIG = (0, import_factory.getActiveConfig)();
@@ -80,7 +85,15 @@ const setEach = (factoryName, props) => {
80
85
  try {
81
86
  return setValue(lowerName, props[key], key);
82
87
  } catch (error) {
83
- if (CONFIG.verbose) console.warn("Error setting", lowerName, "value", props[key], key, error);
88
+ if (CONFIG.verbose)
89
+ console.warn(
90
+ "Error setting",
91
+ lowerName,
92
+ "value",
93
+ props[key],
94
+ key,
95
+ error
96
+ );
84
97
  }
85
98
  });
86
99
  return CONFIG[lowerName] || CONFIG[factoryName];
@@ -115,6 +128,7 @@ const set = (recivedConfig, options = SET_OPTIONS) => {
115
128
  useDefaultConfig,
116
129
  semanticIcons,
117
130
  SEMANTIC_ICONS,
131
+ // deprecated
118
132
  semantic_icons,
119
133
  files,
120
134
  ...config
@@ -131,7 +145,8 @@ const set = (recivedConfig, options = SET_OPTIONS) => {
131
145
  if (useIconSprite !== void 0) CONFIG.useIconSprite = useIconSprite;
132
146
  if (useDocumentTheme !== void 0) CONFIG.useDocumentTheme = useDocumentTheme;
133
147
  if (globalTheme !== void 0) CONFIG.globalTheme = globalTheme;
134
- if (recivedConfig.useThemeSuffixedVars !== void 0) CONFIG.useThemeSuffixedVars = recivedConfig.useThemeSuffixedVars;
148
+ if (recivedConfig.useThemeSuffixedVars !== void 0)
149
+ CONFIG.useThemeSuffixedVars = recivedConfig.useThemeSuffixedVars;
135
150
  if (useDefaultConfig !== void 0) CONFIG.useDefaultConfig = useDefaultConfig;
136
151
  const _semanticIcons = semanticIcons || SEMANTIC_ICONS || semantic_icons;
137
152
  if (_semanticIcons !== void 0) {
@@ -40,7 +40,12 @@ const getColor = (value, key, config) => {
40
40
  [name, alpha, tone] = value;
41
41
  } else {
42
42
  const parsed = (0, import_utils2.parseColorToken)(value);
43
- if (!parsed) return value;
43
+ if (!parsed) {
44
+ const { color: COLOR2, gradient: GRADIENT2 } = CONFIG;
45
+ const directVal = GRADIENT2[value] || COLOR2[value];
46
+ if (directVal) return CONFIG.useVariable ? `var(${directVal.var})` : directVal.value;
47
+ return value;
48
+ }
44
49
  if (parsed.passthrough) return parsed.passthrough;
45
50
  if (parsed.cssVar) return `var(${parsed.cssVar})`;
46
51
  name = parsed.name;
@@ -45,8 +45,12 @@ const setFont = (val, key) => {
45
45
  } else if (val[0]) {
46
46
  fontFace = (0, import_utils2.getFontFaceEach)(key, val, CONFIG.files);
47
47
  } else {
48
- const url = (0, import_utils2.resolveFileUrl)(val.url, CONFIG.files) || val.url;
49
- fontFace = (0, import_utils2.setCustomFontMedia)(key, url);
48
+ const url = Array.isArray(val.url) ? val.url.map((u) => (0, import_utils2.resolveFileUrl)(u, CONFIG.files) || u) : (0, import_utils2.resolveFileUrl)(val.url, CONFIG.files) || val.url;
49
+ fontFace = (0, import_utils2.setCustomFontMedia)(key, url, val.fontWeight, {
50
+ fontStyle: val.fontStyle,
51
+ fontDisplay: val.fontDisplay,
52
+ fontStretch: val.fontStretch
53
+ });
50
54
  }
51
55
  return { var: CSSvar, value: val, fontFace };
52
56
  };
@@ -28,6 +28,163 @@ var import_color = require("./color");
28
28
  var import_factory = require("../factory.js");
29
29
  var import_color2 = require("../utils/color.js");
30
30
  var import_utils = require("@domql/utils");
31
+ const CSS_NAMED_COLORS = /* @__PURE__ */ new Set([
32
+ "black",
33
+ "white",
34
+ "red",
35
+ "green",
36
+ "blue",
37
+ "yellow",
38
+ "orange",
39
+ "purple",
40
+ "pink",
41
+ "brown",
42
+ "gray",
43
+ "grey",
44
+ "cyan",
45
+ "magenta",
46
+ "lime",
47
+ "olive",
48
+ "navy",
49
+ "teal",
50
+ "aqua",
51
+ "maroon",
52
+ "silver",
53
+ "fuchsia",
54
+ "transparent",
55
+ "currentColor",
56
+ "currentcolor",
57
+ "inherit",
58
+ "initial",
59
+ "unset",
60
+ "none",
61
+ "aliceblue",
62
+ "antiquewhite",
63
+ "aquamarine",
64
+ "azure",
65
+ "beige",
66
+ "bisque",
67
+ "blanchedalmond",
68
+ "blueviolet",
69
+ "burlywood",
70
+ "cadetblue",
71
+ "chartreuse",
72
+ "chocolate",
73
+ "coral",
74
+ "cornflowerblue",
75
+ "cornsilk",
76
+ "crimson",
77
+ "darkblue",
78
+ "darkcyan",
79
+ "darkgoldenrod",
80
+ "darkgray",
81
+ "darkgreen",
82
+ "darkgrey",
83
+ "darkkhaki",
84
+ "darkmagenta",
85
+ "darkolivegreen",
86
+ "darkorange",
87
+ "darkorchid",
88
+ "darkred",
89
+ "darksalmon",
90
+ "darkseagreen",
91
+ "darkslateblue",
92
+ "darkslategray",
93
+ "darkslategrey",
94
+ "darkturquoise",
95
+ "darkviolet",
96
+ "deeppink",
97
+ "deepskyblue",
98
+ "dimgray",
99
+ "dimgrey",
100
+ "dodgerblue",
101
+ "firebrick",
102
+ "floralwhite",
103
+ "forestgreen",
104
+ "gainsboro",
105
+ "ghostwhite",
106
+ "gold",
107
+ "goldenrod",
108
+ "greenyellow",
109
+ "honeydew",
110
+ "hotpink",
111
+ "indianred",
112
+ "indigo",
113
+ "ivory",
114
+ "khaki",
115
+ "lavender",
116
+ "lavenderblush",
117
+ "lawngreen",
118
+ "lemonchiffon",
119
+ "lightblue",
120
+ "lightcoral",
121
+ "lightcyan",
122
+ "lightgoldenrodyellow",
123
+ "lightgray",
124
+ "lightgreen",
125
+ "lightgrey",
126
+ "lightpink",
127
+ "lightsalmon",
128
+ "lightseagreen",
129
+ "lightskyblue",
130
+ "lightslategray",
131
+ "lightslategrey",
132
+ "lightsteelblue",
133
+ "lightyellow",
134
+ "limegreen",
135
+ "linen",
136
+ "mediumaquamarine",
137
+ "mediumblue",
138
+ "mediumorchid",
139
+ "mediumpurple",
140
+ "mediumseagreen",
141
+ "mediumslateblue",
142
+ "mediumspringgreen",
143
+ "mediumturquoise",
144
+ "mediumvioletred",
145
+ "midnightblue",
146
+ "mintcream",
147
+ "mistyrose",
148
+ "moccasin",
149
+ "navajowhite",
150
+ "oldlace",
151
+ "olivedrab",
152
+ "orangered",
153
+ "orchid",
154
+ "palegoldenrod",
155
+ "palegreen",
156
+ "paleturquoise",
157
+ "palevioletred",
158
+ "papayawhip",
159
+ "peachpuff",
160
+ "peru",
161
+ "plum",
162
+ "powderblue",
163
+ "rosybrown",
164
+ "royalblue",
165
+ "saddlebrown",
166
+ "salmon",
167
+ "sandybrown",
168
+ "seagreen",
169
+ "seashell",
170
+ "sienna",
171
+ "skyblue",
172
+ "slateblue",
173
+ "slategray",
174
+ "slategrey",
175
+ "snow",
176
+ "springgreen",
177
+ "steelblue",
178
+ "tan",
179
+ "thistle",
180
+ "tomato",
181
+ "turquoise",
182
+ "violet",
183
+ "wheat",
184
+ "whitesmoke",
185
+ "yellowgreen",
186
+ "rebeccapurple"
187
+ ]);
31
188
  const setThemeValue = (theme) => {
32
189
  const value = {};
33
190
  const { state, media, helpers, ...rest } = theme;
@@ -151,6 +308,23 @@ const generateAutoVars = (schemes, varPrefix, CONFIG) => {
151
308
  for (const scheme in schemes) {
152
309
  if (schemes[scheme]) for (const k of Object.keys(schemes[scheme])) allKeys.add(k);
153
310
  }
311
+ const brokenSchemes = /* @__PURE__ */ new Set();
312
+ if (globalTheme === "auto") {
313
+ for (const param of allKeys) {
314
+ const symb = param.slice(0, 1);
315
+ if (symb === "@" || symb === "." || symb === ":") continue;
316
+ for (const scheme in schemes) {
317
+ if (brokenSchemes.has(scheme)) continue;
318
+ const val = schemes[scheme]?.[param];
319
+ if (val === void 0) continue;
320
+ const color = (0, import_color.getColor)(val, `@${scheme}`);
321
+ if (color === void 0) continue;
322
+ if ((0, import_utils.isString)(color) && /^[a-z][a-zA-Z]+$/.test(color) && !CSS_NAMED_COLORS.has(color)) {
323
+ brokenSchemes.add(scheme);
324
+ }
325
+ }
326
+ }
327
+ }
154
328
  for (const param of allKeys) {
155
329
  const symb = param.slice(0, 1);
156
330
  const hasObject = Object.values(schemes).some((s) => (0, import_utils.isObjectLike)(s?.[param]));
@@ -171,11 +345,16 @@ const generateAutoVars = (schemes, varPrefix, CONFIG) => {
171
345
  } else if (symb !== "@" && symb !== "." && symb !== ":") {
172
346
  const autoVar = `--theme-${varPrefix}-${param}`;
173
347
  if (globalTheme === "auto") {
348
+ let fallbackColor;
174
349
  for (const scheme in schemes) {
350
+ if (brokenSchemes.has(scheme)) continue;
175
351
  const val = schemes[scheme]?.[param];
176
352
  if (val === void 0) continue;
177
353
  const color = (0, import_color.getColor)(val, `@${scheme}`);
178
354
  if (color === void 0) continue;
355
+ if (scheme === "light" || fallbackColor === void 0) {
356
+ fallbackColor = color;
357
+ }
179
358
  const selector = `[data-theme="${scheme}"]`;
180
359
  if (!MEDIA_VARS[selector]) MEDIA_VARS[selector] = {};
181
360
  MEDIA_VARS[selector][autoVar] = color;
@@ -185,6 +364,9 @@ const generateAutoVars = (schemes, varPrefix, CONFIG) => {
185
364
  MEDIA_VARS[mq][autoVar] = color;
186
365
  }
187
366
  }
367
+ if (fallbackColor !== void 0) {
368
+ CSS_VARS[autoVar] = fallbackColor;
369
+ }
188
370
  } else {
189
371
  const forced = String(globalTheme).replace(/^'|'$/g, "");
190
372
  const source = schemes[forced]?.[param];
@@ -268,6 +450,8 @@ const recursiveTheme = (val) => {
268
450
  continue;
269
451
  } else if (symb === ":") {
270
452
  obj[`&${param}`] = recursiveTheme(val[param]);
453
+ } else if (symb === ".") {
454
+ obj[`&${param}`] = recursiveTheme(val[param]);
271
455
  }
272
456
  } else obj[param] = val[param];
273
457
  }
@@ -58,24 +58,28 @@ const isGoogleFontsUrl = (url) => url && (url.includes("fonts.googleapis.com") |
58
58
  const setFontImport = (url) => `@import url('${url}');`;
59
59
  const setInCustomFontMedia = (str) => `@font-face { ${str} }`;
60
60
  const setCustomFont = (name, url, weight, options = {}) => {
61
- const format = getFontFormat(url);
62
- const formatStr = format ? ` format('${format}')` : "";
61
+ const urls = Array.isArray(url) ? url : [url];
62
+ const srcList = urls.map((u) => {
63
+ const format = getFontFormat(u);
64
+ const formatStr = format ? ` format('${format}')` : "";
65
+ return `url('${u}')${formatStr}`;
66
+ }).join(",\n ");
63
67
  return `
64
68
  font-family: '${name}';
65
- font-style: normal;${weight ? `
69
+ font-style: ${options.fontStyle || "normal"};${weight ? `
66
70
  font-weight: ${weight};` : ""}${options.fontStretch ? `
67
71
  font-stretch: ${options.fontStretch};` : ""}${options.fontDisplay ? `
68
72
  font-display: ${options.fontDisplay};` : ""}
69
- src: url('${url}')${formatStr};`;
73
+ src: ${srcList};`;
70
74
  };
71
75
  const setCustomFontMedia = (name, url, weight, options) => `@font-face {${setCustomFont(name, url, weight, options)}
72
76
  }`;
73
77
  const getFontFaceEach = (name, weights, files) => {
74
78
  const keys = Object.keys(weights);
75
79
  return keys.map((key) => {
76
- const { url, fontWeight } = weights[key];
77
- const resolvedUrl = resolveFileUrl(url, files) || url;
78
- return setCustomFont(name, resolvedUrl, fontWeight);
80
+ const { url, fontWeight, fontStyle, fontDisplay, fontStretch } = weights[key];
81
+ const resolvedUrl = Array.isArray(url) ? url.map((u) => resolveFileUrl(u, files) || u) : resolveFileUrl(url, files) || url;
82
+ return setCustomFont(name, resolvedUrl, fontWeight, { fontStyle, fontDisplay, fontStretch });
79
83
  });
80
84
  };
81
85
  const getFontFace = (LIBRARY) => {
@@ -95,8 +99,12 @@ const getFontFaceEachString = (name, weights, files) => {
95
99
  }
96
100
  const isArr = weights[0];
97
101
  if (isArr) return getFontFaceEach(name, weights, files).map(setInCustomFontMedia);
98
- const url = resolveFileUrl(weights.url, files) || weights.url;
99
- return setCustomFontMedia(name, url);
102
+ const url = Array.isArray(weights.url) ? weights.url.map((u) => resolveFileUrl(u, files) || u) : resolveFileUrl(weights.url, files) || weights.url;
103
+ return setCustomFontMedia(name, url, weights.fontWeight, {
104
+ fontStyle: weights.fontStyle,
105
+ fontDisplay: weights.fontDisplay,
106
+ fontStretch: weights.fontStretch
107
+ });
100
108
  };
101
109
  const getFontFaceString = (LIBRARY, files) => {
102
110
  const keys = Object.keys(LIBRARY);
@@ -12,13 +12,14 @@ export * from "./icons.js";
12
12
  export * from "./timing.js";
13
13
  export * from "./document.js";
14
14
  export * from "./responsive.js";
15
- export * from "./cases.js";
16
15
  export * from "./animation.js";
17
16
  export * from "./svg.js";
18
17
  export * from "./templates.js";
19
18
  export * from "./grid.js";
20
19
  export * from "./class.js";
21
20
  const reset = {};
21
+ const vars = {};
22
22
  export {
23
- reset
23
+ reset,
24
+ vars
24
25
  };
package/dist/esm/set.js CHANGED
@@ -14,12 +14,15 @@ import {
14
14
  applyDocument,
15
15
  setShadow
16
16
  } from "./system";
17
- import { isFunction, deepMerge } from "@domql/utils";
18
- const setCases = (val, key) => {
19
- if (isFunction(val)) return val();
17
+ import { deepMerge } from "@domql/utils";
18
+ const setVars = (val, key) => {
19
+ const CONFIG = getActiveConfig();
20
+ const { CSS_VARS } = CONFIG;
21
+ const varName = key.startsWith("--") ? key : `--${key}`;
22
+ CSS_VARS[varName] = val;
20
23
  return val;
21
24
  };
22
- const setSameValue = (val, key) => val;
25
+ const asIs = (val) => val;
23
26
  const VALUE_TRANSFORMERS = {
24
27
  color: setColor,
25
28
  gradient: setGradient,
@@ -28,21 +31,21 @@ const VALUE_TRANSFORMERS = {
28
31
  fontfamily: setFontFamily,
29
32
  theme: setTheme,
30
33
  icons: setSvgIcon,
31
- semantic_icons: setSameValue,
32
- semanticicons: setSameValue,
34
+ semantic_icons: asIs,
35
+ semanticicons: asIs,
33
36
  svg: setSVG,
34
- svg_data: setSameValue,
35
- typography: setSameValue,
36
- cases: setCases,
37
+ svg_data: asIs,
38
+ typography: asIs,
37
39
  shadow: setShadow,
38
- spacing: setSameValue,
39
- media: setSameValue,
40
- grid: setSameValue,
41
- class: setSameValue,
42
- timing: setSameValue,
43
- reset: setSameValue,
44
- unit: setSameValue,
45
- animation: setSameValue
40
+ spacing: asIs,
41
+ media: asIs,
42
+ grid: asIs,
43
+ class: asIs,
44
+ timing: asIs,
45
+ reset: asIs,
46
+ unit: asIs,
47
+ animation: asIs,
48
+ vars: setVars
46
49
  };
47
50
  const setValue = (factoryName, value, key) => {
48
51
  const CONFIG = getActiveConfig();
@@ -54,10 +57,12 @@ const setValue = (factoryName, value, key) => {
54
57
  FACTORY2[key] = result;
55
58
  return FACTORY2;
56
59
  } catch (error) {
57
- if (CONFIG.verbose) console.warn("Error setting", lowerName, "value", value, key, error);
60
+ if (CONFIG.verbose)
61
+ console.warn("Error setting", lowerName, "value", value, key, error);
58
62
  }
59
63
  }
60
- if (CONFIG.verbose) console.warn("Can not find", lowerName, "method in scratch");
64
+ if (CONFIG.verbose)
65
+ console.warn("Can not find", lowerName, "method in scratch");
61
66
  };
62
67
  const setEach = (factoryName, props) => {
63
68
  const CONFIG = getActiveConfig();
@@ -67,7 +72,15 @@ const setEach = (factoryName, props) => {
67
72
  try {
68
73
  return setValue(lowerName, props[key], key);
69
74
  } catch (error) {
70
- if (CONFIG.verbose) console.warn("Error setting", lowerName, "value", props[key], key, error);
75
+ if (CONFIG.verbose)
76
+ console.warn(
77
+ "Error setting",
78
+ lowerName,
79
+ "value",
80
+ props[key],
81
+ key,
82
+ error
83
+ );
71
84
  }
72
85
  });
73
86
  return CONFIG[lowerName] || CONFIG[factoryName];
@@ -102,6 +115,7 @@ const set = (recivedConfig, options = SET_OPTIONS) => {
102
115
  useDefaultConfig,
103
116
  semanticIcons,
104
117
  SEMANTIC_ICONS,
118
+ // deprecated
105
119
  semantic_icons,
106
120
  files,
107
121
  ...config
@@ -118,7 +132,8 @@ const set = (recivedConfig, options = SET_OPTIONS) => {
118
132
  if (useIconSprite !== void 0) CONFIG.useIconSprite = useIconSprite;
119
133
  if (useDocumentTheme !== void 0) CONFIG.useDocumentTheme = useDocumentTheme;
120
134
  if (globalTheme !== void 0) CONFIG.globalTheme = globalTheme;
121
- if (recivedConfig.useThemeSuffixedVars !== void 0) CONFIG.useThemeSuffixedVars = recivedConfig.useThemeSuffixedVars;
135
+ if (recivedConfig.useThemeSuffixedVars !== void 0)
136
+ CONFIG.useThemeSuffixedVars = recivedConfig.useThemeSuffixedVars;
122
137
  if (useDefaultConfig !== void 0) CONFIG.useDefaultConfig = useDefaultConfig;
123
138
  const _semanticIcons = semanticIcons || SEMANTIC_ICONS || semantic_icons;
124
139
  if (_semanticIcons !== void 0) {
@@ -19,7 +19,12 @@ const getColor = (value, key, config) => {
19
19
  [name, alpha, tone] = value;
20
20
  } else {
21
21
  const parsed = parseColorToken(value);
22
- if (!parsed) return value;
22
+ if (!parsed) {
23
+ const { color: COLOR2, gradient: GRADIENT2 } = CONFIG;
24
+ const directVal = GRADIENT2[value] || COLOR2[value];
25
+ if (directVal) return CONFIG.useVariable ? `var(${directVal.var})` : directVal.value;
26
+ return value;
27
+ }
23
28
  if (parsed.passthrough) return parsed.passthrough;
24
29
  if (parsed.cssVar) return `var(${parsed.cssVar})`;
25
30
  name = parsed.name;
@@ -27,8 +27,12 @@ const setFont = (val, key) => {
27
27
  } else if (val[0]) {
28
28
  fontFace = getFontFaceEach(key, val, CONFIG.files);
29
29
  } else {
30
- const url = resolveFileUrl(val.url, CONFIG.files) || val.url;
31
- fontFace = setCustomFontMedia(key, url);
30
+ const url = Array.isArray(val.url) ? val.url.map((u) => resolveFileUrl(u, CONFIG.files) || u) : resolveFileUrl(val.url, CONFIG.files) || val.url;
31
+ fontFace = setCustomFontMedia(key, url, val.fontWeight, {
32
+ fontStyle: val.fontStyle,
33
+ fontDisplay: val.fontDisplay,
34
+ fontStretch: val.fontStretch
35
+ });
32
36
  }
33
37
  return { var: CSSvar, value: val, fontFace };
34
38
  };