Format code

This commit is contained in:
Eric Fennis
2025-12-12 10:55:29 +01:00
parent 5528e13644
commit 91506784a2
5 changed files with 54 additions and 47 deletions

View File

@@ -58,4 +58,4 @@
"peerDependencies": {
"preact": "^10.27.2"
}
}
}

View File

@@ -30,7 +30,7 @@ export function LucideProvider({
color,
strokeWidth,
absoluteStrokeWidth,
class: className
class: className,
}: LucideProviderProps) {
const value = useMemo(
() => ({

View File

@@ -76,9 +76,7 @@ describe('Using LucideProvider', () => {
it('should merge class names from LucideProvider and icon props', () => {
const { container } = render(
<LucideProvider
class="provider-class"
>
<LucideProvider class="provider-class">
<House class="icon-class" />
</LucideProvider>,
);

View File

@@ -24,7 +24,13 @@ interface LucideProviderProps {
}
export function LucideProvider(props: LucideProviderProps) {
const [value, rest] = splitProps(props, ['size', 'color', 'strokeWidth', 'absoluteStrokeWidth', 'class']);
const [value, rest] = splitProps(props, [
'size',
'color',
'strokeWidth',
'absoluteStrokeWidth',
'class',
]);
return <LucideContext.Provider value={value}>{rest.children}</LucideContext.Provider>;
}

View File

@@ -47,53 +47,56 @@ describe('Using LucideProvider', () => {
});
it('should render the icon with LucideProvider and custom absoluteStrokeWidth', () => {
const { container } = render(() =>
(<LucideProvider
size={48}
color="red"
absoluteStrokeWidth
>
<House />
</LucideProvider>),
);
const { container } = render(() => (
<LucideProvider
size={48}
color="red"
absoluteStrokeWidth
>
<House />
</LucideProvider>
));
const IconComponent = container.firstElementChild;
const IconComponent = container.firstElementChild;
expect(IconComponent).toHaveAttribute('stroke-width', '1');
});
expect(IconComponent).toHaveAttribute('stroke-width', '1');
});
it("should override the provider's global props when passing props to the icon", () => {
const { container } = render(
() => (<LucideProvider
size={48}
color="red"
strokeWidth={4}
>
<House
size={24}
color="blue"
strokeWidth={2}
/>
</LucideProvider>),
);
it("should override the provider's global props when passing props to the icon", () => {
const { container } = render(() => (
<LucideProvider
size={48}
color="red"
strokeWidth={4}
>
<House
size={24}
color="blue"
strokeWidth={2}
/>
</LucideProvider>
));
const IconComponent = container.firstElementChild;
const IconComponent = container.firstElementChild;
expect(IconComponent).toHaveAttribute('width', '24');
expect(IconComponent).toHaveAttribute('height', '24');
expect(IconComponent).toHaveAttribute('stroke', 'blue');
expect(IconComponent).toHaveAttribute('stroke-width', '2');
});
expect(IconComponent).toHaveAttribute('width', '24');
expect(IconComponent).toHaveAttribute('height', '24');
expect(IconComponent).toHaveAttribute('stroke', 'blue');
expect(IconComponent).toHaveAttribute('stroke-width', '2');
});
it('should merge className from provider and icon', () => {
const { container } = render(() => (
<LucideProvider class="provider-class">
<House class="icon-class" />
</LucideProvider>)
);
it('should merge className from provider and icon', () => {
const { container } = render(() => (
<LucideProvider class="provider-class">
<House class="icon-class" />
</LucideProvider>
));
const IconComponent = container.firstElementChild;
const IconComponent = container.firstElementChild;
expect(IconComponent).toHaveAttribute('class', 'lucide lucide-icon provider-class lucide-house icon-class');
});
expect(IconComponent).toHaveAttribute(
'class',
'lucide lucide-icon provider-class lucide-house icon-class',
);
});
});