Files
freeCodeCamp/client/src/components/helpers/spacer.tsx
Oliver Eyton-Williams d87b472ee7 Fix: assorted next fixes (#42634)
* chore: fix slightly broken package.json

* fix: update children type

* fix: make size optional for Spacer

* fix: correct broken env import

* test: update snapshot and fix typing

* test: fix imports and remove old snapshot
2021-06-30 20:52:17 +05:30

25 lines
462 B
TypeScript

import React from 'react';
interface SpacerProps {
size?: number;
}
const styles = { padding: '15px 0', height: '1px' };
const Comp = ({ ...props }): JSX.Element => (
<div className='spacer' style={styles} {...props} />
);
const Spacer = ({ size = 1 }: SpacerProps): JSX.Element =>
size === 1 ? (
<Comp />
) : (
<>
{Array.from(Array(size), (_, i) => (
<Comp key={`spacer_${i}`} />
))}
</>
);
export default Spacer;