@symbo.ls/atoms 1.2.10 → 1.2.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/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 = getSystemTheme(element)
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
+ const useSVGSymbol = file => `<use xlink:href="${file}" />`
5
+
6
+ // create SVG symbol
7
+ export const Svg = {
8
+ tag: 'svg',
9
+ props: {
10
+ style: { '*': { fill: 'currentColor' } }
11
+ },
12
+ attr: {
13
+ xmlns: 'http://www.w3.org/2000/svg',
14
+ 'xmlns:xlink': 'http://www.w3.org/1999/xlink'
15
+ },
16
+ html: ({ key, props, context, ...el }) => {
17
+ const SVG = context.system && context.system.SVG
18
+ const useSvgSprite = props.spriteId || (context.system && context.system.useSvgSprite)
19
+
20
+ if (!useSvgSprite) return props.src
21
+
22
+ let spriteId = props.spriteId
23
+ if (spriteId) return `<use xlink:href="#${spriteId}" />`
24
+
25
+ const symbolId = Symbol.for(props.src)
26
+ let SVGKey = SVG[symbolId]
27
+ if (SVGKey && SVG[SVGKey]) return `<use xlink:href="#${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 `<use xlink:href="#${SVGKey}" />`
38
+ }
39
+ }
package/index.js CHANGED
@@ -15,7 +15,7 @@ export * from './Collection'
15
15
  export * from './Position'
16
16
  export * from './Picture'
17
17
  export * from './Pseudo'
18
- export * from './SVG'
18
+ export * from './Svg'
19
19
  export * from './Shape'
20
20
  export * from './Theme'
21
21
  export * from './Text'
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@symbo.ls/atoms",
3
- "version": "1.2.10",
3
+ "version": "1.2.14",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
- "gitHead": "28f5cdafce0d8d076801747dead7f2878f5083e5",
6
+ "gitHead": "9103c4984ee5a28b521c35f5b4a9dff58acab495",
7
7
  "dependencies": {
8
8
  "@domql/utils": "latest",
9
9
  "@symbo.ls/create-emotion": "latest",
10
+ "@symbo.ls/create-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
- }