# All files / src/FileToken FileToken.styles.ts

100% Statements 20/20
100% Branches 29/29
100% Functions 2/2
100% Lines 18/18

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
    137
    138
    139
    140
    141
    1425x
    5x
    5x
    5x

    5x

    5x

    5x

    5x

    5x

    5x

    62x
    62x

    62x
    62x
    2x

    60x
    7x

    53x

     import styled, { css, keyframes } from 'styled-components'
    import { StyledLoader } from '../Loader/Loader.styles'
    import { StyledLabel, StyledToken } from '../Token/Token.styles'
    import { colors } from '../_styles/colors'

    export const pulseAnimationDuration = 600

    const focusPulse = keyframes`
      0% {
        box-shadow: 0 0 0 0 ${colors.blue60}, 0 0 0 0 ${colors.blue90}, 0 0 0 0 ${colors.blue94};
      }
      25% {
        box-shadow: 0 0 0 0 ${colors.blue60}, 0 0 0 0 ${colors.blue90}, 0 0 0 0 ${colors.blue94};
      }
      50% {
        box-shadow: 0 0 0 1px ${colors.blue60}, 0 0 0 3px ${colors.blue90}, 0 0 0 2px ${colors.blue94};
      }
      100% {
        box-shadow: 0 0 0 1.5px ${colors.blue60}, 0 0 0 3px ${colors.blue90}, 0 0 0 6px ${colors.blue94};
      }
    `

    export const StyledFilenameShortcut = styled.div`
      display: flex;
    `

    export const StyledFilename = styled.span`
      flex: 1 1 auto;
      overflow: hidden;
      text-overflow: ellipsis;
    `

    export const StyledExtension = styled.span`
      flex-shrink: 0;
    `

    export const StyledFileToken = styled.div<{
      $error?: boolean
      $finalized?: boolean
      $progressComplete?: boolean
    }>`
      background-color: ${colors.gray96};
      border-radius: 200px;
      max-width: 100%;
      outline: none;
      overflow: hidden;
      position: relative;

      &:focus,
      &.focus {
        box-shadow: 0 0 0 2px ${colors.blue40};
        outline: none;

        ${StyledToken} {
          border-color: transparent;

          ${({ $progressComplete }) =>
            $progressComplete &&
            css`
              background-color: ${colors.blue45};
            `}
        }
      }

      ${StyledToken} {
        background: none;
        color: ${colors.blue40};
        display: flex;
        user-select: none;
      }

      ${StyledLoader} {
        overflow: hidden;

        ${StyledToken} {
          border-radius: 200px 0 0 200px;
          color: ${colors.white};
          padding-right: 0;
          transition: color 0s linear, background-color 0s linear;
          user-select: none;

          ${StyledLabel} {
            flex: 0 0 auto;
          }
        }
      }

      ${({ $error, $finalized, $progressComplete }) => {
        if ($error) {
          return css`
            background-color: ${colors.red50};

            &:focus {
              background-color: ${colors.red50};
            }

            ${StyledToken} {
              color: ${colors.white};
            }

            ${StyledLoader} {
              display: none;
            }
          `
        } else if ($finalized || $progressComplete) {
          return css`
            ${$finalized &&
            css`
              animation-delay: 0;
              animation-duration: ${pulseAnimationDuration}ms;
              animation-name: ${focusPulse};
              animation-timing-function: ease-out;
            `};

            ${StyledLoader} {
              opacity: 0;
              pointer-events: none;
            }

            ${StyledToken} {
              background-color: ${colors.blue50};
              color: ${colors.white};

              &:hover,
              &:focus {
                background-color: ${colors.blue45};
              }
            }

            &.hover,
            &.focus {
              ${StyledToken} {
                background-color: ${colors.blue45};
              }
            }
          `
        }

        return css``
      }}
    `