Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add data table #281

Merged
merged 58 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
ad5802e
[BOOKINGSG-4436][BK] [DS] Table Component (Basic)
balakrishnan-s5 Aug 10, 2023
059d36d
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) props update
balakrishnan-s5 Aug 10, 2023
7bbeb21
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) props table update
balakrishnan-s5 Aug 10, 2023
2294a5a
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) with checkbox story
balakrishnan-s5 Aug 10, 2023
5507a6e
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) new stories added
balakrishnan-s5 Aug 10, 2023
80da80c
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) checkbox story updated
balakrishnan-s5 Aug 11, 2023
7e38a1a
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) new stories added
balakrishnan-s5 Aug 13, 2023
d74b7d5
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) new stories added
balakrishnan-s5 Aug 13, 2023
e21699d
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) Loading stories added
balakrishnan-s5 Aug 13, 2023
bda1ffd
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) Props updated
balakrishnan-s5 Aug 15, 2023
940efa5
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) Props updated
balakrishnan-s5 Aug 15, 2023
de4f42f
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) Props updated
balakrishnan-s5 Aug 17, 2023
9fe7d5d
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) Props updated
balakrishnan-s5 Aug 17, 2023
3d385ec
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) Props updated
balakrishnan-s5 Aug 17, 2023
1f6c557
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) Props updated
balakrishnan-s5 Aug 17, 2023
1baaa18
Merge branch 'master' into add-data-table
balakrishnan-s5 Aug 17, 2023
7685633
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) Props updated
balakrishnan-s5 Aug 17, 2023
1ebf30a
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) Props updated
balakrishnan-s5 Aug 17, 2023
d5f5047
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) Props updated
balakrishnan-s5 Aug 17, 2023
869f054
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) Props updated
balakrishnan-s5 Aug 17, 2023
cdf0a2b
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) comments clean up
balakrishnan-s5 Aug 17, 2023
07aa23b
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) row padding updated
balakrishnan-s5 Aug 17, 2023
b1a76ff
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) Custom Empty view a…
balakrishnan-s5 Aug 17, 2023
839ef68
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) action button props…
balakrishnan-s5 Aug 18, 2023
b504c3e
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) Custom Empty image
balakrishnan-s5 Aug 18, 2023
1890535
Merge branch 'master' into add-data-table
balakrishnan-s5 Aug 18, 2023
bef4fcc
[BOOKINGSG-4436][BK] [DS] Table Component (Basic)
balakrishnan-s5 Aug 10, 2023
42db5d1
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) props update
balakrishnan-s5 Aug 10, 2023
449e6d7
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) props table update
balakrishnan-s5 Aug 10, 2023
8183bc3
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) with checkbox story
balakrishnan-s5 Aug 10, 2023
22492ab
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) new stories added
balakrishnan-s5 Aug 10, 2023
6d986c4
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) checkbox story updated
balakrishnan-s5 Aug 11, 2023
95d99ae
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) new stories added
balakrishnan-s5 Aug 13, 2023
c1d0505
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) new stories added
balakrishnan-s5 Aug 13, 2023
e8f9531
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) Loading stories added
balakrishnan-s5 Aug 13, 2023
5853a5a
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) Props updated
balakrishnan-s5 Aug 15, 2023
72e00ca
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) Props updated
balakrishnan-s5 Aug 15, 2023
57ef9a6
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) Props updated
balakrishnan-s5 Aug 17, 2023
6937428
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) Props updated
balakrishnan-s5 Aug 17, 2023
887414b
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) Props updated
balakrishnan-s5 Aug 17, 2023
cab1ac6
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) Props updated
balakrishnan-s5 Aug 17, 2023
7526c4a
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) Props updated
balakrishnan-s5 Aug 17, 2023
0dde103
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) Props updated
balakrishnan-s5 Aug 17, 2023
2d5e622
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) Props updated
balakrishnan-s5 Aug 17, 2023
12e725b
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) Props updated
balakrishnan-s5 Aug 17, 2023
519d0e5
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) comments clean up
balakrishnan-s5 Aug 17, 2023
eb22a71
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) row padding updated
balakrishnan-s5 Aug 17, 2023
8babfc4
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) Custom Empty view a…
balakrishnan-s5 Aug 17, 2023
aad2850
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) action button props…
balakrishnan-s5 Aug 18, 2023
c59e494
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) Custom Empty image
balakrishnan-s5 Aug 18, 2023
edb4495
Merge branch 'add-data-table' of https://github.com/LifeSG/react-desi…
balakrishnan-s5 Aug 21, 2023
895f9a6
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) Sort Indicator tag …
balakrishnan-s5 Aug 21, 2023
7de290e
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) Custom Empty image
balakrishnan-s5 Aug 21, 2023
230ca9c
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) Style Props fixes
balakrishnan-s5 Aug 22, 2023
e826241
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) Style Props fixes
balakrishnan-s5 Aug 23, 2023
3f9d32a
[BOOKINGSG-4436][BK] [DS] Table Component (Basic) PR comment fixes
balakrishnan-s5 Aug 25, 2023
a07ebad
[BOOKINGSG-4436][SR] Refactor code referencing PR comments
SasithaRajapakasha Aug 28, 2023
f06de25
[BOOKINGSG-4436][SR] Add right padding to last cell of the row
SasithaRajapakasha Aug 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 137 additions & 0 deletions src/data-table/data-table.styles.tsx
Copy link
Contributor

@qroll qroll Aug 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • is it intended for the non-first cells to not have horizontal padding? they are misaligned with the headers which do have padding
Screen.Recording.2023-08-22.at.9.31.51.AM.mov

Copy link
Contributor

@qroll qroll Aug 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • similarly the loader and empty image are not centered

Screenshot 2023-08-22 at 9 38 34 AM

Copy link
Contributor

@qroll qroll Aug 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • the last column should have the additional right padding as well to match the first column

Screenshot 2023-08-22 at 9 39 23 AM

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • the last column should have a right padding
Screenshot 2023-08-28 at 11 41 34 AM

Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
import styled, { css } from "styled-components";
import { Color } from "../color";
import { TextStyleHelper } from "../text";

// =============================================================================
// STYLE INTERFACE, transient props are denoted with $
// See more https://styled-components.com/docs/api#transient-props
// =============================================================================
interface TableStyleProps {
$addMarginToFirstColumn?: boolean;
}
interface HeaderCellProps {
$clickable: boolean;
$maxWidth?: string;
}
interface BodyRowProps {
$alternating: boolean;
$isSelected?: boolean;
$isSelectable?: boolean;
}
interface BodyRowProps {
$alternating: boolean;
$isSelected?: boolean;
$isSelectable?: boolean;
}
interface BodyCellProps {
$width?: string;
}
// =============================================================================
// STYLES
// =============================================================================

export const TableWrapper = styled.div`
width: 100%;
border: 0.125rem solid ${Color.Neutral[6]};
border-radius: 0.5rem 0.5rem 0 0;
overflow: auto;
`;

export const Table = styled.table<TableStyleProps>`
width: 100%;
border-collapse: collapse;
tr,
td {
padding: 1.5rem 0;
}
th:last-child,
td:last-child {
padding-right: 1.5rem;
}
${(props) => {
if (props.$addMarginToFirstColumn) {
return css`
th:first-child,
td:first-child {
padding-left: 1.5rem;
}
`;
}
}}
`;

export const HeaderRow = styled.tr`
background-color: #f5f5f5;
height: 5rem;
border-bottom: 0.125rem solid ${Color.Neutral[6]};
`;

export const HeaderCell = styled.th<HeaderCellProps>`
padding: 1rem 0;
text-align: left;
cursor: ${(props) => (props.$clickable ? "pointer" : "default")};
max-width: ${(props) => (props.$maxWidth ? props.$maxWidth : "auto")};
vertical-align: middle;
${TextStyleHelper.getFontFamily("H5", "bold")}
color: ${Color.Neutral[1]};
`;

export const HeaderCellWrapper = styled.div`
display: flex;
flex-direction: row;
align-items: center;

svg {
color: ${Color.Neutral[1]};
margin-left: 0.5rem;
}
`;

export const BodyRow = styled.tr<BodyRowProps>`
background-color: ${(props) => {
if (props.$isSelected) {
return css`
${Color.Accent.Light[5]};
`;
} else if (props.$alternating) {
return css`
${Color.Neutral[7]};
`;
} else {
return css`
${Color.Neutral[8]};
`;
}
}};
border-top: 0.125rem solid ${Color.Neutral[6]};
&:hover {
background-color: ${(props) => {
if (!props.$isSelected && props.$isSelectable) {
return css`
${Color.Accent.Light[4]};
`;
}
}};
}
&:first-child {
border-top: none;
}
`;

export const BodyCell = styled.td<BodyCellProps>`
padding: 1.25rem 1rem;
width: ${(props) => (props.$width ? props.$width : "auto")};
vertical-align: middle;
`;

export const CheckBoxWrapper = styled.div`
display: flex;
align-items: center;
justify-content: center;
`;

export const LoaderWrapper = styled.div`
display: flex;
flex-direction: column;
align-items: center;
`;
Loading