mirror of
https://github.com/lucide-icons/lucide.git
synced 2025-12-22 05:29:23 +01:00
Add support for icon alias classnames in lucide-svelte
This commit is contained in:
@@ -53,14 +53,14 @@ describe('Using lucide icon components', () => {
|
||||
});
|
||||
|
||||
it('should render the alias icon name classNames', () => {
|
||||
const { container } = render(() => (
|
||||
<Pen />
|
||||
));
|
||||
const { container } = render(() => (
|
||||
<Pen />
|
||||
));
|
||||
|
||||
const PenIcon = container.firstChild;
|
||||
const PenIcon = container.firstChild;
|
||||
|
||||
expect(PenIcon).toHaveClass('lucide-edit-2');
|
||||
})
|
||||
expect(PenIcon).toHaveClass('lucide-edit-2');
|
||||
})
|
||||
|
||||
it('should not scale the strokeWidth when absoluteStrokeWidth is set', () => {
|
||||
const { container, getByTestId } = render(() => (
|
||||
|
||||
@@ -9,6 +9,7 @@ export default async ({
|
||||
getSvg,
|
||||
deprecated,
|
||||
deprecationReason,
|
||||
iconNameAliases
|
||||
}) => {
|
||||
const svgContents = await getSvg();
|
||||
const svgBase64 = base64SVG(svgContents);
|
||||
@@ -36,7 +37,9 @@ const iconNode: IconNode = ${JSON.stringify(children)};
|
||||
*/
|
||||
</script>
|
||||
|
||||
<Icon name="${iconName}" {...$$props} iconNode={iconNode}>
|
||||
<Icon name="${iconName}" {...$$props} iconNode={iconNode}${
|
||||
iconNameAliases != null ? ` aliasNames={${JSON.stringify(iconNameAliases)}}` : ''
|
||||
}>
|
||||
<slot/>
|
||||
</Icon>
|
||||
`;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
export let strokeWidth: number | string = 2
|
||||
export let absoluteStrokeWidth: boolean = false
|
||||
export let iconNode: IconNode = []
|
||||
export let aliasNames: string[] = []
|
||||
|
||||
const mergeClasses = <ClassType = string | undefined | null>(
|
||||
...classes: ClassType[]
|
||||
@@ -34,6 +35,7 @@
|
||||
'lucide-icon',
|
||||
'lucide',
|
||||
name ? `lucide-${name}`: '',
|
||||
...aliasNames.map(alias => `lucide-${alias}`),
|
||||
$$props.class
|
||||
)
|
||||
}
|
||||
|
||||
@@ -70,6 +70,14 @@ describe('Using lucide icon components', () => {
|
||||
expect(PenIconRenderedHTML).toBe(Edit2Container.innerHTML);
|
||||
});
|
||||
|
||||
it('should render the alias icon name classNames', () => {
|
||||
const { container } = render(Pen);
|
||||
|
||||
const PenIcon = container.firstChild;
|
||||
|
||||
expect(PenIcon).toHaveClass('lucide-edit-2');
|
||||
})
|
||||
|
||||
it('should not scale the strokeWidth when absoluteStrokeWidth is set', () => {
|
||||
const testId = 'smile-icon';
|
||||
const { container, getByTestId } = render(Smile, {
|
||||
|
||||
Reference in New Issue
Block a user