-
Notifications
You must be signed in to change notification settings - Fork 1
/
HorizontalFlex.js
42 lines (38 loc) · 1012 Bytes
/
HorizontalFlex.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
import React from "react";
import { styled, withTheme } from "styled-components";
import PropTypes from "prop-types";
import Flex from "./Flex";
import Box from "./Box";
export default withTheme(
class HorizontalFlex 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: "row",
alignItems: "center",
width: "100%",
overflow: "hidden"
}}
>
{kids.map(k => (
<Box key={k.key} width={1 / numberOfChildren}>
{k}
</Box>
))}
</Flex>
);
}
}
);