All files / src/Checkbox styles.ts

92.86% Statements 13/14
100% Branches 2/2
85.71% Functions 6/7
100% Lines 8/8

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        72x                     72x                               72x                   3x 72x                                                                     16x           19x           3x          
import { css, cssClass } from '../styled';
import { palette, theme, fontWeight } from '../utils';
import { getHiddenInputStyles } from '../utils/getHiddenInputStyles';
 
export const Checkbox = styleProps => cssClass`
  && {
    display: flex;
    align-items: flex-start;
  }
 
  & {
    ${theme(styleProps.themeKey, `css.root`)(styleProps)};
  }
`;
 
export const CheckboxIcon = styleProps => cssClass`
  -webkit-appearance: none;
  background-color: white;
  border: 1px solid #bdbdbd;
  border-radius: 0.2em;
  height: 1em;
  position: relative;
  min-width: 1em;
  width: 1em;
  transition: box-shadow 0.1s ease-in-out 0s, border-color 0.1s, background-color 0.1s;
 
  & {
    ${theme(styleProps.themeKey, `css.root`)(styleProps)};
  }
`;
 
export const CheckboxLabel = styleProps => cssClass`
  && {
    font-weight: ${fontWeight('normal')(styleProps)};
  }
 
  & {
    ${theme(styleProps.themeKey, `css.root`)(styleProps)};
  }
`;
 
export const HiddenCheckbox = styleProps =>
  getHiddenInputStyles({
    iconClassName: 'fp-CheckboxIcon',
    checkedIconCss: css`
      background-clip: padding-box;
      content: '';
      left: calc(50% - 0.1875em);
      top: calc(50% - 0.375em);
      position: absolute;
 
      & {
        ${styleProps.indeterminate
          ? css`
              background-color: ${palette('primary')(styleProps)};
              height: 0.125em;
              width: 0.625em;
              top: calc(50% - 0.0625em);
              left: calc(50% - 0.3125em);
            `
          : css`
              border: 0.1em solid ${palette('primary')(styleProps)};
              border-left-width: 0;
              border-top-width: 0;
              height: 0.625em;
              transform: rotate(45deg);
              width: 0.375em;
            `};
      }
    `,
    disabledCheckedIconCss: css`
      border-color: ${palette('gray300')(styleProps)};
    `,
    styleProps,
    themeKey: 'Checkbox.Icon'
  });
 
export const CheckboxGroup = styleProps => cssClass`
  & {
    ${theme(styleProps.themeKey, `css.root`)(styleProps)};
  }
`;
 
export const CheckboxField = styleProps => cssClass`
  & {
    ${theme(styleProps.themeKey, `css.root`)(styleProps)};
  }
`;
 
export const CheckboxGroupField = styleProps => cssClass`
  & {
    ${theme(styleProps.themeKey, `css.root`)(styleProps)};
  }
`;