1
0
mirror of https://github.com/tabler/tabler-icons.git synced 2025-01-17 12:48:26 +01:00
Tim Heerwagen 7d1f101f00
Generate dynamic imports for icons-react (#1081)
Co-authored-by: Paweł Kuna <1282324+codecalm@users.noreply.github.com>
2024-09-27 22:09:40 +02:00

32 lines
858 B
JavaScript

#!/usr/bin/env node
import {
buildJsIcons,
buildIconsList,
buildIconsDynamicImport,
} from '../../.build/build-icons.mjs';
const componentTemplate = ({ type, name, namePascal, children }) => `\
import createReactComponent from '../createReactComponent';
export default createReactComponent('${type}', '${name}', '${namePascal}', ${JSON.stringify(children)});`;
const indexItemTemplate = ({ name, namePascal }) =>
`export { default as ${namePascal} } from './${namePascal}';`;
const aliasTemplate = ({ fromPascal, toPascal }) =>
`export { default as Icon${fromPascal} } from './icons/Icon${toPascal}';\n`;
buildJsIcons({
name: 'icons-react',
componentTemplate,
indexItemTemplate,
aliasTemplate,
indexFile: 'index.ts',
pascalCase: true,
extension: 'ts',
});
buildIconsList('icons-react');
buildIconsDynamicImport('icons-react');