# All files / components/Checkbox/styles CheckboxLabel.js

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

    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

    5x
    5x

     import styled from 'styled-components';
    import get from 'extensions/themeGet';
    import Label from '../../Label';
    import Input from './CheckboxInput';
    import icons from 'components/Icon/icons';

    const SIZE = '22px';
    const CHECK_SIZE = '14px';

    // Builds off the base label
    export default Label.extend`
      padding: 0.2em 0 0.2em 2.1em;

      cursor: pointer;
      position: relative;
      user-select: none;

      font-weight: 200;

      /* the check */
      &::before {
        content: "";

        color: ${get('colors.text.inverted')};

        font-family: ${get('fonts.icon')};
        font-size: ${CHECK_SIZE};

        display: block;
        position: absolute;
        top: 50%;
        left: calc(${SIZE} / 2);
        transform: translate(-50%, -48%);
        z-index: 1;
        box-sizing: border-box;
      }

      /* the box */
      &::after {
        content: "";

        background: ${get('colors.background.default')};
        border-color: ${get('colors.primary.dark')};
        border-width: ${get('thicknesses.wide')};
        border-style: solid;
        border-radius: 0.2em;

        width: ${SIZE};
        height: ${SIZE};
        position: absolute;
        top: 50%;
        left: 0;
        transform: translateY(-50%);
        transition: all 0.2s ease;
        box-sizing: border-box;
      }

      ${Input}:focus + &::after {
        box-shadow: ${get('shadows.focusOutline')};
      }
      ${Input}:checked + &::after {
        background: ${get('colors.primary.dark')};
      }
      ${Input}:disabled + & {
        opacity: 0.5;
        &::before { opacity: 0.5 }
      }
      ${Input}:checked + &::before {
        content: "${icons('checkmark')}";
      }
    `;