-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dagit] Introduce sticky table headers (#7568)
## Summary Resolves #4182. A long-standing ticket in our "Later" backlog, I figured I'd go ahead and crank it out. Make the table headers in Runs and Asset catalog sticky when scrolling. I made a `StickyTableContainer` that we should ideally be able to use elsewhere in Dagit. ## Test Plan View Runs, Job runs, Asset catalog. Scroll down, verify header stickiness. Verify that the select-all checkbox behaves as expected. Tested in Chrome, Firefox, Safari.
- Loading branch information
Showing
4 changed files
with
112 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
js_modules/dagit/packages/core/src/ui/StickyTableContainer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import {Colors} from '@dagster-io/ui'; | ||
import styled from 'styled-components/macro'; | ||
|
||
interface Props { | ||
$top: number; | ||
} | ||
|
||
/** | ||
* Wrap a `Table` component with this to cause its `thead` to be sticky while scrolling. | ||
* | ||
* `$top` is the pixel value of the point in the scrolling container that the `thead` | ||
* should stick to. Probably `0`. | ||
*/ | ||
export const StickyTableContainer = styled.div<Props>` | ||
thead tr { | ||
position: sticky; | ||
top: ${({$top}) => $top}px; | ||
background-color: ${Colors.White}; | ||
z-index: 1; | ||
} | ||
/** | ||
* Safari won't render a box-shadow on the \`tr\` and we don't want an inset | ||
* box-shadow on \`th\` elements because it will create a double-border on the | ||
* bottom of the \`thead\` in the non-stuck state. | ||
* | ||
* We therefore render an absoulutely-positioned keyline on the bottom of the | ||
* \`th\` elements. This will appear as a border in the stuck state, and will | ||
* overlap the top box-shadow of the first row in the non-stuck state. | ||
*/ | ||
thead tr th { | ||
position: relative; | ||
} | ||
thead tr th::after { | ||
content: ''; | ||
display: block; | ||
height: 1px; | ||
background-color: ${Colors.KeylineGray}; | ||
position: absolute; | ||
bottom: -1px; | ||
left: 0; | ||
right: 0; | ||
} | ||
`; |