@symbo.ls/atoms 1.2.14 → 1.2.19

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.
Files changed (2) hide show
  1. package/Svg.js +11 -11
  2. package/package.json +3 -3
package/Svg.js CHANGED
@@ -1,7 +1,6 @@
1
1
  'use strict'
2
2
 
3
3
  import { init } from '@symbo.ls/init'
4
- const useSVGSymbol = file => `<use xlink:href="${file}" />`
5
4
 
6
5
  // create SVG symbol
7
6
  export const Svg = {
@@ -16,24 +15,25 @@ export const Svg = {
16
15
  html: ({ key, props, context, ...el }) => {
17
16
  const SVG = context.system && context.system.SVG
18
17
  const useSvgSprite = props.spriteId || (context.system && context.system.useSvgSprite)
18
+ const useSVGSymbol = icon => `<use xlink:href="#${icon}" />`
19
19
 
20
20
  if (!useSvgSprite) return props.src
21
-
22
- let spriteId = props.spriteId
23
- if (spriteId) return `<use xlink:href="#${spriteId}" />`
24
-
21
+
22
+ const spriteId = props.spriteId
23
+ if (spriteId) return useSVGSymbol(spriteId)
24
+
25
25
  const symbolId = Symbol.for(props.src)
26
26
  let SVGKey = SVG[symbolId]
27
- if (SVGKey && SVG[SVGKey]) return `<use xlink:href="#${SVGKey}" />`
28
-
27
+ if (SVGKey && SVG[SVGKey]) return useSVGSymbol(SVGKey)
28
+
29
29
  SVGKey = SVG[symbolId] = Math.random()
30
- const conf = init({
31
- svg: { [SVGKey]: props.src }
30
+ init({
31
+ svg: { [SVGKey]: props.src }
32
32
  }, null, {
33
33
  document: context.document,
34
34
  emotion: context.emotion
35
35
  })
36
-
37
- return `<use xlink:href="#${SVGKey}" />`
36
+
37
+ return useSVGSymbol(SVGKey)
38
38
  }
39
39
  }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@symbo.ls/atoms",
3
- "version": "1.2.14",
3
+ "version": "1.2.19",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
- "gitHead": "9103c4984ee5a28b521c35f5b4a9dff58acab495",
6
+ "gitHead": "e4a8395bb28c9a498ee5de17e8b6dbb38391b0ce",
7
7
  "dependencies": {
8
8
  "@domql/utils": "latest",
9
9
  "@symbo.ls/create-emotion": "latest",
10
- "@symbo.ls/create-init": "latest",
10
+ "@symbo.ls/init": "latest",
11
11
  "@symbo.ls/scratch": "latest"
12
12
  },
13
13
  "source": "src/index.js"