# All files / components/HelpText HelpText.js

0% Statements 0/18
0% Branches 0/6
0% Functions 0/3
0% Lines 0/11

    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

     import React from 'react';
    import PropTypes from 'prop-types';
    import styled from 'styled-components';
    import get from 'extensions/themeGet';
    import userTextSpacing from 'extensions/userTextSpacing';

    const HelpText = styled.div.withConfig({ displayName: 'HelpText' }).attrs({
      spacing: userTextSpacing,
    })`
      color: ${props =>
        props.error ? get('colors.negative.default') : get('colors.gray.medium')};
      font-style: italic;
      font-weight: 300;
      font-family: ${get('fonts.brand')};
      margin: ${props => props.spacing};
    `;

    HelpText.propTypes = {
      /**
       * Adds a class name to the element.
       */
      className: PropTypes.string,
      /**
       * Adds an id to the element.
       */
      id: PropTypes.string,
      /**
       * Whether this help text is in an error state
       */
      error: PropTypes.bool,
      /**
       * Specify a CSS value or an object { top, right, bottom, left } or { vertical, horizontal } to
       * control the spacing around the heading. Defaults to a large space below the element.
       */
      spacing: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
    };

    HelpText.defaultProps = {
      className: null,
      id: null,
    };

    /**
     * @component
     */
    export default HelpText;