# All files / components/Code CodeContainer.js

28.57% Statements 2/7
100% Branches 0/0
0% Functions 0/4
28.57% Lines 2/7

    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

    5x

    5x

     import React from 'react';
    import PropTypes from 'prop-types';
    import styled from 'styled-components';
    import { CodeWrapper } from './CodeBlock';

    const Container = styled.div`
      display: flex;
      flex-direction: column;
      padding: 0;
    `;

    const Content = styled.div`
      background: ${({ theme }) => theme.code.bg};
      padding: ${({ theme }) => theme.code.padding};
      color: ${({ theme }) => theme.code.fg};

      & > ${CodeWrapper} {
        padding: 0;
      }
    `;

    class CodeContainer extends React.Component {
      static propTypes = {
        /**
         * Multiple CodeBlock elements to render in one frame.
         */
        children: PropTypes.node.isRequired,
        /**
         * An optional header element to place above the frame.
         */
        header: PropTypes.node,
        /**
         * A class name to add to the container element.
         */
        className: PropTypes.string,
        /**
         * An id to add to the container element.
         */
        id: PropTypes.string,
      };

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

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

    export default CodeContainer;