@symbo.ls/scratch 2.11.5 → 2.11.17
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/dist/cjs/factory.js +73 -68
- package/dist/cjs/index.js +123 -105
- package/dist/cjs/set.js +118 -100
- package/dist/cjs/system/color.js +106 -103
- package/dist/cjs/system/document.js +77 -72
- package/dist/cjs/system/font.js +77 -72
- package/dist/cjs/system/index.js +124 -106
- package/dist/cjs/system/reset.js +78 -73
- package/dist/cjs/system/spacing.js +77 -72
- package/dist/cjs/system/svg.js +93 -73
- package/dist/cjs/system/theme.js +101 -98
- package/dist/cjs/system/timing.js +77 -72
- package/dist/cjs/system/typography.js +77 -72
- package/dist/cjs/transforms/index.js +106 -103
- package/dist/cjs/utils/index.js +93 -73
- package/dist/cjs/utils/sequence.js +73 -68
- package/dist/cjs/utils/sprite.js +93 -73
- package/dist/cjs/utils/var.js +73 -68
- package/package.json +2 -2
- package/src/system/color.js +26 -28
- package/src/system/reset.js +1 -1
- package/src/utils/sprite.js +21 -2
package/src/system/color.js
CHANGED
|
@@ -12,8 +12,8 @@ import {
|
|
|
12
12
|
getColorShade
|
|
13
13
|
} from '../utils'
|
|
14
14
|
|
|
15
|
-
export const getColor = (value, key) => {
|
|
16
|
-
const CONFIG = getActiveConfig()
|
|
15
|
+
export const getColor = (value, key, config) => {
|
|
16
|
+
const CONFIG = config || getActiveConfig()
|
|
17
17
|
if (!isString(value)) {
|
|
18
18
|
if (CONFIG.verbose) console.warn(value, '- type for color is not valid')
|
|
19
19
|
return
|
|
@@ -41,33 +41,31 @@ export const getColor = (value, key) => {
|
|
|
41
41
|
// if (alpha) return `rgba(var(${val[shade || ''].var}), ${modifier})`
|
|
42
42
|
|
|
43
43
|
let rgb = val.rgb
|
|
44
|
-
if (rgb) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
rgb = newRgb
|
|
59
|
-
}
|
|
60
|
-
val[tone] = { rgb, var: `${val.var}-${tone}` }
|
|
61
|
-
} else rgb = val[tone].rgb
|
|
44
|
+
if (!rgb) return CONFIG.useVariable ? `var(${val.var})` : val.value
|
|
45
|
+
if (tone && !val[tone]) {
|
|
46
|
+
const toHex = rgbArrayToHex(rgb.split(', ').map(v => parseFloat(v)))
|
|
47
|
+
const abs = tone.slice(0, 1)
|
|
48
|
+
if (abs === '-' || abs === '+') {
|
|
49
|
+
rgb = hexToRgbArray(
|
|
50
|
+
getColorShade(toHex, parseFloat(tone))
|
|
51
|
+
).join(', ')
|
|
52
|
+
} else {
|
|
53
|
+
const [r, g, b] = [...rgb.split(', ').map(v => parseInt(v))]
|
|
54
|
+
const hsl = rgbToHSL(r, g, b)
|
|
55
|
+
const [h, s, l] = hsl // eslint-disable-line
|
|
56
|
+
const newRgb = hslToRgb(h, s, parseFloat(tone) / 100 * 255)
|
|
57
|
+
rgb = newRgb
|
|
62
58
|
}
|
|
59
|
+
val[tone] = { rgb, var: `${val.var}-${tone}` }
|
|
60
|
+
}
|
|
61
|
+
if (val[tone]) rgb = val[tone].rgb
|
|
63
62
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
} else return CONFIG.useVariable ? `var(${val.var})` : val.value
|
|
63
|
+
if (alpha) return `rgba(${rgb}, ${alpha})`
|
|
64
|
+
return CONFIG.useVariable ? `var(${val.var})` : `rgb(${rgb})`
|
|
67
65
|
}
|
|
68
66
|
|
|
69
|
-
export const getMediaColor = (value, globalTheme) => {
|
|
70
|
-
const CONFIG = getActiveConfig()
|
|
67
|
+
export const getMediaColor = (value, globalTheme, config) => {
|
|
68
|
+
const CONFIG = config || getActiveConfig()
|
|
71
69
|
if (!globalTheme) globalTheme = CONFIG.globalTheme
|
|
72
70
|
if (!isString(value)) {
|
|
73
71
|
if (CONFIG.verbose) console.warn(value, '- type for color is not valid')
|
|
@@ -82,15 +80,15 @@ export const getMediaColor = (value, globalTheme) => {
|
|
|
82
80
|
const val = COLOR[name] || GRADIENT[name]
|
|
83
81
|
const isObj = isObject(val)
|
|
84
82
|
|
|
85
|
-
if (isObj && val.value) return getColor(value, `@${globalTheme}
|
|
83
|
+
if (isObj && val.value) return getColor(value, `@${globalTheme}`, config)
|
|
86
84
|
else if (isObj) {
|
|
87
|
-
if (globalTheme) return getColor(value, `@${globalTheme}
|
|
85
|
+
if (globalTheme) return getColor(value, `@${globalTheme}`, config)
|
|
88
86
|
else {
|
|
89
87
|
const obj = {}
|
|
90
88
|
for (const mediaName in val) {
|
|
91
89
|
const query = CONFIG.MEDIA[mediaName.slice(1)]
|
|
92
90
|
const media = `@media screen and ${query}`
|
|
93
|
-
obj[media] = getColor(value, mediaName)
|
|
91
|
+
obj[media] = getColor(value, mediaName, config)
|
|
94
92
|
}
|
|
95
93
|
return obj
|
|
96
94
|
}
|
package/src/system/reset.js
CHANGED
package/src/utils/sprite.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { isString } from '@domql/utils'
|
|
3
|
+
import { isArray, isString } from '@domql/utils'
|
|
4
4
|
import { getActiveConfig } from '../factory'
|
|
5
5
|
|
|
6
6
|
export const generateSprite = (icons) => {
|
|
@@ -36,16 +36,35 @@ const parseRootAttributes = (htmlString) => {
|
|
|
36
36
|
}, {})
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
const replaceIdsAndUrls = (code, key) => {
|
|
40
|
+
const idRegex = /id="([^"]*)"/
|
|
41
|
+
const urlRegex = /url\(#([^)]*)\)/g
|
|
42
|
+
const matches = code.match(/id="([^"]*)"/g)
|
|
43
|
+
let replacedCode = code
|
|
44
|
+
if (isArray(matches)) {
|
|
45
|
+
matches.forEach(() => {
|
|
46
|
+
const randomKey = Math.floor(Math.random() * 100000)
|
|
47
|
+
replacedCode = code.replace(idRegex, `id="${key}-${randomKey}"`).replace(urlRegex, `url(#${key}-${randomKey})`)
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
return replacedCode
|
|
51
|
+
}
|
|
52
|
+
|
|
39
53
|
export const convertSvgToSymbol = (key, code) => {
|
|
40
54
|
const extractAttrs = parseRootAttributes(code)
|
|
41
55
|
const { width, height } = extractAttrs
|
|
42
56
|
|
|
57
|
+
console.log(extractAttrs)
|
|
58
|
+
|
|
43
59
|
const viewBox = extractAttrs.viewBox || `0 0 ${width || 24} ${height || 24}`
|
|
44
60
|
const xmlns = 'http://www.w3.org/2000/svg'
|
|
45
61
|
|
|
46
|
-
|
|
62
|
+
const replacedCode = replaceIdsAndUrls(code, key)
|
|
63
|
+
|
|
64
|
+
let symbol = replacedCode.replace('<svg',
|
|
47
65
|
`<symbol id="${key}" xmlns="${xmlns}" viewBox="${viewBox}"`
|
|
48
66
|
)
|
|
67
|
+
|
|
49
68
|
symbol = symbol.replace(/width="[^"]*"/, '')
|
|
50
69
|
symbol = symbol.replace(/height="[^"]*"/, '')
|
|
51
70
|
symbol = symbol.replace('</svg', '</symbol')
|