|
| 1 | +import React from 'react'; |
| 2 | +import classNames from 'classnames'; |
| 3 | +import PropTypes from 'prop-types'; |
| 4 | + |
| 5 | +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; |
| 6 | +import { faSpinnerThird } from '@fortawesome/pro-solid-svg-icons'; |
| 7 | + |
| 8 | +import './LoadingOverlay.scss'; |
| 9 | + |
| 10 | +const LoadingOverlay = (props) => { |
| 11 | + // Only set style if this is not visible to let CSS handle how to display this |
| 12 | + const classes = classNames( |
| 13 | + 'overlay', |
| 14 | + { |
| 15 | + 'overlay--text': !!props.text, |
| 16 | + 'overlay--content-top': props.contentTop, |
| 17 | + }, |
| 18 | + ); |
| 19 | + |
| 20 | + return ( |
| 21 | + <div |
| 22 | + className={classes} |
| 23 | + style={props.visible ? {} : { display: 'none' }} |
| 24 | + > |
| 25 | + { props.header && ( |
| 26 | + <p className="overlay__header"> |
| 27 | + {props.header} |
| 28 | + </p> |
| 29 | + )} |
| 30 | + { props.text && <p className={props.textClassName}>{props.text}</p> } |
| 31 | + |
| 32 | + <FontAwesomeIcon className="fa-spinner" icon={faSpinnerThird} /> |
| 33 | + </div> |
| 34 | + ); |
| 35 | +}; |
| 36 | + |
| 37 | +LoadingOverlay.propTypes = { |
| 38 | + contentTop: PropTypes.bool, |
| 39 | + header: PropTypes.string, |
| 40 | + text: PropTypes.string, |
| 41 | + textClassName: PropTypes.string, |
| 42 | + visible: PropTypes.bool, |
| 43 | +}; |
| 44 | + |
| 45 | +LoadingOverlay.defaultProps = { |
| 46 | + contentTop: false, |
| 47 | + header: undefined, |
| 48 | + text: undefined, |
| 49 | + textClassName: undefined, |
| 50 | + visible: true, |
| 51 | +}; |
| 52 | + |
| 53 | +export default LoadingOverlay; |
0 commit comments