Skip to content

Instantly share code, notes, and snippets.

@Natanagar
Created October 1, 2019 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Natanagar/2bf77400041b8885cfc821b163e4f315 to your computer and use it in GitHub Desktop.
Save Natanagar/2bf77400041b8885cfc821b163e4f315 to your computer and use it in GitHub Desktop.
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