All files / src/alert/AlertHeader AlertHeader.js

100% Statements 5/5
100% Branches 16/16
100% Functions 1/1
100% Lines 5/5

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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85                                                20x 20x             20x                                                                                   2x   2x                
import React, { Component } from 'react';
import { defaultProps } from './props/defaultProps';
import { propTypes } from './props/propTypes';
import Title from '../../lookup/header/Title/Title';
import { Container, Box } from '@zohodesk/components/lib/Layout';
import { Icon } from '@zohodesk/icons';
import Close from '../../lookup/header/Close/Close';
import style from './AlertHeader.module.css';
 
export default class AlertHeader extends Component {
  render() {
    let {
      title,
      palette,
      needIcon,
      iconType,
      onClose,
      iconName,
      iconSize,
      closeTitle,
      children,
      breakChildren,
      dataId,
      iconClass
    } = this.props;
    let iconObj = {
      delete: 'ZD-socialDelete',
      alert: 'ZD-exclamationThincircle',
      remoteAssist: 'ZD-taskDemo',
      splitTicket: 'ZD-splitNew',
      update: 'ZD-update'
    };
    return (
      <Container
        align='vertical'
        alignBox='row'
        className={`${style.container} ${style[palette]}`}
        isCover={false}
        wrap='wrap'
        dataId={`${dataId}_alertHeader`}
      >
        {needIcon ? (
          <div className={style.iconContainer}>
            <Icon
              size={iconSize}
              name={iconName ? iconName : iconObj[iconType] ? iconObj[iconType] : iconName}
              iconClass={`${style.iconStyle} ${iconObj[iconType] && !iconSize ? style[`icon_${iconType}`] : ''} ${
                style[`text_${palette}`]
              } ${iconClass}`}
            />
          </div>
        ) : null}
        <Box flexible>
          <Container alignBox='row' align='vertical' wrap={breakChildren ? 'wrap' : null}>
            <Box className={style.title} shrink>
              <Title text={title} palette={palette} />
            </Box>
            {children ? (
              <Box adjust flexible>
                {children}
              </Box>
            ) : null}
          </Container>
        </Box>
        {onClose ? (
          <Box>
            <Close onClose={onClose} title={closeTitle} dataId={`${dataId}_close`} />
          </Box>
        ) : null}
      </Container>
    );
  }
}
 
AlertHeader.propTypes = propTypes;
 
AlertHeader.defaultProps = defaultProps;
 
// if (__DOCS__) {
//   AlertHeader.docs = {
//     componentGroup: 'AlertHeader',
//     folderName: 'Alert'
//   };
// }