@symbo.ls/icon 2.11.375 → 2.11.389
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 +38 -8
- package/package.json +4 -3
package/index.js
CHANGED
|
@@ -2,22 +2,52 @@
|
|
|
2
2
|
|
|
3
3
|
import { isString, replaceLiteralsWithObjectFields } from '@domql/utils'
|
|
4
4
|
|
|
5
|
+
const getIconName = ({ key, props, context, deps, state }) => {
|
|
6
|
+
let iconName = props.name || props.icon || key
|
|
7
|
+
|
|
8
|
+
if (isString(iconName) && iconName.includes('{{')) {
|
|
9
|
+
iconName = deps.replaceLiteralsWithObjectFields(iconName, state)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return deps.isString(iconName) ? iconName : key
|
|
13
|
+
}
|
|
14
|
+
|
|
5
15
|
export const Icon = {
|
|
6
16
|
extend: 'Svg',
|
|
7
17
|
deps: { isString, replaceLiteralsWithObjectFields },
|
|
8
18
|
props: ({ key, props, parent, context, deps, state }) => {
|
|
9
|
-
const { ICONS, useIconSprite, verbose } = context && context.designSystem
|
|
19
|
+
const { ICONS, SEMANTIC_ICONS, useIconSprite, verbose } = context && context.designSystem
|
|
10
20
|
const { toCamelCase } = context && context.utils
|
|
11
|
-
let iconName = props.name || props.icon || key
|
|
12
|
-
|
|
13
|
-
if (isString(iconName) && iconName.includes('{{')) {
|
|
14
|
-
iconName = deps.replaceLiteralsWithObjectFields(iconName, state)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const camelCase = toCamelCase(deps.isString(iconName) ? iconName : key)
|
|
18
21
|
|
|
22
|
+
let iconName = getIconName({ key, props, parent, context, deps, state })
|
|
23
|
+
const camelCase = toCamelCase(iconName)
|
|
19
24
|
const isArray = camelCase.split(/([a-z])([A-Z])/g)
|
|
20
25
|
|
|
26
|
+
const semanticIconRootName = isArray[1] ? isArray[0] : iconName.split('.')[0].split(' ')[0]
|
|
27
|
+
const semanticIcon = SEMANTIC_ICONS && SEMANTIC_ICONS[semanticIconRootName]
|
|
28
|
+
if (semanticIcon) {
|
|
29
|
+
const iconKey = iconName.includes('.') ? 'sfsymbols.' + iconName.split('.').slice(1).join('.') : 'sfsymbols'
|
|
30
|
+
iconName = semanticIcon[iconKey] || semanticIcon[iconName.split('.')[0].split(' ')[0]]
|
|
31
|
+
return {
|
|
32
|
+
tag: 'span',
|
|
33
|
+
semantic_symbols: true,
|
|
34
|
+
width: 'A',
|
|
35
|
+
height: 'A',
|
|
36
|
+
lineHeight: '1em',
|
|
37
|
+
':after': {
|
|
38
|
+
fontSize: 'Z',
|
|
39
|
+
fontWeight: '300',
|
|
40
|
+
content: `"${iconName}"`,
|
|
41
|
+
textAlign: 'center',
|
|
42
|
+
display: 'inline-block',
|
|
43
|
+
style: {
|
|
44
|
+
color: 'currentColor',
|
|
45
|
+
fontFamily: "'SF Pro Icons', 'SF Pro', 'Segoe UI'"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
21
51
|
let activeIconName
|
|
22
52
|
if (props.active) {
|
|
23
53
|
activeIconName = props['.active'].name || props['.active'].icon
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/icon",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.389",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"gitHead": "
|
|
6
|
+
"gitHead": "e260280a4a50ca08fd7df53104a884086dc3da88",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@symbo.ls/atoms": "latest"
|
|
8
|
+
"@symbo.ls/atoms": "latest",
|
|
9
|
+
"@symbo.ls/utils": "latest"
|
|
9
10
|
},
|
|
10
11
|
"source": "src/index.js"
|
|
11
12
|
}
|