@symbo.ls/scratch 3.1.1 → 3.2.3
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 +40 -20
- package/dist/cjs/index.js +131 -72
- package/dist/cjs/set.js +127 -58
- package/dist/cjs/system/color.js +121 -41
- package/dist/cjs/system/document.js +120 -38
- package/dist/cjs/system/font.js +118 -36
- package/dist/cjs/system/index.js +128 -63
- package/dist/cjs/system/reset.js +120 -38
- package/dist/cjs/system/shadow.js +121 -41
- package/dist/cjs/system/spacing.js +120 -38
- package/dist/cjs/system/svg.js +119 -39
- package/dist/cjs/system/theme.js +121 -41
- package/dist/cjs/system/timing.js +118 -36
- package/dist/cjs/system/typography.js +124 -55
- package/dist/cjs/transforms/index.js +123 -43
- package/dist/cjs/utils/color.js +16 -18
- package/dist/cjs/utils/index.js +125 -53
- package/dist/cjs/utils/sequence.js +110 -36
- package/dist/cjs/utils/sprite.js +49 -23
- package/dist/cjs/utils/var.js +110 -36
- package/package.json +7 -7
- package/src/system/typography.js +12 -20
- package/src/utils/color.js +42 -31
- package/src/utils/sprite.js +12 -8
package/src/utils/sprite.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { isArray, isString } from '@domql/utils'
|
|
3
|
+
import { isArray, isNotProduction, isString } from '@domql/utils'
|
|
4
4
|
import { getActiveConfig } from '../factory'
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
const isDev = ENV === 'development' || ENV === 'testing'
|
|
6
|
+
const isDev = isNotProduction()
|
|
8
7
|
|
|
9
|
-
export const generateSprite =
|
|
8
|
+
export const generateSprite = icons => {
|
|
10
9
|
const CONFIG = getActiveConfig()
|
|
11
10
|
|
|
12
11
|
let sprite = ''
|
|
@@ -20,7 +19,7 @@ export const generateSprite = (icons) => {
|
|
|
20
19
|
return sprite
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
const parseRootAttributes =
|
|
22
|
+
const parseRootAttributes = htmlString => {
|
|
24
23
|
const val = htmlString.default || htmlString
|
|
25
24
|
if (!isString(val)) {
|
|
26
25
|
if (isDev) console.warn('parseRootAttributes:', val, 'is not a string')
|
|
@@ -33,7 +32,9 @@ const parseRootAttributes = (htmlString) => {
|
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
const attrString = match[1]
|
|
36
|
-
const attrs = attrString.match(
|
|
35
|
+
const attrs = attrString.match(
|
|
36
|
+
/(\S+)=["']?((?:.(?!["']?\s+(?:\S+)=|\s*\/?[>"']))+.)["']?/gm
|
|
37
|
+
)
|
|
37
38
|
return attrs.reduce((acc, attr) => {
|
|
38
39
|
const [key, value] = attr.split('=')
|
|
39
40
|
acc[key] = value.replace(/['"]/g, '')
|
|
@@ -49,7 +50,9 @@ const replaceIdsAndUrls = (code, key) => {
|
|
|
49
50
|
if (isArray(matches)) {
|
|
50
51
|
matches.forEach(() => {
|
|
51
52
|
const randomKey = Math.floor(Math.random() * 100000)
|
|
52
|
-
replacedCode = code
|
|
53
|
+
replacedCode = code
|
|
54
|
+
.replace(idRegex, `id="${key}-${randomKey}"`)
|
|
55
|
+
.replace(urlRegex, `url(#${key}-${randomKey})`)
|
|
53
56
|
})
|
|
54
57
|
}
|
|
55
58
|
return replacedCode
|
|
@@ -64,7 +67,8 @@ export const convertSvgToSymbol = (key, code) => {
|
|
|
64
67
|
|
|
65
68
|
const replacedCode = replaceIdsAndUrls(code, key)
|
|
66
69
|
|
|
67
|
-
let symbol = replacedCode.replace(
|
|
70
|
+
let symbol = replacedCode.replace(
|
|
71
|
+
'<svg',
|
|
68
72
|
`<symbol id="${key}" xmlns="${xmlns}" viewBox="${viewBox}"`
|
|
69
73
|
)
|
|
70
74
|
|