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