Skip to content

Instantly share code, notes, and snippets.

@smashercosmo
Last active October 1, 2018 09:00
Show Gist options
  • Save smashercosmo/90ebf9ccce35b894f294cd1a16a2d73d to your computer and use it in GitHub Desktop.
Save smashercosmo/90ebf9ccce35b894f294cd1a16a2d73d to your computer and use it in GitHub Desktop.
VerticalStack
.root {
display: grid;
}
.gap10 {
grid-gap: 10px;
}
.gap20 {
grid-gap: 20px;
}
.gap30 {
grid-gap: 30px;
}
.gap40 {
grid-gap: 40px;
}
.gap50 {
grid-gap: 50px;
}
// @flow
import * as React from 'react'
import cx from 'classnames'
import styles from './VerticalStack.css'
type VerticalStackProps = {|
gap?: 10 | 20 | 30 | 40 | 50,
children: React.Node,
|}
export const VerticalStack = (props: VerticalStackProps) => {
const { children, gap = 10 } = props
const classes = cx(styles.root, {
[styles[`gap${String(gap)}`]]: gap > 0,
})
return (
<div className={classes}>
{React.Children.map(
children,
child => <div>{child}</div>,
)}
</div>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment