2021-09-16 04:21:31 +00:00
|
|
|
import React, { ReactNode } from "react";
|
|
|
|
|
import styled from "styled-components";
|
|
|
|
|
import { ContainerStyle } from "widgets/ContainerWidget/component";
|
|
|
|
|
import { Color } from "constants/Colors";
|
|
|
|
|
|
|
|
|
|
export enum BoxShadowTypes {
|
|
|
|
|
NONE = "NONE",
|
|
|
|
|
VARIANT1 = "VARIANT1",
|
|
|
|
|
VARIANT2 = "VARIANT2",
|
|
|
|
|
VARIANT3 = "VARIANT3",
|
|
|
|
|
VARIANT4 = "VARIANT4",
|
|
|
|
|
VARIANT5 = "VARIANT5",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type BoxShadow = keyof typeof BoxShadowTypes;
|
|
|
|
|
|
|
|
|
|
export interface WidgetStyleContainerProps {
|
|
|
|
|
widgetId: string;
|
|
|
|
|
containerStyle?: ContainerStyle;
|
|
|
|
|
children?: ReactNode;
|
|
|
|
|
borderColor?: Color;
|
2022-06-23 17:55:03 +00:00
|
|
|
backgroundColor?: Color;
|
2021-09-16 04:21:31 +00:00
|
|
|
borderWidth?: number;
|
|
|
|
|
borderRadius?: number;
|
|
|
|
|
boxShadow?: BoxShadow;
|
2022-05-04 09:45:57 +00:00
|
|
|
className?: string;
|
2023-02-14 16:07:31 +00:00
|
|
|
selected?: boolean;
|
2021-09-16 04:21:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const WidgetStyle = styled.div<WidgetStyleContainerProps>`
|
|
|
|
|
height: 100%;
|
|
|
|
|
width: 100%;
|
2022-05-04 09:45:57 +00:00
|
|
|
border-radius: ${({ borderRadius }) => borderRadius};
|
2022-06-23 17:55:03 +00:00
|
|
|
box-shadow: ${(props) => props.boxShadow} !important;
|
2022-05-04 09:45:57 +00:00
|
|
|
border-width: ${(props) => props.borderWidth}px;
|
|
|
|
|
border-color: ${(props) => props.borderColor || "transparent"};
|
2023-02-14 16:07:31 +00:00
|
|
|
outline: ${(props) =>
|
|
|
|
|
props.selected
|
|
|
|
|
? `${props.borderWidth || 1}px solid #3b82f6 !important`
|
|
|
|
|
: ""};
|
2022-05-04 09:45:57 +00:00
|
|
|
border-style: solid;
|
2022-06-23 17:55:03 +00:00
|
|
|
background-color: ${(props) => props.backgroundColor || "transparent"};
|
2022-05-04 09:45:57 +00:00
|
|
|
|
2023-02-03 05:47:40 +00:00
|
|
|
overflow: hidden;
|
2021-09-16 04:21:31 +00:00
|
|
|
& > div {
|
|
|
|
|
height: 100%;
|
|
|
|
|
width: 100%;
|
|
|
|
|
}
|
2022-06-23 17:55:03 +00:00
|
|
|
`;
|
2021-09-16 04:21:31 +00:00
|
|
|
|
|
|
|
|
// wrapper component for apply styles on any widget boundary
|
|
|
|
|
function WidgetStyleContainer(props: WidgetStyleContainerProps) {
|
|
|
|
|
return (
|
|
|
|
|
<WidgetStyle {...props} data-testid={`container-wrapper-${props.widgetId}`}>
|
2023-02-03 05:47:40 +00:00
|
|
|
{props.children}
|
2021-09-16 04:21:31 +00:00
|
|
|
</WidgetStyle>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default WidgetStyleContainer;
|