-
Notifications
You must be signed in to change notification settings - Fork 1
/
VerticalFlex.js
45 lines (41 loc) · 1006 Bytes
/
VerticalFlex.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import React from "react";
import { withTheme } from "styled-components";
import PropTypes from "prop-types";
import Flex from "./Flex";
import Box from "./Box";
export default withTheme(
class VerticalFlex extends React.Component {
static propTypes = {
children: PropTypes.object,
className: PropTypes.string,
theme: PropTypes.object
};
constructor(props) {
super(props);
}
render() {
const { className, children, theme } = this.props;
const kids = React.Children.toArray(children)
const numberOfChildren = kids.length;
return (
<Flex
css={{
flexDirection: "column",
alignItems: "center",
height: "100%",
overflow: "hidden",
}}
>
{kids.map(k => (
<Box
key={k.key}
height={1 / numberOfChildren}
>
{k}
</Box>
))}
</Flex>
);
}
}
);