-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathNumberPanel.tsx
More file actions
47 lines (42 loc) · 1.3 KB
/
NumberPanel.tsx
File metadata and controls
47 lines (42 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import React from "react";
import { PanelResult } from "../../../types";
import { formatDisplayValue } from "./utils";
import PanelWrapper from "./PanelWrapper";
interface NumberPanelProps {
summary: PanelResult;
}
const NumberPanel: React.FC<NumberPanelProps> = ({ summary }) => {
if (!summary.rows || summary.rows.length === 0) {
return null;
}
return (
<>
{summary.rows.map((row, rowIndex) => {
const { value, count, label } = row;
const displayValue = value ?? count;
const numericValue = Number(displayValue);
return (
<PanelWrapper
key={`${summary.name}-${rowIndex}`}
title={label || summary.name}
description={summary.description}
titleClassName="capitalize"
>
<div className="flex flex-1 items-center justify-center">
<p className="text-6xl font-bold sm:text-6xl md:text-6xl lg:text-6xl">
{summary.number
? formatDisplayValue(
numericValue,
summary.number.unit,
summary.number.precision
)
: displayValue}
</p>
</div>
</PanelWrapper>
);
})}
</>
);
};
export default NumberPanel;