Skip to content

Commit 9ec8055

Browse files
authored
fix: sticky table header depending on a sticky page header (#1053)
feat: define CSS variable to accomplish sticky header table cells depending on a sticky header
1 parent d704f50 commit 9ec8055

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

source/_patterns/02-components/table/table.scss

+4-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,10 @@
168168
tbody th {
169169
background-color: #fff;
170170
position: sticky;
171-
top: -1px;
171+
top: var(
172+
--db-table-top-safe-space,
173+
var(--db-has-fixed-header-height, -1px)
174+
);
172175
}
173176
}
174177
}

source/_patterns/02-components/table/table~sticky-header.md

+2
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ title: Table - sticky header
33
---
44

55
You could set the header cells to appear sticky on scrolling, which is especially useful on longer tables with a lot of rows, by setting the `data-sticky="header"` attribute on the table.
6+
7+
To control the top position which should be taken into account at which the table components header starts to get displayed sticky, you could set the CSS variable `--db-table-top-safe-space`. Elsewhere we take `--db-has-fixed-header-height` to accomplish possible sticky headers being defined for a page. If even also this one isn't set, the default `-1` value would get taken for the calculation.

source/_patterns/03-areas/_areas.scss

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ body.has-fixed-footer .rea-footer {
1616
}
1717

1818
body.has-fixed-header {
19+
--db-has-fixed-header-height: #{to-rem($pxValue: 70)};
1920
// TODO: using some outsourced global declarations for the headers dimensions (height, padding and margins)
2021
padding-top: to-rem($pxValue: 95);
2122

0 commit comments

Comments
 (0)