close
Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update Tailwind CSS configuration and enhance Datepicker component
- Added support for additional class list paths in Tailwind CSS configuration for both Storybook and web applications.
- Updated the Datepicker component to include a new 'outside' state for days that are not part of the current month, improving visual feedback for users.
- Refactored the Datepicker's Days view to incorporate the new 'outside' state in the button class logic.
  • Loading branch information
aun-afzaal
aun-afzaal committed Mar 31, 2026
commit 6a8a56bb7fe685ba5cb62d3d761b068939424922
6 changes: 5 additions & 1 deletion packages/ui/src/components/Datepicker/Views/Days.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
isDateEqual,
isDateInRange,
isDateToday,
isOutOfMonth,

Check failure on line 13 in packages/ui/src/components/Datepicker/Views/Days.tsx

View workflow job for this annotation

Image GitHub Actions / 🕵 Lint

'isOutOfMonth' is defined but never used. Allowed unused vars must match /^_/u
isMonthEqual,
Views,
} from "../helpers";

Expand All @@ -25,6 +27,7 @@
selected: string;
disabled: string;
today: string;
outside: string;
};
};
}
Expand All @@ -46,7 +49,6 @@

const weekDays = getWeekDays(language, weekStart);
const startDate = getFirstDayOfTheMonth(viewDate, weekStart);

return (
<>
<div className={theme.header.base}>
Expand All @@ -65,6 +67,7 @@
const isDisabled =
!isDateInRange(currentDate, minDate, maxDate) || (filterDate && !filterDate(currentDate, Views.Days));
const isToday = isDateToday(currentDate);
const isOutOfMonth = !isMonthEqual(currentDate, viewDate)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Make isOutOfMonth year-aware.

Line 69 currently relies on isMonthEqual, which (per packages/ui/src/components/Datepicker/helpers.ts) checks only getMonth(). That can produce incorrect “outside” classification when month numbers match across different years. Also, this line is likely the Prettier warning source.

Proposed fix
-          const isOutOfMonth = !isMonthEqual(currentDate, viewDate)
+          const isOutOfMonth =
+            currentDate.getMonth() !== viewDate.getMonth() ||
+            currentDate.getFullYear() !== viewDate.getFullYear();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const isOutOfMonth = !isMonthEqual(currentDate, viewDate)
const isOutOfMonth =
currentDate.getMonth() !== viewDate.getMonth() ||
currentDate.getFullYear() !== viewDate.getFullYear();
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/ui/src/components/Datepicker/Views/Days.tsx` at line 69, The
isOutOfMonth calculation uses isMonthEqual which only compares month numbers and
therefore misclassifies dates in the same month number but different years;
update the logic where isOutOfMonth is computed (variable isOutOfMonth in
Days.tsx that compares currentDate and viewDate) to compare both month and year
(e.g., replace isMonthEqual with a helper that checks getMonth() and
getFullYear(), or add a new isSameMonthAndYear helper in
packages/ui/src/components/Datepicker/helpers.ts and use it here) so dates from
the same month number but different years are correctly flagged as out-of-month.


return (
<button
Expand All @@ -73,6 +76,7 @@
type="button"
className={twMerge(
theme.items.item.base,
isOutOfMonth && theme.items.item.outside,
isToday && theme.items.item.today,
isSelected && theme.items.item.selected,
isDisabled && theme.items.item.disabled,
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/components/Datepicker/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const datePickerTheme = createTheme<DatepickerTheme>({
base: "block flex-1 cursor-pointer rounded-lg border-0 text-center text-sm font-semibold leading-9 text-gray-900 hover:bg-gray-100 dark:text-white dark:hover:bg-gray-600",
selected: "bg-primary-700 text-white hover:bg-primary-600",
disabled: "text-gray-500",
outside: "opacity-40 text-gray-500",
today: "",
},
},
Expand Down
Loading