commerce/components/hero-icon.tsx
Chloe a1d65a54c1
feat: implement text/image-with-text/icon-with-text content block
Signed-off-by: Chloe <pinkcloudvnn@gmail.com>
2024-05-23 14:17:55 +07:00

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;