@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.
- package/README.md +2 -2
- package/dist/cjs/defaultConfig/animation.js +4 -2
- package/dist/cjs/defaultConfig/cases.js +4 -2
- package/dist/cjs/defaultConfig/class.js +4 -2
- package/dist/cjs/defaultConfig/color.js +6 -9
- package/dist/cjs/defaultConfig/document.js +4 -2
- package/dist/cjs/defaultConfig/font-family.js +8 -12
- package/dist/cjs/defaultConfig/font.js +4 -11
- package/dist/cjs/defaultConfig/grid.js +5 -3
- package/dist/cjs/defaultConfig/icons.js +6 -4
- package/dist/cjs/defaultConfig/index.js +200 -24
- package/dist/cjs/defaultConfig/media.js +4 -2
- package/dist/cjs/defaultConfig/responsive.js +6 -4
- package/dist/cjs/defaultConfig/sequence.js +4 -2
- package/dist/cjs/defaultConfig/shadow.js +4 -2
- package/dist/cjs/defaultConfig/spacing.js +56 -7
- package/dist/cjs/defaultConfig/svg.js +6 -4
- package/dist/cjs/defaultConfig/templates.js +4 -2
- package/dist/cjs/defaultConfig/theme.js +4 -14
- package/dist/cjs/defaultConfig/timing.js +36 -5
- package/dist/cjs/defaultConfig/typography.js +36 -5
- package/dist/cjs/defaultConfig/unit.js +4 -2
- package/dist/cjs/factory.js +341 -40
- package/dist/cjs/index.js +6333 -11
- package/dist/cjs/package.json +4 -0
- package/dist/cjs/set.js +5614 -158
- package/dist/cjs/system/color.js +4481 -104
- package/dist/cjs/system/document.js +4371 -11
- package/dist/cjs/system/font.js +4401 -28
- package/dist/cjs/system/index.js +5748 -11
- package/dist/cjs/system/reset.js +4445 -21
- package/dist/cjs/system/shadow.js +4832 -41
- package/dist/cjs/system/spacing.js +4752 -39
- package/dist/cjs/system/svg.js +4437 -47
- package/dist/cjs/system/theme.js +4526 -335
- package/dist/cjs/system/timing.js +4695 -19
- package/dist/cjs/system/typography.js +4755 -33
- package/dist/cjs/tests/index.js +4 -2
- package/dist/cjs/transforms/index.js +5019 -134
- package/dist/cjs/utils/color.js +47 -66
- package/dist/cjs/utils/font.js +25 -46
- package/dist/cjs/utils/index.js +5068 -8
- package/dist/cjs/utils/sequence.js +4423 -35
- package/dist/cjs/utils/sprite.js +353 -12
- package/dist/cjs/utils/theme.js +3 -1
- package/dist/cjs/utils/unit.js +4 -2
- package/dist/cjs/utils/var.js +4390 -42
- package/index.js +1 -0
- package/package.json +11 -14
- package/src/defaultConfig/class.js +2 -1
- package/src/defaultConfig/font-family.js +3 -3
- package/src/defaultConfig/icons.js +1 -1
- package/src/defaultConfig/svg.js +1 -1
- package/src/defaultConfig/timing.js +1 -1
- package/src/factory.js +85 -13
- package/src/index.js +16 -5
- package/src/set.js +156 -63
- package/src/system/color.js +113 -12
- package/src/system/document.js +3 -3
- package/src/system/font.js +5 -5
- package/src/system/reset.js +41 -8
- package/src/system/shadow.js +4 -3
- package/src/system/spacing.js +3 -3
- package/src/system/svg.js +42 -5
- package/src/system/theme.js +87 -64
- package/src/system/timing.js +2 -2
- package/src/system/typography.js +12 -3
- package/src/transforms/index.js +4 -4
- package/src/utils/color.js +2 -1
- package/src/utils/font.js +7 -1
- package/src/utils/sequence.js +46 -29
- package/src/utils/sprite.js +44 -16
- package/src/utils/var.js +27 -9
- package/dist/esm/defaultConfig/animation.js +0 -4
- package/dist/esm/defaultConfig/cases.js +0 -4
- package/dist/esm/defaultConfig/class.js +0 -5
- package/dist/esm/defaultConfig/color.js +0 -11
- package/dist/esm/defaultConfig/document.js +0 -4
- package/dist/esm/defaultConfig/font-family.js +0 -18
- package/dist/esm/defaultConfig/font.js +0 -13
- package/dist/esm/defaultConfig/grid.js +0 -5
- package/dist/esm/defaultConfig/icons.js +0 -6
- package/dist/esm/defaultConfig/index.js +0 -25
- package/dist/esm/defaultConfig/media.js +0 -9
- package/dist/esm/defaultConfig/responsive.js +0 -30
- package/dist/esm/defaultConfig/sequence.js +0 -29
- package/dist/esm/defaultConfig/shadow.js +0 -4
- package/dist/esm/defaultConfig/spacing.js +0 -18
- package/dist/esm/defaultConfig/svg.js +0 -6
- package/dist/esm/defaultConfig/templates.js +0 -4
- package/dist/esm/defaultConfig/theme.js +0 -16
- package/dist/esm/defaultConfig/timing.js +0 -17
- package/dist/esm/defaultConfig/typography.js +0 -21
- package/dist/esm/defaultConfig/unit.js +0 -6
- package/dist/esm/factory.js +0 -60
- package/dist/esm/index.js +0 -12
- package/dist/esm/set.js +0 -219
- package/dist/esm/system/color.js +0 -193
- package/dist/esm/system/document.js +0 -16
- package/dist/esm/system/font.js +0 -58
- package/dist/esm/system/index.js +0 -10
- package/dist/esm/system/reset.js +0 -67
- package/dist/esm/system/shadow.js +0 -91
- package/dist/esm/system/spacing.js +0 -121
- package/dist/esm/system/svg.js +0 -86
- package/dist/esm/system/theme.js +0 -480
- package/dist/esm/system/timing.js +0 -32
- package/dist/esm/system/typography.js +0 -85
- package/dist/esm/tests/index.js +0 -8
- package/dist/esm/transforms/index.js +0 -216
- package/dist/esm/utils/color.js +0 -192
- package/dist/esm/utils/font.js +0 -92
- package/dist/esm/utils/index.js +0 -7
- package/dist/esm/utils/sequence.js +0 -303
- package/dist/esm/utils/sprite.js +0 -65
- package/dist/esm/utils/theme.js +0 -9
- package/dist/esm/utils/unit.js +0 -59
- package/dist/esm/utils/var.js +0 -82
- package/dist/iife/index.js +0 -3204
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { sequence } from "./sequence.js";
|
|
2
|
-
import { typography } from "./typography.js";
|
|
3
|
-
const defaultProps = {
|
|
4
|
-
base: typography.base,
|
|
5
|
-
type: "spacing",
|
|
6
|
-
ratio: sequence.phi,
|
|
7
|
-
range: [-5, 15],
|
|
8
|
-
subSequence: true,
|
|
9
|
-
mediaRegenerate: false,
|
|
10
|
-
unit: "em",
|
|
11
|
-
sequence: {},
|
|
12
|
-
scales: {},
|
|
13
|
-
vars: {}
|
|
14
|
-
};
|
|
15
|
-
const spacing = defaultProps;
|
|
16
|
-
export {
|
|
17
|
-
spacing
|
|
18
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const themeA = {
|
|
2
|
-
// eslint-disable-line no-unused-vars
|
|
3
|
-
text: "blue",
|
|
4
|
-
background: "white",
|
|
5
|
-
border: "black",
|
|
6
|
-
// .opacity(0.2),
|
|
7
|
-
active: {},
|
|
8
|
-
helpers: [],
|
|
9
|
-
themes: {},
|
|
10
|
-
inverse: {}
|
|
11
|
-
// schemeAInverse
|
|
12
|
-
};
|
|
13
|
-
const theme = {};
|
|
14
|
-
export {
|
|
15
|
-
theme
|
|
16
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { sequence } from "./sequence";
|
|
2
|
-
const defaultProps = {
|
|
3
|
-
default: 150,
|
|
4
|
-
base: 150,
|
|
5
|
-
type: "timing",
|
|
6
|
-
ratio: sequence["perfect-fourth"],
|
|
7
|
-
range: [-3, 12],
|
|
8
|
-
mediaRegenerate: false,
|
|
9
|
-
unit: "ms",
|
|
10
|
-
sequence: {},
|
|
11
|
-
scales: {},
|
|
12
|
-
vars: {}
|
|
13
|
-
};
|
|
14
|
-
const timing = defaultProps;
|
|
15
|
-
export {
|
|
16
|
-
timing
|
|
17
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { sequence } from "./sequence.js";
|
|
2
|
-
const defaultProps = {
|
|
3
|
-
browserDefault: 16,
|
|
4
|
-
base: 16,
|
|
5
|
-
type: "font-size",
|
|
6
|
-
ratio: sequence["minor-third"],
|
|
7
|
-
range: [-3, 12],
|
|
8
|
-
h1Matches: 6,
|
|
9
|
-
lineHeight: 1.5,
|
|
10
|
-
subSequence: true,
|
|
11
|
-
mediaRegenerate: false,
|
|
12
|
-
unit: "em",
|
|
13
|
-
templates: {},
|
|
14
|
-
sequence: {},
|
|
15
|
-
scales: {},
|
|
16
|
-
vars: {}
|
|
17
|
-
};
|
|
18
|
-
const typography = defaultProps;
|
|
19
|
-
export {
|
|
20
|
-
typography
|
|
21
|
-
};
|
package/dist/esm/factory.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
deepClone,
|
|
3
|
-
deepMerge,
|
|
4
|
-
isDefined,
|
|
5
|
-
isObject
|
|
6
|
-
} from "@domql/utils";
|
|
7
|
-
import * as CONF from "./defaultConfig";
|
|
8
|
-
const CSS_VARS = {};
|
|
9
|
-
const CSS_MEDIA_VARS = {};
|
|
10
|
-
const _CONF = CONF;
|
|
11
|
-
const _confLower = {};
|
|
12
|
-
const toCamel = (s) => s.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
13
|
-
const toUpper = (s) => s.replace(/([A-Z])/g, "_$1").toUpperCase();
|
|
14
|
-
for (const key in _CONF) {
|
|
15
|
-
const lower = key.toLowerCase();
|
|
16
|
-
_confLower[lower] = _CONF[key];
|
|
17
|
-
const camel = toCamel(lower);
|
|
18
|
-
if (camel !== lower) _confLower[camel] = _CONF[key];
|
|
19
|
-
if (lower !== key) _confLower[key] = _CONF[key];
|
|
20
|
-
const upper = toUpper(key);
|
|
21
|
-
if (upper !== key) _confLower[upper] = _CONF[key];
|
|
22
|
-
}
|
|
23
|
-
const CONFIG = {
|
|
24
|
-
verbose: false,
|
|
25
|
-
useVariable: true,
|
|
26
|
-
useReset: true,
|
|
27
|
-
globalTheme: "auto",
|
|
28
|
-
CSS_VARS,
|
|
29
|
-
CSS_MEDIA_VARS,
|
|
30
|
-
..._confLower
|
|
31
|
-
};
|
|
32
|
-
const cachedConfig = deepClone(CONFIG);
|
|
33
|
-
const FACTORY = {
|
|
34
|
-
active: "0",
|
|
35
|
-
0: CONFIG
|
|
36
|
-
};
|
|
37
|
-
const activateConfig = (def) => {
|
|
38
|
-
if (isDefined(def)) {
|
|
39
|
-
FACTORY.active = def;
|
|
40
|
-
}
|
|
41
|
-
return FACTORY[def || FACTORY.active];
|
|
42
|
-
};
|
|
43
|
-
const getActiveConfig = (def) => {
|
|
44
|
-
return FACTORY[def || FACTORY.active] || CONFIG;
|
|
45
|
-
};
|
|
46
|
-
const setActiveConfig = (newConfig) => {
|
|
47
|
-
if (!isObject(newConfig)) return;
|
|
48
|
-
FACTORY.active = "1";
|
|
49
|
-
FACTORY["1"] = deepMerge(newConfig, deepClone(cachedConfig));
|
|
50
|
-
return newConfig;
|
|
51
|
-
};
|
|
52
|
-
export {
|
|
53
|
-
CONFIG,
|
|
54
|
-
CSS_MEDIA_VARS,
|
|
55
|
-
CSS_VARS,
|
|
56
|
-
FACTORY,
|
|
57
|
-
activateConfig,
|
|
58
|
-
getActiveConfig,
|
|
59
|
-
setActiveConfig
|
|
60
|
-
};
|
package/dist/esm/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as scratchUtils from "./utils/index.js";
|
|
2
|
-
import * as scratchSystem from "./system/index.js";
|
|
3
|
-
export * from "./factory.js";
|
|
4
|
-
export * from "./defaultConfig";
|
|
5
|
-
export * from "./system";
|
|
6
|
-
export * from "./utils";
|
|
7
|
-
export * from "./transforms";
|
|
8
|
-
export * from "./set.js";
|
|
9
|
-
export {
|
|
10
|
-
scratchSystem,
|
|
11
|
-
scratchUtils
|
|
12
|
-
};
|
package/dist/esm/set.js
DELETED
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import { FACTORY, getActiveConfig, setActiveConfig } from "./factory.js";
|
|
2
|
-
import {
|
|
3
|
-
setColor,
|
|
4
|
-
setGradient,
|
|
5
|
-
setFont,
|
|
6
|
-
setFontFamily,
|
|
7
|
-
setTheme,
|
|
8
|
-
setSvgIcon,
|
|
9
|
-
setSVG,
|
|
10
|
-
applyTypographySequence,
|
|
11
|
-
applySpacingSequence,
|
|
12
|
-
applyReset,
|
|
13
|
-
applyTimingSequence,
|
|
14
|
-
applyDocument,
|
|
15
|
-
setShadow
|
|
16
|
-
} from "./system";
|
|
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;
|
|
23
|
-
return val;
|
|
24
|
-
};
|
|
25
|
-
const asIs = (val) => val;
|
|
26
|
-
const VALUE_TRANSFORMERS = {
|
|
27
|
-
color: setColor,
|
|
28
|
-
gradient: setGradient,
|
|
29
|
-
font: setFont,
|
|
30
|
-
font_family: setFontFamily,
|
|
31
|
-
fontfamily: setFontFamily,
|
|
32
|
-
theme: setTheme,
|
|
33
|
-
icons: setSvgIcon,
|
|
34
|
-
semantic_icons: asIs,
|
|
35
|
-
semanticicons: asIs,
|
|
36
|
-
svg: setSVG,
|
|
37
|
-
svg_data: asIs,
|
|
38
|
-
typography: asIs,
|
|
39
|
-
shadow: setShadow,
|
|
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
|
|
49
|
-
};
|
|
50
|
-
const setValue = (factoryName, value, key) => {
|
|
51
|
-
const CONFIG = getActiveConfig();
|
|
52
|
-
const lowerName = factoryName.toLowerCase();
|
|
53
|
-
const FACTORY2 = CONFIG[lowerName] || CONFIG[factoryName];
|
|
54
|
-
if (VALUE_TRANSFORMERS[lowerName]) {
|
|
55
|
-
try {
|
|
56
|
-
const result = VALUE_TRANSFORMERS[lowerName](value, key);
|
|
57
|
-
FACTORY2[key] = result;
|
|
58
|
-
return FACTORY2;
|
|
59
|
-
} catch (error) {
|
|
60
|
-
if (CONFIG.verbose)
|
|
61
|
-
console.warn("Error setting", lowerName, "value", value, key, error);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
if (CONFIG.verbose)
|
|
65
|
-
console.warn("Can not find", lowerName, "method in scratch");
|
|
66
|
-
};
|
|
67
|
-
const setEach = (factoryName, props) => {
|
|
68
|
-
const CONFIG = getActiveConfig();
|
|
69
|
-
const lowerName = factoryName.toLowerCase();
|
|
70
|
-
const keys = Object.keys(props);
|
|
71
|
-
keys.forEach((key) => {
|
|
72
|
-
try {
|
|
73
|
-
return setValue(lowerName, props[key], key);
|
|
74
|
-
} catch (error) {
|
|
75
|
-
if (CONFIG.verbose)
|
|
76
|
-
console.warn(
|
|
77
|
-
"Error setting",
|
|
78
|
-
lowerName,
|
|
79
|
-
"value",
|
|
80
|
-
props[key],
|
|
81
|
-
key,
|
|
82
|
-
error
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
return CONFIG[lowerName] || CONFIG[factoryName];
|
|
87
|
-
};
|
|
88
|
-
const changeGlobalTheme = (newTheme) => {
|
|
89
|
-
const CONFIG = getActiveConfig();
|
|
90
|
-
CONFIG.globalTheme = newTheme;
|
|
91
|
-
if (typeof document !== "undefined" && newTheme && newTheme !== "auto") {
|
|
92
|
-
document.documentElement.setAttribute("data-theme", newTheme);
|
|
93
|
-
}
|
|
94
|
-
for (const key in CONFIG.CSS_VARS) {
|
|
95
|
-
if (key.startsWith("--theme-")) delete CONFIG.CSS_VARS[key];
|
|
96
|
-
}
|
|
97
|
-
for (const key in CONFIG.CSS_MEDIA_VARS) {
|
|
98
|
-
delete CONFIG.CSS_MEDIA_VARS[key];
|
|
99
|
-
}
|
|
100
|
-
const source = CONFIG._originalTheme || CONFIG.theme;
|
|
101
|
-
if (source) {
|
|
102
|
-
const fresh = JSON.parse(JSON.stringify(source));
|
|
103
|
-
CONFIG.theme = fresh;
|
|
104
|
-
setEach("theme", fresh);
|
|
105
|
-
}
|
|
106
|
-
if (typeof document !== "undefined" && CONFIG.CSS_VARS) {
|
|
107
|
-
const sheets = document.styleSheets;
|
|
108
|
-
for (let i = 0; i < sheets.length; i++) {
|
|
109
|
-
try {
|
|
110
|
-
const rules = sheets[i].cssRules;
|
|
111
|
-
for (let j = 0; j < rules.length; j++) {
|
|
112
|
-
if (rules[j].selectorText === ":root") {
|
|
113
|
-
for (const key in CONFIG.CSS_VARS) {
|
|
114
|
-
rules[j].style.setProperty(key, CONFIG.CSS_VARS[key]);
|
|
115
|
-
}
|
|
116
|
-
return CONFIG;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
} catch (e) {
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return CONFIG;
|
|
124
|
-
};
|
|
125
|
-
const SET_OPTIONS = {};
|
|
126
|
-
const set = (recivedConfig, options = SET_OPTIONS) => {
|
|
127
|
-
let CONFIG = getActiveConfig();
|
|
128
|
-
const {
|
|
129
|
-
version,
|
|
130
|
-
verbose,
|
|
131
|
-
useVariable,
|
|
132
|
-
useReset,
|
|
133
|
-
useSvgSprite,
|
|
134
|
-
useFontImport,
|
|
135
|
-
useIconSprite,
|
|
136
|
-
globalTheme,
|
|
137
|
-
useDocumentTheme,
|
|
138
|
-
useDefaultConfig,
|
|
139
|
-
semanticIcons,
|
|
140
|
-
SEMANTIC_ICONS,
|
|
141
|
-
// deprecated
|
|
142
|
-
semantic_icons,
|
|
143
|
-
files,
|
|
144
|
-
...config
|
|
145
|
-
} = recivedConfig;
|
|
146
|
-
if (options.newConfig) {
|
|
147
|
-
CONFIG = setActiveConfig(options.newConfig);
|
|
148
|
-
}
|
|
149
|
-
if (files !== void 0) CONFIG.files = files;
|
|
150
|
-
if (verbose !== void 0) CONFIG.verbose = verbose;
|
|
151
|
-
if (useVariable !== void 0) CONFIG.useVariable = useVariable;
|
|
152
|
-
if (useReset !== void 0) CONFIG.useReset = useReset;
|
|
153
|
-
if (useFontImport !== void 0) CONFIG.useFontImport = useFontImport;
|
|
154
|
-
if (useSvgSprite !== void 0) CONFIG.useSvgSprite = useSvgSprite;
|
|
155
|
-
if (useIconSprite !== void 0) CONFIG.useIconSprite = useIconSprite;
|
|
156
|
-
if (useDocumentTheme !== void 0) CONFIG.useDocumentTheme = useDocumentTheme;
|
|
157
|
-
if (globalTheme !== void 0) CONFIG.globalTheme = globalTheme;
|
|
158
|
-
if (recivedConfig.useThemeSuffixedVars !== void 0)
|
|
159
|
-
CONFIG.useThemeSuffixedVars = recivedConfig.useThemeSuffixedVars;
|
|
160
|
-
if (useDefaultConfig !== void 0) CONFIG.useDefaultConfig = useDefaultConfig;
|
|
161
|
-
const _semanticIcons = semanticIcons || SEMANTIC_ICONS || semantic_icons;
|
|
162
|
-
if (_semanticIcons !== void 0) {
|
|
163
|
-
CONFIG.semantic_icons = _semanticIcons;
|
|
164
|
-
CONFIG.semanticIcons = CONFIG.semantic_icons;
|
|
165
|
-
CONFIG.SEMANTIC_ICONS = CONFIG.semantic_icons;
|
|
166
|
-
}
|
|
167
|
-
if (CONFIG.verbose) console.log(CONFIG);
|
|
168
|
-
if (typeof document !== "undefined" && CONFIG.globalTheme && CONFIG.globalTheme !== "auto") {
|
|
169
|
-
document.documentElement.setAttribute("data-theme", CONFIG.globalTheme);
|
|
170
|
-
}
|
|
171
|
-
if (!CONFIG.__svg_cache) CONFIG.__svg_cache = {};
|
|
172
|
-
const keys = Object.keys(config);
|
|
173
|
-
const keySet = new Set(keys);
|
|
174
|
-
keys.forEach((key) => {
|
|
175
|
-
const lower = key.toLowerCase();
|
|
176
|
-
if (lower !== key && keySet.has(lower)) {
|
|
177
|
-
deepMerge(config[lower], config[key]);
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
if (config.theme && !CONFIG._originalTheme) {
|
|
181
|
-
CONFIG._originalTheme = JSON.parse(JSON.stringify(config.theme));
|
|
182
|
-
}
|
|
183
|
-
keys.map((key) => {
|
|
184
|
-
const lower = key.toLowerCase();
|
|
185
|
-
if (lower !== key && keySet.has(lower)) return;
|
|
186
|
-
return setEach(key, config[key]);
|
|
187
|
-
});
|
|
188
|
-
if (config.typography || config.TYPOGRAPHY) {
|
|
189
|
-
try {
|
|
190
|
-
applyTypographySequence();
|
|
191
|
-
} catch (e) {
|
|
192
|
-
if (CONFIG.verbose) console.warn("Error applying typography sequence", e);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
if (config.spacing || config.SPACING) {
|
|
196
|
-
try {
|
|
197
|
-
applySpacingSequence();
|
|
198
|
-
} catch (e) {
|
|
199
|
-
if (CONFIG.verbose) console.warn("Error applying spacing sequence", e);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
if (config.timing || config.TIMING) {
|
|
203
|
-
try {
|
|
204
|
-
applyTimingSequence();
|
|
205
|
-
} catch (e) {
|
|
206
|
-
if (CONFIG.verbose) console.warn("Error applying timing sequence", e);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
applyDocument();
|
|
210
|
-
applyReset();
|
|
211
|
-
return CONFIG;
|
|
212
|
-
};
|
|
213
|
-
export {
|
|
214
|
-
VALUE_TRANSFORMERS,
|
|
215
|
-
changeGlobalTheme,
|
|
216
|
-
set,
|
|
217
|
-
setEach,
|
|
218
|
-
setValue
|
|
219
|
-
};
|
package/dist/esm/system/color.js
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import { isObject, isArray, isString } from "@domql/utils";
|
|
2
|
-
import { getActiveConfig } from "../factory.js";
|
|
3
|
-
import {
|
|
4
|
-
colorStringToRgbaArray,
|
|
5
|
-
getRgbTone,
|
|
6
|
-
isCSSVar,
|
|
7
|
-
parseColorToken
|
|
8
|
-
} from "../utils";
|
|
9
|
-
const getColor = (value, key, config) => {
|
|
10
|
-
const CONFIG = config || getActiveConfig();
|
|
11
|
-
if (!isString(value)) {
|
|
12
|
-
if (CONFIG.verbose) console.warn(value, "- type for color is not valid");
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
if (isCSSVar(value)) return `var(${value})`;
|
|
16
|
-
if (key && value[key]) value = value[key];
|
|
17
|
-
let name, alpha, tone;
|
|
18
|
-
if (isArray(value)) {
|
|
19
|
-
[name, alpha, tone] = value;
|
|
20
|
-
} else {
|
|
21
|
-
const parsed = parseColorToken(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
|
-
}
|
|
28
|
-
if (parsed.passthrough) return parsed.passthrough;
|
|
29
|
-
if (parsed.cssVar) return `var(${parsed.cssVar})`;
|
|
30
|
-
name = parsed.name;
|
|
31
|
-
alpha = parsed.alpha;
|
|
32
|
-
tone = parsed.tone;
|
|
33
|
-
}
|
|
34
|
-
const { color: COLOR, gradient: GRADIENT } = CONFIG;
|
|
35
|
-
let val = COLOR[name] || GRADIENT[name];
|
|
36
|
-
if (!val) {
|
|
37
|
-
if (CONFIG.verbose) console.warn("Can't find color ", name);
|
|
38
|
-
return value;
|
|
39
|
-
}
|
|
40
|
-
if (key) {
|
|
41
|
-
if (val[key]) val = val[key];
|
|
42
|
-
else if (CONFIG.verbose) console.warn(value, " - does not have ", key);
|
|
43
|
-
}
|
|
44
|
-
let rgb = val.rgb;
|
|
45
|
-
if (!rgb) {
|
|
46
|
-
return CONFIG.useVariable ? `var(${val.var})` : val.value;
|
|
47
|
-
}
|
|
48
|
-
if (tone && !val[tone]) {
|
|
49
|
-
rgb = getRgbTone(rgb, tone);
|
|
50
|
-
val[tone] = { rgb, var: `${val.var}-${tone}` };
|
|
51
|
-
}
|
|
52
|
-
if (val[tone]) rgb = val[tone].rgb;
|
|
53
|
-
if (alpha) return `rgba(${rgb}, ${alpha})`;
|
|
54
|
-
if (tone) return `rgba(${rgb}, 1)`;
|
|
55
|
-
return CONFIG.useVariable ? `var(${val.var})` : `rgb(${rgb})`;
|
|
56
|
-
};
|
|
57
|
-
const getMediaColor = (value, globalTheme, config) => {
|
|
58
|
-
const CONFIG = config || getActiveConfig();
|
|
59
|
-
if (!globalTheme) globalTheme = CONFIG.globalTheme === "auto" ? null : CONFIG.globalTheme;
|
|
60
|
-
if (!isString(value)) {
|
|
61
|
-
if (CONFIG.verbose) console.warn(value, "- type for color is not valid");
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
if (isCSSVar(value)) return `var(${value})`;
|
|
65
|
-
let name;
|
|
66
|
-
if (isArray(value)) {
|
|
67
|
-
name = value[0];
|
|
68
|
-
} else {
|
|
69
|
-
const parsed = parseColorToken(value);
|
|
70
|
-
if (!parsed) return value;
|
|
71
|
-
if (parsed.passthrough) return parsed.passthrough;
|
|
72
|
-
if (parsed.cssVar) return `var(${parsed.cssVar})`;
|
|
73
|
-
name = parsed.name;
|
|
74
|
-
}
|
|
75
|
-
const { color: COLOR, gradient: GRADIENT } = CONFIG;
|
|
76
|
-
const val = COLOR[name] || GRADIENT[name];
|
|
77
|
-
const isObj = isObject(val);
|
|
78
|
-
if (isObj && val.value) return getColor(value, `@${globalTheme}`, config);
|
|
79
|
-
else if (isObj) {
|
|
80
|
-
if (globalTheme) return getColor(value, `@${globalTheme}`, config);
|
|
81
|
-
else {
|
|
82
|
-
const obj = {};
|
|
83
|
-
for (const mediaName in val) {
|
|
84
|
-
const query = CONFIG.media[mediaName.slice(1)];
|
|
85
|
-
const media = "@media " + (query === "print" ? `${query}` : `screen and ${query}`);
|
|
86
|
-
obj[media] = getColor(value, mediaName, config);
|
|
87
|
-
}
|
|
88
|
-
return obj;
|
|
89
|
-
}
|
|
90
|
-
} else {
|
|
91
|
-
if (CONFIG.verbose) console.warn("Can't find color", value);
|
|
92
|
-
return value;
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
const setColor = (val, key, suffix) => {
|
|
96
|
-
const CONFIG = getActiveConfig();
|
|
97
|
-
if (isString(val) && isCSSVar(val)) {
|
|
98
|
-
const rawRef = val.slice(2);
|
|
99
|
-
val = getColor(rawRef);
|
|
100
|
-
if (!(val.includes("rgb") || val.includes("var") || val.includes("#"))) {
|
|
101
|
-
const parts = rawRef.split(" ");
|
|
102
|
-
const refColor = CONFIG.color[parts[0]];
|
|
103
|
-
if (refColor && refColor.value) {
|
|
104
|
-
let rgb2 = refColor.rgb;
|
|
105
|
-
const alpha2 = parts[1] !== void 0 ? parts[1] : "1";
|
|
106
|
-
const tone = parts[2];
|
|
107
|
-
if (tone) {
|
|
108
|
-
rgb2 = getRgbTone(rgb2, tone);
|
|
109
|
-
}
|
|
110
|
-
val = `rgba(${rgb2}, ${alpha2})`;
|
|
111
|
-
} else {
|
|
112
|
-
const tone = parts[2];
|
|
113
|
-
const alpha2 = parts[1] !== void 0 ? parts[1] : "1";
|
|
114
|
-
if (tone) {
|
|
115
|
-
try {
|
|
116
|
-
const rgb2 = colorStringToRgbaArray(parts[0]);
|
|
117
|
-
if (rgb2 && rgb2.length >= 3) {
|
|
118
|
-
const tonedRgb = getRgbTone(rgb2.slice(0, 3).join(", "), tone);
|
|
119
|
-
val = `rgba(${tonedRgb}, ${alpha2})`;
|
|
120
|
-
} else {
|
|
121
|
-
val = parts[0];
|
|
122
|
-
}
|
|
123
|
-
} catch (e) {
|
|
124
|
-
val = parts[0];
|
|
125
|
-
}
|
|
126
|
-
} else {
|
|
127
|
-
val = parts[0];
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
if (isArray(val)) {
|
|
133
|
-
return {
|
|
134
|
-
"@light": setColor(val[0], key, "light"),
|
|
135
|
-
"@dark": setColor(val[1], key, "dark")
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
if (isObject(val)) {
|
|
139
|
-
const obj = {};
|
|
140
|
-
for (const variant in val) {
|
|
141
|
-
obj[variant] = setColor(
|
|
142
|
-
val[variant],
|
|
143
|
-
key,
|
|
144
|
-
variant.slice(0, 1) === "@" ? variant.slice(1) : variant
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
return obj;
|
|
148
|
-
}
|
|
149
|
-
const CSSVar = `--color-${key}` + (suffix ? `-${suffix}` : "");
|
|
150
|
-
const colorArr = colorStringToRgbaArray(val.value || val);
|
|
151
|
-
const [r, g, b, a = 1] = colorArr;
|
|
152
|
-
const alpha = parseFloat(a.toFixed(2));
|
|
153
|
-
const rgb = `${r}, ${g}, ${b}`;
|
|
154
|
-
const value = `rgba(${rgb}, ${alpha})`;
|
|
155
|
-
if (CONFIG.useVariable) {
|
|
156
|
-
CONFIG.CSS_VARS[CSSVar] = value;
|
|
157
|
-
}
|
|
158
|
-
return {
|
|
159
|
-
var: CSSVar,
|
|
160
|
-
rgb,
|
|
161
|
-
alpha,
|
|
162
|
-
value
|
|
163
|
-
};
|
|
164
|
-
};
|
|
165
|
-
const setGradient = (val, key, suffix) => {
|
|
166
|
-
const CONFIG = getActiveConfig();
|
|
167
|
-
if (isString(val) && isCSSVar(val)) val = getColor(val.slice(2));
|
|
168
|
-
if (isArray(val)) {
|
|
169
|
-
return {
|
|
170
|
-
"@light": setGradient(val[0], key, "light"),
|
|
171
|
-
"@dark": setGradient(val[0], key, "dark")
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
if (isObject(val)) {
|
|
175
|
-
const obj = {};
|
|
176
|
-
for (const variant in val) obj[variant] = setGradient(val[variant], key, variant.slice(0, 1) === "@" ? variant.slice(1) : variant);
|
|
177
|
-
return obj;
|
|
178
|
-
}
|
|
179
|
-
const CSSVar = `--gradient-${key}` + (suffix ? `-${suffix}` : "");
|
|
180
|
-
if (CONFIG.useVariable) {
|
|
181
|
-
CONFIG.CSS_VARS[CSSVar] = val.value || val;
|
|
182
|
-
}
|
|
183
|
-
return {
|
|
184
|
-
var: CSSVar,
|
|
185
|
-
value: val.value || val
|
|
186
|
-
};
|
|
187
|
-
};
|
|
188
|
-
export {
|
|
189
|
-
getColor,
|
|
190
|
-
getMediaColor,
|
|
191
|
-
setColor,
|
|
192
|
-
setGradient
|
|
193
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { merge } from "@domql/utils";
|
|
2
|
-
import { getActiveConfig } from "../factory.js";
|
|
3
|
-
import { getDefaultOrFirstKey } from "../utils";
|
|
4
|
-
const applyDocument = () => {
|
|
5
|
-
const CONFIG = getActiveConfig();
|
|
6
|
-
const { document: DOCUMENT, font_family: FONT_FAMILY, theme: THEME, typography: TYPOGRAPHY } = CONFIG;
|
|
7
|
-
return merge(DOCUMENT, {
|
|
8
|
-
theme: THEME.document,
|
|
9
|
-
fontFamily: getDefaultOrFirstKey(FONT_FAMILY),
|
|
10
|
-
fontSize: TYPOGRAPHY.base,
|
|
11
|
-
lineHeight: TYPOGRAPHY.lineHeight
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
export {
|
|
15
|
-
applyDocument
|
|
16
|
-
};
|
package/dist/esm/system/font.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { isObject, isArray } from "@domql/utils";
|
|
2
|
-
import { arrayzeValue } from "@symbo.ls/smbls-utils";
|
|
3
|
-
import { getActiveConfig } from "../factory.js";
|
|
4
|
-
import {
|
|
5
|
-
getDefaultOrFirstKey,
|
|
6
|
-
getFontFaceEach,
|
|
7
|
-
isGoogleFontsUrl,
|
|
8
|
-
setCustomFontMedia,
|
|
9
|
-
setFontImport,
|
|
10
|
-
resolveFileUrl
|
|
11
|
-
} from "../utils";
|
|
12
|
-
const setFont = (val, key) => {
|
|
13
|
-
const CONFIG = getActiveConfig();
|
|
14
|
-
const CSSvar = `--font-${key}`;
|
|
15
|
-
if (!val || isArray(val) && !val[0]) return;
|
|
16
|
-
let fontFace;
|
|
17
|
-
if (val.isVariable) {
|
|
18
|
-
const url = resolveFileUrl(val.url, CONFIG.files) || val.url;
|
|
19
|
-
if (isGoogleFontsUrl(url)) {
|
|
20
|
-
fontFace = setFontImport(url);
|
|
21
|
-
} else {
|
|
22
|
-
fontFace = setCustomFontMedia(key, url, val.fontWeight, {
|
|
23
|
-
fontStretch: val.fontStretch,
|
|
24
|
-
fontDisplay: val.fontDisplay || "swap"
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
} else if (val[0]) {
|
|
28
|
-
fontFace = getFontFaceEach(key, val, CONFIG.files);
|
|
29
|
-
} else {
|
|
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
|
-
});
|
|
36
|
-
}
|
|
37
|
-
return { var: CSSvar, value: val, fontFace };
|
|
38
|
-
};
|
|
39
|
-
const getFontFamily = (key, factory) => {
|
|
40
|
-
const CONFIG = getActiveConfig();
|
|
41
|
-
const { font_family: FONT_FAMILY } = CONFIG;
|
|
42
|
-
return getDefaultOrFirstKey(factory || FONT_FAMILY, key);
|
|
43
|
-
};
|
|
44
|
-
const setFontFamily = (val, key) => {
|
|
45
|
-
const CONFIG = getActiveConfig();
|
|
46
|
-
const { font_family: FONT_FAMILY, font_family_types: FONT_FAMILY_TYPES } = CONFIG;
|
|
47
|
-
let { value, type } = val;
|
|
48
|
-
if (val.isDefault) FONT_FAMILY.default = key;
|
|
49
|
-
if (isObject(value)) value = arrayzeValue(value);
|
|
50
|
-
const CSSvar = `--font-family-${key}`;
|
|
51
|
-
const str = `${value.join(", ")}, ${FONT_FAMILY_TYPES[type]}`;
|
|
52
|
-
return { var: CSSvar, value: str, arr: value, type };
|
|
53
|
-
};
|
|
54
|
-
export {
|
|
55
|
-
getFontFamily,
|
|
56
|
-
setFont,
|
|
57
|
-
setFontFamily
|
|
58
|
-
};
|
package/dist/esm/system/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from "./color.js";
|
|
2
|
-
export * from "./theme.js";
|
|
3
|
-
export * from "./font.js";
|
|
4
|
-
export * from "./typography.js";
|
|
5
|
-
export * from "./spacing.js";
|
|
6
|
-
export * from "./shadow.js";
|
|
7
|
-
export * from "./timing.js";
|
|
8
|
-
export * from "./document.js";
|
|
9
|
-
export * from "./svg.js";
|
|
10
|
-
export * from "./reset.js";
|