chore: add week days to calendar

This commit is contained in:
Johnny 2025-12-29 08:59:08 +08:00
parent ea3371badb
commit 96a91ebff0

View file

@ -18,7 +18,7 @@ export const CompactMonthCalendar = memo((props: CompactMonthCalendarProps) => {
const today = useTodayDate(); const today = useTodayDate();
const weekDays = useWeekdayLabels(); const weekDays = useWeekdayLabels();
const { weeks } = useCalendarMatrix({ const { weeks, weekDays: rotatedWeekDays } = useCalendarMatrix({
month, month,
data, data,
weekDays, weekDays,
@ -30,23 +30,33 @@ export const CompactMonthCalendar = memo((props: CompactMonthCalendarProps) => {
const sizeConfig = size === "small" ? SMALL_CELL_SIZE : DEFAULT_CELL_SIZE; const sizeConfig = size === "small" ? SMALL_CELL_SIZE : DEFAULT_CELL_SIZE;
return ( return (
<div className={cn("grid grid-cols-7", sizeConfig.gap)}> <div className="flex flex-col gap-1">
{weeks.map((week, weekIndex) => <div className={cn("grid grid-cols-7 gap-0.5 text-muted-foreground", size === "small" ? "text-[10px]" : "text-xs")}>
week.days.map((day, dayIndex) => { {rotatedWeekDays.map((label, index) => (
const tooltipText = getTooltipText(day.count, day.date, t); <div key={index} className="flex h-4 items-center justify-center text-muted-foreground/50">
{label}
</div>
))}
</div>
return ( <div className={cn("grid grid-cols-7", sizeConfig.gap)}>
<CalendarCell {weeks.map((week, weekIndex) =>
key={`${weekIndex}-${dayIndex}-${day.date}`} week.days.map((day, dayIndex) => {
day={day} const tooltipText = getTooltipText(day.count, day.date, t);
maxCount={maxCount}
tooltipText={tooltipText} return (
onClick={onClick} <CalendarCell
size={size} key={`${weekIndex}-${dayIndex}-${day.date}`}
/> day={day}
); maxCount={maxCount}
}), tooltipText={tooltipText}
)} onClick={onClick}
size={size}
/>
);
}),
)}
</div>
</div> </div>
); );
}); });