@symbo.ls/scratch 2.11.331 → 2.11.337

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.
@@ -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) === '--') val = getColor(val.slice(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 [r, g, b, a = 1] = colorStringToRgbaArray(val.value || val)
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})`
@@ -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
@@ -29,7 +29,7 @@ export const colorStringToRgbaArray = color => {
29
29
  // color set failed - some monstrous css rule is probably taking over the color of our object
30
30
  if (elem.style.color !== flag) return
31
31
  elem.style.color = color
32
- if (elem.style.color === flag || elem.style.color === '') return // color parse failed
32
+ if (elem.style.color === flag || elem.style.color === '') return [0, 0, 0, 0] // color parse failed
33
33
  color = window.getComputedStyle(elem).color
34
34
  document.body.removeChild(elem)
35
35
  }
@@ -41,8 +41,7 @@ export const colorStringToRgbaArray = color => {
41
41
  return color.match(/[\.\d]+/g).map(a => +a) // eslint-disable-line
42
42
  }
43
43
 
44
- // TODO: fix this
45
- return []
44
+ return [0, 0, 0, 0]
46
45
  }
47
46
 
48
47
  export const mixTwoColors = (colorA, colorB, range = 0.5) => {