2019-02-10 13:06:05 +00:00
|
|
|
import BaseComponent, { IComponentProps } from "./BaseComponent"
|
|
|
|
|
import { ContainerOrientation } from "../constants/WidgetConstants"
|
2019-02-10 15:06:57 +00:00
|
|
|
import styled from "../constants/DefaultTheme"
|
2019-02-11 18:22:23 +00:00
|
|
|
import React from "react"
|
2019-02-10 13:06:05 +00:00
|
|
|
|
2019-02-11 18:22:23 +00:00
|
|
|
const Container = styled("div")<IContainerProps>`
|
2019-03-19 14:05:48 +00:00
|
|
|
display: "flex"
|
|
|
|
|
flexDirection: ${(props) => { return props.orientation === "HORIZONTAL" ? "row" : "column" }};
|
2019-03-19 15:21:27 +00:00
|
|
|
background: ${props => props.style.backgroundColor};
|
2019-02-10 16:39:09 +00:00
|
|
|
color: ${props => props.theme.primaryColor};
|
2019-03-19 15:21:27 +00:00
|
|
|
position: ${props => { return props.style.positionType === "ABSOLUTE" ? "absolute" : "relative" }};
|
2019-02-11 18:22:23 +00:00
|
|
|
left: ${props => {
|
|
|
|
|
return props.style.xPosition + props.style.xPositionUnit
|
|
|
|
|
}};
|
|
|
|
|
top: ${props => {
|
|
|
|
|
return props.style.yPosition + props.style.yPositionUnit
|
|
|
|
|
}};
|
2019-02-10 13:06:05 +00:00
|
|
|
`
|
|
|
|
|
|
|
|
|
|
class ContainerComponent extends BaseComponent<IContainerProps> {
|
|
|
|
|
render() {
|
|
|
|
|
return (
|
2019-02-11 18:22:23 +00:00
|
|
|
<Container {...this.props}>
|
2019-02-10 13:06:05 +00:00
|
|
|
{this.props.children
|
|
|
|
|
? this.props.children.map(child => {
|
|
|
|
|
return child
|
|
|
|
|
})
|
|
|
|
|
: undefined}
|
|
|
|
|
</Container>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface IContainerProps extends IComponentProps {
|
2019-02-11 18:22:23 +00:00
|
|
|
children?: JSX.Element[]
|
|
|
|
|
snapColumnSpace: number
|
|
|
|
|
snapRowSpace: number
|
|
|
|
|
snapColumns: number
|
|
|
|
|
snapRows: number
|
|
|
|
|
orientation: ContainerOrientation
|
2019-02-10 13:06:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default ContainerComponent
|