All files / src/Tag styles.ts

100% Statements 11/11
100% Branches 6/6
100% Functions 5/5
100% Lines 7/7

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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105      37x                                       37x                     37x                                                                   2x                       1x 37x                                         37x    
import { cssClass, css } from '../styled';
import { borderRadius, darken, fontSize, fontWeight, palette, space, theme } from '../utils';
 
export const Tag = styleProps => cssClass`
  align-items: center;
  background-color: ${palette(styleProps.palette)(styleProps)};
  border-radius: ${borderRadius('default')(styleProps)};
  color: ${palette(`${styleProps.palette}Inverted`)(styleProps)};
  display: inline-flex;
  fill: ${palette(`${styleProps.palette}Inverted`)(styleProps)};
  font-size: ${fontSize('100')(styleProps)}rem;
  font-weight: ${fontWeight('semibold')(styleProps)};
  height: 1.5rem;
  justify-content: center;
 
  ${styleProps.kind === 'outlined' && outlinedProperties(styleProps)}
  ${styleProps.size && sizeProperties(styleProps)}
 
  & {
    ${theme(styleProps.themeKey, `css.root`)(styleProps)};
  }
`;
 
export const TagContent = styleProps => cssClass`
  align-items: center;
  display: flex;
  height: inherit;
  padding: 0 ${space(3)(styleProps)}em;
 
  & {
    ${theme(styleProps.themeKey, `css.root`)(styleProps)};
  }
`;
 
export const TagClose = styleProps => cssClass`
  &&& {
    background-color: ${palette(styleProps.palette)(styleProps)};
    color: ${palette(`${styleProps.palette}Inverted`)(styleProps)};
    fill: ${palette(`${styleProps.palette}Inverted`)(styleProps)};
    height: 1.5em;
    padding: 0 ${space(1)(styleProps)}em;
    margin-right: ${space(1)(styleProps)}em;
    margin-left: -${space(1)(styleProps)}em;
 
    &:hover {
      background-color: ${darken(0.1, palette(styleProps.palette)(styleProps))};
    }
 
    &:focus {
      box-shadow: unset;
    }
 
    ${styleProps.kind === 'outlined' &&
      css`
        background-color: unset;
        color: ${palette(styleProps.palette)(styleProps)};
 
        &:hover {
          background-color: ${palette('white700')(styleProps)};
        }
      `}
 
    & {
      ${theme(styleProps.themeKey, `css.root`)(styleProps)};
    }
  }
`;
 
export const outlinedProperties = styleProps => cssClass`
  & {
    background-color: unset;
    border: 1px solid ${palette(styleProps.palette)(styleProps)};
    color: ${palette(styleProps.palette)(styleProps)};
    fill: ${palette(styleProps.palette)(styleProps)};
  }
  & {
    ${theme(styleProps.themeKey, `css.outlined`)(styleProps)};
  }
`;
 
export const sizeProperties = styleProps => {
  const sizes = {
    default: cssClass`
    & {
      ${theme(styleProps.themeKey, `css.sizes.default`)(styleProps)};
    }
  `,
    medium: cssClass`
    font-size: 1em;
    height: 2rem;
    & {
      ${theme(styleProps.themeKey, `css.sizes.medium`)(styleProps)};
    }
  `,
    large: cssClass`
    font-size: 1.25em;
    height: 2.5rem;
    & {
      ${theme(styleProps.themeKey, `css.sizes.large`)(styleProps)};
    }
  `
  };
  return sizes[styleProps.size];
};