Skip to content

Commit

Permalink
fix: scorecard cells background color
Browse files Browse the repository at this point in the history
  • Loading branch information
atrincas committed Jan 28, 2025
1 parent 3fed571 commit d59e930
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
6 changes: 5 additions & 1 deletion client/src/components/ui/score-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ const DEFAULT_BG_CLASSES: Record<PROJECT_SCORE, string> = {
[PROJECT_SCORE.LOW]: "bg-ramps-red",
};

export const getScoreIndicatorBgClass = (value: PROJECT_SCORE | null) => {
return value ? DEFAULT_BG_CLASSES[value] : "bg-gray-300";
};

export const ScoreIndicator = ({ value, className }: ScoreIndicatorProps) => {
return (
<div
className={cn(
"flex h-10 items-center justify-center text-sm font-normal capitalize text-deep-ocean",
value ? DEFAULT_BG_CLASSES[value] : "bg-gray-300",
getScoreIndicatorBgClass(value),
className,
)}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useState } from "react";

import { ChevronDownIcon, ChevronUpIcon } from "@radix-ui/react-icons";
import { projectScorecardQuerySchema } from "@shared/contracts/projects.contract";
import { PROJECT_SCORE } from "@shared/entities/project-score.enum";
import { ProjectScorecardView } from "@shared/entities/project-scorecard.view";
import { keepPreviousData } from "@tanstack/react-query";
import {
Expand Down Expand Up @@ -39,6 +40,7 @@ import {
import { TABLE_COLUMNS } from "@/containers/overview/table/view/scorecard-prioritization/columns";
import { filtersToQueryParams } from "@/containers/overview/utils";

import { getScoreIndicatorBgClass } from "@/components/ui/score-card";
import {
ScrollableTable,
TableBody,
Expand Down Expand Up @@ -167,9 +169,16 @@ export function ScoredCardPrioritizationTable() {
{row.getVisibleCells().map((cell) => (
<TableCell
key={cell.id}
className={cn({
"p-0": cell.column.id !== "projectName",
})}
className={cn(
getScoreIndicatorBgClass(
cell.row.original[
cell.column.id as keyof ProjectScorecardView
] as PROJECT_SCORE,
),
{
"p-0": cell.column.id !== "projectName",
},
)}
>
{flexRender(cell.column.columnDef.cell, cell.getContext())}
</TableCell>
Expand Down

0 comments on commit d59e930

Please sign in to comment.