All files / src/Select styles.ts

100% Statements 12/12
100% Branches 10/10
100% Functions 6/6
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 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136      55x                                                                                                   55x                       55x                                 55x                               17x             6x                                                       6x    
import { css, cssClass } from '../styled';
import { borderRadius, fontSize, palette, tint, theme } from '../utils';
 
export const Select = styleProps => cssClass`
  appearance: none;
  background: linear-gradient(rgb(255, 255, 255), rgb(249, 250, 251));
  border: 1px solid ${palette('white900')(styleProps)};
  border-radius: ${borderRadius('default')(styleProps)};
  color: ${styleProps.isPlaceholderSelected ? tint(0.4, palette('text')(styleProps)) : palette('text')(styleProps)};
  height: 2.75em;
  padding: 0.4em 2em 0.4em 0.8em;
  line-height: 1.5;
  transition: box-shadow 0.1s ease-in-out 0s, border-color 0.1s, background-color 0.1s;
 
  &:hover {
    box-shadow: ${palette(`${styleProps.state || 'primary'}Tint`)(styleProps)} 0px 0px 0px 2px !important;
    border-color: ${palette(`${styleProps.state || 'primary'}100`)(styleProps)};
  }
 
  &[disabled] {
    background: ${palette('white700')(styleProps)};
    box-shadow: unset;
 
    & {
      ${theme(styleProps.themeKey, `css.disabled`)(styleProps)};
    }
  }
 
  &[disabled] + .fp-Icon {
    color: ${palette('gray400')(styleProps)};
    fill: ${palette('gray400')(styleProps)};
  }
 
  &:focus {
    outline: unset;
    z-index: 2;
    border-color: ${palette('primary')(styleProps)};
    box-shadow: ${palette('primaryTint')(styleProps)} 0px 0px 0px 3px !important;
  }
 
  ${styleProps.state &&
    css`
      & {
        border-color: ${palette(`${styleProps.state}`)(styleProps)};
        box-shadow: ${palette(`${styleProps.state}Tint`)(styleProps)} 0px 0px 0px 3px !important;
      }
    `}
 
  & {
    ${theme(styleProps.themeKey, `css.root`)(styleProps)};
  }
`;
 
export const SelectWrapper = styleProps => cssClass`
  align-items: center;
  position: relative;
  width: fit-content;
 
  ${styleProps.size && wrapperSizeProperties(styleProps)};
 
  & {
    ${theme(styleProps.themeKey, `css.root`)(styleProps)};
  }
`;
 
export const SelectIcon = styleProps => cssClass`
  && {
    position: absolute;
    width: 0.8em;
    height: 2.75em;
    right: 0.8em;
    z-index: 1;
    color: ${palette('text')(styleProps)};
    fill: ${palette('text')(styleProps)};
    pointer-events: none;
  }
 
  & {
    ${theme(styleProps.themeKey, `css.root`)(styleProps)};
  }
`;
 
export const SelectSpinner = styleProps => cssClass`
  && {
    font-size: inherit;
    align-items: center;
    display: flex;
    position: absolute;
    height: 2.75em;
    margin: 0 0.75em;
    top: 0;
    right: 0;
    z-index: 2;
 
    ${theme(styleProps.themeKey, `css.root`)(styleProps)};
  }
`;
 
export const SelectField = styleProps => cssClass`
  & {
    ${theme(styleProps.themeKey, `css.root`)(styleProps)};
  }
`;
 
export function wrapperSizeProperties(styleProps) {
  const properties = {
    small: css`
      font-size: ${fontSize('150')(styleProps)}rem;
 
      & {
        ${theme(styleProps.themeKey, `css.sizes.small`)(styleProps)};
      }
    `,
    default: css`
      & {
        ${theme(styleProps.themeKey, `css.sizes.default`)(styleProps)};
      }
    `,
    medium: css`
      font-size: ${fontSize('300')(styleProps)}rem;
 
      & {
        ${theme(styleProps.themeKey, `css.sizes.medium`)(styleProps)};
      }
    `,
    large: css`
      font-size: ${fontSize('400')(styleProps)}rem;
 
      & {
        ${theme(styleProps.themeKey, `css.sizes.large`)(styleProps)};
      }
    `
  };
  return properties[styleProps.size];
}