@symbo.ls/scratch 0.7.27 → 0.7.29

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": "symbo.ls",
5
- "version": "0.7.27",
5
+ "version": "0.7.29",
6
6
  "files": [
7
7
  "src"
8
8
  ],
package/src/set.js CHANGED
@@ -52,17 +52,13 @@ export const SETTERS = {
52
52
  export const setValue = (FACTORY_NAME, value, key) => {
53
53
  const factoryName = FACTORY_NAME.toLowerCase()
54
54
  const FACTORY = CONFIG[FACTORY_NAME]
55
- const result = SETTERS[factoryName](value, key)
56
55
 
57
- // console.log(CONFIG.verbose)
58
- if (CONFIG.verbose && FACTORY[key]) {
59
- // console.warn('Replacing ', key, ' as ', FACTORY[key], ' in ', factoryName)
56
+ if (SETTERS[factoryName]) {
57
+ const result = SETTERS[factoryName](value, key)
58
+ FACTORY[key] = result
59
+ return FACTORY
60
60
  }
61
-
62
- FACTORY[key] = result
63
- // setVariables(result, key)
64
-
65
- return FACTORY
61
+ if (CONFIG.verbose) console.warn('Can not find', factoryName, 'method in scratch')
66
62
  }
67
63
 
68
64
  export const setEach = (factoryName, props) => {
@@ -74,11 +70,12 @@ export const setEach = (factoryName, props) => {
74
70
  }
75
71
 
76
72
  export const set = recivedConfig => {
77
- const { version, verbose, useVariable, useReset, ...config } = recivedConfig
73
+ const { version, verbose, useVariable, useReset, globalTheme, ...config } = recivedConfig
78
74
 
79
75
  if (verbose !== undefined) CONFIG.verbose = verbose
80
76
  if (useVariable !== undefined) CONFIG.useVariable = useVariable
81
77
  if (useReset !== undefined) CONFIG.useReset = useReset
78
+ if (globalTheme !== undefined) CONFIG.globalTheme = globalTheme
82
79
  if (CONFIG.verbose) console.log(CONFIG)
83
80
 
84
81
  const keys = Object.keys(config)
@@ -64,13 +64,13 @@ export const getColor = (value, key) => {
64
64
  } else return CONFIG.useVariable ? `var(${val.var})` : val.value
65
65
  }
66
66
 
67
- export const getMediaColor = (value, param) => {
67
+ export const getMediaColor = (value, property, globalTheme = CONFIG.globalTheme) => {
68
68
  if (!isString(value)) {
69
69
  if (CONFIG.verbose) console.warn(value, '- type for color is not valid')
70
70
  return
71
71
  }
72
72
 
73
- if (value.slice(0, 2) === '--') return { [param]: `var(${value})` }
73
+ if (value.slice(0, 2) === '--') return { [property]: `var(${value})` }
74
74
 
75
75
  const [name] = isArray(value) ? value : value.split(' ')
76
76
 
@@ -78,18 +78,18 @@ export const getMediaColor = (value, param) => {
78
78
  const val = COLOR[name] || GRADIENT[name]
79
79
 
80
80
  const isObj = isObject(val)
81
- if (isObj && val.value) return { [param]: getColor(value) }
81
+ if (isObj && val.value) return { [property]: getColor(value, globalTheme) }
82
82
  else if (isObj) {
83
83
  const obj = {}
84
84
  for (const mediaName in val) {
85
- const query = MEDIA[mediaName.slice(1)]
85
+ const query = MEDIA[globalTheme || mediaName.slice(1)]
86
86
  const media = `@media screen and ${query}`
87
- obj[media] = { [param]: getColor(value, mediaName) }
87
+ obj[media] = { [property]: getColor(value, globalTheme || mediaName) }
88
88
  }
89
89
  return obj
90
90
  } else {
91
91
  if (CONFIG.verbose) console.warn('Can\'t find color', value)
92
- return { [param]: value }
92
+ return { [property]: value }
93
93
  }
94
94
  }
95
95
 
@@ -2,55 +2,78 @@
2
2
 
3
3
  import * as CONFIG from '../defaultConfig'
4
4
  import { CSS_VARS } from '../factory'
5
- import { getTheme } from '.'
6
- import { deepMerge, merge } from '../utils'
5
+ import { getMediaTheme } from '.'
6
+ import { deepMerge, merge, overwriteDeep } from '@domql/utils' // eslint-disable-line no-unused-vars
7
7
 
8
8
  export const applyReset = (reset = {}) => {
9
- return deepMerge(merge(CONFIG.RESET, reset), {
10
- ':root': CSS_VARS,
11
-
12
- html: {
13
- position: 'absolute',
14
- overflow: 'hidden',
15
- width: '100%',
16
- height: '100%',
17
- top: '0',
18
- left: '0',
19
- margin: '0',
20
- WebkitFontSmoothing: 'antialiased',
21
- transform: 'translate3d(0, 0, 1px)',
22
- scrollBehavior: 'smooth',
23
-
24
- fontSize: CONFIG.TYPOGRAPHY.browserDefault + 'px',
25
-
26
- fontFamily: CONFIG.DOCUMENT.fontFamily,
27
- lineHeight: CONFIG.DOCUMENT.lineHeight
28
- },
29
-
30
- ...CONFIG.TYPOGRAPHY.styles,
31
-
32
- body: {
33
- boxSizing: 'border-box',
34
- height: '100%',
35
- margin: 0,
36
- fontFamily: CONFIG.DOCUMENT.fontFamily,
37
-
38
- ...getTheme('document'),
39
-
40
- fontSize: CONFIG.TYPOGRAPHY.base / CONFIG.TYPOGRAPHY.browserDefault + CONFIG.UNIT.default,
41
-
42
- ...CONFIG.TYPOGRAPHY.styles.body
43
- },
44
-
45
- // form elements
46
- fieldset: {
47
- border: 0,
48
- padding: 0,
49
- margin: 0
50
- },
51
-
52
- 'select, input': {
53
- fontFamily: CONFIG.DOCUMENT.fontFamily
9
+ if (CONFIG.RESET) {
10
+ // if (CONFIG.RESET[':root']) {
11
+ // overwriteDeep(CONFIG.TYPOGRAPHY.styles, CONFIG.RESET)
12
+ // console.log(CONFIG.RESET)
13
+ // CONFIG.RESET[':root'] = CSS_VARS
14
+ // }
15
+ if (CONFIG.RESET[':root']) {
16
+ const configReset = CONFIG.RESET
17
+ const configStyles = CONFIG.TYPOGRAPHY.styles
18
+ configReset[':root'] = CSS_VARS
19
+ configReset.body = {
20
+ ...getMediaTheme('document', CONFIG.globalTheme),
21
+ ...configStyles.body
22
+ }
23
+ configReset.h1 = configStyles.h1
24
+ configReset.h2 = configStyles.h2
25
+ configReset.h3 = configStyles.h3
26
+ configReset.h4 = configStyles.h4
27
+ configReset.h5 = configStyles.h5
28
+ configReset.h6 = configStyles.h6
54
29
  }
55
- })
30
+
31
+ return deepMerge(merge(CONFIG.RESET, reset), {
32
+ ':root': CSS_VARS,
33
+
34
+ html: {
35
+ position: 'absolute',
36
+ overflow: 'hidden',
37
+ width: '100%',
38
+ height: '100%',
39
+ top: '0',
40
+ left: '0',
41
+ margin: '0',
42
+ WebkitFontSmoothing: 'antialiased',
43
+ transform: 'translate3d(0, 0, 1px)',
44
+ scrollBehavior: 'smooth',
45
+
46
+ fontSize: CONFIG.TYPOGRAPHY.browserDefault + 'px',
47
+
48
+ fontFamily: CONFIG.DOCUMENT.fontFamily,
49
+ lineHeight: CONFIG.DOCUMENT.lineHeight
50
+ },
51
+
52
+ ...CONFIG.TYPOGRAPHY.styles,
53
+
54
+ body: {
55
+ boxSizing: 'border-box',
56
+ height: '100%',
57
+ margin: 0,
58
+ fontFamily: CONFIG.DOCUMENT.fontFamily,
59
+
60
+ fontSize: CONFIG.TYPOGRAPHY.base / CONFIG.TYPOGRAPHY.browserDefault + CONFIG.UNIT.default,
61
+
62
+ ...getMediaTheme('document', CONFIG.globalTheme),
63
+
64
+ ...CONFIG.TYPOGRAPHY.styles.body
65
+ },
66
+
67
+ // form elements
68
+ fieldset: {
69
+ border: 0,
70
+ padding: 0,
71
+ margin: 0
72
+ },
73
+
74
+ 'select, input': {
75
+ fontFamily: CONFIG.DOCUMENT.fontFamily
76
+ }
77
+ })
78
+ }
56
79
  }
@@ -205,8 +205,6 @@ const findModifierFromArray = (val, modifierArray) => {
205
205
  }
206
206
 
207
207
  const findModifier = (val, modifier) => {
208
- // console.log(val)
209
- // console.log(modifier)
210
208
  if (isArray(modifier)) return findModifierFromArray(val, modifier)
211
209
  else if (isString(modifier) && val[modifier]) return val[modifier]
212
210
  else return val
@@ -229,7 +227,9 @@ export const getMediaTheme = (val, mod) => {
229
227
 
230
228
  const [name, ...modifier] = isArray(val) ? val : val.split(' ')
231
229
  let value = CONFIG.THEME[name]
232
- if (value && (modifier || mod)) value = findModifier(value, modifier.length ? modifier : mod)
230
+ if (value && (modifier || mod)) {
231
+ value = findModifier(value, modifier.length ? modifier : mod)
232
+ }
233
233
  return recursiveTheme(value)
234
234
  }
235
235