forked from cerc-io/snowballtools-base
Part of [Service provider auctions for web deployments](https://www.notion.so/Service-provider-auctions-for-web-deployments-104a6b22d47280dbad51d28aa3a91d75) Co-authored-by: IshaVenikar <ishavenikar7@gmail.com> Reviewed-on: cerc-io/snowballtools-base#39
28 lines
793 B
TypeScript
28 lines
793 B
TypeScript
import { useMemo } from 'react';
|
|
import { CustomIconProps } from '../CustomIcon';
|
|
import { cloneIcon } from 'utils/cloneIcon';
|
|
import { PWAIcon } from './PWAIcon';
|
|
import { WebAppIcon } from './WebAppIcon';
|
|
|
|
const TEMPLATE_ICONS = ['pwa', 'web'] as const;
|
|
export type TemplateIconType = (typeof TEMPLATE_ICONS)[number];
|
|
|
|
export interface TemplateIconProps extends CustomIconProps {
|
|
type: TemplateIconType;
|
|
}
|
|
|
|
export const TemplateIcon = ({ type, ...props }: TemplateIconProps) => {
|
|
const renderIcon = useMemo(() => {
|
|
switch (type) {
|
|
case 'pwa':
|
|
return <PWAIcon />;
|
|
case 'web':
|
|
return <WebAppIcon />;
|
|
default:
|
|
throw new Error(`Invalid template icon type: ${type}`);
|
|
}
|
|
}, [type]);
|
|
|
|
return cloneIcon(renderIcon, props) as JSX.Element;
|
|
};
|