mirror of
https://github.com/lucide-icons/lucide.git
synced 2025-12-16 16:57:44 +01:00
44 lines
906 B
TypeScript
44 lines
906 B
TypeScript
import { createContext, type ReactNode, useContext, useMemo } from 'react';
|
|
|
|
const LucideContext = createContext<{
|
|
size?: number;
|
|
color?: string;
|
|
strokeWidth?: number;
|
|
absoluteStrokeWidth?: boolean;
|
|
}>({
|
|
size: 24,
|
|
color: 'currentColor',
|
|
strokeWidth: 2,
|
|
absoluteStrokeWidth: false,
|
|
});
|
|
|
|
interface LucideProviderProps {
|
|
children: ReactNode;
|
|
size?: number;
|
|
color?: string;
|
|
strokeWidth?: number;
|
|
absoluteStrokeWidth?: boolean;
|
|
}
|
|
|
|
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);
|