mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-13 13:48:26 +00:00
New setup for new NPM package
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
const createElement = (tag, attrs, children = []) => {
|
||||
const element = document.createElement(tag);
|
||||
|
||||
Object.keys(attrs).forEach(name => {
|
||||
element.setAttribute(name, attrs[name]);
|
||||
})
|
||||
|
||||
if (children.length) {
|
||||
children = children.forEach(child => {
|
||||
const childElement = createElement(child);
|
||||
|
||||
element.appendChild(childElement);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default (iconVnode) => createElement(iconVnode);
|
||||
@@ -0,0 +1,33 @@
|
||||
import { forwardRef, createElement } from "react";
|
||||
|
||||
export default (iconName, [tag, attrs, children]) => {
|
||||
const Component = forwardRef(
|
||||
(
|
||||
{ color = "currentColor", size = 24, width = 2, ...rest },
|
||||
ref
|
||||
) =>
|
||||
createElement(
|
||||
tag,
|
||||
{
|
||||
ref,
|
||||
...attrs,
|
||||
width: size,
|
||||
height: size,
|
||||
color,
|
||||
strokeWidth: width,
|
||||
...rest
|
||||
},
|
||||
children.map(([childTag, childAttrs]) =>
|
||||
createElement(childTag, childAttrs)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
Component.propTypes = {
|
||||
color: PropTypes.string,
|
||||
size: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||||
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||||
};
|
||||
|
||||
Component.displayName = `${iconName}`;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
export default (iconName, [tag, attrs, children]) => ({
|
||||
name: iconName,
|
||||
functional: true,
|
||||
render(
|
||||
createElement,
|
||||
{
|
||||
props: {
|
||||
color = "currentColor",
|
||||
size = 48,
|
||||
width = 2,
|
||||
strokeWidth = 2,
|
||||
...rest
|
||||
}
|
||||
}
|
||||
) {
|
||||
return createElement(
|
||||
tag,
|
||||
{
|
||||
attrs: {
|
||||
...attrs,
|
||||
width: size,
|
||||
height: size,
|
||||
color,
|
||||
strokeWidth,
|
||||
...rest
|
||||
}
|
||||
},
|
||||
children.map(([tag, attrs]) => createElement(tag, { attrs }))
|
||||
);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user