# All files / components/Tabs TabList.js

16.67% Statements 1/6
0% Branches 0/4
0% Functions 0/4
16.67% Lines 1/6

    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

    5x

     import React from 'react';
    import PropTypes from 'prop-types';
    import styled, { css } from 'styled-components';

    const Div = styled.div`
      ${({ vertical }) => {
        if (vertical) {
          return css`
        width: 100%;
        display: table;
      `;
        }
      }}`;

    export default class TabList extends React.Component {

      static propTypes = {
        /**
         * Tab elements within container
         */
        children: PropTypes.node,
        /**
         * Enable vertical tab layout
         */
        vertical: PropTypes.bool,
      };

      static defaultProps = {
        vertical: false,
      };

      attachParams = (children, vertical) => React.Children.map(children,
            child => React.isValidElement(child) ?  React.cloneElement(child, { vertical }) : child);

      render() {
        return (<Div vertical={this.props.vertical}>{this.attachParams(this.props.children, this.props.vertical)}</Div>);
      }
    }