All files / src/TagWithIcon TagWithIcon.js

100% Statements 4/4
25% Branches 2/8
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 55                                        1x 1x                                                               1x 1x
import React from 'react';
import { defaultProps } from './props/defaultProps';
import { propTypes } from './props/propTypes';
import { Container, Box } from '@zohodesk/components/es/Layout';
import Icon from '@zohodesk/icons/es/Icon';
import style from './TagWithIcon.module.css';
 
export default class TagWithIcon extends React.Component {
  render() {
    const {
      text,
      iconName,
      iconSize,
      palette,
      iconClass,
      isBold,
      size,
      dataId,
      className,
      title
    } = this.props;
    return (
      <Container
        isInline
        alignBox='row'
        align='vertical'
        isCover={false}
        className={`${style.wrapper} ${style[palette]} ${style[size]} ${className}`}
        dataId={dataId}
        title={title}
      >
        {iconName ? (
          <Icon
            name={iconName}
            size={iconSize}
            iconClass={`${text ? style.iconSpace : ''} ${iconClass} `}
          />
        ) : null}
        {text ? (
          <Box
            shrink
            data-title={text}
            className={`${style.text} ${style[size]}_text ${
              isBold ? style.bold : ''
            }`}
          >
            {text}
          </Box>
        ): null}
      </Container>
    );
  }
}
TagWithIcon.propTypes = propTypes;
TagWithIcon.defaultProps = defaultProps;