All files / src/common/components/warning Warning.js

100% Statements 3/3
100% Branches 10/10
100% Functions 1/1
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54            2x                   4x                                                 2x                        
import React from 'react'
import * as PropTypes from 'prop-types'
 
import Button from 'common/components/button'
import './Warning.scss'
 
const Warning = ({
  image,
  imageAlt,
  title,
  description,
  footerMessage,
  callToActionText,
  callToActionType,
  onClickCallToAction,
}) => (
  <div className="warning animate__animated animate__fadeIn" role="alert">
    <div className="warning__content">
      {image && (
        <div className="warning__image" role="presentation">
          <img alt={imageAlt} src={image} />
        </div>
      )}
      {title && <div className="warning__title">{title}</div>}
      {description && <div className="warning__description">{description}</div>}
      {footerMessage && <div className="warning__footer-message">{footerMessage}</div>}
    </div>
    {callToActionText && (
      <div className="warning__footer">
        <Button
          styleType={callToActionType}
          className="warning__footer--button"
          onClick={onClickCallToAction}
        >
          {callToActionText}
        </Button>
      </div>
    )}
  </div>
)
 
Warning.propTypes = {
  image: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
  imageAlt: PropTypes.string,
  title: PropTypes.string,
  description: PropTypes.string,
  footerMessage: PropTypes.string,
  callToActionText: PropTypes.string,
  callToActionType: PropTypes.oneOf(['primary', 'secondary']),
  onClickCallToAction: PropTypes.func,
}
 
export default Warning