All files / src/Switch styles.ts

92.86% Statements 13/14
100% Branches 10/10
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        70x                     70x                           70x                   3x 70x                                                                       16x           18x           3x          
import { css, cssClass } from '../styled';
import { palette, tint, theme, fontWeight } from '../utils';
import { getHiddenInputStyles } from '../utils/getHiddenInputStyles';
 
export const Switch = styleProps => cssClass`
  && {
    display: flex;
    align-items: center;
  }
 
  & {
    ${theme(styleProps.themeKey, `css.root`)(styleProps)};
  }
`;
 
export const SwitchIcon = styleProps => cssClass`
  background-color: white;
  border: 1px solid #bdbdbd;
  border-radius: 1em;
  height: 1.5em;
  position: relative;
  width: 2.5em;
  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 SwitchLabel = styleProps => cssClass`
  && {
    font-weight: ${fontWeight('normal')(styleProps)};
  }
 
  & {
    ${theme(styleProps.themeKey, `css.root`)(styleProps)};
  }
`;
 
export const HiddenSwitch = styleProps =>
  getHiddenInputStyles({
    iconClassName: 'fp-SwitchIcon',
    checkedCss: css`
      background-color: ${palette(styleProps.palette || 'primary')(styleProps)};
      transition: all ease 0.2s;
    `,
    disabledCheckedCss: css`
      background-color: ${tint(0.5, palette(styleProps.palette || 'primary')(styleProps))};
      border-color: ${tint(0.5, palette(styleProps.palette || 'primary')(styleProps))};
    `,
    disabledUncheckedIconCss: css`
      background: ${palette('white700')(styleProps)};
    `,
    checkedIconCss: css`
      border-color: ${palette(styleProps.palette || 'primary')(styleProps)};
      left: 1.25em;
    `,
    disabledCheckedIconCss: css`
      border-color: ${tint(0.5, palette(styleProps.palette || 'primary')(styleProps))};
    `,
    uncheckedIconCss: css`
      background: white;
      content: '';
      border-radius: 100%;
      border: 1px solid #bdbdbd;
      height: 1em;
      width: 1em;
      top: 0.2em;
      left: 0.2em;
      transition: all ease 0.2s;
      position: absolute;
    `,
    styleProps,
    themeKey: 'Switch.Icon'
  });
 
export const SwitchGroup = styleProps => cssClass`
  & {
    ${theme(styleProps.themeKey, `css.root`)(styleProps)};
  }
`;
 
export const SwitchField = styleProps => cssClass`
  & {
    ${theme(styleProps.themeKey, `css.root`)(styleProps)};
  }
`;
 
export const SwitchGroupField = styleProps => cssClass`
  & {
    ${theme(styleProps.themeKey, `css.root`)(styleProps)};
  }
`;