Placed the TableContainer in a box to better match figma design.
This commit is contained in:
1 parent
75d16b749d
commit
c2b47e5cc4
1 file changed
+43
-30
@@ -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,12 +6,12 @@ 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,
|
||||||
color: theme.palette.common.black,
|
color: theme.palette.common.black,
|
||||||
},
|
},
|
||||||
[`&.${tableCellClasses.body}`]: {
|
[`&.${tableCellClasses.body}`]: {
|
||||||
@@ -21,18 +21,18 @@ const StyledTableCell = styled(TableCell)(({ theme }) => ({
|
|||||||
|
|
||||||
const StyledTableRow = styled(TableRow)(({ theme }) => ({
|
const StyledTableRow = styled(TableRow)(({ theme }) => ({
|
||||||
'&:nth-of-type(1)': {
|
'&:nth-of-type(1)': {
|
||||||
backgroundColor: theme.palette.action.hover,
|
backgroundColor: theme.palette.action.hover,
|
||||||
},
|
},
|
||||||
'&:nth-of-type(n+1)': {
|
'&:nth-of-type(n+1)': {
|
||||||
backgroundColor: theme.palette.common.white,
|
backgroundColor: theme.palette.common.white,
|
||||||
},
|
},
|
||||||
'&:last-child td, &:last-child th': {
|
'&:last-child td, &:last-child th': {
|
||||||
border: 0,
|
border: 0,
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
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>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user