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

374 lines
8.8 KiB
TypeScript
Raw Normal View History

2020-06-03 10:50:10 +00:00
import styled from "styled-components";
import { TableSizes } from "widgets/TableWidget";
import { Colors, Color } from "constants/Colors";
import { scrollbarLight } from "constants/DefaultTheme";
2020-06-03 10:50:10 +00:00
export const TableWrapper = styled.div<{
width: number;
height: number;
tableSizes: TableSizes;
backgroundColor?: Color;
}>`
width: 100%;
height: 100%;
2020-06-03 10:50:10 +00:00
background: white;
border: 1px solid ${Colors.GEYSER_LIGHT};
box-sizing: border-box;
display: flex;
justify-content: space-between;
flex-direction: column;
Fix-Open image in new tab on clicking it in table widget. (#119) * Added Button component in Table widget for actions * Action button state loading added for Table widget * Action button font-weight made as normal * Created header for common functionalities in Table Widget * Client side searching added in Table Widget. Action created for server side searching also. * Columns visibility feature initial commit * Column visibility list added in Table Widget * Changed pagination designs in accordance with new layout. This enable user to jump page as well. * Using colors values from constants * Table widget pagination, numeric input page number clamped between 1 and total pages * Adding tool tip to truncated values in table widget. Added AutoToolTipComponent that adds tooltip when text is truncated. * Table data download changes. Added downlaod icon and button to table widget. * Table data download changes * Table button loading state fixed. Table code refactored, rendering from props instead of state in ReactTableComponent * Table widget action button alignment fixed * Handled actions column changes * added proper keys to useMemo for react table widget * Download table data as CSV implemented * table data download, unused code removed * Code refactors and added dependency map with meta props and table data for computing columns * Table UI breakages on scroll and empty cells fixed * Handled empty rows in table widget * Fixed last row cut issue * Code review changes * Code review changes * Added table widget component heights as enum * code review changes * Search component in Table widget updated with support for clearing data, renamed properties * Opening image in new tab on clicking in table widget * Fixed table craching due to empty data filtering * Empty extra space on loading removed in table widget * Removed stopping of event propagation on table widget action button click * Table header UI overflow fixed * Clearing selected row on searching data in table widget * fix for cypress test Co-authored-by: Arpit Mohan <me@arpitmohan.com>
2020-07-24 10:32:31 +00:00
overflow: hidden;
2020-06-03 10:50:10 +00:00
.tableWrap {
2020-06-16 07:37:39 +00:00
height: 100%;
2020-06-03 10:50:10 +00:00
display: block;
overflow-x: auto;
overflow-y: hidden;
}
.table {
border-spacing: 0;
color: ${Colors.THUNDER};
2020-06-03 10:50:10 +00:00
position: relative;
background: ${Colors.ATHENS_GRAY_DARKER};
display: table;
width: 100%;
.thead,
2020-06-03 10:50:10 +00:00
.tbody {
overflow: hidden;
2020-06-03 10:50:10 +00:00
}
.tbody {
overflow-y: scroll;
/* Subtracting 9px to handling widget padding */
height: ${props =>
props.height -
props.tableSizes.TABLE_HEADER_HEIGHT -
props.tableSizes.COLUMN_HEADER_HEIGHT -
9}px;
.tr {
width: 100%;
}
}
2020-06-03 10:50:10 +00:00
.tr {
overflow: hidden;
2020-06-03 10:50:10 +00:00
:nth-child(even) {
background: ${Colors.ATHENS_GRAY_DARKER};
}
:nth-child(odd) {
background: ${Colors.WHITE};
}
2020-06-03 10:50:10 +00:00
&.selected-row {
2020-06-16 07:37:39 +00:00
background: ${Colors.POLAR};
&:hover {
background: ${Colors.POLAR};
}
2020-06-03 10:50:10 +00:00
}
&:hover {
background: ${Colors.ATHENS_GRAY};
}
}
.th,
.td {
margin: 0;
padding: 9px 10px;
border-bottom: 1px solid ${Colors.GEYSER_LIGHT};
border-right: 1px solid ${Colors.GEYSER_LIGHT};
position: relative;
font-size: ${props => props.tableSizes.ROW_FONT_SIZE}px;
line-height: ${props => props.tableSizes.ROW_FONT_SIZE}px;
2020-06-03 10:50:10 +00:00
:last-child {
border-right: 0;
}
.resizer {
display: inline-block;
width: 10px;
height: 100%;
position: absolute;
right: 0;
top: 0;
transform: translateX(50%);
z-index: 1;
${"" /* prevents from scrolling while dragging on touch devices */}
touch-action:none;
&.isResizing {
cursor: isResizing;
}
}
}
.th {
padding: 0 10px 0 0;
height: ${props => props.tableSizes.COLUMN_HEADER_HEIGHT}px;
line-height: ${props => props.tableSizes.COLUMN_HEADER_HEIGHT}px;
2020-06-03 10:50:10 +00:00
background: ${Colors.ATHENS_GRAY_DARKER};
}
.td {
height: ${props => props.tableSizes.ROW_HEIGHT}px;
line-height: ${props => props.tableSizes.ROW_HEIGHT}px;
2020-06-03 10:50:10 +00:00
padding: 0 10px;
}
}
.draggable-header,
.hidden-header {
width: 100%;
text-overflow: ellipsis;
overflow: hidden;
color: ${Colors.OXFORD_BLUE};
font-weight: 500;
padding-left: 10px;
&.sorted {
padding-left: 5px;
}
2020-06-03 10:50:10 +00:00
}
.draggable-header {
cursor: pointer;
&.reorder-line {
width: 1px;
height: 100%;
}
}
.hidden-header {
opacity: 0.6;
}
.column-menu {
cursor: pointer;
height: ${props => props.tableSizes.COLUMN_HEADER_HEIGHT}px;
line-height: ${props => props.tableSizes.COLUMN_HEADER_HEIGHT}px;
2020-06-03 10:50:10 +00:00
}
.th {
display: flex;
justify-content: space-between;
&.highlight-left {
border-left: 2px solid ${Colors.GREEN};
}
&.highlight-right {
border-right: 2px solid ${Colors.GREEN};
}
}
.input-group {
height: ${props => props.tableSizes.COLUMN_HEADER_HEIGHT}px;
line-height: ${props => props.tableSizes.COLUMN_HEADER_HEIGHT}px;
2020-06-03 10:50:10 +00:00
padding: 0 5px;
}
`;
export const DropDownWrapper = styled.div`
display: flex;
flex-direction: column;
background: white;
z-index: 1;
padding: 10px;
border-radius: 4px;
border: 1px solid ${Colors.ATHENS_GRAY};
box-shadow: 0px 2px 4px rgba(67, 70, 74, 0.14);
`;
export const OptionWrapper = styled.div<{ selected: boolean }>`
display: flex;
width: 100%;
justify-content: space-between;
height: 32px;
box-sizing: border-box;
padding: 8px;
color: ${props => (props.selected ? Colors.WHITE : Colors.OXFORD_BLUE)};
font-size: 14px;
min-width: 200px;
cursor: pointer;
border-radius: 4px;
margin: 3px 0;
background: ${props => (props.selected ? Colors.GREEN : Colors.WHITE)};
&:hover {
background: ${props => (props.selected ? Colors.GREEN : Colors.POLAR)};
}
.column-type {
width: 100%;
}
&.non-selectable {
background: ${Colors.WHITE_SMOKE};
2020-06-03 10:50:10 +00:00
}
`;
export const IconOptionWrapper = styled.div`
display: flex;
justify-content: space-between;
width: 100%;
cursor: pointer;
`;
export const PaginationWrapper = styled.div`
box-sizing: border-box;
display: flex;
width: 100%;
justify-content: flex-end;
align-items: center;
padding: 8px 20px;
2020-06-03 10:50:10 +00:00
`;
export const PaginationItemWrapper = styled.div<{
disabled?: boolean;
selected?: boolean;
}>`
background: ${props => (props.disabled ? Colors.ATHENS_GRAY : Colors.WHITE)};
border: 1px solid
${props => (props.selected ? Colors.GREEN : Colors.GEYSER_LIGHT)};
box-sizing: border-box;
border-radius: 4px;
width: 24px;
height: 24px;
2020-06-03 10:50:10 +00:00
display: flex;
justify-content: center;
align-items: center;
margin: 0 4px;
2020-06-03 10:50:10 +00:00
pointer-events: ${props => props.disabled && "none"};
cursor: pointer;
&:hover {
border-color: ${Colors.GREEN};
}
`;
export const MenuColumnWrapper = styled.div<{ selected: boolean }>`
display: flex;
justify-content: flex-start;
align-items: center;
width: 100%;
background: ${props => props.selected && Colors.GREEN};
position: relative;
.title {
color: ${props => (props.selected ? Colors.WHITE : Colors.OXFORD_BLUE)};
margin-left: 10px;
}
.sub-menu {
position: absolute;
right: 0;
}
`;
export const ActionWrapper = styled.div`
margin: 0 5px 0 0;
&&&&&& {
.bp3-button span {
font-weight: 400;
}
}
2020-06-03 10:50:10 +00:00
`;
export const CellWrapper = styled.div<{ isHidden?: boolean }>`
2020-06-03 10:50:10 +00:00
display: flex;
align-items: center;
justify-content: flex-start;
width: 100%;
height: 100%;
2020-06-03 10:50:10 +00:00
overflow: hidden;
text-overflow: ellipsis;
2020-06-16 07:37:39 +00:00
white-space: nowrap;
2020-06-03 10:50:10 +00:00
opacity: ${props => (props.isHidden ? "0.6" : "1")};
.image-cell {
width: 40px;
height: 32px;
margin: 0 5px 0 0;
border-radius: 4px;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
video {
border-radius: 4px;
}
2020-06-16 07:37:39 +00:00
&.video-cell {
height: 100%;
iframe {
border: none;
border-radius: 4px;
}
}
2020-06-03 10:50:10 +00:00
`;
export const TableHeaderWrapper = styled.div<{
serverSidePaginationEnabled: boolean;
width: number;
tableSizes: TableSizes;
backgroundColor?: Color;
}>`
display: flex;
border-bottom: 1px solid ${Colors.GEYSER_LIGHT};
width: ${props => props.width}px;
.show-page-items {
display: ${props => (props.width < 700 ? "none" : "flex")};
}
overflow-x: auto;
overflow-y: hidden;
height: ${props => props.tableSizes.TABLE_HEADER_HEIGHT}px;
min-height: ${props => props.tableSizes.TABLE_HEADER_HEIGHT}px;
${scrollbarLight};
`;
export const CommonFunctionsMenuWrapper = styled.div<{
tableSizes: TableSizes;
}>`
display: flex;
align-items: center;
height: ${props => props.tableSizes.TABLE_HEADER_HEIGHT}px;
`;
export const RowWrapper = styled.div`
display: flex;
align-items: center;
justify-content: center;
font-size: 12px;
line-height: 20px;
color: ${Colors.BLUE_BAYOUX};
margin: 0 4px;
white-space: nowrap;
`;
export const TableIconWrapper = styled.div<{
selected?: boolean;
disabled?: boolean;
}>`
background: ${props => (props.selected ? Colors.ATHENS_GRAY : "transparent")};
box-shadow: ${props =>
props.selected ? `inset 0px 4px 0px ${Colors.GREEN}` : "none"};
width: 48px;
height: 42px;
display: flex;
align-items: center;
justify-content: center;
opacity: ${props => (props.disabled ? 0.6 : 1)};
cursor: ${props => !props.disabled && "pointer"};
position: relative;
&:hover {
background: ${Colors.ATHENS_GRAY};
}
`;
export const SortIconWrapper = styled.div<{ rotate: string }>`
transform: ${props => (props.rotate === "true" ? "rotate(180deg)" : "none")};
`;
export const RenderOptionWrapper = styled.div<{ selected: boolean }>`
display: flex;
justify-content: space-between;
align-items: center;
width: 150px;
background: ${props => props.selected && Colors.GREEN};
position: relative;
.title {
color: ${props => (props.selected ? Colors.WHITE : Colors.OXFORD_BLUE)};
width: 120px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.type {
position: absolute;
left: 135px;
font-size: 12px !important;
color: ${props => (props.selected ? Colors.WHITE : Colors.BLUE_BAYOUX)};
}
`;
export const MenuCategoryWrapper = styled.div`
display: flex;
width: 100%;
align-items: center;
justify-content: space-between;
color: ${Colors.RIVER_BED};
`;