# All files / components/Summary Summary.js

21.43% Statements 3/14
0% Branches 0/2
0% Functions 0/10
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

    5x

    5x

    5x

     import React from 'react';
    import PropTypes from 'prop-types';
    import styled from 'styled-components';

    const Container = styled.div`
      display: flex;
      flex-direction: column;
      font-size: ${({ theme }) => theme.card.fontSize};
      margin: 0;
      padding: ${({ theme }) => `${theme.padding.small} 0`};
      background: ${({ theme }) => theme.card.bg};
      color: ${({ theme, active }) => active ? theme.card.activeFG : theme.card.fg};
      border-bottom: ${({ theme }) => theme.card.border};

      &:last-child {
        border-bottom: none;
      }
    `;

    const Help = styled.span`
      font-family: ${({ theme }) => theme.card.helpFontFamily};
      font-style: italic;
      font-size: ${({ theme }) => theme.card.helpFontSize};
      font-weight: ${({ theme }) => theme.card.helpFontWeight};
      color: ${({ theme }) => theme.helpText.fg};
    `;

    /**
     * DEPRECATED: This component is not included in the design system, and may
     * not be considered universal enough to be included in a shared library. Use at
     * your own risk.
     */
    class Summary extends React.Component {
      static propTypes = {
        /**
         * The main content of the summary.
         */
        children: PropTypes.node.isRequired,
        /**
         * Optional aside to render explaining the summary.
         */
        helpText: PropTypes.string,
        /**
         * Adds a class name to the container element.
         */
        className: PropTypes.string,
        /**
         * Adds an id to the container element.
         */
        id: PropTypes.string,
      };

      static defaultProps = {
        helpText: null,
        className: null,
        id: null,
      };

      render() {
        const { children, helpText, className, id } = this.props;
        return (
          <Container className={className} id={id}>
            {children}
            <Help>{helpText}</Help>
          </Container>
        );
      }
    }

    Summary.usage = `
    Summaries are simple data items. They're not meant to be interactive, just informative. Supports adding a little help text with the \`helpText\` property.

    \`\`\`
    <Summary helpText="This is usually bar">Foo</Summary>
    \`\`\`
    `;

    export default Summary;