Skip to content

Commit

Permalink
Merge pull request #270 from flatironinstitute/sticky-headers
Browse files Browse the repository at this point in the history
Make headers sticky on tables
  • Loading branch information
WardBrian authored Feb 3, 2025
2 parents ccdaaac + 8a9fb7b commit 8ed1441
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { Download } from "@mui/icons-material";
import Box from "@mui/material/Box";
import Button from "@mui/material/Button";
import IconButton from "@mui/material/IconButton";
import Table from "@mui/material/Table";
import TableBody from "@mui/material/TableBody";
import TableCell from "@mui/material/TableCell";
import TableContainer from "@mui/material/TableContainer";
import TableRow from "@mui/material/TableRow";
import {
SuccessBorderedTableRow,
SuccessColoredTableHead,
Expand Down Expand Up @@ -70,8 +72,8 @@ const DrawsTablePanel: FunctionComponent<DrawsTableProps> = ({
}, [draws, paramNames, drawChainIds, samplingOpts]);

return (
<>
<div>
<Box display="flex" height="100%" width="100%" flexDirection="column">
<Box flex="1" marginBottom="0.75rem">
<IconButton size="small" title="Download" onClick={handleExportToCsv}>
<Download fontSize="inherit" />
&nbsp;Export to single .csv
Expand All @@ -85,18 +87,17 @@ const DrawsTablePanel: FunctionComponent<DrawsTableProps> = ({
<Download fontSize="inherit" />
&nbsp;Export to multiple .csv
</IconButton>
</div>
<br />
<TableContainer>
<Table size="small" padding="none">
</Box>
<TableContainer sx={{ flex: "0 1 auto", overflow: "auto" }}>
<Table stickyHeader size="small" padding="none">
<SuccessColoredTableHead>
<SuccessBorderedTableRow>
<TableRow>
<TableCell key="chain">Chain</TableCell>
<TableCell key="draw">Draw</TableCell>
{paramNames.map((name, i) => (
<TableCell key={i}>{name}</TableCell>
))}
</SuccessBorderedTableRow>
</TableRow>
</SuccessColoredTableHead>
<TableBody>
{formattedDraws[0].map((_, i) => (
Expand All @@ -123,7 +124,7 @@ const DrawsTablePanel: FunctionComponent<DrawsTableProps> = ({
</div>
)}
</TableContainer>
</>
</Box>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ const SummaryPanel: FunctionComponent<SummaryProps> = ({
}, [draws, paramNames, drawChainIds, computeTimeSec]);

return (
<TableContainer>
<Table>
<TableContainer sx={{ maxHeight: "100%", overflow: "auto" }}>
<Table stickyHeader>
<SecondaryColoredTableHead>
<TableRow>
<TableCell>Parameter</TableCell>
Expand Down
3 changes: 3 additions & 0 deletions gui/src/app/components/StyledTables.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const SecondaryColoredTableHead = styled(TableHead)(({ theme }) => ({
backgroundColor: theme.palette.secondary.light,
th: {
color: theme.palette.secondary.contrastText,
backgroundColor: theme.palette.secondary.light,
whiteSpace: "nowrap",
paddingRight: "0.5rem",
},
Expand All @@ -20,9 +21,11 @@ export const SecondaryColoredTableHead = styled(TableHead)(({ theme }) => ({
export const SuccessColoredTableHead = styled(TableHead)(({ theme }) => ({
backgroundColor: theme.palette.success.light,
th: {
backgroundColor: theme.palette.success.light,
color: theme.palette.success.contrastText,
whiteSpace: "nowrap",
paddingRight: "0.5rem",
borderBottom: "2px solid " + theme.palette.success.main,
},
}));

Expand Down

0 comments on commit 8ed1441

Please sign in to comment.