@symbo.ls/scratch 0.3.9 → 0.3.10

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/methods/set.js +25 -23
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.9",
5
+ "version": "0.3.10",
6
6
  "files": [
7
7
  "src"
8
8
  ],
@@ -21,29 +21,6 @@ import {
21
21
 
22
22
  const ENV = process.env.NODE_ENV
23
23
 
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
24
  export const getColor = value => {
48
25
  if (!isString(value)) {
49
26
  if (ENV === 'test' || ENV === 'development') console.warn(value, '- type for color is not valid')
@@ -84,6 +61,31 @@ export const getColor = value => {
84
61
  } else return val.value
85
62
  }
86
63
 
64
+ const setColor = (val, key) => {
65
+ if (val.slice(0, 2) === '--') val = getColor(val.slice(2))
66
+
67
+ const CSSVar = `--color-${key}`
68
+ const [r, g, b, a = 1] = colorStringToRgbaArray(val.value || val)
69
+ const alpha = parseFloat(a.toFixed(2))
70
+ const rgb = `${r}, ${g}, ${b}`
71
+ const value = `rgba(${rgb}, ${alpha})`
72
+
73
+ return {
74
+ var: CSSVar,
75
+ rgb,
76
+ alpha,
77
+ value
78
+ }
79
+ }
80
+
81
+ const setGradient = (val, key) => {
82
+ const CSSVar = `--gradient-${key}`
83
+ return {
84
+ var: CSSVar,
85
+ value: val.value || val
86
+ }
87
+ }
88
+
87
89
  const setThemeValue = theme => {
88
90
  const value = {}
89
91
  const { state, variants, helpers, ...rest } = theme