From c74a420d5f09336e138b6fc6bfdeeb57796861c8 Mon Sep 17 00:00:00 2001 From: Zack Stickles Date: Fri, 29 May 2020 09:57:15 -0700 Subject: [PATCH] feat: added Steps component --- src/components/Steps.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/components/Steps.js diff --git a/src/components/Steps.js b/src/components/Steps.js new file mode 100644 index 000000000..b3147c731 --- /dev/null +++ b/src/components/Steps.js @@ -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;