Skip to content

Commit 90199d8

Browse files
authored
Merge pull request #91 from AnalogMemory/fix/dates-not-visually-disabled
[style] Disabled dates in next or previous months are not visually disabled
2 parents 23c955f + b65495a commit 90199d8

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/components/Calendar/Days.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,18 @@ const Days: React.FC<Props> = ({
204204
);
205205

206206
const buttonClass = useCallback(
207-
(day: number, type: "current" | "previous" | "next") => {
207+
(day: number, type: "current" | "next" | "previous") => {
208208
const baseClass = "flex items-center justify-center w-12 h-12 lg:w-10 lg:h-10";
209-
return cn(
210-
baseClass,
211-
!activeDateData(day).active ? hoverClassByDay(day) : activeDateData(day).className,
212-
isDateDisabled(day, type) && "line-through"
213-
);
209+
if (type === "current") {
210+
return cn(
211+
baseClass,
212+
!activeDateData(day).active
213+
? hoverClassByDay(day)
214+
: activeDateData(day).className,
215+
isDateDisabled(day, type) && "line-through"
216+
);
217+
}
218+
return cn(baseClass, isDateDisabled(day, type) && "line-through", "text-gray-400");
214219
},
215220
[activeDateData, hoverClassByDay, isDateDisabled]
216221
);
@@ -345,7 +350,7 @@ const Days: React.FC<Props> = ({
345350
type="button"
346351
key={index}
347352
disabled={isDateDisabled(item, "previous")}
348-
className="flex items-center justify-center text-gray-400 h-12 w-12 lg:w-10 lg:h-10"
353+
className={`${buttonClass(item, "previous")}`}
349354
onClick={() => handleClickDay(item, "previous")}
350355
onMouseOver={() => {
351356
hoverDay(item, "previous");
@@ -375,7 +380,7 @@ const Days: React.FC<Props> = ({
375380
type="button"
376381
key={index}
377382
disabled={isDateDisabled(item, "next")}
378-
className="flex items-center justify-center text-gray-400 h-12 w-12 lg:w-10 lg:h-10"
383+
className={`${buttonClass(item, "next")}`}
379384
onClick={() => handleClickDay(item, "next")}
380385
onMouseOver={() => {
381386
hoverDay(item, "next");

0 commit comments

Comments
 (0)