build.mjs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/env node
  2. import { buildIcons } from '../../.build/build-icons.mjs'
  3. const componentTemplate = ({
  4. name,
  5. namePascal,
  6. children
  7. }) => `\
  8. import createPreactComponent from '../createPreactComponent';
  9. export default createPreactComponent('${name}', '${namePascal}', ${JSON.stringify(children)});`;
  10. const indexItemTemplate = ({
  11. name,
  12. namePascal
  13. }) => `export { default as ${namePascal} } from './icons/${name}';`
  14. const typeDefinitionsTemplate = () => `/// <reference types="preact" />
  15. import { JSX, RefObject } from 'preact'
  16. interface TablerIconsProps extends Partial<Omit<JSX.SVGAttributes, "ref" | "size">> {
  17. key?: string | number;
  18. ref?: string | ((component: any) => any) | RefObject<any>;
  19. color?: string
  20. size?: string | number
  21. }
  22. // Generated icons`
  23. const indexTypeTemplate = ({
  24. namePascal
  25. }) => `export declare const ${namePascal}: (props: TablerIconsProps) => JSX.Element;`
  26. buildIcons({
  27. name: 'icons-preact',
  28. componentTemplate,
  29. indexItemTemplate,
  30. typeDefinitionsTemplate,
  31. indexTypeTemplate
  32. })