mirror of
https://github.com/lucide-icons/lucide.git
synced 2025-12-15 21:17:41 +01:00
Format code
This commit is contained in:
@@ -58,4 +58,4 @@
|
||||
"peerDependencies": {
|
||||
"preact": "^10.27.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ export function LucideProvider({
|
||||
color,
|
||||
strokeWidth,
|
||||
absoluteStrokeWidth,
|
||||
class: className
|
||||
class: className,
|
||||
}: LucideProviderProps) {
|
||||
const value = useMemo(
|
||||
() => ({
|
||||
|
||||
@@ -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>,
|
||||
);
|
||||
|
||||
@@ -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>;
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user