UNPKG

lucide-solid

Version:

A Lucide icon library package for Solid applications

51 lines (47 loc) 1.97 kB
/** * @license lucide-solid v0.488.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */ import { spread, mergeProps, memo, insert, createComponent, Dynamic, template } from 'solid-js/web'; import { splitProps, For } from 'solid-js'; import defaultAttributes from './defaultAttributes.js'; import { mergeClasses, toKebabCase, toPascalCase } from './shared/src/utils.js'; var _tmpl$ = /*#__PURE__*/template(`<svg>`); const Icon = props => { const [localProps, rest] = splitProps(props, ['color', 'size', 'strokeWidth', 'children', 'class', 'name', 'iconNode', 'absoluteStrokeWidth']); return (() => { var _el$ = _tmpl$(); spread(_el$, mergeProps(defaultAttributes, { get width() { return localProps.size ?? defaultAttributes.width; }, get height() { return localProps.size ?? defaultAttributes.height; }, get stroke() { return localProps.color ?? defaultAttributes.stroke; }, get ["stroke-width"]() { return memo(() => !!localProps.absoluteStrokeWidth)() ? Number(localProps.strokeWidth ?? defaultAttributes['stroke-width']) * 24 / Number(localProps.size) : Number(localProps.strokeWidth ?? defaultAttributes['stroke-width']); }, get ["class"]() { return mergeClasses('lucide', 'lucide-icon', ...(localProps.name != null ? [`lucide-${toKebabCase(toPascalCase(localProps.name))}`, `lucide-${toKebabCase(localProps.name)}`] : []), localProps.class != null ? localProps.class : ''); } }, rest), true, true); insert(_el$, createComponent(For, { get each() { return localProps.iconNode; }, children: ([elementName, attrs]) => { return createComponent(Dynamic, mergeProps({ component: elementName }, attrs)); } })); return _el$; })(); }; export { Icon as default }; //# sourceMappingURL=Icon.js.map