## Description TL;DR This is a complete architectural change of of List widget works to support all widgets we currently have and should automatically support any future widgets. It also introduces nested List widgets i.e a list widget can have a another list widget which in turn can have another list widget. Fixes #18206 Fixes #6775 Fixes #13211 Fixes #16582 Fixes #11739 Fixes #15094 Fixes #6840 Fixes #10841 Fixes #17386 Fixes #18340 Fixes #16898 Fixes #17555 Fixes #6858 Fixes #9568 Fixes #17480 Fixes #18523 Fixes #18206 Fixes #16586 Fixes #18106 Fixes #16576 Fixes #14697 Fixes #9607 Fixes #19648 Fixes #19739 Fixes #19652 Fixes #18730 Fixes #19503 Fixes #19498 Fixes #19437 Fixes #5245 Fixes #19150 Fixes #18638 Fixes #11332 Fixes #17901 Fixes #19043 Fixes #17777 Fixes #8237 Fixes #15487 Fixes #15988 Fixes #18621 Fixes #16788 Fixes #18110 Fixes #18382 Fixes #17427 Fixes #18105 Fixes #18287 Fixes #19808 Fixes #14655 ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Cypress - Jest - Manual ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes --------- Co-authored-by: Tolulope Adetula <31691737+Tooluloope@users.noreply.github.com> Co-authored-by: Favour Ohanekwu <fohanekwu@gmail.com>
61 lines
1.6 KiB
TypeScript
61 lines
1.6 KiB
TypeScript
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;
|
|
backgroundColor?: Color;
|
|
borderWidth?: number;
|
|
borderRadius?: number;
|
|
boxShadow?: BoxShadow;
|
|
className?: string;
|
|
selected?: boolean;
|
|
}
|
|
|
|
const WidgetStyle = styled.div<WidgetStyleContainerProps>`
|
|
height: 100%;
|
|
width: 100%;
|
|
border-radius: ${({ borderRadius }) => borderRadius};
|
|
box-shadow: ${(props) => props.boxShadow} !important;
|
|
border-width: ${(props) => props.borderWidth}px;
|
|
border-color: ${(props) => props.borderColor || "transparent"};
|
|
outline: ${(props) =>
|
|
props.selected
|
|
? `${props.borderWidth || 1}px solid #3b82f6 !important`
|
|
: ""};
|
|
border-style: solid;
|
|
background-color: ${(props) => props.backgroundColor || "transparent"};
|
|
|
|
overflow: hidden;
|
|
& > div {
|
|
height: 100%;
|
|
width: 100%;
|
|
}
|
|
`;
|
|
|
|
// wrapper component for apply styles on any widget boundary
|
|
function WidgetStyleContainer(props: WidgetStyleContainerProps) {
|
|
return (
|
|
<WidgetStyle {...props} data-testid={`container-wrapper-${props.widgetId}`}>
|
|
{props.children}
|
|
</WidgetStyle>
|
|
);
|
|
}
|
|
|
|
export default WidgetStyleContainer;
|