mirror of
https://github.com/iconoir-icons/iconoir
synced 2024-06-08 08:52:19 +02:00
37 lines
915 B
JavaScript
37 lines
915 B
JavaScript
|
const template = (native) => {
|
||
|
const useClientDirective = native ? '' : '"use client";';
|
||
|
|
||
|
const imports = [
|
||
|
'import React from "react";',
|
||
|
...(native ? ['import type { SvgProps } from "react-native-svg";'] : []),
|
||
|
].join('\n');
|
||
|
|
||
|
return `
|
||
|
${useClientDirective}
|
||
|
${imports}
|
||
|
|
||
|
type IconoirContextValue = Partial<${
|
||
|
native ? 'SvgProps' : 'React.SVGProps<SVGSVGElement>'
|
||
|
}>;
|
||
|
|
||
|
export const IconoirContext = React.createContext<IconoirContextValue>({});
|
||
|
|
||
|
export interface IconoirProviderProps {
|
||
|
iconProps?: Partial<${
|
||
|
native ? `Omit<SvgProps, 'children'>` : 'React.SVGProps<SVGSVGElement>'
|
||
|
}>;
|
||
|
children: React.ReactNode;
|
||
|
}
|
||
|
|
||
|
export function IconoirProvider({ iconProps, children }: IconoirProviderProps) {
|
||
|
return (
|
||
|
<IconoirContext.Provider value={iconProps || {}} children={children} />
|
||
|
);
|
||
|
}
|
||
|
`;
|
||
|
};
|
||
|
|
||
|
export default template;
|
||
|
|
||
|
export const exports = ['IconoirContext', 'IconoirProvider'];
|