# All files / components/WidgetBox Header.js

100% Statements 18/18
100% Branches 0/0
100% Functions 11/11
100% Lines 18/18

    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

    1x

    1x

    1x
    1x

    1x
    1x
    1x

    1x
    1x
    1x
    1x

    1x

    1x
    1x
    1x

    1x

    1x

    1x

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

    import styled from 'styled-components';
    import { themeColor, textColor } from '../../utils/style';

    const StyledHeaderContainer = styled.div`
      flex: 0 0 auto;
      flex-basis: ${(props) => `${props.height}px`};

      background-color: ${(props) => themeColor(props.theme, 'accent', 'base')};
      color: ${(props) => textColor(props.theme, 'dark', 'primary')};
      border-radius: 10px 10px 0 0;
      text-align: center;
      padding: 10px;

      h4 {
        margin: 0;
        font-size: ${(props) => props.theme.typography.classes.body.fontSize};
        line-height: ${(props) => props.theme.typography.classes.body.lineHeight};
        font-weight: ${(props) => props.theme.typography.weights.fontWeightMedium};
      }

      span {
        color: ${(props) => textColor(props.theme, 'dark', 'secondary')};
        font-size: ${(props) => props.theme.typography.classes.caption.fontSize};
        line-height: ${(props) => props.theme.typography.classes.caption.lineHeight};
        font-weight: ${(props) => props.theme.typography.weights.fontWeightThin};
      }
    `;
    StyledHeaderContainer.displayName = 'StyledHeaderContainer';

    const WidgetBoxHeader = (props) => {
      const { children, className, height } = props;
      return (
        <StyledHeaderContainer className={className} height={height}>
          {children}
        </StyledHeaderContainer>
      );
    };

    WidgetBoxHeader.propTypes = {
      children: PropTypes.node.isRequired,
      className: PropTypes.string,
      height: PropTypes.number,
    };

    WidgetBoxHeader.defaultProps = {
      className: 'WidgetBoxHeader-Container',
      height: 50,
    };

    WidgetBoxHeader.displayName = 'WidgetBoxHeader';

    export default WidgetBoxHeader;