2019-11-13 07:00:25 +00:00
|
|
|
import React, { forwardRef, Ref, ReactNode } from "react";
|
|
|
|
|
import styled from "styled-components";
|
2019-09-05 17:47:50 +00:00
|
|
|
import { ComponentProps } from "./BaseComponent";
|
2019-11-13 07:00:25 +00:00
|
|
|
import { getBorderCSSShorthand } from "constants/DefaultTheme";
|
|
|
|
|
import { Color } from "constants/Colors";
|
|
|
|
|
|
|
|
|
|
const StyledContainerComponent = styled.div<ContainerComponentProps>`
|
|
|
|
|
${props =>
|
|
|
|
|
props.containerStyle !== "none"
|
|
|
|
|
? `
|
|
|
|
|
border: ${getBorderCSSShorthand(props.theme.borders[2])};
|
|
|
|
|
box-shadow: ${props.theme.shadows[0]};
|
|
|
|
|
border-radius: ${
|
|
|
|
|
props.containerStyle === "card" || props.containerStyle === "rounded-border"
|
|
|
|
|
? props.theme.radii[1]
|
|
|
|
|
: 0
|
|
|
|
|
}px;`
|
|
|
|
|
: ""}
|
2019-10-01 20:07:43 +00:00
|
|
|
height: 100%;
|
|
|
|
|
width: 100%;
|
2019-11-13 07:00:25 +00:00
|
|
|
background: ${props => props.backgroundColor};
|
2019-10-21 15:12:45 +00:00
|
|
|
padding: ${props => props.theme.spaces[1]}px;
|
2019-11-13 07:00:25 +00:00
|
|
|
}`;
|
Property Pane Controls
- Fixes #121, #122, #123, #124, #90, #46, #65, #100, #101, #68, #102
2019-10-24 05:24:45 +00:00
|
|
|
|
|
|
|
|
/* eslint-disable react/display-name */
|
2019-11-13 07:00:25 +00:00
|
|
|
const ContainerComponent = forwardRef(
|
|
|
|
|
(props: ContainerComponentProps, ref: Ref<HTMLDivElement>) => {
|
|
|
|
|
return (
|
|
|
|
|
<StyledContainerComponent {...props} ref={ref}>
|
|
|
|
|
{props.children}
|
|
|
|
|
</StyledContainerComponent>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
ContainerComponent.defaultProps = {
|
|
|
|
|
containerStyle: "card",
|
|
|
|
|
backgroundColor: "white",
|
Property Pane Controls
- Fixes #121, #122, #123, #124, #90, #46, #65, #100, #101, #68, #102
2019-10-24 05:24:45 +00:00
|
|
|
};
|
2019-10-01 20:07:43 +00:00
|
|
|
|
2019-11-13 07:00:25 +00:00
|
|
|
type ContainerStyle = "border" | "card" | "rounded-border" | "none";
|
2019-02-10 13:06:05 +00:00
|
|
|
|
2019-11-13 07:00:25 +00:00
|
|
|
export interface ContainerComponentProps extends ComponentProps {
|
|
|
|
|
containerStyle?: ContainerStyle;
|
|
|
|
|
children?: ReactNode;
|
|
|
|
|
className?: string;
|
|
|
|
|
backgroundColor?: Color;
|
2019-02-10 13:06:05 +00:00
|
|
|
}
|
|
|
|
|
|
2019-09-09 09:08:54 +00:00
|
|
|
export default ContainerComponent;
|