# All files / components/Steps Steps.js

0% Statements 0/50
0% Branches 0/33
0% Functions 0/12
0% Lines 0/12

    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

     import React from 'react';
    import PropTypes from 'prop-types';
    import Step from './Step';
    import StepList from './styles/StepList';

    export default class Steps extends React.Component {
      static propTypes = {
        /**
         * Children must be an array of Step components
         */
        children: PropTypes.node.isRequired,
        /**
         * Override the component that renders the list container
         */
        List: PropTypes.func,
      };

      static defaultProps = {
        List: StepList,
      };

      renderSteps = () =>
        React.Children.map(this.props.children, (step, index) =>
          React.cloneElement(step, { number: index + 1 }),
        );

      render() {
        const { List } = this.props;

        return <List>{this.renderSteps()}</List>;
      }
    }

    Steps.Step = Step;