@symbo.ls/scratch 2.11.331 → 2.11.338
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/factory.js +26 -26
- package/dist/cjs/index.js +44 -33
- package/dist/cjs/set.js +44 -33
- package/dist/cjs/system/color.js +44 -33
- package/dist/cjs/system/document.js +26 -26
- package/dist/cjs/system/font.js +26 -26
- package/dist/cjs/system/index.js +44 -33
- package/dist/cjs/system/reset.js +26 -26
- package/dist/cjs/system/shadow.js +35 -31
- package/dist/cjs/system/spacing.js +26 -26
- package/dist/cjs/system/svg.js +26 -26
- package/dist/cjs/system/theme.js +35 -31
- package/dist/cjs/system/timing.js +26 -26
- package/dist/cjs/system/typography.js +26 -26
- package/dist/cjs/transforms/index.js +35 -31
- package/dist/cjs/utils/color.js +35 -31
- package/dist/cjs/utils/index.js +35 -31
- package/dist/cjs/utils/sequence.js +26 -26
- package/dist/cjs/utils/sprite.js +26 -26
- package/dist/cjs/utils/var.js +26 -26
- package/package.json +2 -2
- package/src/system/color.js +13 -2
- package/src/utils/color.js +10 -5
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@symbo.ls/scratch",
|
|
3
3
|
"description": "Φ / CSS framework and methodology.",
|
|
4
4
|
"author": "symbo.ls",
|
|
5
|
-
"version": "2.11.
|
|
5
|
+
"version": "2.11.338",
|
|
6
6
|
"files": [
|
|
7
7
|
"src",
|
|
8
8
|
"dist"
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"@symbo.ls/utils": "latest",
|
|
30
30
|
"color-contrast-checker": "^1.5.0"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "f8b3e371bac70f5de8e4bfe27887819bfbb0bfc9"
|
|
33
33
|
}
|
package/src/system/color.js
CHANGED
|
@@ -87,7 +87,17 @@ export const getMediaColor = (value, globalTheme, config) => {
|
|
|
87
87
|
export const setColor = (val, key, suffix) => {
|
|
88
88
|
const CONFIG = getActiveConfig()
|
|
89
89
|
|
|
90
|
-
if (isString(val) && val.slice(0, 2) === '--')
|
|
90
|
+
if (isString(val) && val.slice(0, 2) === '--') {
|
|
91
|
+
val = getColor(val.slice(2))
|
|
92
|
+
if (!(
|
|
93
|
+
val.includes('rgb') ||
|
|
94
|
+
val.includes('var') ||
|
|
95
|
+
val.includes('#')
|
|
96
|
+
)) {
|
|
97
|
+
if (CONFIG.verbose) console.warn(val, '- referred but does not exist')
|
|
98
|
+
val = val.split(' ')[0]
|
|
99
|
+
}
|
|
100
|
+
}
|
|
91
101
|
|
|
92
102
|
if (isArray(val)) {
|
|
93
103
|
return {
|
|
@@ -109,7 +119,8 @@ export const setColor = (val, key, suffix) => {
|
|
|
109
119
|
}
|
|
110
120
|
|
|
111
121
|
const CSSVar = `--color-${key}` + (suffix ? `-${suffix}` : '')
|
|
112
|
-
const
|
|
122
|
+
const colorArr = colorStringToRgbaArray(val.value || val)
|
|
123
|
+
const [r, g, b, a = 1] = colorArr
|
|
113
124
|
const alpha = parseFloat(a.toFixed(2))
|
|
114
125
|
const rgb = `${r}, ${g}, ${b}`
|
|
115
126
|
const value = `rgba(${rgb}, ${alpha})`
|
package/src/utils/color.js
CHANGED
|
@@ -5,7 +5,7 @@ import { isString, isNumber } from '@domql/utils'
|
|
|
5
5
|
const ENV = process.env.NODE_ENV
|
|
6
6
|
|
|
7
7
|
export const colorStringToRgbaArray = color => {
|
|
8
|
-
if (color === '') return
|
|
8
|
+
if (color === '') return [0, 0, 0, 0]
|
|
9
9
|
if (color.toLowerCase() === 'transparent') return [0, 0, 0, 0]
|
|
10
10
|
|
|
11
11
|
// convert #RGB and #RGBA to #RRGGBB and #RRGGBBAA
|
|
@@ -27,9 +27,15 @@ export const colorStringToRgbaArray = color => {
|
|
|
27
27
|
const flag = 'rgb(1, 2, 3)'
|
|
28
28
|
elem.style.color = flag
|
|
29
29
|
// color set failed - some monstrous css rule is probably taking over the color of our object
|
|
30
|
-
if (elem.style.color !== flag)
|
|
30
|
+
if (elem.style.color !== flag) {
|
|
31
|
+
document.body.removeChild(elem)
|
|
32
|
+
return
|
|
33
|
+
}
|
|
31
34
|
elem.style.color = color
|
|
32
|
-
if (elem.style.color === flag || elem.style.color === '')
|
|
35
|
+
if (elem.style.color === flag || elem.style.color === '') {
|
|
36
|
+
document.body.removeChild(elem)
|
|
37
|
+
return [0, 0, 0, 0] // color parse failed
|
|
38
|
+
}
|
|
33
39
|
color = window.getComputedStyle(elem).color
|
|
34
40
|
document.body.removeChild(elem)
|
|
35
41
|
}
|
|
@@ -41,8 +47,7 @@ export const colorStringToRgbaArray = color => {
|
|
|
41
47
|
return color.match(/[\.\d]+/g).map(a => +a) // eslint-disable-line
|
|
42
48
|
}
|
|
43
49
|
|
|
44
|
-
|
|
45
|
-
return []
|
|
50
|
+
return [0, 0, 0, 0]
|
|
46
51
|
}
|
|
47
52
|
|
|
48
53
|
export const mixTwoColors = (colorA, colorB, range = 0.5) => {
|