1
0
mirror of https://github.com/vercel/commerce.git synced 2025-09-18 22:00:17 +00:00
Files
commerce/components/hero-icon.tsx

18 lines
482 B
TypeScript

import * as HeroIcons from '@heroicons/react/24/outline';
import startcase from 'lodash.startcase';
type IconName = keyof typeof HeroIcons;
interface IconProps {
icon: string;
className?: string;
}
const DynamicHeroIcon = ({ icon, className }: IconProps) => {
const _icon = startcase(icon).replace(/\s/g, '');
const SingleIcon = HeroIcons[`${_icon}Icon` as IconName];
return SingleIcon ? <SingleIcon className={className} /> : null;
};
export default DynamicHeroIcon;