Skip to content

Commit

Permalink
chore: Apply requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
LizBaker committed Jun 5, 2020
1 parent b0a581c commit 8605bc6
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/components/Step.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
import React from 'react';
import styles from './Step.module.scss';
import Proptypes from 'prop-types';
import cx from 'classnames';

const Step = ({ children, number, total }) => {
let codeSnippet = null;
let childrenWithoutCodeSnippet = null;
if (children.length) {
codeSnippet = children.find((child) => child?.props?.mdxType === 'pre');
childrenWithoutCodeSnippet = children.filter(
(child) => child !== codeSnippet
);
}
children = React.Children.toArray(children);
const codeSnippet = children.find((child) => child?.props?.mdxType === 'pre');
const childrenWithoutCodeSnippet = children.filter(
(child) => child !== codeSnippet
);

return (
<div className={styles.wrapper}>
<p className={styles.stepNumber}>{`Step ${number} of ${total}`}</p>
<div className={styles.container}>
<div
className={`${styles.stepDetails} ${
codeSnippet && styles.stepDetailsWithCode
}`}
className={cx(styles.stepDetails, {
[styles.stepDetailsWithCode]: codeSnippet,
})}
>
{childrenWithoutCodeSnippet || children}
{childrenWithoutCodeSnippet}
</div>
{codeSnippet && codeSnippet}
{codeSnippet}
</div>
</div>
);
Expand Down

0 comments on commit 8605bc6

Please sign in to comment.