Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@symbo.ls/icon

Package Overview
Dependencies
Maintainers
0
Versions
124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@symbo.ls/icon - npm Package Compare versions

Comparing version 2.11.451 to 2.11.453

117

index.js

@@ -5,5 +5,11 @@ 'use strict'

const inheritFromIsActive = (el) => {
const { props } = el
const propsActive = props['.isActive']
return el.call('exec', propsActive.name || propsActive.icon)
}
const getIconName = (el, s) => {
const { key, props, deps } = el
let iconName = exec(props.name || props.icon || key, el)
let iconName = el.call('exec', props.name || props.icon || key, el)

@@ -20,66 +26,44 @@ if (isString(iconName) && iconName.includes('{{')) {

deps: { isString, replaceLiteralsWithObjectFields },
props: (el, s) => {
const { props, parent, context, deps, state } = el
const { ICONS, SEMANTIC_ICONS, useIconSprite, verbose } = context && context.designSystem
const { toCamelCase } = context && context.utils
props: (el, s, ctx) => {
const { props, parent, deps } = el
const { ICONS, useIconSprite, verbose } = ctx && ctx.designSystem
const { toCamelCase } = ctx && ctx.utils
let iconName = getIconName(el, s)
const iconName = getIconName(el, s)
const camelCase = toCamelCase(iconName)
const isArray = camelCase.split(/([a-z])([A-Z])/g)
const semanticIcon = getSemanticIcon(el, s, ctx)
if (semanticIcon) return semanticIcon
const semanticIconRootName = isArray[1] ? isArray[0] : iconName.split('.')[0].split(' ')[0]
const semanticIcon = SEMANTIC_ICONS && SEMANTIC_ICONS[semanticIconRootName]
if (semanticIcon) {
const iconKey = iconName.includes('.') ? 'sfsymbols.' + iconName.split('.').slice(1).join('.') : 'sfsymbols'
iconName = semanticIcon[iconKey] || semanticIcon[iconName.split('.')[0].split(' ')[0]]
return {
tag: 'span',
semantic_symbols: true,
width: 'A',
height: 'A',
lineHeight: '1em',
':after': {
fontSize: 'Z',
fontWeight: '300',
content: `"${iconName}"`,
textAlign: 'center',
display: 'inline-block',
style: {
color: 'currentColor',
fontFamily: "'SF Pro Icons', 'SF Pro', 'SF Symbols', 'Segoe UI'"
}
}
}
}
let activeIconName
if (props.isActive) {
activeIconName = props['.isActive'].name || props['.isActive'].icon
}
if (props.isActive) activeIconName = inheritFromIsActive(el)
const parentProps = parent.props
const parentPropsActive = parentProps['.isActive']
if (
parent &&
parent.props &&
parent.props.isActive &&
parent.props['.isActive'] &&
parent.props['.isActive'].icon
parentProps &&
parentProps.isActive &&
parentPropsActive &&
parentPropsActive.icon
) {
activeIconName = exec(
parent.props['.isActive'].icon.name || parent.props['.isActive'].icon.icon || parent.props['.isActive'].icon
, el)
parentPropsActive.icon || parentPropsActive.Icon.name || parentPropsActive.Icon.icon,
el
)
}
if (isString(activeIconName) && activeIconName.includes('{{')) {
activeIconName = deps.replaceLiteralsWithObjectFields(activeIconName, state)
activeIconName = deps.replaceLiteralsWithObjectFields(activeIconName, s)
}
let validIconName
if (ICONS[activeIconName]) validIconName = activeIconName
if (ICONS[camelCase]) validIconName = camelCase
else if (ICONS[isArray[0] + isArray[1]]) validIconName = isArray[0] + isArray[1]
else if (ICONS[isArray[0]]) validIconName = isArray[0]
let iconInContext
if (ICONS[activeIconName]) iconInContext = activeIconName
if (ICONS[camelCase]) iconInContext = camelCase
else if (ICONS[isArray[0] + isArray[1]]) iconInContext = isArray[0] + isArray[1]
else if (ICONS[isArray[0]]) iconInContext = isArray[0]
else {
if (verbose) console.warn('Can\'t find icon:', iconName, validIconName)
if (verbose) el.warn('Can\'t find icon:', iconName, iconInContext)
}
const iconFromLibrary = ICONS[validIconName]
const iconFromLibrary = ICONS[iconInContext]
const directSrc = (parent && parent.props && parent.props.src) || props.src

@@ -91,3 +75,3 @@

display: 'inline-block',
spriteId: useIconSprite && validIconName,
spriteId: useIconSprite && iconInContext,
src: iconFromLibrary || directSrc || ICONS.noIcon,

@@ -109,3 +93,3 @@ style: { fill: 'currentColor', '*': { fill: 'currentColor' } }

Icon: {
props: ({ parent }) => ({ icon: parent.props.icon }),
props: el => ({ icon: el.call('exec', el.parent.props.icon, el.parent) }),
if: ({ parent, props }) => {

@@ -141,1 +125,34 @@ return parent.props.icon || parent.props.Icon || props.name || props.icon || props.sfSymbols || parent.props.sfSymbols

}
const getSemanticIcon = (el, s, ctx) => {
const { SEMANTIC_ICONS } = ctx && ctx.designSystem
const { toCamelCase } = ctx && ctx.utils
let iconName = getIconName(el, s)
const camelCase = toCamelCase(iconName)
const isArray = camelCase.split(/([a-z])([A-Z])/g)
const semanticIconRootName = isArray[1] ? isArray[0] : iconName.split('.')[0].split(' ')[0]
const semanticIcon = SEMANTIC_ICONS && SEMANTIC_ICONS[semanticIconRootName]
if (semanticIcon) {
const iconKey = iconName.includes('.') ? 'sfsymbols.' + iconName.split('.').slice(1).join('.') : 'sfsymbols'
iconName = semanticIcon[iconKey] || semanticIcon[iconName.split('.')[0].split(' ')[0]]
return {
tag: 'span',
semantic_symbols: true,
width: 'A',
height: 'A',
lineHeight: '1em',
':after': {
fontSize: 'Z',
fontWeight: '300',
content: `"${iconName}"`,
textAlign: 'center',
display: 'inline-block',
style: {
color: 'currentColor',
fontFamily: "'SF Pro Icons', 'SF Pro', 'SF Symbols', 'Segoe UI'"
}
}
}
}
}
{
"name": "@symbo.ls/icon",
"version": "2.11.451",
"version": "2.11.453",
"main": "index.js",
"license": "MIT",
"gitHead": "f3a8fdc4c82ba34580bd324cd1c922f2041506e3",
"gitHead": "8e5458a957b9d2c75944023e2c31bab157034314",
"dependencies": {
"@symbo.ls/atoms": "^2.11.450",
"@symbo.ls/utils": "^2.11.446"
"@symbo.ls/atoms": "^2.11.453",
"@symbo.ls/utils": "^2.11.453"
},
"source": "src/index.js"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc