generated from EyeSeeTea/dhis2-app-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
fdelemarre
committed
Jul 8, 2024
1 parent
2dd88a3
commit de6212c
Showing
3 changed files
with
52 additions
and
22 deletions.
There are no files selected for viewing
27 changes: 16 additions & 11 deletions
27
src/webapp/components/table/statistic-table/ColoredCell.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,30 @@ | ||
import React from "react"; | ||
import styled from "styled-components"; | ||
import { TableCell } from "@material-ui/core"; | ||
import { CellStatus, CellStatusValues } from "../../../hooks/useTableCell"; | ||
|
||
type ColoredCellProps = { | ||
value: string; | ||
color?: string; | ||
boldUnderline?: boolean; | ||
color?: CellStatusValues; | ||
}; | ||
|
||
const StyledTableCell = styled(TableCell)<{ color?: string; boldUnderline?: boolean }>` | ||
background-color: ${props => | ||
props.color ? props.theme.palette.common[props.color] : "initial"}; | ||
color: ${props => (props.color ? props.theme.palette.common.white : "initial")}; | ||
text-decoration: ${props => (props.boldUnderline ? "underline" : "none")}; | ||
font-weight: ${props => (props.boldUnderline || props.color ? "600" : "initial")}; | ||
`; | ||
const cellStatusColor = { | ||
[CellStatus.Valid]: "green", | ||
[CellStatus.Alert]: "red", | ||
[CellStatus.Warning]: "orange", | ||
}; | ||
|
||
export const ColoredCell: React.FC<ColoredCellProps> = ({ value, color, boldUnderline }) => { | ||
export const ColoredCell: React.FC<ColoredCellProps> = ({ value, color }) => { | ||
return ( | ||
<StyledTableCell color={color} boldUnderline={boldUnderline}> | ||
<StyledTableCell color={color ? cellStatusColor[color] : undefined}> | ||
{value} | ||
</StyledTableCell> | ||
); | ||
}; | ||
|
||
const StyledTableCell = styled(TableCell)<{ color?: string }>` | ||
background-color: ${props => | ||
props.color ? props.theme.palette.common[props.color] : "initial"}; | ||
color: ${props => (props.color ? props.theme.palette.common.white : "initial")}; | ||
font-weight: ${props => (props.color ? "600" : "initial")}; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters