@symbo.ls/icon 3.1.1 → 3.2.3
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 +34 -17
- package/package.json +4 -4
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const inheritFromIsActive =
|
|
3
|
+
const inheritFromIsActive = el => {
|
|
4
4
|
const { props } = el
|
|
5
5
|
const propsActive = props['.isActive']
|
|
6
6
|
return el.call('exec', propsActive.name || propsActive.icon)
|
|
@@ -46,22 +46,30 @@ export const Icon = {
|
|
|
46
46
|
parentPropsActive &&
|
|
47
47
|
parentPropsActive.icon
|
|
48
48
|
) {
|
|
49
|
-
activeIconName = el.call(
|
|
50
|
-
|
|
49
|
+
activeIconName = el.call(
|
|
50
|
+
'exec',
|
|
51
|
+
parentPropsActive.icon ||
|
|
52
|
+
parentPropsActive.Icon.name ||
|
|
53
|
+
parentPropsActive.Icon.icon,
|
|
54
|
+
el
|
|
51
55
|
)
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
if (el.call('isString', activeIconName) && activeIconName.includes('{{')) {
|
|
55
|
-
activeIconName = el.call(
|
|
59
|
+
activeIconName = el.call(
|
|
60
|
+
'replaceLiteralsWithObjectFields',
|
|
61
|
+
activeIconName
|
|
62
|
+
)
|
|
56
63
|
}
|
|
57
64
|
|
|
58
65
|
let iconInContext
|
|
59
66
|
if (ICONS[activeIconName]) iconInContext = activeIconName
|
|
60
67
|
if (ICONS[camelCase]) iconInContext = camelCase
|
|
61
|
-
else if (ICONS[isArray[0] + isArray[1]])
|
|
68
|
+
else if (ICONS[isArray[0] + isArray[1]])
|
|
69
|
+
iconInContext = isArray[0] + isArray[1]
|
|
62
70
|
else if (ICONS[isArray[0]]) iconInContext = isArray[0]
|
|
63
71
|
else {
|
|
64
|
-
if (verbose) el.warn(
|
|
72
|
+
if (verbose) el.warn("Can't find icon:", iconName, iconInContext)
|
|
65
73
|
}
|
|
66
74
|
|
|
67
75
|
const iconFromLibrary = ICONS[iconInContext]
|
|
@@ -77,7 +85,7 @@ export const Icon = {
|
|
|
77
85
|
}
|
|
78
86
|
|
|
79
87
|
export const IconText = {
|
|
80
|
-
|
|
88
|
+
display: 'flex',
|
|
81
89
|
|
|
82
90
|
align: 'center center',
|
|
83
91
|
lineHeight: 1,
|
|
@@ -91,13 +99,16 @@ export const IconText = {
|
|
|
91
99
|
},
|
|
92
100
|
|
|
93
101
|
Icon: {
|
|
94
|
-
if:
|
|
102
|
+
if: el => {
|
|
95
103
|
const { parent, props } = el
|
|
96
|
-
return el.call(
|
|
97
|
-
|
|
98
|
-
props.
|
|
99
|
-
|
|
100
|
-
|
|
104
|
+
return el.call(
|
|
105
|
+
'exec',
|
|
106
|
+
parent.props.icon ||
|
|
107
|
+
props.name ||
|
|
108
|
+
props.sfSymbols ||
|
|
109
|
+
parent.props.sfSymbols,
|
|
110
|
+
el
|
|
111
|
+
)
|
|
101
112
|
},
|
|
102
113
|
icon: el => el.call('exec', el.parent.props.icon, el.parent)
|
|
103
114
|
},
|
|
@@ -106,7 +117,7 @@ export const IconText = {
|
|
|
106
117
|
}
|
|
107
118
|
|
|
108
119
|
export const FileIcon = {
|
|
109
|
-
|
|
120
|
+
display: 'flex',
|
|
110
121
|
theme: 'tertiary',
|
|
111
122
|
boxSize: 'C1',
|
|
112
123
|
align: 'center center',
|
|
@@ -125,11 +136,17 @@ const getSemanticIcon = (el, s, ctx) => {
|
|
|
125
136
|
let iconName = getIconName(el, s)
|
|
126
137
|
const camelCase = toCamelCase(iconName)
|
|
127
138
|
const isArray = camelCase.split(/([a-z])([A-Z])/g)
|
|
128
|
-
const semanticIconRootName = isArray[1]
|
|
139
|
+
const semanticIconRootName = isArray[1]
|
|
140
|
+
? isArray[0]
|
|
141
|
+
: iconName.split('.')[0].split(' ')[0]
|
|
129
142
|
const semanticIcon = SEMANTIC_ICONS && SEMANTIC_ICONS[semanticIconRootName]
|
|
130
143
|
if (semanticIcon) {
|
|
131
|
-
const iconKey = iconName.includes('.')
|
|
132
|
-
|
|
144
|
+
const iconKey = iconName.includes('.')
|
|
145
|
+
? 'sfsymbols.' + iconName.split('.').slice(1).join('.')
|
|
146
|
+
: 'sfsymbols'
|
|
147
|
+
iconName =
|
|
148
|
+
semanticIcon[iconKey] ||
|
|
149
|
+
semanticIcon[iconName.split('.')[0].split(' ')[0]]
|
|
133
150
|
return {
|
|
134
151
|
tag: 'span',
|
|
135
152
|
semantic_symbols: true,
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/icon",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.3",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"gitHead": "
|
|
6
|
+
"gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@symbo.ls/atoms": "^3.
|
|
9
|
-
"@symbo.ls/utils": "^3.
|
|
8
|
+
"@symbo.ls/atoms": "^3.2.3",
|
|
9
|
+
"@symbo.ls/utils": "^3.2.3"
|
|
10
10
|
},
|
|
11
11
|
"source": "src/index.js"
|
|
12
12
|
}
|