1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import React from 'react';
- import { IconWrapper, ClickZone } from './styled';
- import data from './data';
- type Props = {
- id?: string;
- glyph: string;
- onClick?: (e: any) => void;
- onBlur?: () => void;
- style?: {};
- isActive?: boolean;
- isDisabled?: boolean;
- };
- const Icon: React.FC<Props> = ({
- glyph,
- id = '',
- onClick,
- onBlur,
- style,
- isActive = false,
- isDisabled = false,
- }: Props) => {
- const { Normal, Hover } = data[glyph];
- return (
- <IconWrapper isHover={!!Hover} style={style} isDisabled={isDisabled}>
- {Normal && <Normal data-status="normal" />}
- {Hover && <Hover data-status="hover" />}
- {isActive && Hover ? <Hover data-status="active" /> : null}
- <ClickZone
- id={id}
- onMouseDown={
- isDisabled
- ? (): void => {
- // do something
- }
- : onClick
- }
- onBlur={onBlur}
- />
- </IconWrapper>
- );
- };
- export default Icon;
|