All files / packages/design-system/ui/components/toast index.jsx

100% Statements 4/4
100% Branches 2/2
100% Functions 0/0
100% Lines 4/4

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            8x   7x                                                 1x             1x          
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import ButtonIcon from '../button-icons/';
 
const Toast = props => {
  const { containerClassName, className, type, children } = props;
 
  return (
    <div className={classNames('slds-notify_container', containerClassName)}>
      <div
        className={classNames(
          'slds-notify slds-notify_toast',
          className,
          type && 'slds-theme_' + type
        )}
        role="status"
      >
        <span className="slds-assistive-text">{type}</span>
        {children}
        <div className="slds-notify__close">
          <ButtonIcon
            className="slds-button_icon-inverse"
            symbol="close"
            assistiveText="Close"
            title="Close"
          />
        </div>
      </div>
    </div>
  );
};
 
Toast.propTypes = {
  containerClassName: PropTypes.string,
  className: PropTypes.string,
  type: PropTypes.oneOf(['info', 'success', 'warning', 'error']),
  children: PropTypes.node
};
 
Toast.defaultProps = {
  type: 'info'
};
 
export default Toast;