forked from benvinegar/counterscale
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChangeIndicator.tsx
46 lines (42 loc) · 1.18 KB
/
ChangeIndicator.tsx
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
import { ArrowUp, ArrowDown } from "lucide-react";
const ChangeIndicator = ({
isIncreased,
percentageChange,
}: {
isIncreased: boolean | null;
percentageChange: string;
}) => {
const getIndicatorStyles = () => {
if (isIncreased === true) return "bg-green-100";
if (isIncreased === false) return "bg-red-100";
return "bg-gray-200";
};
const renderArrow = () => {
if (isIncreased === true)
return (
<ArrowUp
size={16}
strokeWidth={0.75}
className="fill-green-200"
/>
);
if (isIncreased === false)
return (
<ArrowDown
size={16}
strokeWidth={0.75}
className="fill-red-200"
/>
);
return "-";
};
return (
<span
className={`rounded text-black py-1 px-2 ${getIndicatorStyles()} flex items-center gap-2 w-fit`}
>
{renderArrow()}
<p className="font-semibold text-sm">{percentageChange}</p>
</span>
);
};
export default ChangeIndicator;