# All files / components/SidebarList SidebarListItem.js

0% Statements 0/2
0% Branches 0/2
0% Functions 0/1
0% Lines 0/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
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87

     import React from 'react';
    import PropTypes from 'prop-types';
    import styled, { css } from 'styled-components';
    import NewBadge from '../NewBadge';
    import SidebarListItemContainer from './styles/SidebarListItemContainer';
    import SidebarListItemLabel from './styles/SidebarListItemLabel';
    import SidebarListItemDetails from './styles/SidebarListItemDetails';

    class SidebarListItem extends React.Component {
      static propTypes = {
        /**
         * The main details of the list item.
         */
        label: PropTypes.string,
        /**
         * Extra details to render on another line.
         */
        details: PropTypes.node,
        /**
         * Renders the item as the one currently selected.
         */
        active: PropTypes.bool,
        /**
         * Adds a new badge to the list item.
         */
        isNew: PropTypes.bool,
        /**
         * Adds a class name to the outer item element.
         */
        className: PropTypes.string,
        /**
         * Adds an id to the outer item element.
         */
        id: PropTypes.string,
        /**
         * A component for rendering a container of an item
         */
        Container: PropTypes.func,
        /**
         * A component for rendering an item label
         */
        Label: PropTypes.func,
        /**
         * A component for rendering the details container in the item
         */
        Details: PropTypes.func,
      };

      static defaultProps = {
        label: null,
        details: null,
        active: false,
        isNew: false,
        className: null,
        id: null,
        Container: SidebarListItemContainer,
        Details: SidebarListItemDetails,
        Label: SidebarListItemLabel,
      };

      render() {
        const {
          label,
          details,
          active,
          isNew,
          id,
          className,
          Container,
          Label,
          Details,
        } = this.props;

        return (
          <Container active={active} className={className} id={id}>
            <Label>
              {isNew ? <NewBadge /> : null}
              {label}
            </Label>
            <Details>{details}</Details>
          </Container>
        );
      }
    }

    export default SidebarListItem;