@symbo.ls/init 2.6.8 → 2.6.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/index.js +32 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/init",
3
- "version": "2.6.8",
3
+ "version": "2.6.10",
4
4
  "license": "MIT",
5
5
  "gitHead": "54fa6500c697604b3f48ba33a573545d7bff35fa",
6
6
  "source": "src/index.js",
package/src/index.js CHANGED
@@ -9,38 +9,58 @@ import {
9
9
  import { isObject, deepMerge } from '@domql/utils'
10
10
  import { initDOMQLEmotion } from 'domql/packages/emotion'
11
11
 
12
- import { emotion } from '@symbo.ls/create-emotion'
12
+ import { emotion as defaultEmotion } from '@symbo.ls/create-emotion'
13
13
  // import { setClassname } from 'css-in-props'
14
14
 
15
15
  import DYNAMIC_JSON from './dynamic.json'
16
16
 
17
17
  const CONFIG = getActiveConfig()
18
18
 
19
- const prepareInit = (config = {}, RC_FILE) => {
20
- // const defaultConfig = merge(config, CONFIG_DEFAULT)
19
+ const prepareInit = (config = CONFIG, RC_FILE) => {
21
20
  const rcfile = isObject(RC_FILE) ? RC_FILE : DYNAMIC_JSON || {}
22
21
  return deepMerge(config, rcfile)
23
22
  }
24
23
 
25
- export const init = (config, RC_FILE, options = { emotion, initDOMQLDefine: true }) => {
24
+ const SET_OPTIONS = {
25
+ emotion: defaultEmotion,
26
+ useVariable: true,
27
+ useReset: true,
28
+ initDOMQLDefine: true
29
+ }
30
+
31
+ export const init = (config, RC_FILE, options = SET_OPTIONS) => {
26
32
  if (options.initDOMQLDefine) initDOMQLEmotion(options.emotion, options)
27
33
 
28
- const resultConfig = prepareInit(config)
34
+ const resultConfig = prepareInit(config, RC_FILE)
35
+ const emotion = options.emotion || defaultEmotion
36
+
37
+ const conf = set({
38
+ verbose: false,
39
+ useReset: options.useReset,
40
+ ...resultConfig
41
+ }, { newConfig: options.newConfig })
29
42
 
30
- const conf = set({ verbose: false, ...resultConfig }, { newConfig: options.newConfig })
31
43
  const FontFace = getFontFaceString(conf.FONT)
32
44
 
33
- options.emotion.injectGlobal(FontFace)
34
- if (conf.useReset) options.emotion.injectGlobal(conf.RESET)
45
+ emotion.injectGlobal(FontFace)
46
+ if (options.useVariable) emotion.injectGlobal({ ':root': conf.CSS_VARS })
47
+ if (options.useReset) emotion.injectGlobal(conf.RESET)
35
48
 
36
49
  return conf
37
50
  }
38
51
 
39
- export const updateReset = (options = { emotion }) => {
40
- const CONFIG = getActiveConfig()
41
- options.emotion.injectGlobal(CONFIG.RESET)
52
+ export const updateReset = (config, RC_FILE, options = { emotion: defaultEmotion }) => {
53
+ const resultConfig = prepareInit(config, RC_FILE)
54
+ // console.log(resultConfig)
55
+ const conf = set({
56
+ verbose: false,
57
+ ...resultConfig
58
+ })
59
+ console.log(conf.CSS_VARS)
60
+ options.emotion.injectGlobal({ ':root': conf.CSS_VARS })
61
+ options.emotion.injectGlobal(conf.RESET)
42
62
  }
43
63
 
44
- export const setClass = (props, options = { emotion }) => {}// setClassname(props, options.emotion.css)
64
+ export const setClass = (props, options = { emotion: defaultEmotion }) => {}// setClassname(props, options.emotion.css)
45
65
 
46
66
  export { CONFIG }