Skip to content

Commit 45ce194

Browse files
committed
fix(table): fix scrollable table
allow no spacing fix z index issues fix sticky multiple thead tr
1 parent 1a3d942 commit 45ce194

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed

packages/components/base/src/table/Table/index.module.scss

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,19 @@
3838
max-height: 100%;
3939

4040
@include sticky-column {
41+
background-color: theme.get-color(neutral-light-100);
4142
position: sticky;
4243
left: 0;
43-
background-color: theme.get-color(neutral-light-100);
44+
z-index: 2;
4445
}
4546

46-
@include sticky_headers {
47+
thead {
4748
position: sticky;
4849
top: 0;
50+
z-index: 3 !important;
51+
}
52+
53+
@include sticky_headers {
4954
background-color: theme.get-color(neutral-light-300-solid) !important;
5055
white-space: nowrap;
5156

@@ -61,15 +66,15 @@
6166
.scrollable.skin_bordered {
6267
@include sticky_headers {
6368
&::before {
69+
content: "";
70+
background-color: scss-utils.get-css-var(table, border-color);
71+
display: block;
6472
position: absolute;
65-
z-index: 1;
6673
bottom: calc(#{scss-utils.get-css-var(spacing, border)} * -1);
6774
left: 0;
68-
display: block;
6975
width: 100%;
7076
height: scss-utils.get-css-var(spacing, border);
71-
background-color: scss-utils.get-css-var(table, border-color);
72-
content: "";
77+
z-index: 1;
7378
}
7479
}
7580
}
@@ -78,14 +83,14 @@
7883
.scrollable.skin_bordered {
7984
@include sticky-column {
8085
&::after {
86+
content: "";
87+
background-color: scss-utils.get-css-var(table, border-color);
88+
display: block;
8189
position: absolute;
8290
top: 0;
8391
right: 0;
84-
display: block;
8592
width: scss-utils.get-css-var(spacing, border);
8693
height: 100%;
87-
background-color: scss-utils.get-css-var(table, border-color);
88-
content: "";
8994
}
9095
}
9196
}
@@ -126,6 +131,11 @@
126131
@include scss-utils.define-css-var(table, min-height, theme.get-spacing(4));
127132
}
128133

134+
.spacing_none {
135+
@include scss-utils.define-css-var(table, spacing, 0);
136+
@include scss-utils.define-css-var(table, min-height, 0);
137+
}
138+
129139
// Table
130140

131141
.table {

packages/components/base/src/table/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export interface TableContextProps {
44
/** Specifies the visual style of the table */
55
skin: "default" | "bordered" | "bordered-row" | "bordered-column";
66
/** Specifies the spacing between table elements */
7-
spacing: "default" | "compact";
7+
spacing: "default" | "compact" | "none";
88
/** Allows container to be scrollable and adds sticky headers */
99
scrollable: boolean;
1010
}

packages/docs/stories/src/generic-table.stories.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,24 @@ const children = [
3434
<Table.Th key={i}>{CC.capitalCase(faker.company.buzzAdjective())}</Table.Th>
3535
))}
3636
</Table.Tr>
37+
<Table.Tr>
38+
<Table.Th>
39+
<Checkbox indeterminate />
40+
</Table.Th>
41+
<Table.Th colSpan={columns}>{CC.capitalCase(faker.company.buzzAdjective())}</Table.Th>
42+
</Table.Tr>
3743
</Table.Thead>,
3844
<Table.TBody key="body">
3945
{Object.keys(Array.from({ length: rows })).map((r) => (
4046
<Table.Tr key={r} selected={r === "1"} interactive={Number(r) < rows / 2}>
4147
<Table.Td>
4248
<Checkbox />
4349
</Table.Td>
50+
<Table.Td>
51+
<div
52+
style={{ background: "pink", position: "relative", zIndex: 1, height: 20, width: 20 }}
53+
/>
54+
</Table.Td>
4455
{Object.keys(Array.from({ length: columns })).map((i) => (
4556
<Table.Td key={i}>{faker.company.catchPhraseDescriptor()}</Table.Td>
4657
))}

0 commit comments

Comments
 (0)