mirror of
https://github.com/lucide-icons/lucide.git
synced 2025-12-16 16:17:42 +01:00
Apply feedback
This commit is contained in:
@@ -21,7 +21,7 @@ interface LucideProviderProps {
|
||||
color?: string;
|
||||
strokeWidth?: number;
|
||||
absoluteStrokeWidth?: boolean;
|
||||
class?: string
|
||||
class?: string;
|
||||
}
|
||||
|
||||
export function LucideProvider({
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { createContext, type ReactNode, useContext } from 'react';
|
||||
import { createContext, type ReactNode, useContext, useMemo } from 'react';
|
||||
|
||||
const LucideContext = createContext<{
|
||||
size?: number;
|
||||
@@ -20,8 +20,24 @@ interface LucideProviderProps {
|
||||
absoluteStrokeWidth?: boolean;
|
||||
}
|
||||
|
||||
export function LucideProvider({ children, ...props }: LucideProviderProps) {
|
||||
return <LucideContext.Provider value={props}>{children}</LucideContext.Provider>;
|
||||
export function LucideProvider({
|
||||
children,
|
||||
size,
|
||||
color,
|
||||
strokeWidth,
|
||||
absoluteStrokeWidth,
|
||||
}: LucideProviderProps) {
|
||||
const value = useMemo(
|
||||
() => ({
|
||||
size,
|
||||
color,
|
||||
strokeWidth,
|
||||
absoluteStrokeWidth,
|
||||
}),
|
||||
[size, color, strokeWidth, absoluteStrokeWidth],
|
||||
);
|
||||
|
||||
return <LucideContext.Provider value={value}>{children}</LucideContext.Provider>;
|
||||
}
|
||||
|
||||
export const useLucideContext = () => useContext(LucideContext);
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import { forwardRef, createElement } from 'react';
|
||||
import { IconNode, LucideIcon, LucideProps } from './types';
|
||||
|
||||
// import { createElement, forwardRef } from 'react';
|
||||
import { mergeClasses, toKebabCase, toPascalCase } from '@lucide/shared';
|
||||
// import { IconNode, LucideProps } from './types';
|
||||
import { IconNode, LucideProps } from './types';
|
||||
import { toPascalCase } from '@lucide/shared';
|
||||
import Icon from './Icon';
|
||||
|
||||
/**
|
||||
|
||||
@@ -63,18 +63,18 @@ describe('Using LucideProvider', () => {
|
||||
strokeWidth={4}
|
||||
>
|
||||
<House
|
||||
size={24}
|
||||
size={32}
|
||||
color="blue"
|
||||
strokeWidth={2}
|
||||
strokeWidth={3}
|
||||
/>
|
||||
</LucideProvider>,
|
||||
);
|
||||
|
||||
const IconComponent = container.firstElementChild;
|
||||
|
||||
expect(IconComponent).toHaveAttribute('width', '24');
|
||||
expect(IconComponent).toHaveAttribute('height', '24');
|
||||
expect(IconComponent).toHaveAttribute('width', '32');
|
||||
expect(IconComponent).toHaveAttribute('height', '32');
|
||||
expect(IconComponent).toHaveAttribute('stroke', 'blue');
|
||||
expect(IconComponent).toHaveAttribute('stroke-width', '2');
|
||||
expect(IconComponent).toHaveAttribute('stroke-width', '3');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -83,7 +83,7 @@ describe('Using lucide icon components', () => {
|
||||
expect(container.innerHTML).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should use context values from he global set properties', () => {
|
||||
it('should use context values from the global set properties', () => {
|
||||
const { container } = render(ContextWrapper);
|
||||
|
||||
const IconComponent = container.firstElementChild;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { h } from 'vue';
|
||||
import type { FunctionalComponent } from 'vue';
|
||||
import { IconNode, LucideProps, LucideIcon } from './types';
|
||||
import { IconNode, LucideIcon } from './types';
|
||||
import Icon from './Icon';
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user