Add default classnames, fix #317

This commit is contained in:
Eric Fennis
2021-09-17 16:23:17 +02:00
parent 26f85a75d2
commit f70a0e1945
9 changed files with 50 additions and 13 deletions

View File

@@ -2,6 +2,16 @@ import { forwardRef, createElement } from 'react';
import PropTypes from 'prop-types';
import defaultAttributes from './defaultAttributes';
/**
* Converts string to KebabCase
* Copied from scripts/helper. If anyone knows how to properly import it here
* then please fix it.
*
* @param {string} string
* @returns {string} A kebabized string
*/
export const toKebabCase = string => string.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
export default (iconName, iconNode) => {
const Component = forwardRef(
({ color = 'currentColor', size = 24, strokeWidth = 2, ...rest }, ref) =>
@@ -14,6 +24,7 @@ export default (iconName, iconNode) => {
height: size,
stroke: color,
strokeWidth,
className: `lucide lucide-${toKebabCase(iconName)}`,
...rest,
},
iconNode.map(([tag, attrs]) => createElement(tag, attrs)),