Skip to content

Commit

Permalink
feat: added Steps component
Browse files Browse the repository at this point in the history
  • Loading branch information
zstix committed May 29, 2020
1 parent 203b680 commit c74a420
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/components/Steps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';

const Steps = ({ children }) => {
// get the number of steps
const totalSteps = children.filter(
(child) => child?.props?.mdxType === 'Step'
).length;

// return the children with additional props
return (
<>
{children.map((child, index) => ({
...child,
props: {
...child.props,
number: index + 1,
total: totalSteps,
},
}))}
</>
);
};

export default Steps;

0 comments on commit c74a420

Please sign in to comment.