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

0% Statements 0/12
0% Branches 0/4
0% Functions 0/1
0% Lines 0/5

    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

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

    export const SIZE = '30px';
    const TOGGLE_WIDTH = '58px';

    export default styled.label`
      display: block;
      cursor: pointer;
      position: relative;
      user-select: none;

      padding-right: 0;
      padding-left: calc(${TOGGLE_WIDTH} + ${get('spacing.small')});
      padding-top: 4px;
      padding-bottom: 5px;
      transition: all 0.2s ease;
      line-height: 1.5;
      font-family: ${get('fonts.brand')};
      font-weight: 300;

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

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

      &::after {
        content: '';
        box-sizing: border-box;
        border-width: ${get('thicknesses.wide')};
        border-style: solid;
        border-radius: 15px;
        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')};
        }
      }

      ${Input}:disabled + & {
        cursor: default;
        color: ${get('colors.gray.border')};

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

      ${Input}:checked:disabled + &::before {
        background: ${get('colors.background.disabledSelected')};
      }
    `;