Skip to content

Commit

Permalink
Final data view styling
Browse files Browse the repository at this point in the history
Signed-off-by: Emil Balitzki <emil.balitzki@gmail.com>
  • Loading branch information
Corgam committed Jul 12, 2024
1 parent 06b87af commit 4f9f45a
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 20 deletions.
14 changes: 14 additions & 0 deletions frontend/src/components/DataView/DataRow.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,22 @@

.data-row {
height: 40px;
background-color: rgb(251, 251, 251);
}

.data-row-title-container {
padding-left: 0 !important;
}

.data-row-title {
display: flex !important;
gap: 0.5rem;
}

.data-row-value {
text-align: end !important;
}

.subdata-rows-container > *:last-child > * {
border-bottom: none;
}
43 changes: 25 additions & 18 deletions frontend/src/components/DataView/DataRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Fragment, useState, useEffect } from "react";
import { DatasetItem } from "../../types/LocationDataTypes";
import { useContext } from "react";
import {
Box,
Collapse,
IconButton,
Table,
Expand Down Expand Up @@ -94,6 +93,13 @@ const DataRow: React.FC<RowProps> = ({ row, currentDatasets }) => {
}
};

const getIconByDatasetID = (datasetID: string | null) => {
const dataset = currentDatasets.find((ds) => ds.datasetId === datasetID);
return (
dataset?.icon && <CustomSvgIcon svgString={dataset.icon} size={20} />
);
};

return (
<Fragment>
<TableRow className="data-row">
Expand All @@ -113,10 +119,13 @@ const DataRow: React.FC<RowProps> = ({ row, currentDatasets }) => {
<TableCell
component="th"
scope="row"
className="data-row-title"
size="small"
className="data-row-title-container"
>
{row.displayName}
<div className="data-row-title">
{getIconByDatasetID(row.datasetID)}
{row.displayName}
</div>
</TableCell>
{row.value && row.value !== "" ? (
<TableCell
Expand All @@ -130,7 +139,7 @@ const DataRow: React.FC<RowProps> = ({ row, currentDatasets }) => {
) : (
<TableCell />
)}
{row.datasetID && row.datasetID != "" ? (
{row.datasetID && row.datasetID !== "" ? (
<TableCell className="toggle-column" size="small">
<Tooltip title="Locate on the map" arrow placement="left">
<IconButton
Expand All @@ -151,20 +160,18 @@ const DataRow: React.FC<RowProps> = ({ row, currentDatasets }) => {
<TableRow>
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={6}>
<Collapse in={open} timeout="auto" unmountOnExit>
<Box margin={1}>
<Table size="small" aria-label="subdata">
<TableBody>
{row.subdata.map((subItem) => (
<TableRow key={subItem.key}>
<TableCell component="th" scope="row" size="small">
{subItem.key}
</TableCell>
<TableCell size="small">{subItem.value}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</Box>
<Table size="small" aria-label="subdata">
<TableBody className="subdata-rows-container">
{row.subdata.map((subItem) => (
<TableRow key={subItem.key}>
<TableCell component="th" scope="row" size="small">
{subItem.key}
</TableCell>
<TableCell size="small">{subItem.value}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</Collapse>
</TableCell>
</TableRow>
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/components/DataView/DataView.css
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@
max-height: 100%;
display: flex;
flex-direction: column;
overflow-y: scroll;
overflow-y: auto;
margin-bottom: 1rem;
}

.data-collapse-table {
min-height: auto !important;
}
7 changes: 6 additions & 1 deletion frontend/src/components/DataView/DataView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,12 @@ const DataView = () => {
{showSelectionData ? <CaretUp /> : <CaretDown />}
Selection Data
</p>
<Collapse in={showSelectionData} timeout="auto" unmountOnExit>
<Collapse
in={showSelectionData}
timeout="auto"
unmountOnExit
className="data-collapse-table"
>
<TableContainer>
<Table>
<TableBody>
Expand Down

0 comments on commit 4f9f45a

Please sign in to comment.