# All files / components/Tabs/styles Tab.js

21.43% Statements 3/14
0% Branches 0/24
0% Functions 0/9
21.43% Lines 3/14

    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

    4x

    4x

     import styled, { css } from 'styled-components';
    import get from 'extensions/themeGet';
    import TabList from './TabList';
    import TabContainer from './TabContainer';

    const verticalStyles = css`
      border-bottom-color: ${get('colors.border.medium')};
      border-right-color: ${props =>
        props.active
          ? get('colors.background.default')(props)
          : get('colors.border.medium')(props)};

      &:last-child {
        border-radius: 0 0 0 3px;
        margin-bottom: 0;
      }

      ${({ disabled, active }) => {
        if (!disabled && !active) {
          return css`
            &:hover {
              border-bottom-color: ${props =>
                props.active
                  ? get('colors.border.medium')(props)
                  : get('colors.primary.default')(props)};
            }
          `;
        }
      }};
    `;

    const Tab = styled.li`
      position: relative;
      display: flex;
      flex-direction: column;
      align-content: flex-start;

      opacity: ${({ active }) => (active ? 1 : 0.5)};

      padding: 1em 1.4em;
      margin-right: -1px;
      margin-bottom: -1px;

      cursor: ${({ disabled, active }) =>
        disabled || active ? 'default' : 'pointer'};

      color: inherit;
      background: ${props =>
        props.disabled
          ? get('colors.background.disabled')(props)
          : get('colors.background.default')(props)};

      font-weight: bold;
      text-transform: uppercase;
      white-space: nowrap;

      transition: opacity 0.2s ease, border-color 0.2s ease;

      border-width: ${get('thicknesses.normal')};
      border-style: solid;
      border-color: ${get('colors.border.medium')};

      border-bottom-color: ${props =>
        props.active
          ? get('colors.background.default')(props)
          : get('colors.border.medium')(props)};

      &:first-child {
        border-radius: 3px 0 0 0;
      }

      &:last-child {
        border-radius: 0 3px 0 0;
        margin-right: 0;
      }

      ${({ disabled, active }) => {
        if (!disabled && !active) {
          return css`
            &:hover {
              border-color: ${props =>
                props.active
                  ? get('colors.border.medium')(props)
                  : get('colors.primary.default')(props)};
              opacity: 1;
              z-index: 1;
            }
          `;
        }
      }} ${TabList} > & {
        flex: 1 0 0;
      }

      ${TabList.Vertical} > &, ${TabContainer.Vertical} > ${TabList} > & {
        ${verticalStyles};
      }
    `;

    Tab.Vertical = Tab.extend`
      ${verticalStyles};
    `;

    /**
     * @component
     */
    export default Tab;