PromucFlow_constructor/app/client/src/components/designSystems/appsmith/ContainerComponent.tsx

57 lines
1.6 KiB
TypeScript
Raw Normal View History

import React, { forwardRef, Ref, ReactNode } from "react";
import styled from "styled-components";
2019-09-05 17:47:50 +00:00
import { ComponentProps } from "./BaseComponent";
2020-02-13 09:32:24 +00:00
import { invisible } from "constants/DefaultTheme";
import { Color } from "constants/Colors";
const StyledContainerComponent = styled.div<ContainerComponentProps>`
${props =>
props.containerStyle !== "none"
? `
2020-02-13 09:32:24 +00:00
border: none;
border-radius: ${
props.containerStyle === "card" || props.containerStyle === "rounded-border"
? props.theme.radii[1]
: 0
}px;`
: ""}
height: 100%;
width: 100%;
2020-02-13 09:32:24 +00:00
background: ${props =>
props.isMainContainer ? "none" : props.backgroundColor};
box-shadow: ${props =>
props.isMainContainer
? "none"
: "0 1px 1px 0 rgba(60,75,100,.14),0 2px 1px -1px rgba(60,75,100,.12),0 1px 3px 0 rgba(60,75,100,.2)"};
2020-01-16 11:46:21 +00:00
position: relative;
2020-02-11 09:56:21 +00:00
${props => (!props.isVisible ? invisible : "")};
}`;
/* eslint-disable react/display-name */
const ContainerComponent = forwardRef(
(props: ContainerComponentProps, ref: Ref<HTMLDivElement>) => {
return (
<StyledContainerComponent {...props} ref={ref}>
{props.children}
</StyledContainerComponent>
);
},
);
ContainerComponent.defaultProps = {
containerStyle: "card",
backgroundColor: "white",
};
export type ContainerStyle = "border" | "card" | "rounded-border" | "none";
export interface ContainerComponentProps extends ComponentProps {
containerStyle?: ContainerStyle;
children?: ReactNode;
className?: string;
backgroundColor?: Color;
2020-02-13 09:32:24 +00:00
isMainContainer: boolean;
}
2019-09-09 09:08:54 +00:00
export default ContainerComponent;