# All files / components/Toggle/styles ToggleLabel.js

100% Statements 1/1
100% Branches 0/0
100% Functions 0/0
100% Lines 1/1

    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

    4x

     import styled from 'styled-components';
    import get from 'extensions/themeGet';
    import Input from './ToggleInput';

    export const SIZE = '24px';

    export default styled.label`
      cursor: pointer;
      position: relative;
      padding: ${get('spacing.extraSmall')};
      padding-right: 0;
      padding-left: calc(${SIZE} * 2 + ${get('spacing.medium')});
      user-select: none;
      transition: all 0.2s ease;
      line-height: calc(${SIZE} * 1.5);
      font-family: ${get('fonts.brand')};
      font-weight: 300;
      display: inline;

      &::before {
        content: '';
        border-width: ${get('thicknesses.wide')};
        border-style: solid;
        border-radius: ${SIZE};
        width: calc(${SIZE} * 2);
        height: ${SIZE};
        cursor: pointer;
        display: block;
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        transition: all 0.2s ease;
      }

      &::after {
        content: '';
        border-width: ${get('thicknesses.wide')};
        border-style: solid;
        border-radius: ${SIZE};
        width: ${SIZE};
        height: ${SIZE};
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        left: 0;
        display: block;
        transition: all 0.2s ease;
      }

      ${Input}:focus + &::before {
        box-shadow: ${get('shadows.focusOutline')};
      }

      ${Input} + &::before {
        background: ${get('colors.background.default')};
        border-color: ${get('colors.primary.dark')};
      }

      ${Input} + &::after {
        background: ${get('colors.text.inverted')};
        border-color: ${get('colors.primary.dark')};
      }

      ${Input} + &:hover::before, ${Input} + &:hover::after {
        border-color: ${get('colors.primary.dark')};
      }

      ${Input}:checked + & {
        &::before {
          background: ${get('colors.primary.dark')};
          border-color: ${get('colors.primary.dark')};
        }

        &::after {
          left: ${SIZE};
          background: ${get('colors.text.inverted')};
          border-color: ${get('colors.primary.dark')};
        }

        &:hover {
          &::before {
            background: ${get('colors.primary.dark')};
          }
          &::before,
          &::after {
            border-color: ${get('colors.primary.dark')};
          }
        }
      }

      ${Input}:disabled + & {
        &::before,
        &::after {
          border-color: ${get('colors.gray.medium')};
        }

        &::before {
          background: ${get('colors.background.disabled')};
        }

        &::after {
          background: ${get('colors.background.disabled')};
        }
      }
    `;