refactor: changes per PR feedback

This commit is contained in:
Antonella Sgarlatta
2021-05-07 19:17:57 -03:00
parent 3906b9a9b4
commit 8f29b62744
7 changed files with 78 additions and 102 deletions

View File

@@ -11,42 +11,28 @@ import RestoreIcon from '../../icons/ic-restore.svg';
import CloseIcon from '../../icons/ic-close.svg';
import { toDirective } from './utils';
export enum IconType {
PencilOff = 'pencil-off',
RichText = 'rich-text',
Trash = 'trash',
Pin = 'pin',
Unpin = 'unpin',
Archive = 'archive',
Unarchive = 'unarchive',
Hashtag = 'hashtag',
ChevronRight = 'chevron-right',
Restore = 'restore',
Close = 'close',
}
const ICONS = {
[IconType.PencilOff]: PencilOffIcon,
[IconType.RichText]: RichTextIcon,
[IconType.Trash]: TrashIcon,
[IconType.Pin]: PinIcon,
[IconType.Unpin]: UnpinIcon,
[IconType.Archive]: ArchiveIcon,
[IconType.Unarchive]: UnarchiveIcon,
[IconType.Hashtag]: HashtagIcon,
[IconType.ChevronRight]: ChevronRightIcon,
[IconType.Restore]: RestoreIcon,
[IconType.Close]: CloseIcon,
'pencil-off': PencilOffIcon,
'rich-text': RichTextIcon,
'trash': TrashIcon,
'pin': PinIcon,
'unpin': UnpinIcon,
'archive': ArchiveIcon,
'unarchive': UnarchiveIcon,
'hashtag': HashtagIcon,
'chevron-right': ChevronRightIcon,
'restore': RestoreIcon,
'close': CloseIcon,
};
type Props = {
type: IconType;
type: keyof (typeof ICONS);
className: string;
}
export const Icon: React.FC<Props> = ({ type, className }) => {
const IconComponent = ICONS[type];
return IconComponent ? <IconComponent className={className} /> : null;
return <IconComponent className={className} />;
};
export const IconDirective = toDirective<Props>(