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-03-21 12:10:32 +00:00
|
|
|
export const Container = styled("div")<IContainerProps>`
|
2019-08-20 13:19:19 +00:00
|
|
|
display: flex;
|
|
|
|
|
flex-direction: ${props => {
|
2019-03-21 12:10:32 +00:00
|
|
|
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-21 12:10:32 +00:00
|
|
|
position: ${props => {
|
|
|
|
|
return props.style.positionType === "ABSOLUTE" ? "absolute" : "relative"
|
|
|
|
|
}};
|
2019-02-11 18:22:23 +00:00
|
|
|
left: ${props => {
|
2019-04-02 16:12:08 +00:00
|
|
|
return props.style.positionType !== "ABSOLUTE" ? undefined : props.style.xPosition + props.style.xPositionUnit
|
2019-02-11 18:22:23 +00:00
|
|
|
}};
|
|
|
|
|
top: ${props => {
|
2019-04-02 16:12:08 +00:00
|
|
|
return props.style.positionType !== "ABSOLUTE" ? undefined : props.style.yPosition + props.style.yPositionUnit
|
2019-02-11 18:22:23 +00:00
|
|
|
}};
|
2019-02-10 13:06:05 +00:00
|
|
|
`
|
|
|
|
|
|
|
|
|
|
class ContainerComponent extends BaseComponent<IContainerProps> {
|
|
|
|
|
render() {
|
2019-03-21 12:10:32 +00:00
|
|
|
return <Container {...this.props}>{this.props.children}</Container>
|
2019-02-10 13:06:05 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface IContainerProps extends IComponentProps {
|
2019-03-21 12:10:32 +00:00
|
|
|
children?: JSX.Element[] | JSX.Element
|
|
|
|
|
orientation?: ContainerOrientation
|
2019-02-10 13:06:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default ContainerComponent
|