@symbo.ls/scratch 3.4.5 → 3.4.9
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/dist/cjs/defaultConfig/animation.js +24 -0
- package/dist/cjs/defaultConfig/cases.js +24 -0
- package/dist/cjs/defaultConfig/class.js +25 -0
- package/dist/cjs/defaultConfig/color.js +31 -0
- package/dist/cjs/defaultConfig/document.js +24 -0
- package/dist/cjs/defaultConfig/font-family.js +38 -0
- package/dist/cjs/defaultConfig/font.js +33 -0
- package/dist/cjs/defaultConfig/grid.js +25 -0
- package/dist/cjs/defaultConfig/icons.js +26 -0
- package/dist/cjs/defaultConfig/index.js +45 -0
- package/dist/cjs/defaultConfig/media.js +29 -0
- package/dist/cjs/defaultConfig/responsive.js +50 -0
- package/dist/cjs/defaultConfig/sequence.js +49 -0
- package/dist/cjs/defaultConfig/shadow.js +29 -0
- package/dist/cjs/defaultConfig/spacing.js +38 -0
- package/dist/cjs/defaultConfig/svg.js +26 -0
- package/dist/cjs/defaultConfig/templates.js +24 -0
- package/dist/cjs/defaultConfig/theme.js +36 -0
- package/dist/cjs/defaultConfig/timing.js +37 -0
- package/dist/cjs/defaultConfig/typography.js +41 -0
- package/dist/cjs/defaultConfig/unit.js +26 -0
- package/dist/cjs/system/color.js +203 -0
- package/dist/cjs/system/document.js +36 -0
- package/dist/cjs/system/font.js +64 -0
- package/dist/cjs/system/index.js +27 -0
- package/dist/cjs/system/reset.js +87 -0
- package/dist/cjs/system/shadow.js +107 -0
- package/dist/cjs/system/spacing.js +134 -0
- package/dist/cjs/system/svg.js +97 -0
- package/dist/cjs/system/theme.js +234 -0
- package/dist/cjs/system/timing.js +48 -0
- package/dist/cjs/system/typography.js +99 -0
- package/dist/cjs/tests/index.js +28 -0
- package/dist/cjs/transforms/index.js +219 -0
- package/dist/cjs/utils/color.js +206 -0
- package/dist/cjs/utils/font.js +89 -0
- package/dist/cjs/utils/index.js +24 -0
- package/dist/cjs/utils/sequence.js +323 -0
- package/dist/cjs/utils/sprite.js +85 -0
- package/dist/cjs/utils/theme.js +29 -0
- package/dist/cjs/utils/unit.js +79 -0
- package/dist/cjs/utils/var.js +102 -0
- package/dist/esm/defaultConfig/animation.js +4 -0
- package/dist/esm/defaultConfig/cases.js +4 -0
- package/dist/esm/defaultConfig/class.js +5 -0
- package/dist/esm/defaultConfig/color.js +11 -0
- package/dist/esm/defaultConfig/document.js +4 -0
- package/dist/esm/defaultConfig/font-family.js +18 -0
- package/dist/esm/defaultConfig/font.js +13 -0
- package/dist/esm/defaultConfig/grid.js +5 -0
- package/dist/esm/defaultConfig/icons.js +6 -0
- package/dist/esm/defaultConfig/index.js +24 -0
- package/dist/esm/defaultConfig/media.js +9 -0
- package/dist/esm/defaultConfig/responsive.js +30 -0
- package/dist/esm/defaultConfig/sequence.js +29 -0
- package/dist/esm/defaultConfig/shadow.js +9 -0
- package/dist/esm/defaultConfig/spacing.js +18 -0
- package/dist/esm/defaultConfig/svg.js +6 -0
- package/dist/esm/defaultConfig/templates.js +4 -0
- package/dist/esm/defaultConfig/theme.js +16 -0
- package/dist/esm/defaultConfig/timing.js +17 -0
- package/dist/esm/defaultConfig/typography.js +21 -0
- package/dist/esm/defaultConfig/unit.js +6 -0
- package/dist/esm/system/color.js +188 -0
- package/dist/esm/system/document.js +16 -0
- package/dist/esm/system/font.js +50 -0
- package/dist/esm/system/index.js +10 -0
- package/dist/esm/system/reset.js +67 -0
- package/dist/esm/system/shadow.js +91 -0
- package/dist/esm/system/spacing.js +121 -0
- package/dist/esm/system/svg.js +77 -0
- package/dist/esm/system/theme.js +219 -0
- package/dist/esm/system/timing.js +32 -0
- package/dist/esm/system/typography.js +85 -0
- package/dist/esm/tests/index.js +8 -0
- package/dist/esm/transforms/index.js +216 -0
- package/dist/esm/utils/color.js +192 -0
- package/dist/esm/utils/font.js +69 -0
- package/dist/esm/utils/index.js +7 -0
- package/dist/esm/utils/sequence.js +303 -0
- package/dist/esm/utils/sprite.js +65 -0
- package/dist/esm/utils/theme.js +9 -0
- package/dist/esm/utils/unit.js +59 -0
- package/dist/esm/utils/var.js +82 -0
- package/package.json +7 -7
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export * from "./sequence.js";
|
|
2
|
+
export * from "./unit.js";
|
|
3
|
+
export * from "./typography.js";
|
|
4
|
+
export * from "./font.js";
|
|
5
|
+
export * from "./font-family.js";
|
|
6
|
+
export * from "./media.js";
|
|
7
|
+
export * from "./spacing.js";
|
|
8
|
+
export * from "./color.js";
|
|
9
|
+
export * from "./theme.js";
|
|
10
|
+
export * from "./shadow.js";
|
|
11
|
+
export * from "./icons.js";
|
|
12
|
+
export * from "./timing.js";
|
|
13
|
+
export * from "./document.js";
|
|
14
|
+
export * from "./responsive.js";
|
|
15
|
+
export * from "./cases.js";
|
|
16
|
+
export * from "./animation.js";
|
|
17
|
+
export * from "./svg.js";
|
|
18
|
+
export * from "./templates.js";
|
|
19
|
+
export * from "./grid.js";
|
|
20
|
+
export * from "./class.js";
|
|
21
|
+
const RESET = {};
|
|
22
|
+
export {
|
|
23
|
+
RESET
|
|
24
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const BREAKPOINTS = {
|
|
2
|
+
screenL: 1920,
|
|
3
|
+
screenM: 1680,
|
|
4
|
+
screenS: 1440,
|
|
5
|
+
tabletL: 1366,
|
|
6
|
+
tabletM: 1280,
|
|
7
|
+
tabletS: 1024,
|
|
8
|
+
mobileL: 768,
|
|
9
|
+
mobileM: 560,
|
|
10
|
+
mobileS: 480,
|
|
11
|
+
mobileXS: 375
|
|
12
|
+
};
|
|
13
|
+
const DEVICES = {
|
|
14
|
+
screenXXL: [2560, 1440],
|
|
15
|
+
screenXL: [2240, 1260],
|
|
16
|
+
screenL: [1920, 1024],
|
|
17
|
+
screenM: [1680, 1024],
|
|
18
|
+
screenS: [1440, 720],
|
|
19
|
+
tabletL: [1366, 926],
|
|
20
|
+
tabletM: [1280, 768],
|
|
21
|
+
tabletS: [1024, 768],
|
|
22
|
+
mobileL: [768, 375],
|
|
23
|
+
mobileM: [560, 768],
|
|
24
|
+
mobileS: [480, 768],
|
|
25
|
+
mobileXS: [375, 768]
|
|
26
|
+
};
|
|
27
|
+
export {
|
|
28
|
+
BREAKPOINTS,
|
|
29
|
+
DEVICES
|
|
30
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const SEQUENCE = {
|
|
2
|
+
"minor-second": 1.067,
|
|
3
|
+
"major-second": 1.125,
|
|
4
|
+
"minor-third": 1.2,
|
|
5
|
+
"major-third": 1.25,
|
|
6
|
+
"perfect-fourth": 1.333,
|
|
7
|
+
"augmented-fourth": 1.414,
|
|
8
|
+
"perfect-fifth": 1.5,
|
|
9
|
+
"minor-sixth": 1.6,
|
|
10
|
+
phi: 1.618,
|
|
11
|
+
// golden-ratio
|
|
12
|
+
"major-sixth": 1.667,
|
|
13
|
+
"square-root-3": 1.732,
|
|
14
|
+
// theodorus
|
|
15
|
+
"minor-seventh": 1.778,
|
|
16
|
+
"major-seventh": 1.875,
|
|
17
|
+
octave: 2,
|
|
18
|
+
"square-root-5": 2.23,
|
|
19
|
+
// pythagoras
|
|
20
|
+
"major-tenth": 2.5,
|
|
21
|
+
"major-eleventh": 2.667,
|
|
22
|
+
"major-twelfth": 3,
|
|
23
|
+
pi: 3.14,
|
|
24
|
+
// archimedes
|
|
25
|
+
"double-octave": 4
|
|
26
|
+
};
|
|
27
|
+
export {
|
|
28
|
+
SEQUENCE
|
|
29
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,188 @@
|
|
|
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) return value;
|
|
23
|
+
if (parsed.passthrough) return parsed.passthrough;
|
|
24
|
+
if (parsed.cssVar) return `var(${parsed.cssVar})`;
|
|
25
|
+
name = parsed.name;
|
|
26
|
+
alpha = parsed.alpha;
|
|
27
|
+
tone = parsed.tone;
|
|
28
|
+
}
|
|
29
|
+
const { COLOR, GRADIENT } = CONFIG;
|
|
30
|
+
let val = COLOR[name] || GRADIENT[name];
|
|
31
|
+
if (!val) {
|
|
32
|
+
if (CONFIG.verbose) console.warn("Can't find color ", name);
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
if (key) {
|
|
36
|
+
if (val[key]) val = val[key];
|
|
37
|
+
else if (CONFIG.verbose) console.warn(value, " - does not have ", key);
|
|
38
|
+
}
|
|
39
|
+
let rgb = val.rgb;
|
|
40
|
+
if (!rgb) {
|
|
41
|
+
return CONFIG.useVariable ? `var(${val.var})` : val.value;
|
|
42
|
+
}
|
|
43
|
+
if (tone && !val[tone]) {
|
|
44
|
+
rgb = getRgbTone(rgb, tone);
|
|
45
|
+
val[tone] = { rgb, var: `${val.var}-${tone}` };
|
|
46
|
+
}
|
|
47
|
+
if (val[tone]) rgb = val[tone].rgb;
|
|
48
|
+
if (alpha) return `rgba(${rgb}, ${alpha})`;
|
|
49
|
+
if (tone) return `rgba(${rgb}, 1)`;
|
|
50
|
+
return CONFIG.useVariable ? `var(${val.var})` : `rgb(${rgb})`;
|
|
51
|
+
};
|
|
52
|
+
const getMediaColor = (value, globalTheme, config) => {
|
|
53
|
+
const CONFIG = config || getActiveConfig();
|
|
54
|
+
if (!globalTheme) globalTheme = CONFIG.globalTheme === "auto" ? null : CONFIG.globalTheme;
|
|
55
|
+
if (!isString(value)) {
|
|
56
|
+
if (CONFIG.verbose) console.warn(value, "- type for color is not valid");
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (isCSSVar(value)) return `var(${value})`;
|
|
60
|
+
let name;
|
|
61
|
+
if (isArray(value)) {
|
|
62
|
+
name = value[0];
|
|
63
|
+
} else {
|
|
64
|
+
const parsed = parseColorToken(value);
|
|
65
|
+
if (!parsed) return value;
|
|
66
|
+
if (parsed.passthrough) return parsed.passthrough;
|
|
67
|
+
if (parsed.cssVar) return `var(${parsed.cssVar})`;
|
|
68
|
+
name = parsed.name;
|
|
69
|
+
}
|
|
70
|
+
const { COLOR, GRADIENT } = CONFIG;
|
|
71
|
+
const val = COLOR[name] || GRADIENT[name];
|
|
72
|
+
const isObj = isObject(val);
|
|
73
|
+
if (isObj && val.value) return getColor(value, `@${globalTheme}`, config);
|
|
74
|
+
else if (isObj) {
|
|
75
|
+
if (globalTheme) return getColor(value, `@${globalTheme}`, config);
|
|
76
|
+
else {
|
|
77
|
+
const obj = {};
|
|
78
|
+
for (const mediaName in val) {
|
|
79
|
+
const query = CONFIG.MEDIA[mediaName.slice(1)];
|
|
80
|
+
const media = "@media " + (query === "print" ? `${query}` : `screen and ${query}`);
|
|
81
|
+
obj[media] = getColor(value, mediaName, config);
|
|
82
|
+
}
|
|
83
|
+
return obj;
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
if (CONFIG.verbose) console.warn("Can't find color", value);
|
|
87
|
+
return value;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const setColor = (val, key, suffix) => {
|
|
91
|
+
const CONFIG = getActiveConfig();
|
|
92
|
+
if (isString(val) && isCSSVar(val)) {
|
|
93
|
+
const rawRef = val.slice(2);
|
|
94
|
+
val = getColor(rawRef);
|
|
95
|
+
if (!(val.includes("rgb") || val.includes("var") || val.includes("#"))) {
|
|
96
|
+
const parts = rawRef.split(" ");
|
|
97
|
+
const refColor = CONFIG.COLOR[parts[0]];
|
|
98
|
+
if (refColor && refColor.value) {
|
|
99
|
+
let rgb2 = refColor.rgb;
|
|
100
|
+
const alpha2 = parts[1] !== void 0 ? parts[1] : "1";
|
|
101
|
+
const tone = parts[2];
|
|
102
|
+
if (tone) {
|
|
103
|
+
rgb2 = getRgbTone(rgb2, tone);
|
|
104
|
+
}
|
|
105
|
+
val = `rgba(${rgb2}, ${alpha2})`;
|
|
106
|
+
} else {
|
|
107
|
+
const tone = parts[2];
|
|
108
|
+
const alpha2 = parts[1] !== void 0 ? parts[1] : "1";
|
|
109
|
+
if (tone) {
|
|
110
|
+
try {
|
|
111
|
+
const rgb2 = colorStringToRgbaArray(parts[0]);
|
|
112
|
+
if (rgb2 && rgb2.length >= 3) {
|
|
113
|
+
const tonedRgb = getRgbTone(rgb2.slice(0, 3).join(", "), tone);
|
|
114
|
+
val = `rgba(${tonedRgb}, ${alpha2})`;
|
|
115
|
+
} else {
|
|
116
|
+
val = parts[0];
|
|
117
|
+
}
|
|
118
|
+
} catch (e) {
|
|
119
|
+
val = parts[0];
|
|
120
|
+
}
|
|
121
|
+
} else {
|
|
122
|
+
val = parts[0];
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (isArray(val)) {
|
|
128
|
+
return {
|
|
129
|
+
"@light": setColor(val[0], key, "light"),
|
|
130
|
+
"@dark": setColor(val[1], key, "dark")
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
if (isObject(val)) {
|
|
134
|
+
const obj = {};
|
|
135
|
+
for (const variant in val) {
|
|
136
|
+
obj[variant] = setColor(
|
|
137
|
+
val[variant],
|
|
138
|
+
key,
|
|
139
|
+
variant.slice(0, 1) === "@" ? variant.slice(1) : variant
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
return obj;
|
|
143
|
+
}
|
|
144
|
+
const CSSVar = `--color-${key}` + (suffix ? `-${suffix}` : "");
|
|
145
|
+
const colorArr = colorStringToRgbaArray(val.value || val);
|
|
146
|
+
const [r, g, b, a = 1] = colorArr;
|
|
147
|
+
const alpha = parseFloat(a.toFixed(2));
|
|
148
|
+
const rgb = `${r}, ${g}, ${b}`;
|
|
149
|
+
const value = `rgba(${rgb}, ${alpha})`;
|
|
150
|
+
if (CONFIG.useVariable) {
|
|
151
|
+
CONFIG.CSS_VARS[CSSVar] = value;
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
var: CSSVar,
|
|
155
|
+
rgb,
|
|
156
|
+
alpha,
|
|
157
|
+
value
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
const setGradient = (val, key, suffix) => {
|
|
161
|
+
const CONFIG = getActiveConfig();
|
|
162
|
+
if (isString(val) && isCSSVar(val)) val = getColor(val.slice(2));
|
|
163
|
+
if (isArray(val)) {
|
|
164
|
+
return {
|
|
165
|
+
"@light": setGradient(val[0], key, "light"),
|
|
166
|
+
"@dark": setGradient(val[0], key, "dark")
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
if (isObject(val)) {
|
|
170
|
+
const obj = {};
|
|
171
|
+
for (const variant in val) obj[variant] = setGradient(val[variant], key, variant.slice(0, 1) === "@" ? variant.slice(1) : variant);
|
|
172
|
+
return obj;
|
|
173
|
+
}
|
|
174
|
+
const CSSVar = `--gradient-${key}` + (suffix ? `-${suffix}` : "");
|
|
175
|
+
if (CONFIG.useVariable) {
|
|
176
|
+
CONFIG.CSS_VARS[CSSVar] = val.value || val;
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
var: CSSVar,
|
|
180
|
+
value: val.value || val
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
export {
|
|
184
|
+
getColor,
|
|
185
|
+
getMediaColor,
|
|
186
|
+
setColor,
|
|
187
|
+
setGradient
|
|
188
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
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, FONT_FAMILY, THEME, 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
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
} from "../utils";
|
|
11
|
+
const setFont = (val, key) => {
|
|
12
|
+
const CSSvar = `--font-${key}`;
|
|
13
|
+
if (!val || isArray(val) && !val[0]) return;
|
|
14
|
+
let fontFace;
|
|
15
|
+
if (val.isVariable) {
|
|
16
|
+
if (isGoogleFontsUrl(val.url)) {
|
|
17
|
+
fontFace = setFontImport(val.url);
|
|
18
|
+
} else {
|
|
19
|
+
fontFace = setCustomFontMedia(key, val.url, val.fontWeight, {
|
|
20
|
+
fontStretch: val.fontStretch,
|
|
21
|
+
fontDisplay: val.fontDisplay || "swap"
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
} else if (val[0]) {
|
|
25
|
+
fontFace = getFontFaceEach(key, val);
|
|
26
|
+
} else {
|
|
27
|
+
fontFace = setCustomFontMedia(key, val.url);
|
|
28
|
+
}
|
|
29
|
+
return { var: CSSvar, value: val, fontFace };
|
|
30
|
+
};
|
|
31
|
+
const getFontFamily = (key, factory) => {
|
|
32
|
+
const CONFIG = getActiveConfig();
|
|
33
|
+
const { FONT_FAMILY } = CONFIG;
|
|
34
|
+
return getDefaultOrFirstKey(factory || FONT_FAMILY, key);
|
|
35
|
+
};
|
|
36
|
+
const setFontFamily = (val, key) => {
|
|
37
|
+
const CONFIG = getActiveConfig();
|
|
38
|
+
const { FONT_FAMILY, FONT_FAMILY_TYPES } = CONFIG;
|
|
39
|
+
let { value, type } = val;
|
|
40
|
+
if (val.isDefault) FONT_FAMILY.default = key;
|
|
41
|
+
if (isObject(value)) value = arrayzeValue(value);
|
|
42
|
+
const CSSvar = `--font-family-${key}`;
|
|
43
|
+
const str = `${value.join(", ")}, ${FONT_FAMILY_TYPES[type]}`;
|
|
44
|
+
return { var: CSSvar, value: str, arr: value, type };
|
|
45
|
+
};
|
|
46
|
+
export {
|
|
47
|
+
getFontFamily,
|
|
48
|
+
setFont,
|
|
49
|
+
setFontFamily
|
|
50
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
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";
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { deepMerge, merge, overwriteDeep } from "@domql/utils";
|
|
2
|
+
import { getActiveConfig } from "../factory.js";
|
|
3
|
+
import { getMediaTheme } from "./theme.js";
|
|
4
|
+
const applyReset = (reset = {}) => {
|
|
5
|
+
const CONFIG = getActiveConfig();
|
|
6
|
+
const { RESET, TYPOGRAPHY, DOCUMENT } = CONFIG;
|
|
7
|
+
if (RESET) {
|
|
8
|
+
if (RESET[":root"]) {
|
|
9
|
+
const configReset = RESET;
|
|
10
|
+
const configTemplates = TYPOGRAPHY.templates;
|
|
11
|
+
configReset.body = {
|
|
12
|
+
...CONFIG.useDocumentTheme ? getMediaTheme("document", `@${CONFIG.globalTheme}`) : {},
|
|
13
|
+
...configTemplates.body
|
|
14
|
+
};
|
|
15
|
+
configReset.h1 = configTemplates.h1;
|
|
16
|
+
configReset.h2 = configTemplates.h2;
|
|
17
|
+
configReset.h3 = configTemplates.h3;
|
|
18
|
+
configReset.h4 = configTemplates.h4;
|
|
19
|
+
configReset.h5 = configTemplates.h5;
|
|
20
|
+
configReset.h6 = configTemplates.h6;
|
|
21
|
+
}
|
|
22
|
+
const { body, ...templates } = TYPOGRAPHY.templates;
|
|
23
|
+
const globalTheme = CONFIG.useDocumentTheme ? getMediaTheme("document", `@${CONFIG.globalTheme}`) : {};
|
|
24
|
+
if (RESET.html) overwriteDeep(RESET.html, globalTheme);
|
|
25
|
+
return deepMerge(merge(RESET, reset), {
|
|
26
|
+
html: {
|
|
27
|
+
position: "absolute",
|
|
28
|
+
// overflow: 'hidden',
|
|
29
|
+
width: "100%",
|
|
30
|
+
height: "100%",
|
|
31
|
+
top: "0",
|
|
32
|
+
left: "0",
|
|
33
|
+
margin: "0",
|
|
34
|
+
WebkitFontSmoothing: "subpixel-antialiased",
|
|
35
|
+
scrollBehavior: "smooth",
|
|
36
|
+
...globalTheme,
|
|
37
|
+
fontSize: TYPOGRAPHY.browserDefault + "px",
|
|
38
|
+
fontFamily: DOCUMENT.fontFamily,
|
|
39
|
+
lineHeight: DOCUMENT.lineHeight
|
|
40
|
+
},
|
|
41
|
+
body: {
|
|
42
|
+
boxSizing: "border-box",
|
|
43
|
+
height: "100%",
|
|
44
|
+
margin: 0,
|
|
45
|
+
fontFamily: DOCUMENT.fontFamily,
|
|
46
|
+
fontSize: TYPOGRAPHY.base / TYPOGRAPHY.browserDefault + CONFIG.UNIT.default,
|
|
47
|
+
...templates,
|
|
48
|
+
...body
|
|
49
|
+
},
|
|
50
|
+
a: {
|
|
51
|
+
color: "currentColor"
|
|
52
|
+
},
|
|
53
|
+
// form elements
|
|
54
|
+
fieldset: {
|
|
55
|
+
border: 0,
|
|
56
|
+
padding: 0,
|
|
57
|
+
margin: 0
|
|
58
|
+
},
|
|
59
|
+
"select, input": {
|
|
60
|
+
fontFamily: DOCUMENT.fontFamily
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
export {
|
|
66
|
+
applyReset
|
|
67
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { getActiveConfig } from "../factory.js";
|
|
2
|
+
import { getColor } from "./color.js";
|
|
3
|
+
import { getSpacingByKey } from "./spacing.js";
|
|
4
|
+
import { isResolvedColor, isCSSVar, splitTopLevelCommas, CSS_NATIVE_COLOR_REGEX } from "../utils/color.js";
|
|
5
|
+
import {
|
|
6
|
+
isObject,
|
|
7
|
+
isString,
|
|
8
|
+
isArray
|
|
9
|
+
} from "@domql/utils";
|
|
10
|
+
const setShadow = (value, key, suffix, prefers) => {
|
|
11
|
+
const CONFIG = getActiveConfig();
|
|
12
|
+
if (isArray(value)) {
|
|
13
|
+
return {
|
|
14
|
+
"@light": setShadow(value[0], key, "light"),
|
|
15
|
+
"@dark": setShadow(value[1], key, "dark")
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
if (isObject(value)) {
|
|
19
|
+
const obj = {};
|
|
20
|
+
for (const variant in value) {
|
|
21
|
+
obj[variant] = setShadow(
|
|
22
|
+
value[variant],
|
|
23
|
+
key,
|
|
24
|
+
variant.startsWith("@") ? variant.slice(1) : variant
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
return obj;
|
|
28
|
+
}
|
|
29
|
+
if (isString(value) && !CSS_NATIVE_COLOR_REGEX.test(value)) {
|
|
30
|
+
value = splitTopLevelCommas(value).map((shadow) => {
|
|
31
|
+
shadow = shadow.trim();
|
|
32
|
+
return shadow.split(/\s+/).map((v) => {
|
|
33
|
+
v = v.trim();
|
|
34
|
+
if (!v) return "";
|
|
35
|
+
if (v.startsWith("--")) return `var(${v})`;
|
|
36
|
+
const color = getColor(v);
|
|
37
|
+
if (isResolvedColor(color)) return color;
|
|
38
|
+
if (/^\d/.test(v) || v === "0" || v.includes("px") || v.slice(-2) === "em") return v;
|
|
39
|
+
if (v === "inset" || v === "none") return v;
|
|
40
|
+
const spacing = getSpacingByKey(v, "shadow");
|
|
41
|
+
if (spacing && spacing.shadow) return spacing.shadow;
|
|
42
|
+
return v;
|
|
43
|
+
}).join(" ");
|
|
44
|
+
}).join(", ");
|
|
45
|
+
}
|
|
46
|
+
const CSSVar = `--shadow-${key}` + (suffix ? `-${suffix}` : "");
|
|
47
|
+
if (CONFIG.useVariable) {
|
|
48
|
+
CONFIG.CSS_VARS[CSSVar] = value;
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
var: CSSVar,
|
|
52
|
+
value
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
const getShadow = (value, globalTheme) => {
|
|
56
|
+
const CONFIG = getActiveConfig();
|
|
57
|
+
if (!globalTheme) globalTheme = CONFIG.globalTheme;
|
|
58
|
+
if (!isString(value)) {
|
|
59
|
+
if (CONFIG.verbose) console.warn(value, "- type for color is not valid");
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (isCSSVar(value)) return `var(${value})`;
|
|
63
|
+
const [name] = isArray(value) ? value : value.split(" ");
|
|
64
|
+
const { SHADOW } = CONFIG;
|
|
65
|
+
const val = SHADOW[name];
|
|
66
|
+
const isObj = isObject(val);
|
|
67
|
+
if (!val) {
|
|
68
|
+
if (CONFIG.verbose) console.warn("Can't find color ", name);
|
|
69
|
+
return value;
|
|
70
|
+
}
|
|
71
|
+
if (globalTheme) {
|
|
72
|
+
if (val[globalTheme]) return val[globalTheme].value;
|
|
73
|
+
else if (CONFIG.verbose) console.warn(value, " - does not have ", globalTheme);
|
|
74
|
+
}
|
|
75
|
+
if (isObj && val.value) return val.value;
|
|
76
|
+
if (isObj) {
|
|
77
|
+
const obj = {};
|
|
78
|
+
for (const mediaName in val) {
|
|
79
|
+
const query = CONFIG.MEDIA[mediaName.slice(1)];
|
|
80
|
+
const media = "@media " + (query === "print" ? `${query}` : `screen and ${query}`);
|
|
81
|
+
obj[media] = val.value;
|
|
82
|
+
}
|
|
83
|
+
return obj;
|
|
84
|
+
}
|
|
85
|
+
if (CONFIG.verbose) console.warn("Can't find color", value);
|
|
86
|
+
return value;
|
|
87
|
+
};
|
|
88
|
+
export {
|
|
89
|
+
getShadow,
|
|
90
|
+
setShadow
|
|
91
|
+
};
|