All files / src/MessageBanner MessageBanner.js

100% Statements 4/4
100% Branches 4/4
100% Functions 1/1
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 47 48 49 50 51 52 53 54                    9x   9x                                                                 1x 1x              
import React from 'react';
import { defaultProps } from './props/defaultProps';
import { propTypes } from './props/propTypes';
import Link from '../Link/Link';
import { Icon } from '@zohodesk/icons';
import { Container, Box } from '@zohodesk/components/lib/Layout';
import style from './MessageBanner.module.css';
 
export default class MessageBanner extends React.Component {
  render() {
    let { type, message, onClose, href, onClick, urlText, palette, customClass, dataId, dataSelectorId } = this.props;
 
    return (
      <Container
        className={`${style[`type_${type}`]} ${style[`palette_${palette}`]} ${customClass}`}
        alignBox='row'
        isCover={false}
        dataId={dataId}
        dataSelectorId={dataSelectorId}
      >
        <Box className={style.content} flexible>
          <Container alignBox='row' align='both'>
            <Box className={style.message} adjust shrink data-title={message}>
              {message}
            </Box>
            {href && (
              <Box>
                <Link href={href} onClick={onClick} className={style.link} target='_blank' dataId={`${dataId}_link`}>
                  {urlText}
                </Link>
              </Box>
            )}
          </Container>
        </Box>
        {onClose ? (
          <Box className={style.close} onClick={onClose} dataId={`${dataId}_close`}>
            <Container align='both'>
              <Icon name='ZD-closee' size='35' />
            </Container>
          </Box>
        ) : null}
      </Container>
    );
  }
}
MessageBanner.defaultProps = defaultProps;
MessageBanner.propTypes = propTypes;
 
// if (__DOCS__) {
//   MessageBanner.docs = {
//     componentGroup: 'Atom'
//   };
// }