index.js
21 lines
| 1 | import classNames from 'classnames'; |
| 2 | import styles from './styles.module.scss'; |
| 3 | |
| 4 | const Label = ({type, text}) => { |
| 5 | const labelClasses = classNames( |
| 6 | styles.label, |
| 7 | {[styles.error]: type === 'error' || type === 'failed'}, |
| 8 | {[styles.warning]: type === 'warning' || type === 'incomplete' || type === 'reversed'}, |
| 9 | {[styles.notice]: type === 'notice'}, |
| 10 | {[styles.success]: type === 'success'}, |
| 11 | {[styles.info]: type === 'info' || type === 'running'}, |
| 12 | {[styles.http]: type.toUpperCase() === 'HTTP'} |
| 13 | ); |
| 14 | |
| 15 | const labelText = text && text.length > 0 ? text : type.charAt(0).toUpperCase() + type.slice(1); |
| 16 | |
| 17 | return <div className={labelClasses}>{labelText}</div>; |
| 18 | }; |
| 19 | |
| 20 | export default Label; |
| 21 |