/** @jsx jsx */ import { SVGAttributes, forwardRef } from 'react'; import { ResponsiveProp, jsx } from '@elemental-ui-alpha/core'; import { ElementalNamedTheme, useElementalTheme, } from '@elemental-ui-alpha/theme'; import { useMediaQuery } from '@elemental-ui-alpha/utils'; export type IconProps = SVGAttributes & { /** The color key for the SVG fill property. */ fill?: ResponsiveProp | string; /** The size key for the icon. */ size?: ResponsiveProp | number; }; const sizeMap = { xsmall: 8, small: 16, medium: 24, large: 32, }; export const createIcon = ( children: React.ReactNode, name: string, viewBox: string ) => { let Icon = forwardRef( ({ size = 'medium', fill = 'currentColor', ...props }, ref) => { const theme = useElementalTheme(); const { mq, mapResponsiveProp } = useMediaQuery(); const resolvedSize = typeof size === 'number' ? size : mapResponsiveProp(size, sizeMap); const resolvedColor = fill in theme.foreground ? mapResponsiveProp( fill as keyof typeof theme.foreground, theme.foreground ) : fill; return ( ); } ); Icon.displayName = name; return Icon; };