added a way to do cell styling in the responsive tables

This commit is contained in:
csawatzky 2025-03-07 14:03:45 -06:00
parent d19d37410e
commit 2fc25431bd
2 changed files with 7 additions and 3 deletions

View file

@ -450,7 +450,7 @@ export default function ResponsiveTable<T extends Object>(props: Props<T>) {
columns.map((column, j) => { columns.map((column, j) => {
if (filterList.includes(column.title)) return null if (filterList.includes(column.title)) return null
if (column.render) return ( if (column.render) return (
<TableCell key={"row-"+index+"cell-"+j} sx={{ padding: 0}} > <TableCell key={"row-"+index+"cell-"+j} sx={column.cellStyle ? column.cellStyle : {padding: 0}}>
{column.render(row)} {column.render(row)}
</TableCell> </TableCell>
) )

View file

@ -1,4 +1,4 @@
import { Box, Grid2 as Grid, Skeleton, Theme, Tooltip } from "@mui/material"; import { Box, Grid2 as Grid, Skeleton, Theme, Tooltip, Typography } from "@mui/material";
import { makeStyles } from "@mui/styles"; import { makeStyles } from "@mui/styles";
import { NextMeasurementChip } from "common/NextMeasurementChip"; import { NextMeasurementChip } from "common/NextMeasurementChip";
import ResponsiveTable, { Column } from "common/ResponsiveTable"; import ResponsiveTable, { Column } from "common/ResponsiveTable";
@ -465,16 +465,20 @@ export default function DeviceComponent() {
return [ return [
{ {
title: "Timestamp", title: "Timestamp",
cellStyle: {width: "50%"},
render: row => { render: row => {
return ( return (
<Tooltip title={moment(row.timestamp).calendar()}> <Tooltip title={moment(row.timestamp).calendar()}>
<span>{moment(row.timestamp).fromNow()}</span> <Box>
<Typography>{moment(row.timestamp).fromNow()}</Typography>
</Box>
</Tooltip> </Tooltip>
) )
} }
}, },
{ {
title: "Measurement", title: "Measurement",
cellStyle: {width: "50%"},
render: row => { render: row => {
return ( return (
<UnitMeasurementSummary <UnitMeasurementSummary