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

Make headers sticky on tables #270

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
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