@symbo.ls/scratch 2.10.149 → 2.10.156

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 (82) hide show
  1. package/dist/cjs/defaultConfig/animation.js +24 -0
  2. package/dist/cjs/defaultConfig/cases.js +24 -0
  3. package/dist/cjs/defaultConfig/color.js +32 -0
  4. package/dist/cjs/defaultConfig/document.js +24 -0
  5. package/dist/cjs/defaultConfig/font-family.js +39 -0
  6. package/dist/cjs/defaultConfig/font.js +33 -0
  7. package/dist/cjs/defaultConfig/icons.js +24 -0
  8. package/dist/cjs/defaultConfig/index.js +41 -0
  9. package/dist/cjs/defaultConfig/media.js +39 -0
  10. package/dist/cjs/defaultConfig/responsive.js +48 -0
  11. package/dist/cjs/defaultConfig/sequence.js +49 -0
  12. package/dist/cjs/defaultConfig/spacing.js +36 -0
  13. package/dist/cjs/defaultConfig/svg.js +26 -0
  14. package/dist/cjs/defaultConfig/theme.js +36 -0
  15. package/dist/cjs/defaultConfig/timing.js +36 -0
  16. package/dist/cjs/defaultConfig/typography.js +39 -0
  17. package/dist/cjs/defaultConfig/unit.js +26 -0
  18. package/dist/cjs/factory.js +69 -0
  19. package/dist/cjs/index.js +21 -0
  20. package/dist/cjs/package.json +4 -0
  21. package/dist/cjs/set.js +121 -0
  22. package/dist/cjs/system/color.js +169 -0
  23. package/dist/cjs/system/document.js +35 -0
  24. package/dist/cjs/system/font.js +50 -0
  25. package/dist/cjs/system/index.js +26 -0
  26. package/dist/cjs/system/reset.js +83 -0
  27. package/dist/cjs/system/spacing.js +129 -0
  28. package/dist/cjs/system/svg.js +81 -0
  29. package/dist/cjs/system/theme.js +255 -0
  30. package/dist/cjs/system/timing.js +48 -0
  31. package/dist/cjs/system/typography.js +94 -0
  32. package/dist/cjs/tests/index.js +28 -0
  33. package/dist/cjs/utils/color.js +163 -0
  34. package/dist/cjs/utils/font.js +70 -0
  35. package/dist/cjs/utils/index.js +23 -0
  36. package/dist/cjs/utils/object.js +73 -0
  37. package/dist/cjs/utils/sequence.js +199 -0
  38. package/dist/cjs/utils/sprite.js +63 -0
  39. package/dist/cjs/utils/theme.js +32 -0
  40. package/dist/cjs/utils/var.js +64 -0
  41. package/dist/esm/defaultConfig/animation.js +4 -0
  42. package/dist/esm/defaultConfig/cases.js +4 -0
  43. package/dist/esm/defaultConfig/color.js +12 -0
  44. package/dist/esm/defaultConfig/document.js +4 -0
  45. package/dist/esm/defaultConfig/font-family.js +19 -0
  46. package/dist/esm/defaultConfig/font.js +13 -0
  47. package/dist/esm/defaultConfig/icons.js +4 -0
  48. package/dist/esm/defaultConfig/index.js +20 -0
  49. package/dist/esm/defaultConfig/media.js +19 -0
  50. package/dist/esm/defaultConfig/responsive.js +28 -0
  51. package/dist/esm/defaultConfig/sequence.js +29 -0
  52. package/dist/esm/defaultConfig/spacing.js +16 -0
  53. package/dist/esm/defaultConfig/svg.js +6 -0
  54. package/dist/esm/defaultConfig/theme.js +16 -0
  55. package/dist/esm/defaultConfig/timing.js +16 -0
  56. package/dist/esm/defaultConfig/typography.js +19 -0
  57. package/dist/esm/defaultConfig/unit.js +6 -0
  58. package/dist/esm/factory.js +39 -0
  59. package/dist/esm/index.js +4 -0
  60. package/dist/esm/set.js +113 -0
  61. package/dist/esm/system/color.js +156 -0
  62. package/dist/esm/system/document.js +15 -0
  63. package/dist/esm/system/font.js +35 -0
  64. package/dist/esm/system/index.js +9 -0
  65. package/dist/esm/system/reset.js +63 -0
  66. package/dist/esm/system/spacing.js +115 -0
  67. package/dist/esm/system/svg.js +61 -0
  68. package/dist/esm/system/theme.js +240 -0
  69. package/dist/esm/system/timing.js +32 -0
  70. package/dist/esm/system/typography.js +80 -0
  71. package/dist/esm/tests/index.js +8 -0
  72. package/dist/esm/utils/color.js +143 -0
  73. package/dist/esm/utils/font.js +50 -0
  74. package/dist/esm/utils/index.js +6 -0
  75. package/dist/esm/utils/object.js +53 -0
  76. package/dist/esm/utils/sequence.js +179 -0
  77. package/dist/esm/utils/sprite.js +43 -0
  78. package/dist/esm/utils/theme.js +12 -0
  79. package/dist/esm/utils/var.js +44 -0
  80. package/package.json +15 -15
  81. package/dist/index.cjs.js +0 -2389
  82. package/dist/index.cjs.js.map +0 -7
@@ -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,16 @@
1
+ import { SEQUENCE, TYPOGRAPHY } from ".";
2
+ const defaultProps = {
3
+ base: TYPOGRAPHY.base,
4
+ type: "spacing",
5
+ ratio: SEQUENCE.phi,
6
+ range: [-5, 15],
7
+ subSequence: true,
8
+ unit: "em",
9
+ sequence: {},
10
+ scales: {},
11
+ vars: {}
12
+ };
13
+ const SPACING = defaultProps;
14
+ export {
15
+ SPACING
16
+ };
@@ -0,0 +1,6 @@
1
+ const SVG = {};
2
+ const SVG_DATA = {};
3
+ export {
4
+ SVG,
5
+ SVG_DATA
6
+ };
@@ -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,16 @@
1
+ import { SEQUENCE } from ".";
2
+ const defaultProps = {
3
+ default: 150,
4
+ base: 150,
5
+ type: "timing",
6
+ ratio: SEQUENCE["perfect-fourth"],
7
+ range: [-3, 12],
8
+ unit: "ms",
9
+ sequence: {},
10
+ scales: {},
11
+ vars: {}
12
+ };
13
+ const TIMING = defaultProps;
14
+ export {
15
+ TIMING
16
+ };
@@ -0,0 +1,19 @@
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
+ unit: "em",
11
+ templates: {},
12
+ sequence: {},
13
+ scales: {},
14
+ vars: {}
15
+ };
16
+ const TYPOGRAPHY = defaultProps;
17
+ export {
18
+ TYPOGRAPHY
19
+ };
@@ -0,0 +1,6 @@
1
+ const UNIT = {
2
+ default: "em"
3
+ };
4
+ export {
5
+ UNIT
6
+ };
@@ -0,0 +1,39 @@
1
+ import { deepClone, isDefined } from "@domql/utils";
2
+ import * as CONF from "./defaultConfig";
3
+ const CSS_VARS = {};
4
+ const CONFIG = {
5
+ verbose: false,
6
+ useVariable: true,
7
+ useReset: true,
8
+ CSS_VARS,
9
+ ...CONF
10
+ };
11
+ const cachedConfig = deepClone(CONFIG);
12
+ const FACTORY = {
13
+ active: "0",
14
+ 0: CONFIG
15
+ };
16
+ const activateConfig = (def) => {
17
+ if (isDefined(def)) {
18
+ FACTORY.active = def;
19
+ }
20
+ return FACTORY[def || FACTORY.active];
21
+ };
22
+ const getActiveConfig = (def) => {
23
+ if (isDefined(def) && !FACTORY[def]) {
24
+ FACTORY[def] = deepClone(cachedConfig);
25
+ return FACTORY[def];
26
+ }
27
+ return FACTORY[def || FACTORY.active];
28
+ };
29
+ const setActiveConfig = (def) => {
30
+ return FACTORY.active = FACTORY[def];
31
+ };
32
+ export {
33
+ CONFIG,
34
+ CSS_VARS,
35
+ FACTORY,
36
+ activateConfig,
37
+ getActiveConfig,
38
+ setActiveConfig
39
+ };
@@ -0,0 +1,4 @@
1
+ export * from "./factory.js";
2
+ export * from "./utils";
3
+ export * from "./set.js";
4
+ export * from "./defaultConfig";
@@ -0,0 +1,113 @@
1
+ import { FACTORY, getActiveConfig } from "./factory.js";
2
+ import {
3
+ setColor,
4
+ setGradient,
5
+ setFont,
6
+ setFontFamily,
7
+ setTheme,
8
+ setIcon,
9
+ setSVG,
10
+ applyTypographySequence,
11
+ applySpacingSequence,
12
+ applyReset,
13
+ applyTimingSequence,
14
+ applyDocument
15
+ } from "./system";
16
+ import { isFunction } from "./utils";
17
+ const ENV = "development";
18
+ const setCases = (val, key) => {
19
+ if (isFunction(val))
20
+ return val();
21
+ return val;
22
+ };
23
+ const setSameValue = (val, key) => val;
24
+ const VALUE_TRANSFORMERS = {
25
+ color: setColor,
26
+ gradient: setGradient,
27
+ font: setFont,
28
+ font_family: setFontFamily,
29
+ theme: setTheme,
30
+ icons: setIcon,
31
+ svg: setSVG,
32
+ svg_data: setSameValue,
33
+ typography: setSameValue,
34
+ cases: setCases,
35
+ spacing: setSameValue,
36
+ media: setSameValue,
37
+ timing: setSameValue,
38
+ reset: setSameValue,
39
+ unit: setSameValue,
40
+ animation: setSameValue
41
+ };
42
+ const setValue = (FACTORY_NAME, value, key) => {
43
+ const CONFIG = getActiveConfig();
44
+ const factoryName = FACTORY_NAME.toLowerCase();
45
+ const FACTORY2 = CONFIG[FACTORY_NAME];
46
+ if (VALUE_TRANSFORMERS[factoryName]) {
47
+ const result = VALUE_TRANSFORMERS[factoryName](value, key);
48
+ FACTORY2[key] = result;
49
+ return FACTORY2;
50
+ }
51
+ if (CONFIG.verbose)
52
+ console.warn("Can not find", factoryName, "method in scratch");
53
+ };
54
+ const setEach = (factoryName, props) => {
55
+ const CONFIG = getActiveConfig();
56
+ const FACTORY_NAME = factoryName.toUpperCase();
57
+ const keys = Object.keys(props);
58
+ keys.map((key) => setValue(FACTORY_NAME, props[key], key));
59
+ return CONFIG[FACTORY_NAME];
60
+ };
61
+ const SET_OPTIONS = {};
62
+ const set = (recivedConfig, options = SET_OPTIONS) => {
63
+ let CONFIG = getActiveConfig();
64
+ const {
65
+ version,
66
+ verbose,
67
+ useVariable,
68
+ useReset,
69
+ useSvgSprite,
70
+ useFontImport,
71
+ useIconSprite,
72
+ globalTheme,
73
+ useDocumentTheme,
74
+ ...config
75
+ } = recivedConfig;
76
+ if (options.newConfig) {
77
+ FACTORY["active"] = options.newConfig;
78
+ CONFIG = getActiveConfig(options.newConfig);
79
+ }
80
+ if (verbose !== void 0)
81
+ CONFIG.verbose = verbose;
82
+ if (useVariable !== void 0)
83
+ CONFIG.useVariable = useVariable;
84
+ if (useReset !== void 0)
85
+ CONFIG.useReset = useReset;
86
+ if (useFontImport !== void 0)
87
+ CONFIG.useFontImport = useFontImport;
88
+ if (useSvgSprite !== void 0)
89
+ CONFIG.useSvgSprite = useSvgSprite;
90
+ if (useIconSprite !== void 0)
91
+ CONFIG.useIconSprite = useIconSprite;
92
+ if (useDocumentTheme !== void 0)
93
+ CONFIG.useDocumentTheme = useDocumentTheme;
94
+ if (globalTheme !== void 0)
95
+ CONFIG.globalTheme = globalTheme;
96
+ if (CONFIG.verbose)
97
+ console.log(CONFIG);
98
+ const keys = Object.keys(config);
99
+ keys.map((key) => setEach(key, config[key]));
100
+ applyTypographySequence();
101
+ applySpacingSequence();
102
+ applyTimingSequence();
103
+ applyDocument();
104
+ applyReset();
105
+ return CONFIG;
106
+ };
107
+ export * from "./system";
108
+ export {
109
+ VALUE_TRANSFORMERS,
110
+ set,
111
+ setEach,
112
+ setValue
113
+ };
@@ -0,0 +1,156 @@
1
+ import { getActiveConfig } from "../factory.js";
2
+ import { isObject, isArray, isString } from "@domql/utils";
3
+ import {
4
+ colorStringToRgbaArray,
5
+ rgbToHSL,
6
+ hexToRgbArray,
7
+ rgbArrayToHex,
8
+ hslToRgb,
9
+ getColorShade
10
+ } from "../utils";
11
+ const getColor = (value, key) => {
12
+ const CONFIG = getActiveConfig();
13
+ if (!isString(value)) {
14
+ if (CONFIG.verbose)
15
+ console.warn(value, "- type for color is not valid");
16
+ return;
17
+ }
18
+ if (value.slice(0, 2) === "--")
19
+ return `var(${value})`;
20
+ if (key && value[key])
21
+ value = value[key];
22
+ const [name, alpha, tone] = isArray(value) ? value : value.split(" ");
23
+ const { COLOR, GRADIENT } = CONFIG;
24
+ let val = COLOR[name] || GRADIENT[name];
25
+ if (!val) {
26
+ if (CONFIG.verbose)
27
+ console.warn("Can't find color ", name);
28
+ return value;
29
+ }
30
+ if (key) {
31
+ if (val[key])
32
+ val = val[key];
33
+ else if (CONFIG.verbose)
34
+ console.warn(value, " - does not have ", key);
35
+ }
36
+ let rgb = val.rgb;
37
+ if (rgb) {
38
+ if (tone) {
39
+ if (!val[tone]) {
40
+ const toHex = rgbArrayToHex(rgb.split(", ").map((v) => parseFloat(v)));
41
+ if (tone.slice(0, 1) === "-" || tone.slice(0, 1) === "+") {
42
+ rgb = hexToRgbArray(getColorShade(toHex, parseFloat(tone))).join(", ");
43
+ } else {
44
+ const [r, g, b] = [...rgb.split(", ").map((v) => parseInt(v))];
45
+ const hsl = rgbToHSL(r, g, b);
46
+ const [h, s, l] = hsl;
47
+ const newRgb = hslToRgb(h, s, parseFloat(tone) / 100 * 255);
48
+ rgb = newRgb;
49
+ }
50
+ val[tone] = { rgb, var: `${val.var}-${tone}` };
51
+ } else
52
+ rgb = val[tone].rgb;
53
+ }
54
+ if (alpha)
55
+ return `rgba(${rgb}, ${alpha})`;
56
+ return CONFIG.useVariable ? `var(${val.var})` : `rgb(${rgb})`;
57
+ } else
58
+ return CONFIG.useVariable ? `var(${val.var})` : val.value;
59
+ };
60
+ const getMediaColor = (value, property, globalTheme) => {
61
+ const CONFIG = getActiveConfig();
62
+ if (!globalTheme)
63
+ globalTheme = CONFIG.globalTheme;
64
+ if (!isString(value)) {
65
+ if (CONFIG.verbose)
66
+ console.warn(value, "- type for color is not valid");
67
+ return;
68
+ }
69
+ if (value.slice(0, 2) === "--")
70
+ return { [property]: `var(${value})` };
71
+ const [name] = isArray(value) ? value : value.split(" ");
72
+ const { COLOR, GRADIENT } = CONFIG;
73
+ const val = COLOR[name] || GRADIENT[name];
74
+ const isObj = isObject(val);
75
+ if (isObj && val.value)
76
+ return { [property]: getColor(value, globalTheme) };
77
+ else if (isObj) {
78
+ if (globalTheme)
79
+ return { [property]: getColor(value, `@${globalTheme}`) };
80
+ else {
81
+ const obj = {};
82
+ for (const mediaName in val) {
83
+ const query = CONFIG.MEDIA[mediaName.slice(1)];
84
+ const media = `@media screen and ${query}`;
85
+ obj[media] = { [property]: getColor(value, mediaName) };
86
+ }
87
+ return obj;
88
+ }
89
+ } else {
90
+ if (CONFIG.verbose)
91
+ console.warn("Can't find color", value);
92
+ return { [property]: value };
93
+ }
94
+ };
95
+ const setColor = (val, key, suffix) => {
96
+ const CONFIG = getActiveConfig();
97
+ if (isString(val) && val.slice(0, 2) === "--")
98
+ val = getColor(val.slice(2));
99
+ if (isArray(val)) {
100
+ return {
101
+ "@light": setColor(val[0], key, "light"),
102
+ "@dark": setColor(val[1], key, "dark")
103
+ };
104
+ }
105
+ if (isObject(val)) {
106
+ const obj = {};
107
+ for (const variant in val)
108
+ obj[variant] = setColor(val[variant], key, variant.slice(0, 1) === "@" ? variant.slice(1) : variant);
109
+ return obj;
110
+ }
111
+ const CSSVar = `--color-${key}` + (suffix ? `-${suffix}` : "");
112
+ const [r, g, b, a = 1] = colorStringToRgbaArray(val.value || val);
113
+ const alpha = parseFloat(a.toFixed(2));
114
+ const rgb = `${r}, ${g}, ${b}`;
115
+ const value = `rgba(${rgb}, ${alpha})`;
116
+ if (CONFIG.useVariable) {
117
+ CONFIG.CSS_VARS[CSSVar] = value;
118
+ }
119
+ return {
120
+ var: CSSVar,
121
+ rgb,
122
+ alpha,
123
+ value
124
+ };
125
+ };
126
+ const setGradient = (val, key, suffix) => {
127
+ const CONFIG = getActiveConfig();
128
+ if (isString(val) && val.slice(0, 2) === "--")
129
+ val = getColor(val.slice(2));
130
+ if (isArray(val)) {
131
+ return {
132
+ "@light": setGradient(val[0], key, "light"),
133
+ "@dark": setGradient(val[0], key, "dark")
134
+ };
135
+ }
136
+ if (isObject(val)) {
137
+ const obj = {};
138
+ for (const variant in val)
139
+ obj[variant] = setGradient(val[variant], key, variant.slice(0, 1) === "@" ? variant.slice(1) : variant);
140
+ return obj;
141
+ }
142
+ const CSSVar = `--gradient-${key}` + (suffix ? `-${suffix}` : "");
143
+ if (CONFIG.useVariable) {
144
+ CONFIG.CSS_VARS[CSSVar] = val.value || val;
145
+ }
146
+ return {
147
+ var: CSSVar,
148
+ value: val.value || val
149
+ };
150
+ };
151
+ export {
152
+ getColor,
153
+ getMediaColor,
154
+ setColor,
155
+ setGradient
156
+ };
@@ -0,0 +1,15 @@
1
+ import { getActiveConfig } from "../factory.js";
2
+ import { getDefaultOrFirstKey, merge } from "../utils";
3
+ const applyDocument = () => {
4
+ const CONFIG = getActiveConfig();
5
+ const { DOCUMENT, FONT_FAMILY, THEME, TYPOGRAPHY } = CONFIG;
6
+ return merge(DOCUMENT, {
7
+ theme: THEME.document,
8
+ fontFamily: getDefaultOrFirstKey(FONT_FAMILY),
9
+ fontSize: TYPOGRAPHY.base,
10
+ lineHeight: TYPOGRAPHY.lineHeight
11
+ });
12
+ };
13
+ export {
14
+ applyDocument
15
+ };
@@ -0,0 +1,35 @@
1
+ import { isObject } from "@domql/utils";
2
+ import { getActiveConfig } from "../factory.js";
3
+ import {
4
+ arrayze,
5
+ getDefaultOrFirstKey,
6
+ getFontFaceEach,
7
+ setCustomFontMedia
8
+ } from "../utils";
9
+ const setFont = (val, key) => {
10
+ const CSSvar = `--font-${key}`;
11
+ const fontFace = val[0] ? getFontFaceEach(key, val) : setCustomFontMedia(key, val.url);
12
+ return { var: CSSvar, value: val, fontFace };
13
+ };
14
+ const getFontFamily = (key, factory) => {
15
+ const CONFIG = getActiveConfig();
16
+ const { FONT_FAMILY } = CONFIG;
17
+ return getDefaultOrFirstKey(factory || FONT_FAMILY, key);
18
+ };
19
+ const setFontFamily = (val, key) => {
20
+ const CONFIG = getActiveConfig();
21
+ const { FONT_FAMILY, FONT_FAMILY_TYPES } = CONFIG;
22
+ let { value, type } = val;
23
+ if (val.isDefault)
24
+ FONT_FAMILY.default = key;
25
+ if (isObject(value))
26
+ value = arrayze(value);
27
+ const CSSvar = `--font-family-${key}`;
28
+ const str = `${value.join(", ")}, ${FONT_FAMILY_TYPES[type]}`;
29
+ return { var: CSSvar, value: str, arr: value, type };
30
+ };
31
+ export {
32
+ getFontFamily,
33
+ setFont,
34
+ setFontFamily
35
+ };
@@ -0,0 +1,9 @@
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 "./timing.js";
7
+ export * from "./document.js";
8
+ export * from "./svg.js";
9
+ export * from "./reset.js";
@@ -0,0 +1,63 @@
1
+ import { getActiveConfig } from "../factory.js";
2
+ import { getMediaTheme } from ".";
3
+ import { deepMerge, merge } from "@domql/utils";
4
+ const applyReset = (reset = {}) => {
5
+ const CONFIG = getActiveConfig();
6
+ const { CSS_VARS, RESET, TYPOGRAPHY, DOCUMENT } = CONFIG;
7
+ if (RESET) {
8
+ if (RESET[":root"]) {
9
+ const configReset = RESET;
10
+ const configTemplates = TYPOGRAPHY.templates;
11
+ configReset.body = {
12
+ ...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
+ return deepMerge(merge(RESET, reset), {
24
+ html: {
25
+ position: "absolute",
26
+ overflow: "hidden",
27
+ width: "100%",
28
+ height: "100%",
29
+ top: "0",
30
+ left: "0",
31
+ margin: "0",
32
+ WebkitFontSmoothing: "antialiased",
33
+ transform: "translate3d(0, 0, 1px)",
34
+ scrollBehavior: "smooth",
35
+ fontSize: TYPOGRAPHY.browserDefault + "px",
36
+ fontFamily: DOCUMENT.fontFamily,
37
+ lineHeight: DOCUMENT.lineHeight
38
+ },
39
+ body: {
40
+ boxSizing: "border-box",
41
+ height: "100%",
42
+ margin: 0,
43
+ fontFamily: DOCUMENT.fontFamily,
44
+ fontSize: TYPOGRAPHY.base / TYPOGRAPHY.browserDefault + CONFIG.UNIT.default,
45
+ ...CONFIG.useDocumentTheme ? getMediaTheme("document", `@${CONFIG.globalTheme}`) : {},
46
+ ...templates,
47
+ ...body
48
+ },
49
+ // form elements
50
+ fieldset: {
51
+ border: 0,
52
+ padding: 0,
53
+ margin: 0
54
+ },
55
+ "select, input": {
56
+ fontFamily: DOCUMENT.fontFamily
57
+ }
58
+ });
59
+ }
60
+ };
61
+ export {
62
+ applyReset
63
+ };
@@ -0,0 +1,115 @@
1
+ import { getActiveConfig } from "../factory.js";
2
+ import { isString } from "@domql/utils";
3
+ import {
4
+ applySequenceVars,
5
+ arrayze,
6
+ generateSequence,
7
+ getSequenceValuePropertyPair,
8
+ merge
9
+ } from "../utils";
10
+ const runThroughMedia = (sequenceProps) => {
11
+ for (const prop in sequenceProps) {
12
+ const mediaProps = sequenceProps[prop];
13
+ if (prop.slice(0, 1) === "@") {
14
+ const { type, base, ratio, range, subSequence, h1Matches, unit } = sequenceProps;
15
+ merge(mediaProps, {
16
+ type,
17
+ base,
18
+ ratio,
19
+ range,
20
+ subSequence,
21
+ h1Matches,
22
+ unit,
23
+ sequence: {},
24
+ scales: {},
25
+ templates: {},
26
+ vars: {}
27
+ });
28
+ generateSequence(mediaProps);
29
+ const mediaName = prop.slice(1);
30
+ applySequenceVars(mediaProps, mediaName);
31
+ }
32
+ }
33
+ };
34
+ const applySpacingSequence = () => {
35
+ const CONFIG = getActiveConfig();
36
+ const { SPACING } = CONFIG;
37
+ generateSequence(SPACING);
38
+ applySequenceVars(SPACING);
39
+ runThroughMedia(SPACING);
40
+ };
41
+ const getSequence = (sequenceProps) => {
42
+ const CONFIG = getActiveConfig();
43
+ const { SPACING } = CONFIG;
44
+ if (!sequenceProps)
45
+ return SPACING;
46
+ const hasGenerated = Object.keys(sequenceProps.sequence).length > 0;
47
+ return hasGenerated ? sequenceProps : generateSequence(sequenceProps);
48
+ };
49
+ const getSpacingByKey = (value, propertyName = "padding", sequenceProps) => {
50
+ const sequence = getSequence(sequenceProps);
51
+ const stack = arrayze(value);
52
+ if (!stack)
53
+ return;
54
+ if (isString(value) && value.includes("calc")) {
55
+ return { [propertyName]: value };
56
+ }
57
+ if (stack.length > 1) {
58
+ let suffix = "";
59
+ if (propertyName === "borderWidth") {
60
+ propertyName = "border";
61
+ suffix = "Width";
62
+ }
63
+ const directions = {
64
+ 2: ["Block", "Inline"],
65
+ 3: ["BlockStart", "Inline", "BlockEnd"],
66
+ 4: ["BlockStart", "InlineEnd", "BlockEnd", "InlineStart"]
67
+ };
68
+ const wrapSequenceValueByDirection = (direction, i) => getSequenceValuePropertyPair(
69
+ stack[i],
70
+ propertyName + direction + suffix,
71
+ sequence
72
+ );
73
+ return directions[stack.length].map((dir, key) => wrapSequenceValueByDirection(dir, key));
74
+ }
75
+ return getSequenceValuePropertyPair(
76
+ value,
77
+ propertyName,
78
+ sequence
79
+ );
80
+ };
81
+ const getSpacingBasedOnRatio = (props, propertyName, val) => {
82
+ const CONFIG = getActiveConfig();
83
+ const { SPACING } = CONFIG;
84
+ const { spacingRatio, unit } = props;
85
+ const value = val || props[propertyName];
86
+ if (spacingRatio) {
87
+ let sequenceProps = SPACING[spacingRatio];
88
+ if (!sequenceProps) {
89
+ const { type, base, range, subSequence } = SPACING;
90
+ sequenceProps = SPACING[spacingRatio] = merge({
91
+ ratio: spacingRatio,
92
+ type: type + "-" + spacingRatio,
93
+ unit,
94
+ sequence: {},
95
+ scales: {},
96
+ templates: {},
97
+ vars: {}
98
+ }, {
99
+ base,
100
+ range,
101
+ subSequence,
102
+ ratio: SPACING.ratio,
103
+ unit: SPACING.unit
104
+ });
105
+ }
106
+ applySequenceVars(sequenceProps, null, { useDefault: false });
107
+ return getSpacingByKey(value, propertyName, sequenceProps);
108
+ }
109
+ return getSpacingByKey(value, propertyName);
110
+ };
111
+ export {
112
+ applySpacingSequence,
113
+ getSpacingBasedOnRatio,
114
+ getSpacingByKey
115
+ };