@symbo.ls/icon 1.2.13 → 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.
Files changed (2) hide show
  1. package/index.js +16 -5
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  'use strict'
2
2
 
3
- import { toCamelCase } from '@symbo.ls/utils'
4
- import { Flex, SVG } from '@symbo.ls/atoms'
3
+ import { Flex, Svg } from '@symbo.ls/atoms'
5
4
 
6
5
  export const Icon = {
7
- extend: SVG,
6
+ extend: Svg,
8
7
  props: ({ key, props, parent, context }) => {
9
- const { ICONS } = context && context.system
8
+ const { ICONS, useIconSprite, verbose } = context && context.system
9
+ const { toCamelCase } = context && context.utils
10
10
  const iconName = props.inheritedString || props.name || props.icon || key
11
11
  const camelCase = toCamelCase(iconName)
12
12
 
@@ -19,13 +19,24 @@ export const Icon = {
19
19
  if (parent.props.active && parent.props['.active'] && parent.props['.active'].icon) {
20
20
  activeIconName = parent.props['.active'].icon.name || parent.props['.active'].icon.icon || parent.props['.active'].icon
21
21
  }
22
+
23
+ let validIconName
24
+ if (ICONS[activeIconName]) validIconName = activeIconName
25
+ if (ICONS[camelCase]) validIconName = camelCase
26
+ else if (ICONS[isArray[0] + isArray[1]]) validIconName = isArray[0] + isArray[1]
27
+ else if (ICONS[isArray[0]]) validIconName = isArray[0]
28
+ else {
29
+ console.log(`can't find icon:`, iconName, validIconName)
30
+ validIconName = 'noIcon'
31
+ }
22
32
 
23
- const iconFromLibrary = ICONS[activeIconName] || ICONS[camelCase] || (ICONS[isArray[0] + isArray[1]]) || ICONS[isArray[0]] || ICONS['noIcon']
33
+ const iconFromLibrary = ICONS[validIconName]
24
34
 
25
35
  return {
26
36
  width: 'A',
27
37
  height: 'A',
28
38
  display: 'inline-block',
39
+ spriteId: useIconSprite && validIconName,
29
40
  src: iconFromLibrary,
30
41
  style: { fill: 'currentColor' }
31
42
  }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@symbo.ls/icon",
3
- "version": "1.2.13",
3
+ "version": "1.2.14",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
- "gitHead": "8fda2aa90bb6eba3f1de567260a01cebf4082ea2",
6
+ "gitHead": "9103c4984ee5a28b521c35f5b4a9dff58acab495",
7
7
  "dependencies": {
8
8
  "@symbo.ls/svg": "latest",
9
9
  "@symbo.ls/utils": "latest"