mirror of
https://github.com/iconoir-icons/iconoir
synced 2024-05-23 00:32:22 +02:00
27 lines
594 B
JavaScript
27 lines
594 B
JavaScript
const template = (
|
|
{ template },
|
|
opts,
|
|
{ imports, interfaces, componentName, props, jsx, exports }
|
|
) => {
|
|
const plugins = ['jsx'];
|
|
if (opts.typescript) {
|
|
plugins.push('typescript');
|
|
}
|
|
const typeScriptTpl = template.smart({ plugins });
|
|
props[0].name = 'passedProps';
|
|
return typeScriptTpl.ast`${imports}
|
|
import { IconoirContext } from './IconoirContext'
|
|
|
|
${interfaces}
|
|
|
|
function ${componentName}(${props}) {
|
|
const context = React.useContext(IconoirContext);
|
|
const props = { ...context, ...passedProps };
|
|
return ${jsx};
|
|
}
|
|
${exports}
|
|
`;
|
|
};
|
|
|
|
module.exports = template;
|