Placed the TableContainer in a box to better match figma design.

This commit is contained in:
M M committed 2024-07-02 20:24:51 -07:00
1 parent 75d16b749d
commit c2b47e5cc4
1 file changed
+40 -27
+40 -27
View File
@@ -1,4 +1,4 @@
import { styled } from '@mui/material/styles'; import { styled, useTheme } from '@mui/material/styles';
import Table from '@mui/material/Table'; import Table from '@mui/material/Table';
import TableBody from '@mui/material/TableBody'; import TableBody from '@mui/material/TableBody';
import TableCell, { tableCellClasses } from '@mui/material/TableCell'; import TableCell, { tableCellClasses } from '@mui/material/TableCell';
@@ -6,9 +6,9 @@ import TableContainer from '@mui/material/TableContainer';
import TableHead from '@mui/material/TableHead'; import TableHead from '@mui/material/TableHead';
import TableRow from '@mui/material/TableRow'; import TableRow from '@mui/material/TableRow';
import Paper from '@mui/material/Paper'; import Paper from '@mui/material/Paper';
import Box from '@mui/material/Box';
import { StatusLabel } from "../../Components/Label/"; import { StatusLabel } from "../../Components/Label/";
const StyledTableCell = styled(TableCell)(({ theme }) => ({ const StyledTableCell = styled(TableCell)(({ theme }) => ({
[`&.${tableCellClasses.head}`]: { [`&.${tableCellClasses.head}`]: {
backgroundColor: theme.palette.action.hover, backgroundColor: theme.palette.action.hover,
@@ -31,8 +31,8 @@ const StyledTableRow = styled(TableRow)(({ theme }) => ({
}, },
})); }));
function createData(name, calories, fat, carbs, protein) { function createData(name, date, message) {
return { name, calories, fat, carbs, protein }; return { name, date, message };
} }
const rows = [ const rows = [
@@ -43,30 +43,43 @@ const rows = [
createData(<StatusLabel status="Down" customStyles={{ backgroundColor: '#fff9f9', borderColor: '#ffcac6', color: '#344054' }} />, '2024-03-14 21:41:09', 'HTTP 350 - NOK'), createData(<StatusLabel status="Down" customStyles={{ backgroundColor: '#fff9f9', borderColor: '#ffcac6', color: '#344054' }} />, '2024-03-14 21:41:09', 'HTTP 350 - NOK'),
]; ];
export default function CustomizedTables() { export default function CustomizedTables() {
const theme = useTheme();
return ( return (
<TableContainer component={Paper}> <Box
<Table sx={{ minWidth: 700 }} aria-label="customized table"> sx={{
<TableHead> marginTop: theme.spacing(4),
<TableRow> marginX: 'auto',
<StyledTableCell>Status</StyledTableCell> width: '80%',
<StyledTableCell align="right">Date & Time</StyledTableCell> paddingX: theme.spacing(6),
<StyledTableCell align="right">Message</StyledTableCell> [theme.breakpoints.down('md')]: {
</TableRow> width: '100%',
</TableHead> },
<TableBody> }}
{rows.map((row, index) => ( >
<StyledTableRow key={index}> <TableContainer component={Paper}>
<StyledTableCell component="th" scope="row"> <Table sx={{ minWidth: 700 }} aria-label="customized table">
{row.name} <TableHead>
</StyledTableCell> <TableRow>
<StyledTableCell align="right">{row.calories}</StyledTableCell> <StyledTableCell>Status</StyledTableCell>
<StyledTableCell align="right">{row.fat}</StyledTableCell> <StyledTableCell align="right">Date & Time</StyledTableCell>
</StyledTableRow> <StyledTableCell align="right">Message</StyledTableCell>
))} </TableRow>
</TableBody> </TableHead>
</Table> <TableBody>
</TableContainer> {rows.map((row, index) => (
<StyledTableRow key={index}>
<StyledTableCell component="th" scope="row">
{row.name}
</StyledTableCell>
<StyledTableCell align="right">{row.date}</StyledTableCell>
<StyledTableCell align="right">{row.message}</StyledTableCell>
</StyledTableRow>
))}
</TableBody>
</Table>
</TableContainer>
</Box>
); );
} }