Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: standardize table header and cell text styling #191

Merged
merged 2 commits into from
Dec 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions client/src/containers/overview/table/view/overview/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,21 @@ const createSegments = (
];
};

const HeaderText = ({ children }: { children: React.ReactNode }) => (
<span className="text-xs font-normal">{children}</span>
);
const CellText = ({ children }: { children: React.ReactNode }) => (
<span className="text-sm font-normal">{children}</span>
);

export const columns = (filters: z.infer<typeof filtersSchema>) => [
columnHelper.accessor("projectName", {
enableSorting: true,
header: () => <span>Project Name</span>,
header: () => <HeaderText>Project Name</HeaderText>,
}),
columnHelper.accessor("scoreCardRating", {
enableSorting: true,
header: () => <span>Scorecard rating</span>,
header: () => <HeaderText>Scorecard rating</HeaderText>,
cell: (props) => {
const value = props.getValue();
if (value === undefined) {
Expand All @@ -82,20 +89,20 @@ export const columns = (filters: z.infer<typeof filtersSchema>) => [
filters.costRangeSelector === "npv" ? "costPerTCO2eNPV" : "costPerTCO2e",
{
enableSorting: true,
header: () => <span>Cost $(USD)/tCo2</span>,
header: () => <HeaderText>Cost $(USD)/tCo2</HeaderText>,
cell: (props) => {
const value = props.getValue();
if (value === null || value === undefined) {
return "-";
}

return formatCurrency(value);
return <CellText>{formatCurrency(value)}</CellText>;
},
},
),
columnHelper.accessor("abatementPotential", {
enableSorting: true,
header: () => <span>Abatement potential</span>,
header: () => <HeaderText>Abatement potential (tCO2e/yr)</HeaderText>,
cell: (props) => {
const value = props.getValue();
if (value === null || value === undefined) {
Expand All @@ -119,7 +126,7 @@ export const columns = (filters: z.infer<typeof filtersSchema>) => [
},
]}
/>
<p className="text-sm font-normal">{formatNumber(value)}</p>
<CellText>{formatNumber(value)}</CellText>
</div>
);
},
Expand All @@ -128,7 +135,13 @@ export const columns = (filters: z.infer<typeof filtersSchema>) => [
filters.costRangeSelector === "npv" ? "totalCostNPV" : "totalCost",
{
enableSorting: true,
header: () => <span>Total Cost (CapEx + OpEx)</span>,
header: () => (
<HeaderText>
Total Cost (<span className="text-sky-blue-500">CapEx</span>
&nbsp;+&nbsp;
<span className="text-sky-blue-200">OpEx</span>)
</HeaderText>
),
cell: (props) => {
const value = props.getValue();
if (value === null || value === undefined) {
Expand All @@ -152,7 +165,7 @@ export const columns = (filters: z.infer<typeof filtersSchema>) => [
props.row.original,
)}
/>
<p className="text-sm font-normal">{formatNumber(value)}</p>
<CellText>{formatNumber(value)}</CellText>
</div>
);
},
Expand Down
Loading