# All files / src/IconButton IconButton.styled.ts

100% Statements 15/15
100% Branches 0/0
100% Functions 7/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
    2x

    8x

    8x

    8x

    8x
    8x
    8x

    8x

     import { Style, Styles } from 'jss'
    import { Theme, lighten } from '../styles'
    import { IconButtonClassProps } from './IconButton.type'

    const root = (theme: Theme): Style => ({
      border: 'none',
      outline: 'none',
      display: 'inline-flex',
      flexDirection: 'column',
      alignItems: 'center',
      justifyContent: 'center',
      cursor: 'pointer',
      color: 'inherit',
      borderRadius: '50%',
      overflow: 'hidden',
      transition: theme.transitions!.button,
      '&:disabled': {
        color: theme.colors!.standard!.dark3,
        cursor: 'not-allowed',
        pointerEvents: 'none'
      }
    })
    const variantStandard = (theme: Theme): Style => ({
      color: theme.colors!.primary!.default,
      backgroundColor: 'transparent',
      '&:hover, &:focus': {
        backgroundColor: lighten('primary.light1', 0.08)
      },
      '&:active': {
        backgroundColor: lighten('primary.light1', 0.36)
      }
    })
    const variantPrimary = (theme: Theme): Style => ({
      color: theme.colors!.white!.default,
      backgroundColor: theme.colors!.primary!.default,
      boxShadow: theme.shadows![3],
      '&:hover, &:focus': {
        backgroundColor: theme.colors!.primary!.dark1
      },
      '&:active': {
        color: theme.colors!.white!.default,
        backgroundColor: theme.colors!.primary!.dark3,
        boxShadow: theme.shadows![4]
      }
    })
    const sizeSmall = (theme: Theme): Style => theme.sizes!.small!.iconButton
    const sizeMedium = (theme: Theme): Style => theme.sizes!.medium!.iconButton
    const sizeLarge = (theme: Theme): Style => theme.sizes!.large!.iconButton

    export const styles = (theme: Theme): Styles<IconButtonClassProps> => ({
      root: root(theme),
      variantStandard: variantStandard(theme),
      variantPrimary: variantPrimary(theme),
      sizeSmall: sizeSmall(theme),
      sizeMedium: sizeMedium(theme),
      sizeLarge: sizeLarge(theme)
    })