-
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.
[TBCCT-133] Added Project details Drawer (#109)
Co-authored-by: onehanddev <[email protected]>
- Loading branch information
1 parent
8e7677e
commit de5b2d8
Showing
7 changed files
with
746 additions
and
4 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { toCompactAmount } from "@/lib/format"; | ||
|
||
interface BarChartProps { | ||
total: number; | ||
segments: { | ||
value: number; | ||
label: string; | ||
colorClass: string; | ||
}[]; | ||
orientation?: "horizontal" | "vertical"; | ||
} | ||
|
||
const BarChart = ({ | ||
total, | ||
segments, | ||
orientation = "horizontal", | ||
}: BarChartProps) => { | ||
const getSize = (value: number) => { | ||
const percentage = (value / total) * 100; | ||
return `${Math.max(percentage, 0)}%`; | ||
}; | ||
|
||
if (orientation === "horizontal") { | ||
return ( | ||
<div className="relative h-full min-h-[150px] w-full overflow-hidden rounded-lg"> | ||
<div className="absolute flex h-full w-full flex-row gap-1"> | ||
{segments.map((segment, index) => ( | ||
<div | ||
key={index} | ||
style={{ | ||
height: getSize(segment.value), | ||
width: "100%", | ||
}} | ||
className={`relative h-full rounded transition-all duration-300 ease-in-out ${segment.colorClass}`} | ||
> | ||
<div className="absolute bottom-1 left-0 right-0 mx-1"> | ||
<div className="rounded bg-white/50 px-1.5 py-0.5 text-center text-xs font-semibold text-big-stone-950"> | ||
${toCompactAmount(segment.value)} | ||
</div> | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<div className="relative h-40 w-full overflow-hidden rounded-lg"> | ||
<div className="absolute flex h-full w-full flex-col gap-1"> | ||
{segments.map((segment, index) => ( | ||
<div | ||
key={index} | ||
style={{ | ||
height: getSize(segment.value), | ||
}} | ||
className={`relative min-h-[30px] w-full transition-all duration-300 ease-in-out ${segment.colorClass}`} | ||
> | ||
<div className="absolute bottom-1 left-0 right-0 mx-1"> | ||
<div className="rounded bg-white/50 px-1.5 py-0.5 text-center text-xs font-semibold text-big-stone-950"> | ||
${toCompactAmount(segment.value)} | ||
</div> | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default BarChart; |
Oops, something went wrong.