forked from lucide-icons/lucide
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontext.ts
More file actions
42 lines (35 loc) · 896 Bytes
/
context.ts
File metadata and controls
42 lines (35 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'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);