mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-15 14:08:49 +00:00
* fix(lucide-react): correct client directives in RSC files * format code * Add TS ignore --------- Co-authored-by: Eric Fennis <eric.fennis@gmail.com>
43 lines
896 B
TypeScript
43 lines
896 B
TypeScript
'use client';
|
|
|
|
import { createContext, createElement, type ReactNode, useContext, useMemo } from 'react';
|
|
import { LucideProps } from './types';
|
|
|
|
type LucideConfig = {
|
|
size: number;
|
|
color: string;
|
|
strokeWidth: number;
|
|
absoluteStrokeWidth: boolean;
|
|
className: string;
|
|
};
|
|
|
|
const LucideContext = createContext<LucideProps>({});
|
|
|
|
type LucideProviderProps = {
|
|
children: ReactNode;
|
|
} & Partial<LucideConfig>;
|
|
|
|
export function LucideProvider({
|
|
children,
|
|
size,
|
|
color,
|
|
strokeWidth,
|
|
absoluteStrokeWidth,
|
|
className,
|
|
}: LucideProviderProps) {
|
|
const value = useMemo(
|
|
() => ({
|
|
size,
|
|
color,
|
|
strokeWidth,
|
|
absoluteStrokeWidth,
|
|
className,
|
|
}),
|
|
[size, color, strokeWidth, absoluteStrokeWidth, className],
|
|
);
|
|
|
|
return createElement(LucideContext.Provider, { value }, children);
|
|
}
|
|
|
|
export const useLucideContext = () => useContext(LucideContext);
|