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

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

View File

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

View File

@@ -24,7 +24,13 @@ interface LucideProviderProps {
} }
export function LucideProvider(props: 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>; return <LucideContext.Provider value={value}>{rest.children}</LucideContext.Provider>;
} }

View File

@@ -47,15 +47,15 @@ describe('Using LucideProvider', () => {
}); });
it('should render the icon with LucideProvider and custom absoluteStrokeWidth', () => { it('should render the icon with LucideProvider and custom absoluteStrokeWidth', () => {
const { container } = render(() => const { container } = render(() => (
(<LucideProvider <LucideProvider
size={48} size={48}
color="red" color="red"
absoluteStrokeWidth absoluteStrokeWidth
> >
<House /> <House />
</LucideProvider>), </LucideProvider>
); ));
const IconComponent = container.firstElementChild; const IconComponent = container.firstElementChild;
@@ -63,8 +63,8 @@ describe('Using LucideProvider', () => {
}); });
it("should override the provider's global props when passing props to the icon", () => { it("should override the provider's global props when passing props to the icon", () => {
const { container } = render( const { container } = render(() => (
() => (<LucideProvider <LucideProvider
size={48} size={48}
color="red" color="red"
strokeWidth={4} strokeWidth={4}
@@ -74,8 +74,8 @@ describe('Using LucideProvider', () => {
color="blue" color="blue"
strokeWidth={2} strokeWidth={2}
/> />
</LucideProvider>), </LucideProvider>
); ));
const IconComponent = container.firstElementChild; const IconComponent = container.firstElementChild;
@@ -89,11 +89,14 @@ describe('Using LucideProvider', () => {
const { container } = render(() => ( const { container } = render(() => (
<LucideProvider class="provider-class"> <LucideProvider class="provider-class">
<House class="icon-class" /> <House class="icon-class" />
</LucideProvider>) </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',
);
}); });
}); });