Skip to content

Commit b65495a

Browse files
committed
Refactor how the buttonClass returns the class name
1 parent 419ce87 commit b65495a

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/components/Calendar/Days.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,16 @@ const Days: React.FC<Props> = ({
206206
const buttonClass = useCallback(
207207
(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-
(type == "previous" || type == "next") && "text-gray-400"
214-
);
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");
215219
},
216220
[activeDateData, hoverClassByDay, isDateDisabled]
217221
);

0 commit comments

Comments
 (0)