@symbo.ls/scratch 0.3.11 → 0.3.14
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 +3 -3
- package/src/methods/set.js +8 -8
- package/src/utils/index.js +5 -5
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@symbo.ls/scratch",
|
|
3
3
|
"description": "Φ / CSS framework and methodology.",
|
|
4
4
|
"author": "Symbols",
|
|
5
|
-
"version": "0.3.
|
|
5
|
+
"version": "0.3.14",
|
|
6
6
|
"files": [
|
|
7
7
|
"src"
|
|
8
8
|
],
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"bump": "npx np"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@babel/core": "^7.
|
|
23
|
-
"@babel/preset-env": "^7.
|
|
22
|
+
"@babel/core": "^7.0.0-0",
|
|
23
|
+
"@babel/preset-env": "^7.18.9",
|
|
24
24
|
"babel-eslint": "^10.0.3",
|
|
25
25
|
"babel-jest": "^27.0.2",
|
|
26
26
|
"babel-preset-env": "^1.7.0",
|
package/src/methods/set.js
CHANGED
|
@@ -14,16 +14,14 @@ import {
|
|
|
14
14
|
getDefaultOrFirstKey,
|
|
15
15
|
getFontFaceEach,
|
|
16
16
|
hslToRgb,
|
|
17
|
-
getColorShade
|
|
18
|
-
pSBC,
|
|
19
|
-
changeLightness
|
|
17
|
+
getColorShade
|
|
20
18
|
} from '../utils'
|
|
21
19
|
|
|
22
20
|
const ENV = process.env.NODE_ENV
|
|
23
21
|
|
|
24
22
|
export const getColor = value => {
|
|
25
23
|
if (!isString(value)) {
|
|
26
|
-
if (ENV === 'test' || ENV === 'development') console.warn(value, '- type for color is not valid')
|
|
24
|
+
if ((ENV === 'test' || ENV === 'development') && CONFIG.verbose) console.warn(value, '- type for color is not valid')
|
|
27
25
|
return
|
|
28
26
|
}
|
|
29
27
|
|
|
@@ -32,7 +30,7 @@ export const getColor = value => {
|
|
|
32
30
|
const val = COLOR[name] || GRADIENT[name]
|
|
33
31
|
|
|
34
32
|
if (!val) {
|
|
35
|
-
if (ENV === 'test' || ENV === 'development') console.warn('Can\'t find color', name)
|
|
33
|
+
if ((ENV === 'test' || ENV === 'development') && CONFIG.verbose) console.warn('Can\'t find color', name)
|
|
36
34
|
return value
|
|
37
35
|
}
|
|
38
36
|
|
|
@@ -49,7 +47,7 @@ export const getColor = value => {
|
|
|
49
47
|
} else {
|
|
50
48
|
const [r, g, b] = [...rgb.split(', ').map(v => parseFloat(v))]
|
|
51
49
|
const hsl = rgbToHSL(r, g, b)
|
|
52
|
-
const [h, s, l] = hsl
|
|
50
|
+
const [h, s, l] = hsl // eslint-disable-line
|
|
53
51
|
const newRgb = hslToRgb(h, s, parseFloat(tone) / 100 * 255)
|
|
54
52
|
rgb = newRgb
|
|
55
53
|
}
|
|
@@ -117,7 +115,7 @@ export const getTheme = value => {
|
|
|
117
115
|
} else if (isObject(value)) return setThemeValue(value)
|
|
118
116
|
else if (isString(value) && THEME[value]) return getThemeValue(THEME[value])
|
|
119
117
|
|
|
120
|
-
if (ENV === 'test' || ENV === 'development') console.warn('Can\'t find theme', value)
|
|
118
|
+
if ((ENV === 'test' || ENV === 'development') && CONFIG.verbose) console.warn('Can\'t find theme', value)
|
|
121
119
|
}
|
|
122
120
|
|
|
123
121
|
const setPrefersScheme = (theme, key, variant, themeValue) => {
|
|
@@ -254,7 +252,7 @@ export const setEach = (factoryName, props) => {
|
|
|
254
252
|
}
|
|
255
253
|
|
|
256
254
|
export const set = recivedConfig => {
|
|
257
|
-
const { version, ...config } = recivedConfig
|
|
255
|
+
const { version, verbose, ...config } = recivedConfig
|
|
258
256
|
const keys = Object.keys(config)
|
|
259
257
|
keys.map(key => setEach(key, config[key]))
|
|
260
258
|
|
|
@@ -263,6 +261,8 @@ export const set = recivedConfig => {
|
|
|
263
261
|
applySpacingSequence()
|
|
264
262
|
applyDocument()
|
|
265
263
|
|
|
264
|
+
CONFIG.verbose = verbose
|
|
265
|
+
|
|
266
266
|
console.log(CONFIG)
|
|
267
267
|
return CONFIG
|
|
268
268
|
}
|
package/src/utils/index.js
CHANGED
|
@@ -160,7 +160,7 @@ export const changeLightness = (delta, hsl) => {
|
|
|
160
160
|
|
|
161
161
|
export const rgbToHSL = (r, g, b) => {
|
|
162
162
|
const a = Math.max(r, g, b); const n = a - Math.min(r, g, b); const f = (1 - Math.abs(a + a - n - 1))
|
|
163
|
-
const h = n && ((a == r) ? (g - b) / n : ((a == g) ? 2 + (b - r) / n : 4 + (r - g) / n))
|
|
163
|
+
const h = n && ((a == r) ? (g - b) / n : ((a == g) ? 2 + (b - r) / n : 4 + (r - g) / n)) //eslint-disable-line
|
|
164
164
|
return [60 * (h < 0 ? h + 6 : h), f ? n / f : 0, (a + a - n) / 2]
|
|
165
165
|
}
|
|
166
166
|
|
|
@@ -282,7 +282,7 @@ const setSequenceValue = ({ key, variable, value, scaling, state, index }) => {
|
|
|
282
282
|
state.scales[variable] = scaling
|
|
283
283
|
}
|
|
284
284
|
|
|
285
|
-
export const generateSubSequence = ({ key, base, value, ratio, variable, state }) => {
|
|
285
|
+
export const generateSubSequence = ({ key, base, value, ratio, variable, state, index }) => {
|
|
286
286
|
const next = value * ratio
|
|
287
287
|
const smallscale = (next - value) / ratio
|
|
288
288
|
|
|
@@ -303,7 +303,7 @@ export const generateSubSequence = ({ key, base, value, ratio, variable, state }
|
|
|
303
303
|
const scaling = Math.round(v / base * 1000) / 1000
|
|
304
304
|
const newVar = variable + (k + 1)
|
|
305
305
|
|
|
306
|
-
return setSequenceValue({ key: key + (k + 1), variable: newVar, value: v, scaling, state })
|
|
306
|
+
return setSequenceValue({ key: key + (k + 1), variable: newVar, value: v, scaling, state, index: index + (k + 1) / 10 })
|
|
307
307
|
})
|
|
308
308
|
}
|
|
309
309
|
|
|
@@ -319,7 +319,7 @@ export const generateSequence = ({ type, base, ratio, range, subSequence, ...sta
|
|
|
319
319
|
|
|
320
320
|
setSequenceValue({ key: letterKey, variable, value, scaling, state, index: key })
|
|
321
321
|
|
|
322
|
-
if (subSequence) generateSubSequence({ key: letterKey, base, value, ratio, variable, state })
|
|
322
|
+
if (subSequence) generateSubSequence({ key: letterKey, base, value, ratio, variable, state, index: key })
|
|
323
323
|
}
|
|
324
324
|
return state
|
|
325
325
|
}
|
|
@@ -328,7 +328,7 @@ export const fallBack = ({ type, prop, val = 'A', prefix = '--font-size-', unit
|
|
|
328
328
|
if (typeof val !== 'string') console.warn(prop, val, 'is not a string')
|
|
329
329
|
|
|
330
330
|
if (val === '-' || val === '') return ({ })
|
|
331
|
-
if (val === 'auto' || val === 'fit-content' || val === 'min-content' || val === 'max-content') return ({ [prop]: val })
|
|
331
|
+
if (val === 'none' || val === 'auto' || val === 'fit-content' || val === 'min-content' || val === 'max-content') return ({ [prop]: val })
|
|
332
332
|
|
|
333
333
|
// const startsWithLetterRegex = /^[a-zA-Z]/i
|
|
334
334
|
const startsWithLetterRegex = /^-?[a-zA-Z]/i
|