Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

964 B
Raw Blame
/* eslint-disable import/no-extraneous-dependencies */
import { base64SVG } from '@supabase/build-icons'

export default ({ componentName, iconName, children, getSvg, deprecated, svgAttributes = {} }) => {
  const svgContents = getSvg()
  const svgBase64 = base64SVG(svgContents)

  const hasAttrs = Object.keys(svgAttributes).length > 0
  const attrsArg = hasAttrs ? `, ${JSON.stringify(svgAttributes)}` : ''

  return `
import createSupabaseIcon from '../createSupabaseIcon';

/**
 * @component @name ${componentName}
 * @description Supabase SVG icon component, renders SVG Element with children.
 *
 * @preview ![img](data:image/svg+xml;base64,${svgBase64})
 *
 * @param {Object} props - Supabase icons props and any valid SVG attribute
 * @returns {JSX.Element} JSX Element
 * ${deprecated ? '@deprecated' : ''}
 */
const ${componentName} = createSupabaseIcon('${componentName}', ${JSON.stringify(children)}${attrsArg});

export default ${componentName};
`
}