2024-02-12 09:38:17 +00:00
|
|
|
import { FC } from "react";
|
|
|
|
// hooks
|
|
|
|
import { useChart } from "components/gantt-chart";
|
|
|
|
// helpers
|
|
|
|
import { cn } from "helpers/common.helper";
|
|
|
|
// types
|
|
|
|
import { IMonthBlock } from "../../views";
|
|
|
|
// constants
|
|
|
|
import { HEADER_HEIGHT, SIDEBAR_WIDTH } from "components/gantt-chart/constants";
|
|
|
|
|
|
|
|
export const MonthChartView: FC<any> = () => {
|
|
|
|
// chart hook
|
|
|
|
const { currentViewData, renderView } = useChart();
|
|
|
|
const monthBlocks: IMonthBlock[] = renderView;
|
|
|
|
|
|
|
|
return (
|
2024-02-12 13:40:07 +00:00
|
|
|
<div className="absolute top-0 left-0 h-full w-max flex divide-x divide-custom-border-100/50">
|
|
|
|
{monthBlocks?.map((block, rootIndex) => (
|
|
|
|
<div key={`month-${block?.month}-${block?.year}`} className="relative">
|
|
|
|
<div
|
|
|
|
className="w-full sticky top-0 z-[5] bg-custom-background-100"
|
|
|
|
style={{
|
|
|
|
height: `${HEADER_HEIGHT}px`,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<div className="h-1/2">
|
|
|
|
<div
|
|
|
|
className="sticky inline-flex whitespace-nowrap px-3 py-2 text-xs font-medium capitalize"
|
|
|
|
style={{
|
|
|
|
left: `${SIDEBAR_WIDTH}px`,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{block?.title}
|
2024-02-12 09:38:17 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-02-12 13:40:07 +00:00
|
|
|
<div className="h-1/2 w-full flex">
|
2024-02-12 09:38:17 +00:00
|
|
|
{block?.children?.map((monthDay, index) => (
|
|
|
|
<div
|
2024-02-12 13:40:07 +00:00
|
|
|
key={`sub-title-${rootIndex}-${index}`}
|
|
|
|
className="flex-shrink-0 border-b-[0.5px] border-custom-border-200 py-1 text-center capitalize"
|
2024-02-12 09:38:17 +00:00
|
|
|
style={{ width: `${currentViewData?.data.width}px` }}
|
|
|
|
>
|
2024-02-12 13:40:07 +00:00
|
|
|
<div className="space-x-1 text-xs">
|
|
|
|
<span className="text-custom-text-200">{monthDay.dayData.shortTitle[0]}</span>{" "}
|
|
|
|
<span
|
|
|
|
className={cn({
|
|
|
|
"rounded-full bg-custom-primary-100 px-1 text-white": monthDay.today,
|
|
|
|
})}
|
|
|
|
>
|
|
|
|
{monthDay.day}
|
|
|
|
</span>
|
|
|
|
</div>
|
2024-02-12 09:38:17 +00:00
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-02-12 13:40:07 +00:00
|
|
|
<div className="h-full w-full flex divide-x divide-custom-border-100/50">
|
|
|
|
{block?.children?.map((monthDay, index) => (
|
|
|
|
<div
|
|
|
|
key={`column-${rootIndex}-${index}`}
|
|
|
|
className="h-full overflow-hidden"
|
|
|
|
style={{ width: `${currentViewData?.data.width}px` }}
|
|
|
|
>
|
|
|
|
{["sat", "sun"].includes(monthDay?.dayData?.shortTitle) && (
|
|
|
|
<div className="h-full bg-custom-background-90" />
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
</div>
|
2024-02-12 09:38:17 +00:00
|
|
|
);
|
|
|
|
};
|