@symbo.ls/scratch 0.3.0 → 0.3.3

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 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.0",
5
+ "version": "0.3.3",
6
6
  "files": [
7
7
  "src"
8
8
  ],
@@ -15,6 +15,8 @@ import {
15
15
  getFontFaceEach
16
16
  } from '../utils'
17
17
 
18
+ const ENV = process.env.NODE_ENV
19
+
18
20
  const setColor = (val, key) => {
19
21
  const [r, g, b, a = 1] = colorStringToRgbaArray(val.value || val)
20
22
  const alpha = parseFloat(a.toFixed(2))
@@ -39,14 +41,17 @@ const setGradient = (val, key) => {
39
41
  }
40
42
 
41
43
  export const getColor = value => {
42
- if (!isString(value)) return console.warn(value, '- type for color is not valid')
44
+ if (!isString(value)) {
45
+ if (ENV === 'test' || ENV === 'development') console.warn(value, '- type for color is not valid')
46
+ return
47
+ }
43
48
 
44
49
  const [name, alpha, tone] = isArray(value) ? value : value.split(' ')
45
50
  const { COLOR, GRADIENT } = CONFIG
46
51
  const val = COLOR[name] || GRADIENT[name]
47
52
 
48
53
  if (!val) {
49
- console.warn('Can\'t find color', name)
54
+ if (ENV === 'test' || ENV === 'development') console.warn('Can\'t find color', name)
50
55
  return value
51
56
  }
52
57
 
@@ -97,7 +102,8 @@ export const getTheme = value => {
97
102
  if (state && state[subThemeName]) return getThemeValue(state[subThemeName])
98
103
  } else if (isObject(value)) return setThemeValue(value)
99
104
  else if (isString(value) && THEME[value]) return getThemeValue(THEME[value])
100
- console.warn('Can\'t find theme', value)
105
+
106
+ if (ENV === 'test' || ENV === 'development') console.warn('Can\'t find theme', value)
101
107
  }
102
108
 
103
109
  const setPrefersScheme = (theme, key, variant, themeValue) => {
@@ -196,7 +202,7 @@ const setFontFamily = (val, key) => {
196
202
  return { var: CSSvar, value: str, arr: value, type }
197
203
  }
198
204
 
199
- const setTypography = (val, key) => {
205
+ const setSameValue = (val, key) => {
200
206
  return val
201
207
  }
202
208
 
@@ -206,7 +212,9 @@ export const SETTERS = {
206
212
  font: setFont,
207
213
  font_family: setFontFamily,
208
214
  theme: setTheme,
209
- typography: setTypography
215
+ typography: setSameValue,
216
+ spacing: setSameValue,
217
+ responsive: setSameValue
210
218
  }
211
219
 
212
220
  /**
package/src/reset.js CHANGED
@@ -1,11 +1,11 @@
1
1
  'use strict'
2
2
 
3
3
  import * as CONFIG from './config'
4
- import { merge } from './utils'
4
+ import { deepMerge, merge } from './utils'
5
5
 
6
6
  export const RESET = {}
7
7
 
8
- export const applyReset = () => merge(RESET, {
8
+ export const applyReset = (reset = {}) => deepMerge(merge(RESET, reset), {
9
9
  html: {
10
10
  position: 'absolute',
11
11
  overflow: 'hidden',
@@ -2,6 +2,8 @@
2
2
 
3
3
  import { UNIT } from '../config'
4
4
 
5
+ const ENV = process.env.NODE_ENV
6
+
5
7
  export const isString = arg => typeof arg === 'string'
6
8
 
7
9
  export const isArray = arg => Array.isArray(arg)
@@ -27,6 +29,19 @@ export const merge = (obj, original) => {
27
29
  return obj
28
30
  }
29
31
 
32
+ export const deepMerge = (obj, obj2) => {
33
+ for (const e in obj2) {
34
+ const objProp = obj[e]
35
+ const obj2Prop = obj2[e]
36
+ if (objProp === undefined) {
37
+ obj[e] = obj2Prop
38
+ } else if (isObjectLike(objProp) && isObject(obj2Prop)) {
39
+ deepMerge(objProp, obj2Prop)
40
+ }
41
+ }
42
+ return obj
43
+ }
44
+
30
45
  export const colorStringToRgbaArray = color => {
31
46
  if (color === '') return
32
47
  if (color.toLowerCase() === 'transparent') return [0, 0, 0, 0]
@@ -140,7 +155,10 @@ export const mixTwoRgba = (colorA, colorB, range = 0.5) => {
140
155
 
141
156
  export const opacify = (color, opacity) => {
142
157
  const arr = colorStringToRgbaArray(color)
143
- if (!arr) return console.warn(color + 'color is not rgba')
158
+ if (!arr) {
159
+ if (ENV === 'test' || ENV === 'development') console.warn(color + 'color is not rgba')
160
+ return
161
+ }
144
162
  arr[3] = opacity
145
163
  return `rgba(${arr})`
146
164
  }