@symbo.ls/icon 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/index.js +16 -5
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import {
|
|
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:
|
|
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[
|
|
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.
|
|
3
|
+
"version": "1.2.16",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"gitHead": "
|
|
6
|
+
"gitHead": "bc1518b87d8089e706a0f0c2df3a0012c0d1c5a3",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@symbo.ls/svg": "latest",
|
|
9
9
|
"@symbo.ls/utils": "latest"
|