@symbo.ls/scratch 2.10.161 → 2.10.163
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/package.json +5 -5
- package/dist/esm/defaultConfig/animation.js +0 -4
- package/dist/esm/defaultConfig/cases.js +0 -4
- package/dist/esm/defaultConfig/color.js +0 -12
- package/dist/esm/defaultConfig/document.js +0 -4
- package/dist/esm/defaultConfig/font-family.js +0 -19
- package/dist/esm/defaultConfig/font.js +0 -13
- package/dist/esm/defaultConfig/icons.js +0 -4
- package/dist/esm/defaultConfig/index.js +0 -20
- package/dist/esm/defaultConfig/media.js +0 -19
- package/dist/esm/defaultConfig/responsive.js +0 -28
- package/dist/esm/defaultConfig/sequence.js +0 -29
- package/dist/esm/defaultConfig/spacing.js +0 -16
- package/dist/esm/defaultConfig/svg.js +0 -6
- package/dist/esm/defaultConfig/theme.js +0 -16
- package/dist/esm/defaultConfig/timing.js +0 -16
- package/dist/esm/defaultConfig/typography.js +0 -19
- package/dist/esm/defaultConfig/unit.js +0 -6
- package/dist/esm/factory.js +0 -39
- package/dist/esm/index.js +0 -4
- package/dist/esm/set.js +0 -113
- package/dist/esm/system/color.js +0 -156
- package/dist/esm/system/document.js +0 -15
- package/dist/esm/system/font.js +0 -35
- package/dist/esm/system/index.js +0 -9
- package/dist/esm/system/reset.js +0 -63
- package/dist/esm/system/spacing.js +0 -115
- package/dist/esm/system/svg.js +0 -61
- package/dist/esm/system/theme.js +0 -240
- package/dist/esm/system/timing.js +0 -32
- package/dist/esm/system/typography.js +0 -80
- package/dist/esm/tests/index.js +0 -8
- package/dist/esm/utils/color.js +0 -143
- package/dist/esm/utils/font.js +0 -50
- package/dist/esm/utils/index.js +0 -6
- package/dist/esm/utils/object.js +0 -53
- package/dist/esm/utils/sequence.js +0 -179
- package/dist/esm/utils/sprite.js +0 -43
- package/dist/esm/utils/theme.js +0 -12
- package/dist/esm/utils/var.js +0 -44
package/package.json
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
"name": "@symbo.ls/scratch",
|
|
3
3
|
"description": "Φ / CSS framework and methodology.",
|
|
4
4
|
"author": "symbo.ls",
|
|
5
|
-
"version": "2.10.
|
|
5
|
+
"version": "2.10.163",
|
|
6
6
|
"files": [
|
|
7
7
|
"src",
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
10
|
"repository": "https://github.com/symbo-ls/scratch",
|
|
11
11
|
"type": "module",
|
|
12
|
-
"module": "
|
|
12
|
+
"module": "index.js",
|
|
13
13
|
"unpkg": "dist/iife/index.js",
|
|
14
14
|
"jsdelivr": "dist/iife/index.js",
|
|
15
|
-
"main": "
|
|
15
|
+
"main": "index.js",
|
|
16
16
|
"exports": "./dist/cjs/index.js",
|
|
17
17
|
"source": "src/index.js",
|
|
18
18
|
"publishConfig": {},
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"build:esm": "npx esbuild ./src/*.js ./src/**/*.js --target=es2020 --format=esm --outdir=dist/esm",
|
|
22
22
|
"build:cjs": "npx esbuild ./src/*.js ./src/**/*.js --target=node16 --format=cjs --outdir=dist/cjs",
|
|
23
23
|
"build:iife": "npx esbuild ./src/index.js --target=es2020 --format=iife --outdir=dist/iife --bundle --minify",
|
|
24
|
-
"build": "yarn build:
|
|
24
|
+
"build": "yarn build:cjs",
|
|
25
25
|
"prepublish": "rimraf -I dist && yarn build && yarn copy:package:cjs"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"> 1%",
|
|
37
37
|
"ie >= 9"
|
|
38
38
|
],
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "9b654d48bb8ba26e3b1b7095b5ed7b813b61e1e0"
|
|
40
40
|
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { getFontFace } from "../utils";
|
|
2
|
-
var defaultFont = {
|
|
3
|
-
// eslint-disable-line
|
|
4
|
-
name: "",
|
|
5
|
-
family: "",
|
|
6
|
-
type: ""
|
|
7
|
-
};
|
|
8
|
-
const FONT_FAMILY = {};
|
|
9
|
-
const FONT_FAMILY_TYPES = {
|
|
10
|
-
"sans-serif": "Helvetica, Arial, sans-serif, --system-default",
|
|
11
|
-
serif: "Times New Roman, Georgia, serif, --system-default",
|
|
12
|
-
monospace: "Courier New, monospace, --system-default"
|
|
13
|
-
};
|
|
14
|
-
const FONT_FACE = getFontFace(FONT_FAMILY);
|
|
15
|
-
export {
|
|
16
|
-
FONT_FACE,
|
|
17
|
-
FONT_FAMILY,
|
|
18
|
-
FONT_FAMILY_TYPES
|
|
19
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
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 "./icons.js";
|
|
11
|
-
export * from "./timing.js";
|
|
12
|
-
export * from "./document.js";
|
|
13
|
-
export * from "./responsive.js";
|
|
14
|
-
export * from "./cases.js";
|
|
15
|
-
export * from "./animation.js";
|
|
16
|
-
export * from "./svg.js";
|
|
17
|
-
const RESET = {};
|
|
18
|
-
export {
|
|
19
|
-
RESET
|
|
20
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const MEDIA = {
|
|
2
|
-
tv: "(min-width: 2780px)",
|
|
3
|
-
screenL: "(max-width: 1920px)",
|
|
4
|
-
screenM: "(max-width: 1680px)",
|
|
5
|
-
screenS: "(max-width: 1440px)",
|
|
6
|
-
tabletL: "(max-width: 1366px)",
|
|
7
|
-
tabletM: "(max-width: 1280px)",
|
|
8
|
-
tabletS: "(max-width: 1024px)",
|
|
9
|
-
mobileL: "(max-width: 768px)",
|
|
10
|
-
mobileM: "(max-width: 560px)",
|
|
11
|
-
mobileS: "(max-width: 480px)",
|
|
12
|
-
mobileXS: "(max-width: 375px)",
|
|
13
|
-
light: "(prefers-color-scheme: light)",
|
|
14
|
-
dark: "(prefers-color-scheme: dark)",
|
|
15
|
-
print: "print"
|
|
16
|
-
};
|
|
17
|
-
export {
|
|
18
|
-
MEDIA
|
|
19
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
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
|
-
screenL: [1920, 1024],
|
|
15
|
-
screenM: [1680, 1024],
|
|
16
|
-
screenS: [1440, 978],
|
|
17
|
-
tabletL: [1366, 926],
|
|
18
|
-
tabletM: [1280, 768],
|
|
19
|
-
tabletS: [1024, 768],
|
|
20
|
-
mobileL: [768, 375],
|
|
21
|
-
mobileM: [560, 768],
|
|
22
|
-
mobileS: [480, 768],
|
|
23
|
-
mobileXS: [375, 768]
|
|
24
|
-
};
|
|
25
|
-
export {
|
|
26
|
-
BREAKPOINTS,
|
|
27
|
-
DEVICES
|
|
28
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -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,16 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,19 +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
|
-
unit: "em",
|
|
11
|
-
templates: {},
|
|
12
|
-
sequence: {},
|
|
13
|
-
scales: {},
|
|
14
|
-
vars: {}
|
|
15
|
-
};
|
|
16
|
-
const TYPOGRAPHY = defaultProps;
|
|
17
|
-
export {
|
|
18
|
-
TYPOGRAPHY
|
|
19
|
-
};
|
package/dist/esm/factory.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
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
|
-
};
|
package/dist/esm/index.js
DELETED
package/dist/esm/set.js
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
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
|
-
};
|
package/dist/esm/system/color.js
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
};
|
package/dist/esm/system/font.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
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
|
-
};
|
package/dist/esm/system/index.js
DELETED
|
@@ -1,9 +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 "./timing.js";
|
|
7
|
-
export * from "./document.js";
|
|
8
|
-
export * from "./svg.js";
|
|
9
|
-
export * from "./reset.js";
|