Skip to content

Commit

Permalink
apply conditional styling
Browse files Browse the repository at this point in the history
  • Loading branch information
NikhilShahi committed Aug 10, 2022
1 parent e24883a commit 5ded8f8
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions frontend/src/components/Endpoint/AlertList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,25 @@ const AlertList: React.FC<AlertListProps> = React.memo(
}
}

const selectedRowColor = useColorModeValue(
"rgb(242, 242, 242)",
"rgb(34, 37, 42)"
);

const conditionalStyles = [
{
when: (row: Alert) => {
if (!alert) {
return false;
}
return row.uuid == alert.uuid;
},
style: {
backgroundColor: selectedRowColor,
},
},
];

useEffect(() => {
setAlertList(alerts);
}, [alerts]);
Expand Down Expand Up @@ -149,9 +168,12 @@ const AlertList: React.FC<AlertListProps> = React.memo(
>
<Box w={alert ? "calc(100% - 650px)" : "full"} h="full">
<DataTable
fixedHeader={true}
fixedHeaderScrollHeight="100%"
style={rowStyles}
columns={columns}
data={alertList}
conditionalRowStyles={conditionalStyles}
customStyles={getCustomStyles(colorMode.colorMode)}
onRowClicked={onRowClicked}
/>
Expand Down

0 comments on commit 5ded8f8

Please sign in to comment.