PromucFlow_constructor/app/client/src/editorComponents/ContainerComponent.tsx

44 lines
1.3 KiB
TypeScript
Raw Normal View History

import BaseComponent, { IComponentProps } from "./BaseComponent"
import { ContainerOrientation } from "../constants/WidgetConstants"
2019-02-10 15:06:57 +00:00
import styled from "../constants/DefaultTheme"
import React from "react"
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};
color: ${props => props.theme.primaryColor};
2019-03-19 15:21:27 +00:00
position: ${props => { return props.style.positionType === "ABSOLUTE" ? "absolute" : "relative" }};
left: ${props => {
return props.style.xPosition + props.style.xPositionUnit
}};
top: ${props => {
return props.style.yPosition + props.style.yPositionUnit
}};
`
class ContainerComponent extends BaseComponent<IContainerProps> {
render() {
return (
<Container {...this.props}>
{this.props.children
? this.props.children.map(child => {
return child
})
: undefined}
</Container>
)
}
}
export interface IContainerProps extends IComponentProps {
children?: JSX.Element[]
snapColumnSpace: number
snapRowSpace: number
snapColumns: number
snapRows: number
orientation: ContainerOrientation
}
export default ContainerComponent