| 1 |
import { arrayToClassName } from 'elementor-app/utils/utils.js'; |
| 2 |
|
| 3 |
import Text from 'elementor-app/ui/atoms/text'; |
| 4 |
import Icon from 'elementor-app/ui/atoms/icon'; |
| 5 |
import Grid from 'elementor-app/ui/grid/grid'; |
| 6 |
|
| 7 |
import './notice.scss'; |
| 8 |
|
| 9 |
const iconsClassesMap = { |
| 10 |
danger: 'eicon-warning', |
| 11 |
info: 'eicon-info-circle-o', |
| 12 |
warning: 'eicon-warning', |
| 13 |
}; |
| 14 |
|
| 15 |
export default function Notice( props ) { |
| 16 |
const baseClassName = 'eps-notice', |
| 17 |
classes = [ baseClassName, props.className ]; |
| 18 |
|
| 19 |
if ( props.color ) { |
| 20 |
classes.push( baseClassName + '-semantic', baseClassName + '--' + props.color ); |
| 21 |
} |
| 22 |
|
| 23 |
return ( |
| 24 |
<Grid className={ arrayToClassName( classes ) } container noWrap alignItems="center" justify="space-between"> |
| 25 |
<Grid item container alignItems="start" noWrap> |
| 26 |
{ |
| 27 |
props.withIcon && |
| 28 |
props.color && |
| 29 |
<Icon className={ arrayToClassName( [ 'eps-notice__icon', iconsClassesMap[ props.color ] ] ) } /> |
| 30 |
} |
| 31 |
|
| 32 |
<Text variant="xs" className="eps-notice__text"> |
| 33 |
{ props.label && <strong>{ props.label + ' ' }</strong> } |
| 34 |
|
| 35 |
{ props.children } |
| 36 |
</Text> |
| 37 |
</Grid> |
| 38 |
|
| 39 |
{ |
| 40 |
props.button && |
| 41 |
<Grid item container justify="end" className={ baseClassName + '__button-container' }> |
| 42 |
{ props.button } |
| 43 |
</Grid> |
| 44 |
} |
| 45 |
</Grid> |
| 46 |
); |
| 47 |
} |
| 48 |
|
| 49 |
Notice.propTypes = { |
| 50 |
className: PropTypes.string, |
| 51 |
color: PropTypes.string, |
| 52 |
label: PropTypes.string, |
| 53 |
children: PropTypes.any.isRequired, |
| 54 |
icon: PropTypes.string, |
| 55 |
withIcon: PropTypes.bool, |
| 56 |
button: PropTypes.object, |
| 57 |
}; |
| 58 |
|
| 59 |
Notice.defaultProps = { |
| 60 |
className: '', |
| 61 |
withIcon: true, |
| 62 |
button: null, |
| 63 |
}; |
| 64 |
|