mirror of
https://github.com/lucide-icons/lucide.git
synced 2025-12-16 11:47:42 +01:00
Format code
This commit is contained in:
@@ -58,4 +58,4 @@
|
|||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"preact": "^10.27.2"
|
"preact": "^10.27.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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(
|
||||||
() => ({
|
() => ({
|
||||||
|
|||||||
@@ -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>,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -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>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,53 +47,56 @@ 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;
|
||||||
|
|
||||||
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", () => {
|
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}
|
||||||
>
|
>
|
||||||
<House
|
<House
|
||||||
size={24}
|
size={24}
|
||||||
color="blue"
|
color="blue"
|
||||||
strokeWidth={2}
|
strokeWidth={2}
|
||||||
/>
|
/>
|
||||||
</LucideProvider>),
|
</LucideProvider>
|
||||||
);
|
));
|
||||||
|
|
||||||
const IconComponent = container.firstElementChild;
|
const IconComponent = container.firstElementChild;
|
||||||
|
|
||||||
expect(IconComponent).toHaveAttribute('width', '24');
|
expect(IconComponent).toHaveAttribute('width', '24');
|
||||||
expect(IconComponent).toHaveAttribute('height', '24');
|
expect(IconComponent).toHaveAttribute('height', '24');
|
||||||
expect(IconComponent).toHaveAttribute('stroke', 'blue');
|
expect(IconComponent).toHaveAttribute('stroke', 'blue');
|
||||||
expect(IconComponent).toHaveAttribute('stroke-width', '2');
|
expect(IconComponent).toHaveAttribute('stroke-width', '2');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should merge className from provider and icon', () => {
|
it('should merge className from provider and icon', () => {
|
||||||
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',
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user