@symbo.ls/scratch 0.3.9 → 0.3.12
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 +3 -3
- package/src/config/font-family.js +2 -1
- package/src/methods/set.js +33 -31
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@symbo.ls/scratch",
|
|
3
3
|
"description": "Φ / CSS framework and methodology.",
|
|
4
4
|
"author": "Symbols",
|
|
5
|
-
"version": "0.3.
|
|
5
|
+
"version": "0.3.12",
|
|
6
6
|
"files": [
|
|
7
7
|
"src"
|
|
8
8
|
],
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"bump": "npx np"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@babel/core": "^7.
|
|
23
|
-
"@babel/preset-env": "^7.
|
|
22
|
+
"@babel/core": "^7.0.0-0",
|
|
23
|
+
"@babel/preset-env": "^7.18.9",
|
|
24
24
|
"babel-eslint": "^10.0.3",
|
|
25
25
|
"babel-jest": "^27.0.2",
|
|
26
26
|
"babel-preset-env": "^1.7.0",
|
|
@@ -11,6 +11,7 @@ var defaultFont = { // eslint-disable-line
|
|
|
11
11
|
export const FONT_FAMILY = {}
|
|
12
12
|
export const FONT_FAMILY_TYPES = {
|
|
13
13
|
serif: 'Helvetica, Arial, sans-serif, --system-default',
|
|
14
|
-
'sans-serif': 'Times New Roman, Georgia, serif, --system-default'
|
|
14
|
+
'sans-serif': 'Times New Roman, Georgia, serif, --system-default',
|
|
15
|
+
monospace: 'Courier New, monospace, --system-default'
|
|
15
16
|
}
|
|
16
17
|
export const FONT_FACE = getFontFace(FONT_FAMILY)
|
package/src/methods/set.js
CHANGED
|
@@ -14,39 +14,14 @@ import {
|
|
|
14
14
|
getDefaultOrFirstKey,
|
|
15
15
|
getFontFaceEach,
|
|
16
16
|
hslToRgb,
|
|
17
|
-
getColorShade
|
|
18
|
-
pSBC,
|
|
19
|
-
changeLightness
|
|
17
|
+
getColorShade
|
|
20
18
|
} from '../utils'
|
|
21
19
|
|
|
22
20
|
const ENV = process.env.NODE_ENV
|
|
23
21
|
|
|
24
|
-
const setColor = (val, key) => {
|
|
25
|
-
const [r, g, b, a = 1] = colorStringToRgbaArray(val.value || val)
|
|
26
|
-
const alpha = parseFloat(a.toFixed(2))
|
|
27
|
-
const CSSVar = `--color-${key}`
|
|
28
|
-
const rgb = `${r}, ${g}, ${b}`
|
|
29
|
-
const value = `rgba(${rgb}, ${alpha})`
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
var: CSSVar,
|
|
33
|
-
rgb,
|
|
34
|
-
alpha,
|
|
35
|
-
value
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const setGradient = (val, key) => {
|
|
40
|
-
const CSSVar = `--gradient-${key}`
|
|
41
|
-
return {
|
|
42
|
-
var: CSSVar,
|
|
43
|
-
value: val.value || val
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
22
|
export const getColor = value => {
|
|
48
23
|
if (!isString(value)) {
|
|
49
|
-
if (ENV === 'test' || ENV === 'development') console.warn(value, '- type for color is not valid')
|
|
24
|
+
if ((ENV === 'test' || ENV === 'development') && CONFIG.verbose) console.warn(value, '- type for color is not valid')
|
|
50
25
|
return
|
|
51
26
|
}
|
|
52
27
|
|
|
@@ -55,7 +30,7 @@ export const getColor = value => {
|
|
|
55
30
|
const val = COLOR[name] || GRADIENT[name]
|
|
56
31
|
|
|
57
32
|
if (!val) {
|
|
58
|
-
if (ENV === 'test' || ENV === 'development') console.warn('Can\'t find color', name)
|
|
33
|
+
if ((ENV === 'test' || ENV === 'development') && CONFIG.verbose) console.warn('Can\'t find color', name)
|
|
59
34
|
return value
|
|
60
35
|
}
|
|
61
36
|
|
|
@@ -72,7 +47,7 @@ export const getColor = value => {
|
|
|
72
47
|
} else {
|
|
73
48
|
const [r, g, b] = [...rgb.split(', ').map(v => parseFloat(v))]
|
|
74
49
|
const hsl = rgbToHSL(r, g, b)
|
|
75
|
-
const [h, s, l] = hsl
|
|
50
|
+
const [h, s, l] = hsl // eslint-disable-line
|
|
76
51
|
const newRgb = hslToRgb(h, s, parseFloat(tone) / 100 * 255)
|
|
77
52
|
rgb = newRgb
|
|
78
53
|
}
|
|
@@ -84,6 +59,31 @@ export const getColor = value => {
|
|
|
84
59
|
} else return val.value
|
|
85
60
|
}
|
|
86
61
|
|
|
62
|
+
const setColor = (val, key) => {
|
|
63
|
+
if (val.slice(0, 2) === '--') val = getColor(val.slice(2))
|
|
64
|
+
|
|
65
|
+
const CSSVar = `--color-${key}`
|
|
66
|
+
const [r, g, b, a = 1] = colorStringToRgbaArray(val.value || val)
|
|
67
|
+
const alpha = parseFloat(a.toFixed(2))
|
|
68
|
+
const rgb = `${r}, ${g}, ${b}`
|
|
69
|
+
const value = `rgba(${rgb}, ${alpha})`
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
var: CSSVar,
|
|
73
|
+
rgb,
|
|
74
|
+
alpha,
|
|
75
|
+
value
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const setGradient = (val, key) => {
|
|
80
|
+
const CSSVar = `--gradient-${key}`
|
|
81
|
+
return {
|
|
82
|
+
var: CSSVar,
|
|
83
|
+
value: val.value || val
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
87
|
const setThemeValue = theme => {
|
|
88
88
|
const value = {}
|
|
89
89
|
const { state, variants, helpers, ...rest } = theme
|
|
@@ -115,7 +115,7 @@ export const getTheme = value => {
|
|
|
115
115
|
} else if (isObject(value)) return setThemeValue(value)
|
|
116
116
|
else if (isString(value) && THEME[value]) return getThemeValue(THEME[value])
|
|
117
117
|
|
|
118
|
-
if (ENV === 'test' || ENV === 'development') console.warn('Can\'t find theme', value)
|
|
118
|
+
if ((ENV === 'test' || ENV === 'development') && CONFIG.verbose) console.warn('Can\'t find theme', value)
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
const setPrefersScheme = (theme, key, variant, themeValue) => {
|
|
@@ -252,7 +252,7 @@ export const setEach = (factoryName, props) => {
|
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
export const set = recivedConfig => {
|
|
255
|
-
const { version, ...config } = recivedConfig
|
|
255
|
+
const { version, verbose, ...config } = recivedConfig
|
|
256
256
|
const keys = Object.keys(config)
|
|
257
257
|
keys.map(key => setEach(key, config[key]))
|
|
258
258
|
|
|
@@ -261,6 +261,8 @@ export const set = recivedConfig => {
|
|
|
261
261
|
applySpacingSequence()
|
|
262
262
|
applyDocument()
|
|
263
263
|
|
|
264
|
+
CONFIG.verbose = verbose
|
|
265
|
+
|
|
264
266
|
console.log(CONFIG)
|
|
265
267
|
return CONFIG
|
|
266
268
|
}
|