@symbo.ls/icon 3.2.3 → 3.3.4

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 +60 -1
  2. package/package.json +12 -4
package/index.js CHANGED
@@ -3,6 +3,7 @@
3
3
  const inheritFromIsActive = el => {
4
4
  const { props } = el
5
5
  const propsActive = props['.isActive']
6
+ if (!propsActive) return
6
7
  return el.call('exec', propsActive.name || propsActive.icon)
7
8
  }
8
9
 
@@ -29,6 +30,64 @@ export const Icon = {
29
30
  const { ICONS, useIconSprite, verbose } = ctx && ctx.designSystem
30
31
  const { toCamelCase } = ctx && ctx.utils
31
32
 
33
+ const inheritFromIsActive = (el) => {
34
+ const { props } = el
35
+ const propsActive = props['.isActive']
36
+ if (!propsActive) return
37
+ return el.call('exec', propsActive.name || propsActive.icon)
38
+ }
39
+
40
+ const getSemanticIcon = (el, s, ctx) => {
41
+ const { SEMANTIC_ICONS } = ctx && ctx.designSystem
42
+ const { toCamelCase } = ctx && ctx.utils
43
+
44
+ let iconName = getIconName(el, s)
45
+ const camelCase = toCamelCase(iconName)
46
+ const isArray = camelCase.split(/([a-z])([A-Z])/g)
47
+ const semanticIconRootName = isArray[1]
48
+ ? isArray[0]
49
+ : iconName.split('.')[0].split(' ')[0]
50
+ const semanticIcon =
51
+ SEMANTIC_ICONS && SEMANTIC_ICONS[semanticIconRootName]
52
+ if (semanticIcon) {
53
+ const iconKey = iconName.includes('.')
54
+ ? 'sfsymbols.' + iconName.split('.').slice(1).join('.')
55
+ : 'sfsymbols'
56
+ iconName =
57
+ semanticIcon[iconKey] ||
58
+ semanticIcon[iconName.split('.')[0].split(' ')[0]]
59
+ return {
60
+ tag: 'span',
61
+ semantic_symbols: true,
62
+ width: 'A',
63
+ height: 'A',
64
+ lineHeight: '1em',
65
+ ':after': {
66
+ fontSize: 'Z',
67
+ fontWeight: '300',
68
+ content: `"${iconName}"`,
69
+ textAlign: 'center',
70
+ display: 'inline-block',
71
+ style: {
72
+ color: 'currentColor',
73
+ fontFamily: "'SF Pro Icons', 'SF Pro', 'SF Symbols', 'Segoe UI'"
74
+ }
75
+ }
76
+ }
77
+ }
78
+ }
79
+
80
+ const getIconName = (el, s) => {
81
+ const { key, props } = el
82
+ let icon = el.call('exec', props.name || props.icon || key, el)
83
+
84
+ if (el.call('isString', icon) && icon.includes('{{')) {
85
+ icon = el.call('replaceLiteralsWithObjectFields', icon)
86
+ }
87
+
88
+ return el.call('isString', icon) ? icon : key
89
+ }
90
+
32
91
  const iconName = getIconName(el, s)
33
92
  const camelCase = toCamelCase(iconName)
34
93
  const isArray = camelCase.split(/([a-z])([A-Z])/g)
@@ -110,7 +169,7 @@ export const IconText = {
110
169
  el
111
170
  )
112
171
  },
113
- icon: el => el.call('exec', el.parent.props.icon, el.parent)
172
+ icon: (el) => el.call('exec', el.parent.props.icon, el.parent)
114
173
  },
115
174
 
116
175
  text: ({ props }) => props.text
package/package.json CHANGED
@@ -1,12 +1,20 @@
1
1
  {
2
2
  "name": "@symbo.ls/icon",
3
- "version": "3.2.3",
3
+ "version": "3.3.4",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681",
7
7
  "dependencies": {
8
- "@symbo.ls/atoms": "^3.2.3",
9
- "@symbo.ls/utils": "^3.2.3"
8
+ "@symbo.ls/atoms": "^3.3.4",
9
+ "@symbo.ls/smbls-utils": "^3.3.4"
10
10
  },
11
- "source": "src/index.js"
11
+ "source": "index.js",
12
+ "type": "module",
13
+ "module": "index.js",
14
+ "exports": {
15
+ ".": {
16
+ "import": "./index.js",
17
+ "default": "./index.js"
18
+ }
19
+ }
12
20
  }