Skip to content

Commit 96a91eb

Browse files
committed
chore: add week days to calendar
1 parent ea3371b commit 96a91eb

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

web/src/components/ActivityCalendar/CompactMonthCalendar.tsx

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const CompactMonthCalendar = memo((props: CompactMonthCalendarProps) => {
1818
const today = useTodayDate();
1919
const weekDays = useWeekdayLabels();
2020

21-
const { weeks } = useCalendarMatrix({
21+
const { weeks, weekDays: rotatedWeekDays } = useCalendarMatrix({
2222
month,
2323
data,
2424
weekDays,
@@ -30,23 +30,33 @@ export const CompactMonthCalendar = memo((props: CompactMonthCalendarProps) => {
3030
const sizeConfig = size === "small" ? SMALL_CELL_SIZE : DEFAULT_CELL_SIZE;
3131

3232
return (
33-
<div className={cn("grid grid-cols-7", sizeConfig.gap)}>
34-
{weeks.map((week, weekIndex) =>
35-
week.days.map((day, dayIndex) => {
36-
const tooltipText = getTooltipText(day.count, day.date, t);
37-
38-
return (
39-
<CalendarCell
40-
key={`${weekIndex}-${dayIndex}-${day.date}`}
41-
day={day}
42-
maxCount={maxCount}
43-
tooltipText={tooltipText}
44-
onClick={onClick}
45-
size={size}
46-
/>
47-
);
48-
}),
49-
)}
33+
<div className="flex flex-col gap-1">
34+
<div className={cn("grid grid-cols-7 gap-0.5 text-muted-foreground", size === "small" ? "text-[10px]" : "text-xs")}>
35+
{rotatedWeekDays.map((label, index) => (
36+
<div key={index} className="flex h-4 items-center justify-center text-muted-foreground/50">
37+
{label}
38+
</div>
39+
))}
40+
</div>
41+
42+
<div className={cn("grid grid-cols-7", sizeConfig.gap)}>
43+
{weeks.map((week, weekIndex) =>
44+
week.days.map((day, dayIndex) => {
45+
const tooltipText = getTooltipText(day.count, day.date, t);
46+
47+
return (
48+
<CalendarCell
49+
key={`${weekIndex}-${dayIndex}-${day.date}`}
50+
day={day}
51+
maxCount={maxCount}
52+
tooltipText={tooltipText}
53+
onClick={onClick}
54+
size={size}
55+
/>
56+
);
57+
}),
58+
)}
59+
</div>
5060
</div>
5161
);
5262
});

0 commit comments

Comments
 (0)