exportTemplate.mjs 954 B

12345678910111213141516171819202122232425262728
  1. /* eslint-disable import/no-extraneous-dependencies */
  2. import { base64SVG } from '@supabase/build-icons'
  3. export default ({ componentName, iconName, children, getSvg, deprecated, svgAttributes = {} }) => {
  4. const svgContents = getSvg()
  5. const svgBase64 = base64SVG(svgContents)
  6. const hasAttrs = Object.keys(svgAttributes).length > 0
  7. const attrsArg = hasAttrs ? `, ${JSON.stringify(svgAttributes)}` : ''
  8. return `
  9. import createBrivenIcon from '../createBrivenIcon';
  10. /**
  11. * @component @name ${componentName}
  12. * @description Briven SVG icon component, renders SVG Element with children.
  13. *
  14. * @preview ![img](data:image/svg+xml;base64,${svgBase64})
  15. *
  16. * @param {Object} props - Briven icons props and any valid SVG attribute
  17. * @returns {JSX.Element} JSX Element
  18. * ${deprecated ? '@deprecated' : ''}
  19. */
  20. const ${componentName} = createBrivenIcon('${componentName}', ${JSON.stringify(children)}${attrsArg});
  21. export default ${componentName};
  22. `
  23. }