Skip to content

Commit 5b20882

Browse files
committed
Fix active day color
1 parent dd03cda commit 5b20882

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/components/Calendar/Days.tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,16 @@ const Days: React.FC<Props> = ({calendarData, onClickPreviousDays, onClickDay, o
3636
const activeDateData = useCallback((day: number) => {
3737
const fullDay = `${calendarData.date.year()}-${calendarData.date.month() + 1}-${day}`;
3838
let className = "";
39-
const bgColor = BG_COLOR["500"][primaryColor as keyof typeof BG_COLOR["500"]];
39+
4040
if ((dayjs(fullDay).isSame(period.start) && dayjs(fullDay).isSame(period.end))) {
41-
className = ` ${bgColor} text-white font-medium rounded-full`;
41+
// @ts-ignore
42+
className = ` ${BG_COLOR["500"][primaryColor]} text-white font-medium rounded-full`;
4243
} else if (dayjs(fullDay).isSame(period.start)) {
43-
className = ` ${bgColor} text-white font-medium ${(dayjs(fullDay).isSame(dayHover) && !period.end) ? "rounded-full" : "rounded-l-full"}`;
44+
// @ts-ignore
45+
className = ` ${BG_COLOR["500"][primaryColor]} text-white font-medium ${(dayjs(fullDay).isSame(dayHover) && !period.end) ? "rounded-full" : "rounded-l-full"}`;
4446
} else if(dayjs(fullDay).isSame(period.end)) {
45-
className = ` ${bgColor} text-white font-medium ${(dayjs(fullDay).isSame(dayHover) && !period.start) ? "rounded-full" : "rounded-r-full"}`;
47+
// @ts-ignore
48+
className = ` ${BG_COLOR["500"][primaryColor]} text-white font-medium ${(dayjs(fullDay).isSame(dayHover) && !period.start) ? "rounded-full" : "rounded-r-full"}`;
4649
}
4750

4851
return {
@@ -54,31 +57,34 @@ const Days: React.FC<Props> = ({calendarData, onClickPreviousDays, onClickDay, o
5457
const hoverClassByDay = useCallback((day: number) => {
5558
let className = currentDateClass(day);
5659
const fullDay = `${calendarData.date.year()}-${calendarData.date.month() + 1}-${day >= 10 ? day : "0"+day}`;
57-
const bgColor100 = BG_COLOR["100"][primaryColor as keyof typeof BG_COLOR["100"]];
58-
const bgColor500 = BG_COLOR["500"][primaryColor as keyof typeof BG_COLOR["100"]];
5960

6061
// @ts-ignore
6162
if (period.start && period.end && dayjs(fullDay).isBetween(period.start, period.end, 'day', '[)')) {
62-
return ` ${bgColor100} ${currentDateClass(day)} dark:bg-white/10`;
63+
// @ts-ignore
64+
return ` ${BG_COLOR["100"][primaryColor]} ${currentDateClass(day)} dark:bg-white/10`;
6365
}
6466

6567
if (!dayHover) {
68+
// @ts-ignore
6669
return className;
6770
}
6871

6972

7073
// @ts-ignore
7174
if (period.start && dayjs(fullDay).isBetween(period.start, dayHover, 'day', '[)')) {
72-
className = ` ${bgColor100} ${currentDateClass(day)} dark:bg-white/10`;
75+
// @ts-ignore
76+
className = ` ${BG_COLOR["100"][primaryColor]} ${currentDateClass(day)} dark:bg-white/10`;
7377
}
7478

7579
// @ts-ignore
7680
if (period.end && dayjs(fullDay).isBetween(dayHover, period.end, 'day', '[)')) {
77-
className = ` ${bgColor100} ${currentDateClass(day)} dark:bg-white/10`;
81+
// @ts-ignore
82+
className = ` ${BG_COLOR["100"][primaryColor]} ${currentDateClass(day)} dark:bg-white/10`;
7883
}
7984

8085
if (dayHover === fullDay) {
81-
className = ` transition-all duration-500 ${bgColor500} text-white font-medium ${period.start ? 'rounded-r-full' : 'rounded-l-full'}`;
86+
// @ts-ignore
87+
className = ` transition-all duration-500 ${BG_COLOR["500"][primaryColor]} text-white font-medium ${period.start ? 'rounded-r-full' : 'rounded-l-full'}`;
8288
}
8389

8490
return className;

0 commit comments

Comments
 (0)