@symbo.ls/atoms 1.2.13 → 1.2.16
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/Media.js +2 -2
- package/Svg.js +39 -0
- package/index.js +1 -1
- package/package.json +3 -2
- package/SVG.js +0 -16
package/Media.js
CHANGED
|
@@ -120,8 +120,8 @@ const beforeClassAssign = (element, s) => {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
export const initUpdate = element => {
|
|
123
|
-
const { props, class: className } = element
|
|
124
|
-
const globalTheme =
|
|
123
|
+
const { props, context, class: className } = element
|
|
124
|
+
const globalTheme = context.system.globalTheme
|
|
125
125
|
|
|
126
126
|
const parentProps = element.parent.props
|
|
127
127
|
if (parentProps && parentProps.spacingRatio && parentProps.inheritSpacingRatio) {
|
package/Svg.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
import { init } from '@symbo.ls/init'
|
|
4
|
+
|
|
5
|
+
// create SVG symbol
|
|
6
|
+
export const Svg = {
|
|
7
|
+
tag: 'svg',
|
|
8
|
+
props: {
|
|
9
|
+
style: { '*': { fill: 'currentColor' } }
|
|
10
|
+
},
|
|
11
|
+
attr: {
|
|
12
|
+
xmlns: 'http://www.w3.org/2000/svg',
|
|
13
|
+
'xmlns:xlink': 'http://www.w3.org/1999/xlink'
|
|
14
|
+
},
|
|
15
|
+
html: ({ key, props, context, ...el }) => {
|
|
16
|
+
const SVG = context.system && context.system.SVG
|
|
17
|
+
const useSvgSprite = props.spriteId || (context.system && context.system.useSvgSprite)
|
|
18
|
+
const useSVGSymbol = icon => `<use xlink:href="#${icon}" />`
|
|
19
|
+
|
|
20
|
+
if (!useSvgSprite) return props.src
|
|
21
|
+
|
|
22
|
+
let spriteId = props.spriteId
|
|
23
|
+
if (spriteId) return useSVGSymbol(spriteId)
|
|
24
|
+
|
|
25
|
+
const symbolId = Symbol.for(props.src)
|
|
26
|
+
let SVGKey = SVG[symbolId]
|
|
27
|
+
if (SVGKey && SVG[SVGKey]) return useSVGSymbol(SVGKey)
|
|
28
|
+
|
|
29
|
+
SVGKey = SVG[symbolId] = Math.random()
|
|
30
|
+
const conf = init({
|
|
31
|
+
svg: { [SVGKey]: props.src }
|
|
32
|
+
}, null, {
|
|
33
|
+
document: context.document,
|
|
34
|
+
emotion: context.emotion
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
return useSVGSymbol(SVGKey)
|
|
38
|
+
}
|
|
39
|
+
}
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/atoms",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.16",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"gitHead": "
|
|
6
|
+
"gitHead": "bc1518b87d8089e706a0f0c2df3a0012c0d1c5a3",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@domql/utils": "latest",
|
|
9
9
|
"@symbo.ls/create-emotion": "latest",
|
|
10
|
+
"@symbo.ls/init": "latest",
|
|
10
11
|
"@symbo.ls/scratch": "latest"
|
|
11
12
|
},
|
|
12
13
|
"source": "src/index.js"
|
package/SVG.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const useSVGSymbol = file => `<use xlink:href="${file}" />`
|
|
4
|
-
|
|
5
|
-
// create SVG symbol
|
|
6
|
-
export const SVG = {
|
|
7
|
-
tag: 'svg',
|
|
8
|
-
props: {
|
|
9
|
-
style: { '*': { fill: 'currentColor' } }
|
|
10
|
-
},
|
|
11
|
-
attr: {
|
|
12
|
-
xmlns: 'http://www.w3.org/2000/svg',
|
|
13
|
-
'xmlns:xlink': 'http://www.w3.org/1999/xlink'
|
|
14
|
-
},
|
|
15
|
-
html: ({ key, props }) => useSVGSymbol(props.src)
|
|
16
|
-
}
|