@symbo.ls/scratch 0.7.28 → 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.28",
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,7 +2,7 @@
2
2
 
3
3
  import * as CONFIG from '../defaultConfig'
4
4
  import { CSS_VARS } from '../factory'
5
- import { getTheme } from '.'
5
+ import { getMediaTheme } from '.'
6
6
  import { deepMerge, merge, overwriteDeep } from '@domql/utils' // eslint-disable-line no-unused-vars
7
7
 
8
8
  export const applyReset = (reset = {}) => {
@@ -16,7 +16,10 @@ export const applyReset = (reset = {}) => {
16
16
  const configReset = CONFIG.RESET
17
17
  const configStyles = CONFIG.TYPOGRAPHY.styles
18
18
  configReset[':root'] = CSS_VARS
19
- configReset.body = configStyles.body
19
+ configReset.body = {
20
+ ...getMediaTheme('document', CONFIG.globalTheme),
21
+ ...configStyles.body
22
+ }
20
23
  configReset.h1 = configStyles.h1
21
24
  configReset.h2 = configStyles.h2
22
25
  configReset.h3 = configStyles.h3
@@ -54,10 +57,10 @@ export const applyReset = (reset = {}) => {
54
57
  margin: 0,
55
58
  fontFamily: CONFIG.DOCUMENT.fontFamily,
56
59
 
57
- ...getTheme('document'),
58
-
59
60
  fontSize: CONFIG.TYPOGRAPHY.base / CONFIG.TYPOGRAPHY.browserDefault + CONFIG.UNIT.default,
60
61
 
62
+ ...getMediaTheme('document', CONFIG.globalTheme),
63
+
61
64
  ...CONFIG.TYPOGRAPHY.styles.body
62
65
  },
63
66
 
@@ -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