# All files / components/Navigation/styles NavigationItem.js

0% Statements 0/28
0% Branches 0/13
0% Functions 0/5
0% Lines 0/15

    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

     import PropTypes from 'prop-types';
    import styled, { css } from 'styled-components';
    import get from 'extensions/themeGet';
    import NavigationItemList from './NavigationItemList';
    import NavigationItemListStack from './NavigationItemListStack';
    import NavigationBar from './NavigationBar';
    import { calcTopOffset, calcBottomOffset } from 'extensions/userSpacing';

    const NavigationItem = styled.div.withConfig({ displayName: 'NavigationItem' })`
      border: 0;
      padding-bottom: calc(${calcBottomOffset(1.5)} + 20px);
      margin-top: ${calcTopOffset(1.5)};
      line-height: 1.5;
      opacity: 1;
      transition: all 0.2s ease;
      position: relative;
      cursor: pointer;
      color: inherit;
      font-size: 1em;
      font-weight: 200;
      pointer-events: ${({ disabled }) => (disabled ? 'none' : 'inherit')};

      &::before {
        content: '';
        opacity: ${({ active }) => (active ? 1 : 0)};
        background: ${get('colors.primary.dark')};
        width: 104%;
        height: ${({ active }) => (active ? '5px' : 0)};
        display: block;
        position: absolute;
        bottom: 0;
        top: auto;
        left: 50%;
        transform: translateX(-50%);
        transition: height 0.2s ease, opacity 0.2s ease;
      }

      ${NavigationBar.Dark} &, ${NavigationBar.Sub.Dark} & {
        &:before {background: ${get('colors.primary.default')}; }
      }

      ${NavigationItemList}:not(:last-child) & {
        padding-bottom: calc(${calcBottomOffset(1.5)} + 10px);
      }

      /* make items smaller when they're inside a small list */

      ${NavigationItemList.Small} & {
        font-size: 0.8em;
      }

      ${({ active, disabled }) =>
        active ||
        disabled ||
        css`
          &:focus,
          &:active {
            opacity: 0.7;
          }

          &:hover::before {
            opacity: 0.25;
          }

          &:hover,
          &:focus,
          &:active {
            &:before {
              height: 5px;
            }
          }
        `};
    `;

    NavigationItem.propTypes = {
      /**
       * Adds a class name to the element.
       */
      className: PropTypes.string,

      /**
       * Adds an id to the element.
       */
      id: PropTypes.string,
      /**
       * Determines if a navigation item is active or not
       */
      active: PropTypes.bool,
      /**
       * Determines if a navigation item is disabled or not
       */
      disabled: PropTypes.bool,
    };

    NavigationItem.defaultProps = {
      className: null,
      id: null,
      active: false,
      disabled: false,
    };

    export default NavigationItem;