@symbo.ls/scratch 0.7.35 → 0.7.37
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 +1 -1
- package/src/defaultConfig/index.js +0 -2
- package/src/factory.js +22 -1
- package/src/set.js +12 -2
- package/src/system/color.js +13 -10
- package/src/system/document.js +11 -7
- package/src/system/font.js +10 -5
- package/src/system/reset.js +17 -15
- package/src/system/spacing.js +17 -2
- package/src/system/theme.js +9 -2
- package/src/system/timing.js +18 -7
- package/src/system/typography.js +18 -7
- package/src/utils/font.js +3 -5
- package/src/utils/sequence.js +5 -3
- package/src/utils/var.js +8 -4
package/package.json
CHANGED
package/src/factory.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
import { deepClone, isDefined } from '@domql/utils'
|
|
3
4
|
import * as CONF from './defaultConfig'
|
|
4
5
|
|
|
5
6
|
export const CSS_VARS = {}
|
|
@@ -7,6 +8,26 @@ export const CONFIG = {
|
|
|
7
8
|
verbose: false,
|
|
8
9
|
useVariable: true,
|
|
9
10
|
useReset: true,
|
|
10
|
-
|
|
11
|
+
CSS_VARS,
|
|
11
12
|
...CONF
|
|
12
13
|
}
|
|
14
|
+
|
|
15
|
+
const cachedConfig = deepClone(CONFIG)
|
|
16
|
+
|
|
17
|
+
export const FACTORY = {
|
|
18
|
+
active: '0',
|
|
19
|
+
0: CONFIG
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const activateConfig = (def) => {
|
|
23
|
+
if (isDefined(def)) { FACTORY.active = def }
|
|
24
|
+
return FACTORY[def || FACTORY.active]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const getActiveConfig = (def) => {
|
|
28
|
+
if (isDefined(def) && !FACTORY[def]) {
|
|
29
|
+
FACTORY[def] = deepClone(cachedConfig)
|
|
30
|
+
return FACTORY[def]
|
|
31
|
+
}
|
|
32
|
+
return FACTORY[def || FACTORY.active]
|
|
33
|
+
}
|
package/src/set.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { FACTORY, getActiveConfig } from './factory' // eslint-disable-line no-unused-vars
|
|
4
4
|
import {
|
|
5
5
|
setColor,
|
|
6
6
|
setGradient,
|
|
@@ -50,6 +50,7 @@ export const SETTERS = {
|
|
|
50
50
|
* @returns {Object} Factory
|
|
51
51
|
*/
|
|
52
52
|
export const setValue = (FACTORY_NAME, value, key) => {
|
|
53
|
+
const CONFIG = getActiveConfig()
|
|
53
54
|
const factoryName = FACTORY_NAME.toLowerCase()
|
|
54
55
|
const FACTORY = CONFIG[FACTORY_NAME]
|
|
55
56
|
|
|
@@ -62,6 +63,7 @@ export const setValue = (FACTORY_NAME, value, key) => {
|
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
export const setEach = (factoryName, props) => {
|
|
66
|
+
const CONFIG = getActiveConfig()
|
|
65
67
|
const FACTORY_NAME = factoryName.toUpperCase()
|
|
66
68
|
const keys = Object.keys(props)
|
|
67
69
|
keys.map(key => setValue(FACTORY_NAME, props[key], key))
|
|
@@ -69,9 +71,17 @@ export const setEach = (factoryName, props) => {
|
|
|
69
71
|
return CONFIG[FACTORY_NAME]
|
|
70
72
|
}
|
|
71
73
|
|
|
72
|
-
|
|
74
|
+
const SET_OPTIONS = {}
|
|
75
|
+
|
|
76
|
+
export const set = (recivedConfig, options = SET_OPTIONS) => {
|
|
77
|
+
let CONFIG = getActiveConfig()
|
|
73
78
|
const { version, verbose, useVariable, useReset, globalTheme, ...config } = recivedConfig
|
|
74
79
|
|
|
80
|
+
if (options.newConfig) {
|
|
81
|
+
FACTORY['active'] = options.newConfig
|
|
82
|
+
CONFIG = getActiveConfig(options.newConfig)
|
|
83
|
+
}
|
|
84
|
+
|
|
75
85
|
if (verbose !== undefined) CONFIG.verbose = verbose
|
|
76
86
|
if (useVariable !== undefined) CONFIG.useVariable = useVariable
|
|
77
87
|
if (useReset !== undefined) CONFIG.useReset = useReset
|
package/src/system/color.js
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { getActiveConfig } from '../factory'
|
|
4
|
+
import { isObject, isArray, isString } from '@domql/utils'
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
|
-
isArray,
|
|
8
7
|
colorStringToRgbaArray,
|
|
9
|
-
isString,
|
|
10
8
|
rgbToHSL,
|
|
11
9
|
hexToRgbArray,
|
|
12
10
|
rgbArrayToHex,
|
|
13
11
|
hslToRgb,
|
|
14
|
-
getColorShade
|
|
15
|
-
isObject
|
|
12
|
+
getColorShade
|
|
16
13
|
} from '../utils'
|
|
17
14
|
|
|
18
15
|
export const getColor = (value, key) => {
|
|
16
|
+
const CONFIG = getActiveConfig()
|
|
19
17
|
if (!isString(value)) {
|
|
20
18
|
if (CONFIG.verbose) console.warn(value, '- type for color is not valid')
|
|
21
19
|
return
|
|
@@ -64,7 +62,9 @@ export const getColor = (value, key) => {
|
|
|
64
62
|
} else return CONFIG.useVariable ? `var(${val.var})` : val.value
|
|
65
63
|
}
|
|
66
64
|
|
|
67
|
-
export const getMediaColor = (value, property, globalTheme
|
|
65
|
+
export const getMediaColor = (value, property, globalTheme) => {
|
|
66
|
+
const CONFIG = getActiveConfig()
|
|
67
|
+
if (!globalTheme) 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
|
|
@@ -84,7 +84,7 @@ export const getMediaColor = (value, property, globalTheme = CONFIG.globalTheme)
|
|
|
84
84
|
else {
|
|
85
85
|
const obj = {}
|
|
86
86
|
for (const mediaName in val) {
|
|
87
|
-
const query = MEDIA[mediaName.slice(1)]
|
|
87
|
+
const query = CONFIG.MEDIA[mediaName.slice(1)]
|
|
88
88
|
const media = `@media screen and ${query}`
|
|
89
89
|
obj[media] = { [property]: getColor(value, mediaName) }
|
|
90
90
|
}
|
|
@@ -97,6 +97,8 @@ export const getMediaColor = (value, property, globalTheme = CONFIG.globalTheme)
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
export const setColor = (val, key, suffix) => {
|
|
100
|
+
const CONFIG = getActiveConfig()
|
|
101
|
+
|
|
100
102
|
if (isString(val) && val.slice(0, 2) === '--') val = getColor(val.slice(2))
|
|
101
103
|
|
|
102
104
|
if (isArray(val)) {
|
|
@@ -118,7 +120,7 @@ export const setColor = (val, key, suffix) => {
|
|
|
118
120
|
const rgb = `${r}, ${g}, ${b}`
|
|
119
121
|
const value = `rgba(${rgb}, ${alpha})`
|
|
120
122
|
|
|
121
|
-
if (CONFIG.useVariable) { CSS_VARS[CSSVar] = value }
|
|
123
|
+
if (CONFIG.useVariable) { CONFIG.CSS_VARS[CSSVar] = value }
|
|
122
124
|
|
|
123
125
|
return {
|
|
124
126
|
var: CSSVar,
|
|
@@ -129,6 +131,7 @@ export const setColor = (val, key, suffix) => {
|
|
|
129
131
|
}
|
|
130
132
|
|
|
131
133
|
export const setGradient = (val, key, suffix) => {
|
|
134
|
+
const CONFIG = getActiveConfig()
|
|
132
135
|
if (isString(val) && val.slice(0, 2) === '--') val = getColor(val.slice(2))
|
|
133
136
|
|
|
134
137
|
if (isArray(val)) {
|
|
@@ -147,7 +150,7 @@ export const setGradient = (val, key, suffix) => {
|
|
|
147
150
|
const CSSVar = `--gradient-${key}` + (suffix ? `-${suffix}` : '')
|
|
148
151
|
|
|
149
152
|
if (CONFIG.useVariable) {
|
|
150
|
-
CSS_VARS[CSSVar] = val.value || val
|
|
153
|
+
CONFIG.CSS_VARS[CSSVar] = val.value || val
|
|
151
154
|
}
|
|
152
155
|
|
|
153
156
|
return {
|
package/src/system/document.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { getActiveConfig } from '../factory'
|
|
4
4
|
import { getDefaultOrFirstKey, merge } from '../utils'
|
|
5
5
|
|
|
6
|
-
export const applyDocument = () =>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
export const applyDocument = () => {
|
|
7
|
+
const CONFIG = getActiveConfig()
|
|
8
|
+
const { DOCUMENT, FONT_FAMILY, THEME, TYPOGRAPHY } = CONFIG
|
|
9
|
+
return merge(DOCUMENT, {
|
|
10
|
+
theme: THEME.document,
|
|
11
|
+
fontFamily: getDefaultOrFirstKey(FONT_FAMILY),
|
|
12
|
+
fontSize: TYPOGRAPHY.base,
|
|
13
|
+
lineHeight: TYPOGRAPHY.lineHeight
|
|
14
|
+
})
|
|
15
|
+
}
|
package/src/system/font.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
import { isObject } from '@domql/utils'
|
|
4
|
-
import {
|
|
4
|
+
import { getActiveConfig } from '../factory'
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
|
+
arrayze,
|
|
7
8
|
getDefaultOrFirstKey,
|
|
8
9
|
getFontFaceEach,
|
|
9
10
|
setCustomFontMedia
|
|
@@ -13,22 +14,26 @@ import {
|
|
|
13
14
|
|
|
14
15
|
export const setFont = (val, key) => {
|
|
15
16
|
const CSSvar = `--font-${key}`
|
|
16
|
-
const fontFace =
|
|
17
|
-
?
|
|
18
|
-
:
|
|
17
|
+
const fontFace = val[0]
|
|
18
|
+
? getFontFaceEach(key, val)
|
|
19
|
+
: setCustomFontMedia(key, val.url)
|
|
19
20
|
return { var: CSSvar, value: val, fontFace }
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
export const getFontFamily = (key, factory) => {
|
|
24
|
+
const CONFIG = getActiveConfig()
|
|
23
25
|
const { FONT_FAMILY } = CONFIG
|
|
24
26
|
return getDefaultOrFirstKey(factory || FONT_FAMILY, key)
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
export const setFontFamily = (val, key) => {
|
|
30
|
+
const CONFIG = getActiveConfig()
|
|
28
31
|
const { FONT_FAMILY, FONT_FAMILY_TYPES } = CONFIG
|
|
29
|
-
|
|
32
|
+
let { value, type } = val
|
|
30
33
|
if (val.isDefault) FONT_FAMILY.default = key
|
|
31
34
|
|
|
35
|
+
if (isObject(value)) value = arrayze(value)
|
|
36
|
+
|
|
32
37
|
const CSSvar = `--font-family-${key}`
|
|
33
38
|
const str = `${value.join(', ')}, ${FONT_FAMILY_TYPES[type]}`
|
|
34
39
|
return { var: CSSvar, value: str, arr: value, type }
|
package/src/system/reset.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { getActiveConfig } from '../factory'
|
|
4
4
|
import { getMediaTheme } from '.'
|
|
5
|
-
import { deepMerge, merge
|
|
5
|
+
import { deepMerge, merge } from '@domql/utils' // eslint-disable-line no-unused-vars
|
|
6
6
|
|
|
7
7
|
export const applyReset = (reset = {}) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const CONFIG = getActiveConfig()
|
|
9
|
+
const { CSS_VARS, RESET, TYPOGRAPHY, DOCUMENT } = CONFIG
|
|
10
|
+
if (RESET) {
|
|
11
|
+
if (RESET[':root']) {
|
|
12
|
+
const configReset = RESET
|
|
13
|
+
const configStyles = TYPOGRAPHY.styles
|
|
12
14
|
|
|
13
15
|
configReset[':root'] = CSS_VARS
|
|
14
16
|
configReset.body = {
|
|
@@ -23,7 +25,7 @@ export const applyReset = (reset = {}) => {
|
|
|
23
25
|
configReset.h6 = configStyles.h6
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
return deepMerge(merge(
|
|
28
|
+
return deepMerge(merge(RESET, reset), {
|
|
27
29
|
':root': CSS_VARS,
|
|
28
30
|
|
|
29
31
|
html: {
|
|
@@ -38,25 +40,25 @@ export const applyReset = (reset = {}) => {
|
|
|
38
40
|
transform: 'translate3d(0, 0, 1px)',
|
|
39
41
|
scrollBehavior: 'smooth',
|
|
40
42
|
|
|
41
|
-
fontSize:
|
|
43
|
+
fontSize: TYPOGRAPHY.browserDefault + 'px',
|
|
42
44
|
|
|
43
|
-
fontFamily:
|
|
44
|
-
lineHeight:
|
|
45
|
+
fontFamily: DOCUMENT.fontFamily,
|
|
46
|
+
lineHeight: DOCUMENT.lineHeight
|
|
45
47
|
},
|
|
46
48
|
|
|
47
|
-
...
|
|
49
|
+
...TYPOGRAPHY.styles,
|
|
48
50
|
|
|
49
51
|
body: {
|
|
50
52
|
boxSizing: 'border-box',
|
|
51
53
|
height: '100%',
|
|
52
54
|
margin: 0,
|
|
53
|
-
fontFamily:
|
|
55
|
+
fontFamily: DOCUMENT.fontFamily,
|
|
54
56
|
|
|
55
|
-
fontSize:
|
|
57
|
+
fontSize: TYPOGRAPHY.base / TYPOGRAPHY.browserDefault + CONFIG.UNIT.default,
|
|
56
58
|
|
|
57
59
|
...getMediaTheme('document', `@${CONFIG.globalTheme}`),
|
|
58
60
|
|
|
59
|
-
...
|
|
61
|
+
...TYPOGRAPHY.styles.body
|
|
60
62
|
},
|
|
61
63
|
|
|
62
64
|
// form elements
|
|
@@ -67,7 +69,7 @@ export const applyReset = (reset = {}) => {
|
|
|
67
69
|
},
|
|
68
70
|
|
|
69
71
|
'select, input': {
|
|
70
|
-
fontFamily:
|
|
72
|
+
fontFamily: DOCUMENT.fontFamily
|
|
71
73
|
}
|
|
72
74
|
})
|
|
73
75
|
}
|
package/src/system/spacing.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { getActiveConfig } from '../factory'
|
|
4
|
+
|
|
5
|
+
import { isString } from '@domql/utils'
|
|
6
|
+
import {
|
|
7
|
+
applySequenceVars,
|
|
8
|
+
arrayze,
|
|
9
|
+
generateSequence,
|
|
10
|
+
getSequenceValuePropertyPair,
|
|
11
|
+
merge
|
|
12
|
+
} from '../utils'
|
|
5
13
|
|
|
6
14
|
const runThroughMedia = sequenceProps => {
|
|
7
15
|
for (const prop in sequenceProps) {
|
|
@@ -32,12 +40,16 @@ const runThroughMedia = sequenceProps => {
|
|
|
32
40
|
}
|
|
33
41
|
|
|
34
42
|
export const applySpacingSequence = () => {
|
|
43
|
+
const CONFIG = getActiveConfig()
|
|
44
|
+
const { SPACING } = CONFIG
|
|
35
45
|
generateSequence(SPACING)
|
|
36
46
|
applySequenceVars(SPACING)
|
|
37
47
|
runThroughMedia(SPACING)
|
|
38
48
|
}
|
|
39
49
|
|
|
40
50
|
const getSequence = (sequenceProps) => {
|
|
51
|
+
const CONFIG = getActiveConfig()
|
|
52
|
+
const { SPACING } = CONFIG
|
|
41
53
|
if (!sequenceProps) return SPACING
|
|
42
54
|
const hasGenerated = Object.keys(sequenceProps.sequence).length > 0
|
|
43
55
|
return hasGenerated ? sequenceProps : generateSequence(sequenceProps)
|
|
@@ -87,6 +99,9 @@ export const getSpacingByKey = (
|
|
|
87
99
|
}
|
|
88
100
|
|
|
89
101
|
export const getSpacingBasedOnRatio = (props, propertyName, val) => {
|
|
102
|
+
const CONFIG = getActiveConfig()
|
|
103
|
+
const { SPACING } = CONFIG
|
|
104
|
+
|
|
90
105
|
const { spacingRatio, unit } = props
|
|
91
106
|
const value = val || props[propertyName]
|
|
92
107
|
|
package/src/system/theme.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
import { getColor } from './color'
|
|
4
|
-
import {
|
|
4
|
+
import { getActiveConfig } from '../factory'
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
isObject,
|
|
8
8
|
isString,
|
|
9
9
|
isObjectLike,
|
|
10
10
|
isArray
|
|
11
|
-
} from '
|
|
11
|
+
} from '@domql/utils'
|
|
12
12
|
|
|
13
13
|
const ENV = process.env.NODE_ENV // eslint-disable-line
|
|
14
14
|
|
|
@@ -31,6 +31,7 @@ const getThemeValue = theme => {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export const getTheme = (value, modifier) => {
|
|
34
|
+
const CONFIG = getActiveConfig()
|
|
34
35
|
if (CONFIG.useVariable) return getMediaTheme(value, modifier)
|
|
35
36
|
const { THEME } = CONFIG
|
|
36
37
|
|
|
@@ -106,6 +107,7 @@ const setMedia = (theme, value) => {
|
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
const setHelpers = (theme, value) => {
|
|
110
|
+
const CONFIG = getActiveConfig()
|
|
109
111
|
const { helpers } = theme
|
|
110
112
|
if (!helpers) return
|
|
111
113
|
const keys = Object.keys(helpers)
|
|
@@ -119,6 +121,7 @@ const setHelpers = (theme, value) => {
|
|
|
119
121
|
}
|
|
120
122
|
|
|
121
123
|
export const setTheme = (val, key) => {
|
|
124
|
+
const CONFIG = getActiveConfig()
|
|
122
125
|
if (CONFIG.useVariable) return setMediaTheme(val, key)
|
|
123
126
|
|
|
124
127
|
const { state, media, helpers } = val
|
|
@@ -139,6 +142,8 @@ const keySetters = { // eslint-disable-line
|
|
|
139
142
|
}
|
|
140
143
|
|
|
141
144
|
export const setMediaTheme = (val, key, suffix, prefers) => {
|
|
145
|
+
const CONFIG = getActiveConfig()
|
|
146
|
+
const { CSS_VARS } = CONFIG
|
|
142
147
|
const theme = { value: val }
|
|
143
148
|
|
|
144
149
|
if (isObject(val)) {
|
|
@@ -182,6 +187,7 @@ export const setMediaTheme = (val, key, suffix, prefers) => {
|
|
|
182
187
|
}
|
|
183
188
|
|
|
184
189
|
const recursiveTheme = val => {
|
|
190
|
+
const CONFIG = getActiveConfig()
|
|
185
191
|
const obj = {}
|
|
186
192
|
for (const param in val) {
|
|
187
193
|
const symb = param.slice(0, 1)
|
|
@@ -218,6 +224,7 @@ const checkForReference = (val, callback) => {
|
|
|
218
224
|
const checkThemeReference = (val) => checkForReference(val, checkThemeReference) // eslint-disable-line
|
|
219
225
|
|
|
220
226
|
export const getMediaTheme = (val, mod) => {
|
|
227
|
+
const CONFIG = getActiveConfig()
|
|
221
228
|
if (isString(val) && val.slice(0, 2) === '--') val = getMediaTheme(val.slice(2))
|
|
222
229
|
|
|
223
230
|
if (!val || !isString(val)) {
|
package/src/system/timing.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { toCamelCase } from '@symbo.ls/utils'
|
|
4
|
+
import { getActiveConfig } from '../factory'
|
|
4
5
|
import {
|
|
5
6
|
applySequenceVars,
|
|
6
7
|
generateSequence,
|
|
@@ -8,14 +9,24 @@ import {
|
|
|
8
9
|
} from '../utils'
|
|
9
10
|
|
|
10
11
|
export const applyTimingSequence = () => {
|
|
12
|
+
const CONFIG = getActiveConfig()
|
|
13
|
+
const { TIMING } = CONFIG
|
|
11
14
|
generateSequence(TIMING)
|
|
12
15
|
applySequenceVars(TIMING)
|
|
13
16
|
}
|
|
14
17
|
|
|
15
|
-
export const getTimingFunction = value =>
|
|
18
|
+
export const getTimingFunction = value => {
|
|
19
|
+
const CONFIG = getActiveConfig()
|
|
20
|
+
const { TIMING } = CONFIG
|
|
21
|
+
return TIMING[value] || TIMING[toCamelCase(value)] || value
|
|
22
|
+
}
|
|
16
23
|
|
|
17
|
-
export const getTimingByKey = (value, property = 'timing') =>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
export const getTimingByKey = (value, property = 'timing') => {
|
|
25
|
+
const CONFIG = getActiveConfig()
|
|
26
|
+
const { TIMING } = CONFIG
|
|
27
|
+
return getSequenceValuePropertyPair(
|
|
28
|
+
value,
|
|
29
|
+
property,
|
|
30
|
+
TIMING
|
|
31
|
+
)
|
|
32
|
+
}
|
package/src/system/typography.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { getActiveConfig } from '../factory'
|
|
4
|
+
|
|
5
5
|
import {
|
|
6
6
|
applySequenceVars,
|
|
7
7
|
findHeadings,
|
|
@@ -11,6 +11,9 @@ import {
|
|
|
11
11
|
} from '../utils'
|
|
12
12
|
|
|
13
13
|
export const runThroughMedia = props => {
|
|
14
|
+
const CONFIG = getActiveConfig()
|
|
15
|
+
const { TYPOGRAPHY, MEDIA } = CONFIG
|
|
16
|
+
|
|
14
17
|
for (const prop in props) {
|
|
15
18
|
const mediaProps = props[prop]
|
|
16
19
|
if (prop.slice(0, 1) === '@') {
|
|
@@ -44,6 +47,7 @@ export const runThroughMedia = props => {
|
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
export const applyHeadings = (props) => {
|
|
50
|
+
const CONFIG = getActiveConfig()
|
|
47
51
|
if (props.h1Matches) {
|
|
48
52
|
const unit = props.unit
|
|
49
53
|
const HEADINGS = findHeadings(props)
|
|
@@ -63,14 +67,21 @@ export const applyHeadings = (props) => {
|
|
|
63
67
|
}
|
|
64
68
|
|
|
65
69
|
export const applyTypographySequence = () => {
|
|
70
|
+
const CONFIG = getActiveConfig()
|
|
71
|
+
const { TYPOGRAPHY } = CONFIG
|
|
72
|
+
|
|
66
73
|
generateSequence(TYPOGRAPHY)
|
|
67
74
|
applyHeadings(TYPOGRAPHY)
|
|
68
75
|
applySequenceVars(TYPOGRAPHY)
|
|
69
76
|
runThroughMedia(TYPOGRAPHY)
|
|
70
77
|
}
|
|
71
78
|
|
|
72
|
-
export const getFontSizeByKey = value =>
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
79
|
+
export const getFontSizeByKey = value => {
|
|
80
|
+
const CONFIG = getActiveConfig()
|
|
81
|
+
const { TYPOGRAPHY } = CONFIG
|
|
82
|
+
return getSequenceValuePropertyPair(
|
|
83
|
+
value,
|
|
84
|
+
'fontSize',
|
|
85
|
+
TYPOGRAPHY
|
|
86
|
+
)
|
|
87
|
+
}
|
package/src/utils/font.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { isObject } from '@domql/utils'
|
|
4
|
-
|
|
5
3
|
export const getDefaultOrFirstKey = (LIBRARY, key) => {
|
|
6
4
|
if (LIBRARY[key]) return LIBRARY[key].value
|
|
7
5
|
if (LIBRARY.default) return LIBRARY[LIBRARY.default].value
|
|
@@ -38,9 +36,9 @@ export const getFontFace = LIBRARY => {
|
|
|
38
36
|
}
|
|
39
37
|
|
|
40
38
|
export const getFontFaceEachString = (name, weights) => {
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
-
return
|
|
39
|
+
const isArr = weights[0]
|
|
40
|
+
if (isArr) return getFontFaceEach(name, weights).map(setInCustomFontMedia)
|
|
41
|
+
return setCustomFontMedia(name, weights.url)
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
export const getFontFaceString = LIBRARY => {
|
package/src/utils/sequence.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
import { getActiveConfig } from '../factory'
|
|
4
|
+
import { isString } from '@domql/utils'
|
|
3
5
|
import { toDashCase } from '@symbo.ls/utils'
|
|
4
|
-
import { UNIT } from '../defaultConfig'
|
|
5
|
-
import { CONFIG } from '../factory'
|
|
6
|
-
import { isString } from './object'
|
|
7
6
|
|
|
8
7
|
export const numToLetterMap = {
|
|
9
8
|
'-6': 'U',
|
|
@@ -126,6 +125,9 @@ export const generateSequence = (sequenceProps) => {
|
|
|
126
125
|
}
|
|
127
126
|
|
|
128
127
|
export const getSequenceValue = (value = 'A', sequenceProps) => {
|
|
128
|
+
const CONFIG = getActiveConfig()
|
|
129
|
+
const { UNIT } = CONFIG
|
|
130
|
+
|
|
129
131
|
const {
|
|
130
132
|
sequence,
|
|
131
133
|
unit = UNIT.default,
|
package/src/utils/var.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { isObjectLike } from './object'
|
|
3
|
+
import { getActiveConfig } from '../factory'
|
|
4
|
+
import { isObjectLike } from '@domql/utils'
|
|
6
5
|
|
|
7
6
|
const ENV = process.env.NODE_ENV // eslint-disable-line
|
|
8
7
|
|
|
9
8
|
export const setVariables = (result, key) => {
|
|
9
|
+
const CONFIG = getActiveConfig()
|
|
10
|
+
const { CSS_VARS } = CONFIG
|
|
10
11
|
// CSS_VARS[result.var] =
|
|
11
12
|
if (isObjectLike(result.value)) {
|
|
12
13
|
// console.group(key)
|
|
@@ -21,7 +22,10 @@ export const setVariables = (result, key) => {
|
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
export const applySequenceVars = (props, mediaName, options = {}) => {
|
|
24
|
-
const
|
|
25
|
+
const CONFIG = getActiveConfig()
|
|
26
|
+
const { UNIT, MEDIA, TIMING, CSS_VARS } = CONFIG
|
|
27
|
+
|
|
28
|
+
const unit = props.unit || UNIT.default
|
|
25
29
|
const { sequence, scales } = props
|
|
26
30
|
|
|
27
31
|
for (const key in sequence) {
|