ReactJS
1import React from 'react';
2import {BlockIcon, CommentIcon, IconAnon, MenuIcon, SaveIcon, ShareIcon, WarningIcon} from "../Icons";
3
4export interface IIconBaseProp{
5size: number
6}
7export enum EIcons{
8block='block',
9comment='comment',
10save='save',
11share='share',
12warning='warning',
13menu='menu',
14iconAnon='iconAnon'
15}
16
17const getIcon = (size: number) => ({
18block: <BlockIcon size={size}/>,
19comment: <CommentIcon size={size}/>,
20save: <SaveIcon size={size}/>,
21share: <ShareIcon size={size}/>,
22warning: <WarningIcon size={size}/>,
23menu: <MenuIcon size={size}/>,
24iconAnon: <IconAnon size={size}/>,
25});
26
27interface IIconProps {
28name: EIcons,
29size?: number
30}
31
32export function Icon({name, size = 14}: IIconProps) {
33return (
34getIcon(size)[name]
35);
36}
37