lucide-solid
Version:
A Lucide icon library package for Solid applications
71 lines (67 loc) • 2.16 kB
JSX
/**
* @license lucide-solid v0.487.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
// src/Icon.tsx
import { For, splitProps } from "solid-js";
import { Dynamic } from "solid-js/web";
import defaultAttributes from "./defaultAttributes";
// ../shared/src/utils.ts
var toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
var toCamelCase = (string) => string.replace(
/^([A-Z])|[\s-_]+(\w)/g,
(match, p1, p2) => p2 ? p2.toUpperCase() : p1.toLowerCase()
);
var toPascalCase = (string) => {
const camelCase = toCamelCase(string);
return camelCase.charAt(0).toUpperCase() + camelCase.slice(1);
};
var mergeClasses = (...classes) => classes.filter((className, index, array) => {
return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
}).join(" ").trim();
// src/Icon.tsx
var Icon = (props) => {
const [localProps, rest] = splitProps(props, [
"color",
"size",
"strokeWidth",
"children",
"class",
"name",
"iconNode",
"absoluteStrokeWidth"
]);
return <svg
{...defaultAttributes}
width={localProps.size ?? defaultAttributes.width}
height={localProps.size ?? defaultAttributes.height}
stroke={localProps.color ?? defaultAttributes.stroke}
stroke-width={localProps.absoluteStrokeWidth ? Number(localProps.strokeWidth ?? defaultAttributes["stroke-width"]) * 24 / Number(localProps.size) : Number(localProps.strokeWidth ?? defaultAttributes["stroke-width"])}
class={mergeClasses(
"lucide",
"lucide-icon",
...localProps.name != null ? [
`lucide-${toKebabCase(toPascalCase(localProps.name))}`,
`lucide-${toKebabCase(localProps.name)}`
] : [],
localProps.class != null ? localProps.class : ""
)}
{...rest}
>
<For each={localProps.iconNode}>
{([elementName, attrs]) => {
return <Dynamic
component={elementName}
{...attrs}
/>;
}}
</For>
</svg>;
};
var Icon_default = Icon;
export {
Icon_default as default
};
//# sourceMappingURL=Icon.jsx.map