@symbo.ls/scratch 0.6.4 → 0.7.1

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.6.4",
5
+ "version": "0.7.1",
6
6
  "files": [
7
7
  "src"
8
8
  ],
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/src/factory.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- import * as CONF from './config'
3
+ import * as CONF from './defaultConfig'
4
4
 
5
5
  export const CSS_VARS = {}
6
6
  export const CONFIG = {
package/src/index.js CHANGED
@@ -3,4 +3,4 @@
3
3
  export * from './factory'
4
4
  export * from './utils'
5
5
  export * from './set'
6
- export * from './config'
6
+ export * from './defaultConfig'
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- import { MEDIA } from '../config'
3
+ import { MEDIA } from '../defaultConfig'
4
4
  import { CONFIG, CSS_VARS } from '../factory' // eslint-disable-line
5
5
 
6
6
  import {
@@ -32,7 +32,7 @@ export const getColor = (value, key) => {
32
32
  let val = (COLOR[name] || GRADIENT[name])
33
33
 
34
34
  if (!val) {
35
- if ((ENV === 'test' || ENV === 'development') && CONFIG.verbose) console.warn('Can\'t find color', name)
35
+ if ((ENV === 'test' || ENV === 'development') && CONFIG.verbose) console.warn('Can\'t find color ', name)
36
36
  return value
37
37
  }
38
38
 
@@ -72,6 +72,8 @@ export const getMediaColor = (value, param) => {
72
72
  return
73
73
  }
74
74
 
75
+ if (value.slice(0, 2) === '--') return { [param]: `var(${value})` }
76
+
75
77
  const [name] = isArray(value) ? value : value.split(' ')
76
78
 
77
79
  const { COLOR, GRADIENT } = CONFIG
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- import { DOCUMENT, FONT_FAMILY, THEME, TYPOGRAPHY } from '../config'
3
+ import { DOCUMENT, FONT_FAMILY, THEME, TYPOGRAPHY } from '../defaultConfig'
4
4
  import { getDefaultOrFirstKey, merge } from '../utils'
5
5
 
6
6
  export const applyDocument = () => merge(DOCUMENT, {
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- import * as CONFIG from '../config'
3
+ import * as CONFIG from '../defaultConfig'
4
4
  import { CSS_VARS } from '../factory'
5
5
  import { getTheme } from '.'
6
6
  import { deepMerge, merge } from '../utils'
@@ -1,13 +1,13 @@
1
1
  'use strict'
2
2
 
3
- import { SPACING } from '../config'
4
- import { applySequenceVars, Arrayize, generateSequence, getSequenceValue, merge } from '../utils'
3
+ import { SPACING } from '../defaultConfig'
4
+ import { applySequenceVars, arrayze, generateSequence, getSequenceValuePropertyPair, merge } from '../utils'
5
5
 
6
- const runThroughMedia = props => {
7
- for (const prop in props) {
8
- const mediaProps = props[prop]
6
+ const runThroughMedia = sequenceProps => {
7
+ for (const prop in sequenceProps) {
8
+ const mediaProps = sequenceProps[prop]
9
9
  if (prop.slice(0, 1) === '@') {
10
- const { type, base, ratio, range, subSequence, h1Matches, unit } = props
10
+ const { type, base, ratio, range, subSequence, h1Matches, unit } = sequenceProps
11
11
 
12
12
  merge(mediaProps, {
13
13
  type,
@@ -37,57 +37,81 @@ export const applySpacingSequence = () => {
37
37
  runThroughMedia(SPACING)
38
38
  }
39
39
 
40
- const getSequence = (props) => {
41
- if (!props) return
42
- const hasGenerated = Object.keys(props.sequence).length > 0
43
- return hasGenerated ? props : generateSequence(props)
40
+ const getSequence = (sequenceProps) => {
41
+ if (!sequenceProps) return SPACING
42
+ const hasGenerated = Object.keys(sequenceProps.sequence).length > 0
43
+ return hasGenerated ? sequenceProps : generateSequence(sequenceProps)
44
44
  }
45
45
 
46
- export const getSpacingByKey = (val, property = 'padding', props, unit) => {
47
- const prefix = '--spacing-'
46
+ export const getSpacingByKey = (
47
+ value,
48
+ propertyName = 'padding',
49
+ sequenceProps
50
+ ) => {
51
+ const sequence = getSequence(sequenceProps)
48
52
 
49
- const generatedSequence = getSequence(props)
50
- const type = (generatedSequence || SPACING).sequence
51
-
52
- const stack = Arrayize(val)
53
+ const stack = arrayze(value)
53
54
  if (!stack) return
54
55
 
55
- const length = stack.length
56
-
57
- const wrapSequenceItem = (prop, i) => getSequenceValue({
58
- type,
59
- prop,
60
- val: stack[i],
61
- prefix,
62
- unit
63
- })
64
-
65
56
  let suffix = ''
66
- if (property === 'borderWidth') {
67
- property = 'border'
57
+ if (propertyName === 'borderWidth') {
58
+ propertyName = 'border'
68
59
  suffix = 'Width'
69
60
  }
70
61
 
71
- if (length === 2) {
72
- return [
73
- wrapSequenceItem(property + 'Block' + suffix, 0),
74
- wrapSequenceItem(property + 'Inline' + suffix, 1)
75
- ]
62
+ const directions = {
63
+ 2: ['Block', 'Inline'],
64
+ 3: ['BlockStart', 'Inline', 'BlockEnd'],
65
+ 4: ['BlockStart', 'InlineEnd', 'BlockEnd', 'InlineStart']
76
66
  }
77
- if (length === 3) {
78
- return [
79
- wrapSequenceItem(property + 'BlockStart' + suffix, 0),
80
- wrapSequenceItem(property + 'Inline' + suffix, 1),
81
- wrapSequenceItem(property + 'BlockEnd' + suffix, 2)
82
- ]
83
- } else if (length === 4) {
84
- return [
85
- wrapSequenceItem(property + 'BlockStart' + suffix, 0),
86
- wrapSequenceItem(property + 'InlineStart' + suffix, 3),
87
- wrapSequenceItem(property + 'BlockEnd' + suffix, 2),
88
- wrapSequenceItem(property + 'InlineEnd' + suffix, 1)
89
- ]
67
+
68
+ const wrapSequenceValueByDirection = (direction, i) => getSequenceValuePropertyPair(
69
+ stack[i],
70
+ propertyName + direction + suffix,
71
+ sequence
72
+ )
73
+
74
+ if (stack.length > 1) {
75
+ return directions[stack.length].map((dir, key) => wrapSequenceValueByDirection(dir, key))
90
76
  }
91
77
 
92
- return getSequenceValue({ type, prop: property, val, prefix, unit })
78
+ return getSequenceValuePropertyPair(
79
+ value,
80
+ propertyName,
81
+ sequence
82
+ )
83
+ }
84
+
85
+ export const getSpacingBasedOnRatio = (props, propertyName, val) => {
86
+ const { spacingRatio, unit } = props
87
+ const value = val || props[propertyName]
88
+
89
+ if (spacingRatio) {
90
+ let sequenceProps = SPACING[spacingRatio]
91
+
92
+ if (!sequenceProps) {
93
+ const { type, base, range, subSequence } = SPACING
94
+
95
+ sequenceProps = SPACING[spacingRatio] = merge({
96
+ ratio: spacingRatio,
97
+ type: type + '-' + spacingRatio,
98
+ unit,
99
+ sequence: {},
100
+ scales: {},
101
+ styles: {},
102
+ vars: {}
103
+ }, {
104
+ base,
105
+ range,
106
+ subSequence,
107
+ ratio: SPACING.ratio,
108
+ unit: SPACING.unit
109
+ })
110
+ }
111
+
112
+ applySequenceVars(sequenceProps, null, { useDefault: false })
113
+
114
+ return getSpacingByKey(value, propertyName, sequenceProps)
115
+ }
116
+ return getSpacingByKey(value, propertyName)
93
117
  }
@@ -10,7 +10,7 @@ import {
10
10
  isArray
11
11
  } from '../utils'
12
12
 
13
- const ENV = process.env.NODE_ENV
13
+ const ENV = process.env.NODE_ENV // eslint-disable-line
14
14
 
15
15
  const setThemeValue = theme => {
16
16
  const value = {}
@@ -53,7 +53,7 @@ export const getTheme = (value, modifier) => {
53
53
  if (state && state[subThemeName]) return getThemeValue(state[subThemeName])
54
54
  } else if (isObject(value)) return setThemeValue(value)
55
55
 
56
- if ((ENV === 'test' || ENV === 'development') && CONFIG.verbose) console.warn('Can\'t find theme', value)
56
+ // if ((ENV === 'test' || ENV === 'development') && CONFIG.verbose) console.warn('Can\'t find theme', value)
57
57
  }
58
58
 
59
59
  const setInverseTheme = (theme, variant, value) => {
@@ -161,8 +161,23 @@ export const setMediaTheme = (val, key, suffix, prefers) => {
161
161
  } else {
162
162
  theme[param] = color
163
163
  }
164
+ theme[`.${param}`] = { [param]: theme[param] }
164
165
  }
165
166
  }
167
+
168
+ if (theme['background'] || theme['color'] || theme['backgroundColor']) {
169
+ theme['.inversed'] = {
170
+ color: theme['background'] || theme['backgroundColor'],
171
+ background: theme['color']
172
+ }
173
+ }
174
+ }
175
+
176
+ if (isString(val) && val.slice(0, 2) === '--') {
177
+ const { THEME } = CONFIG
178
+ const value = THEME[val.slice(2)]
179
+ const getReferenced = getMediaTheme(value)
180
+ return getReferenced
166
181
  }
167
182
 
168
183
  return theme
@@ -185,13 +200,42 @@ const recursiveTheme = val => {
185
200
  return obj
186
201
  }
187
202
 
188
- export const getMediaTheme = (val, key, themeObj) => {
203
+ const findModifierFromArray = (val, modifierArray) => {
204
+ const currentMod = modifierArray.shift()
205
+ if (val[currentMod]) return findModifierFromArray(val[currentMod], modifierArray)
206
+ return val
207
+ }
208
+
209
+ const findModifier = (val, modifier) => {
210
+ // console.log(val)
211
+ // console.log(modifier)
212
+ if (isArray(modifier)) return findModifierFromArray(val, modifier)
213
+ else if (isString(modifier)) return val[modifier]
214
+ else return val
215
+ }
216
+
217
+ const checkForReference = (val, callback) => {
218
+ if (isString(val) && val.slice(0, 2) === '--') return getMediaTheme(val.slice(2))
219
+ return val
220
+ }
221
+
222
+ const checkThemeReference = (val) => checkForReference(val, checkThemeReference) // eslint-disable-line
223
+
224
+ export const getMediaTheme = (val, mod, themeObj) => {
225
+ if (isString(val) && val.slice(0, 2) === '--') val = getMediaTheme(val.slice(2))
226
+
189
227
  if (!val || !isString(val)) {
190
- if ((ENV === 'test' || ENV === 'development') && CONFIG.verbose) console.warn(val, '- type for color is not valid')
228
+ // if ((ENV === 'test' || ENV === 'development') && CONFIG.verbose) console.warn(val, '- type for color is not valid')
191
229
  return
192
230
  }
193
- const [name, modifier] = isArray(val) ? val : val.split(' ')
231
+
232
+ // console.group(val)
233
+ const [name, ...modifier] = isArray(val) ? val : val.split(' ')
194
234
  let value = CONFIG.THEME[name]
195
- if (value && modifier && value[modifier]) value = value[modifier]
235
+ if (value && (modifier || mod)) value = findModifier(value, modifier.length ? modifier : mod)
236
+ // console.log('finalval', value)
237
+ // console.groupEnd(val)
196
238
  return recursiveTheme(value)
197
239
  }
240
+
241
+ window.getMediaTheme = getMediaTheme
@@ -1,10 +1,10 @@
1
1
  'use strict'
2
2
 
3
- import { TIMING } from '../config'
3
+ import { TIMING } from '../defaultConfig'
4
4
  import {
5
5
  applySequenceVars,
6
6
  generateSequence,
7
- getSequenceValue
7
+ getSequenceValuePropertyPair
8
8
  } from '../utils'
9
9
 
10
10
  export const applyTimingSequence = () => {
@@ -12,10 +12,8 @@ export const applyTimingSequence = () => {
12
12
  applySequenceVars(TIMING)
13
13
  }
14
14
 
15
- export const getTimingByKey = val => getSequenceValue({
16
- type: TIMING.sequence,
17
- prop: 'duration',
18
- val,
19
- unit: 'ms',
20
- prefix: '--duration-'
21
- })
15
+ export const getTimingByKey = value => getSequenceValuePropertyPair(
16
+ value,
17
+ 'duration',
18
+ TIMING
19
+ )
@@ -1,12 +1,12 @@
1
1
  'use strict'
2
2
 
3
- import { MEDIA, TYPOGRAPHY } from '../config'
3
+ import { MEDIA, TYPOGRAPHY } from '../defaultConfig'
4
4
  import { CONFIG } from '../factory'
5
5
  import {
6
6
  applySequenceVars,
7
7
  findHeadings,
8
8
  generateSequence,
9
- getSequenceValue,
9
+ getSequenceValuePropertyPair,
10
10
  merge
11
11
  } from '../utils'
12
12
 
@@ -63,10 +63,8 @@ export const applyTypographySequence = () => {
63
63
  runThroughMedia(TYPOGRAPHY)
64
64
  }
65
65
 
66
- export const getFontSizeByKey = val => getSequenceValue({
67
- type: TYPOGRAPHY.sequence,
68
- prop: 'fontSize',
69
- val,
70
- unit: TYPOGRAPHY.unit,
71
- prefix: '--font-size-'
72
- })
66
+ export const getFontSizeByKey = value => getSequenceValuePropertyPair(
67
+ value,
68
+ 'fontSize',
69
+ TYPOGRAPHY
70
+ )
@@ -38,7 +38,7 @@ export const deepMerge = (obj, obj2) => {
38
38
  return obj
39
39
  }
40
40
 
41
- export const Arrayize = val => {
41
+ export const arrayze = val => {
42
42
  const isString = typeof val === 'string'
43
43
  if (isString) return val.split(' ')
44
44
  if (isObject(val)) return Object.keys(val).map(v => val[v])
@@ -1,7 +1,8 @@
1
1
  'use strict'
2
2
 
3
- import { UNIT } from '../config'
3
+ import { UNIT } from '../defaultConfig'
4
4
  import { CONFIG } from '../factory'
5
+ import { isString } from './object'
5
6
 
6
7
  export const numToLetterMap = {
7
8
  '-6': 'U',
@@ -32,8 +33,9 @@ export const numToLetterMap = {
32
33
  19: 'T'
33
34
  }
34
35
 
35
- const setSequenceValue = ({ key, variable, value, scaling, state, index }) => {
36
- state.sequence[key] = {
36
+ const setSequenceValue = (props, sequenceProps) => {
37
+ const { key, variable, value, scaling, index } = props
38
+ sequenceProps.sequence[key] = {
37
39
  key,
38
40
  decimal: Math.round(value * 100) / 100,
39
41
  val: Math.round(value),
@@ -41,68 +43,20 @@ const setSequenceValue = ({ key, variable, value, scaling, state, index }) => {
41
43
  index,
42
44
  variable
43
45
  }
44
- state.scales[key] = scaling
45
- state.vars[variable] = scaling + state.unit
46
+ sequenceProps.scales[key] = scaling
47
+ sequenceProps.vars[variable] = scaling + sequenceProps.unit
46
48
  }
47
49
 
48
- export const getSequenceValue = ({
49
- type,
50
- prop,
51
- val = 'A',
52
- prefix = '--font-size-',
53
- unit = UNIT.default,
54
- useVariable
55
- }) => {
56
- if (typeof val !== 'string') console.warn(prop, val, 'is not a string')
57
-
58
- if (val === '-' || val === '') return ({ })
59
- if (
60
- val === 'none' ||
61
- val === 'auto' ||
62
- val === 'fit-content' ||
63
- val === 'min-content' ||
64
- val === 'max-content'
65
- ) return ({ [prop]: val })
66
-
67
- const startsWithLetterRegex = /^-?[a-zA-Z]/i
68
- const startsWithLetter = startsWithLetterRegex.test(val)
69
- if (!startsWithLetter) return ({ [prop]: val })
70
-
71
- const letterVal = val.toUpperCase()
72
- const isNegative = letterVal.slice(0, 1) === '-' ? '-' : ''
73
- let pureVal = isNegative ? letterVal.slice(1) : letterVal
74
-
75
- let mediaName = ''
76
- if (pureVal.includes('-')) {
77
- mediaName = '-' + pureVal.split('-')[1].toLowerCase()
78
- pureVal = pureVal.split('-')[0]
79
- }
50
+ const dashize = val => val
51
+ .replace(/[A-Z]/g, (match, offset) => (offset > 0 ? '-' : '') + match.toLowerCase())
52
+ .replace('.', '-')
80
53
 
81
- const value = type ? type[pureVal] : null
82
- if (!value) return console.warn('can\'t find', type, pureVal)
54
+ export const generateSubSequence = (props, sequenceProps) => {
55
+ const { key, base, value, ratio, variable, index } = props
83
56
 
84
- if (useVariable || CONFIG.useVariable) {
85
- const varVal = `var(${prefix}${pureVal}${mediaName})`
86
- return isNegative ? {
87
- [prop]: `calc(${varVal} * -1)`
88
- } : {
89
- [prop]: varVal
90
- }
91
- }
92
-
93
- if (unit === 'ms' || unit === 's') {
94
- return ({ [prop]: isNegative + value.val + unit })
95
- }
96
-
97
- return ({
98
- [prop]: isNegative + value.val + value.unit,
99
- [prop]: isNegative + value.scaling + unit
100
- })
101
- }
102
-
103
- export const generateSubSequence = ({ key, base, value, ratio, variable, state, index }) => {
104
57
  const next = value * ratio
105
- const smallscale = (next - value) / ratio
58
+ const diff = next - value
59
+ const smallscale = diff / 1.618
106
60
 
107
61
  const valueRounded = Math.round(value)
108
62
  const nextRounded = Math.round(next)
@@ -112,20 +66,29 @@ export const generateSubSequence = ({ key, base, value, ratio, variable, state,
112
66
  const first = next - smallscale
113
67
  const second = value + smallscale
114
68
  const middle = (first + second) / 2
115
- if (diffRounded > 100) arr = [first, middle, second]
69
+ if (diffRounded > 16) arr = [first, middle, second]
116
70
  else arr = [first, second]
117
71
 
118
72
  arr.map((v, k) => {
119
73
  const scaling = Math.round(v / base * 1000) / 1000
120
74
  const newVar = variable + (k + 1)
121
75
 
122
- return setSequenceValue({ key: key + (k + 1), variable: newVar, value: v, scaling, state, index: index + (k + 1) / 10 })
76
+ const props = {
77
+ key: key + (k + 1),
78
+ variable: newVar,
79
+ value: v,
80
+ scaling,
81
+ index: index + (k + 1) / 10
82
+ }
83
+
84
+ return setSequenceValue(props, sequenceProps)
123
85
  })
124
86
  }
125
87
 
126
- export const generateSequence = ({ type, base, ratio, range, subSequence, ...state }) => {
88
+ export const generateSequence = (sequenceProps) => {
89
+ const { type, base, ratio, range, subSequence } = sequenceProps
127
90
  const n = Math.abs(range[0]) + Math.abs(range[1])
128
- const prefix = '--' + type + '-'
91
+ const prefix = '--' + type.replace('.', '-') + '-'
129
92
 
130
93
  for (let i = 0; i <= n; i++) {
131
94
  const key = range[1] - i
@@ -134,15 +97,84 @@ export const generateSequence = ({ type, base, ratio, range, subSequence, ...sta
134
97
  const scaling = Math.round(value / base * 1000) / 1000
135
98
  const variable = prefix + letterKey
136
99
 
137
- setSequenceValue({ key: letterKey, variable, value, scaling, state, index: key })
100
+ const props = {
101
+ key: letterKey,
102
+ variable,
103
+ value,
104
+ base,
105
+ scaling,
106
+ ratio,
107
+ index: key
108
+ }
109
+
110
+ setSequenceValue(props, sequenceProps)
111
+
112
+ if (subSequence) generateSubSequence(props, sequenceProps)
113
+ }
114
+ return sequenceProps
115
+ }
116
+
117
+ export const getSequenceValue = (value = 'A', sequenceProps) => {
118
+ const {
119
+ sequence,
120
+ unit = UNIT.default,
121
+ useVariable
122
+ } = sequenceProps
123
+
124
+ if (isString(value) && value.slice(0, 2) === '--') {
125
+ return `var(${value})`
126
+ }
127
+
128
+ const prefix = `--${dashize(sequenceProps.type.replace('.', '-'))}-`
129
+
130
+ const startsWithDashOrLetterRegex = /^-?[a-zA-Z]/i
131
+ const startsWithDashOrLetter = startsWithDashOrLetterRegex.test(value)
132
+
133
+ if (
134
+ value === 'none' ||
135
+ value === 'auto' ||
136
+ value === 'fit-content' ||
137
+ value === 'min-content' ||
138
+ value === 'max-content' ||
139
+ !startsWithDashOrLetter
140
+ ) return value
141
+
142
+ const letterVal = value.toUpperCase()
143
+ const isNegative = letterVal.slice(0, 1) === '-' ? '-' : ''
144
+ let absValue = isNegative ? letterVal.slice(1) : letterVal
145
+
146
+ let mediaName = ''
147
+ if (absValue.includes('-')) {
148
+ mediaName = '-' + absValue.split('-')[1].toLowerCase()
149
+ absValue = absValue.split('-')[0]
150
+ }
151
+
152
+ if (useVariable || CONFIG.useVariable) {
153
+ const varValue = `var(${prefix}${absValue}${mediaName})`
154
+ return isNegative ? `calc(${varValue} * -1)` : varValue
155
+ }
156
+
157
+ const sequenceItem = sequence ? sequence[absValue] : null
158
+ if (!sequenceItem) return console.warn('can\'t find', sequence, absValue)
159
+
160
+ if (unit === 'ms' || unit === 's') {
161
+ return isNegative + sequenceItem.value + unit
162
+ }
163
+
164
+ return isNegative + sequenceItem.scaling + unit
165
+ }
138
166
 
139
- if (subSequence) generateSubSequence({ key: letterKey, base, value, ratio, variable, state, index: key })
167
+ export const getSequenceValuePropertyPair = (value, propertyName, sequenceProps) => {
168
+ if (typeof value !== 'string') {
169
+ console.warn(propertyName, value, 'is not a string')
170
+ return ({})
140
171
  }
141
- return state
172
+ if (value === '-' || value === '') return ({})
173
+ return { [propertyName]: getSequenceValue(value, sequenceProps) }
142
174
  }
143
175
 
144
- export const findHeadings = props => {
145
- const { h1Matches, sequence } = props
176
+ export const findHeadings = propertyNames => {
177
+ const { h1Matches, sequence } = propertyNames
146
178
  return new Array(6).fill(null).map((_, i) => {
147
179
  const findLetter = numToLetterMap[h1Matches - i]
148
180
  return sequence[findLetter]
package/src/utils/var.js CHANGED
@@ -1,9 +1,11 @@
1
1
  'use strict'
2
2
 
3
- import { MEDIA } from '../config'
3
+ import { MEDIA } from '../defaultConfig'
4
4
  import { CONFIG, CSS_VARS } from '../factory'
5
5
  import { isObjectLike } from './object'
6
6
 
7
+ const ENV = process.env.NODE_ENV
8
+
7
9
  export const setVariables = (result, key) => {
8
10
  // CSS_VARS[result.var] =
9
11
  if (isObjectLike(result.value)) {
@@ -18,23 +20,30 @@ export const setVariables = (result, key) => {
18
20
  }
19
21
  }
20
22
 
21
- export const applySequenceVars = (props, mediaName) => {
23
+ export const applySequenceVars = (props, mediaName, options = {}) => {
22
24
  const unit = props.unit || CONFIG.UNIT.default
23
25
  const { sequence, scales } = props
24
26
 
25
27
  for (const key in sequence) {
26
28
  const item = sequence[key]
27
29
  const value = (props.type === 'duration' ? sequence[key].val : scales[key]) + unit
28
- const query = MEDIA[mediaName]
29
30
 
30
31
  if (mediaName) {
32
+ const query = MEDIA[mediaName]
33
+ if (!query) {
34
+ if ((ENV === 'test' || ENV === 'development') && CONFIG.verbose) console.warn('Can\'t find query ', query)
35
+ }
31
36
  let underMediaQuery = CSS_VARS[`@media ${query}`]
32
37
  if (!underMediaQuery) underMediaQuery = CSS_VARS[`@media ${query}`] = {}
33
38
  underMediaQuery[item.variable] = `var(${item.variable + '-' + mediaName})`
34
39
  CSS_VARS[item.variable + '-' + mediaName] = value
35
40
  } else {
36
- CSS_VARS[item.variable + '-default'] = value
37
- CSS_VARS[item.variable] = `var(${item.variable + '-default'})`
41
+ if (options.useDefault === false) {
42
+ CSS_VARS[item.variable] = value
43
+ } else {
44
+ CSS_VARS[item.variable + '-default'] = value
45
+ CSS_VARS[item.variable] = `var(${item.variable + '-default'})`
46
+ }
38
47
  }
39
48
  }
40
49
  }