Created
October 1, 2019 21:51
-
-
Save Natanagar/2bf77400041b8885cfc821b163e4f315 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Icon, Tag } from 'antd'; | |
import React, { FC } from 'react'; | |
import styles from './Label.module.scss'; | |
import { LabelProps, LabelIconProps, LabelCrossProps } from './interfaces'; | |
let className; | |
const BaseLabel: FC<LabelProps> = (props) => { | |
const { color, text, opacity, backgroundColor, size } = props; | |
className = `ant-label-${size}`; | |
const style = [styles.label, className, styles.position].join(' '); | |
const labelStyle = { color, opacity }; | |
const IconLeft = () => { | |
return ( | |
<> | |
{text} | |
<Icon className={styles.icon} type="check" /> | |
</> | |
); | |
}; | |
const IconRight = () => { | |
return ( | |
<> | |
{text} | |
<Icon className={styles.icon} type="check" /> | |
</> | |
); | |
}; | |
const IconTag = ({ position }) => { | |
if (position === 'left') { | |
return <IconLeft />; | |
} else { | |
return <IconRight />; | |
} | |
}; | |
return ( | |
<> | |
<Tag color={props.backgroundColor} style={labelStyle} className={style}> | |
<IconTag position={iconPosition} /> | |
</Tag> | |
</> | |
); | |
}; | |
const Label = { | |
BaseLabel, | |
}; | |
/*Label.defaultProps = { | |
color: '#1d1d1d', | |
text: 'Label', | |
opacity: 1, | |
size: 'default', | |
backgroundColor: 'rgba(1,113,211,0.05)', | |
//iconPosition: 'right', | |
};*/ | |
export default Label; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment