feat(datepicker): add showOutsideDays prop and css fixes#1671
feat(datepicker): add showOutsideDays prop and css fixes#1671Karan5656 wants to merge 4 commits intothemesberg:mainfrom
Conversation
|
@Karan5656 is attempting to deploy a commit to the Bergside Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: feb3544 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughAdded a new Datepicker prop Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Datepicker as Datepicker(Component)
participant Context as DatepickerContext
participant DaysView as Days(Views/Days)
User->>Datepicker: click day (date)
Datepicker->>Context: changeSelectedDate(date)
Context->>Context: setSelectedDate(date)\nsetViewDate(date)
Context->>DaysView: provide showOutsideDays, viewDate, selectedDate
DaysView->>DaysView: compute isOutsideDay via isMonthEqual\ndetermine isHidden = isOutsideDay && !showOutsideDays
DaysView-->>User: render day cells (apply outside/hidden styles, block clicks if hidden)
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly Related PRs
Suggested Reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/ui/src/components/Datepicker/Datepicker.tsx (1)
161-164: Small cleanup: avoid duplicateviewDateupdates.After Line 163,
changeSelectedDate(today, true)already syncsviewDate, so the extrasetViewDate(today)in the Today button handler is redundant.♻️ Suggested simplification
onClick={() => { const today = new Date(); changeSelectedDate(today, true); - setViewDate(today); }}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/ui/src/components/Datepicker/Datepicker.tsx` around lines 161 - 164, The Today button handler is redundantly calling setViewDate(today) even though changeSelectedDate(today, true) already updates viewDate; remove the extra setViewDate(today) from the Today button's onClick handler (or equivalent) so that only changeSelectedDate handles syncing viewDate, keeping the changeSelectedDate(date: Date | null, useAutohide: boolean) function as the single source of truth for updating viewDate.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/ui/src/components/Datepicker/theme.ts`:
- Around line 51-53: The disabled/outside/hidden state class strings in the
Datepicker theme object still inherit the base "dark:text-white" and stay too
bright in dark mode; update the object entries for the keys disabled, outside,
and hidden to include explicit dark-mode de-emphasis (e.g., add a
"dark:text-gray-500" or similar muted dark token) so those states override the
base dark:text-white — modify the strings for disabled, outside, and hidden in
the theme.ts Datepicker theme object accordingly.
---
Nitpick comments:
In `@packages/ui/src/components/Datepicker/Datepicker.tsx`:
- Around line 161-164: The Today button handler is redundantly calling
setViewDate(today) even though changeSelectedDate(today, true) already updates
viewDate; remove the extra setViewDate(today) from the Today button's onClick
handler (or equivalent) so that only changeSelectedDate handles syncing
viewDate, keeping the changeSelectedDate(date: Date | null, useAutohide:
boolean) function as the single source of truth for updating viewDate.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 1aaecba9-e1da-4d99-8264-5c8083c4fde9
📒 Files selected for processing (8)
apps/storybook/src/Datepicker.stories.tsxapps/web/content/docs/components/datepicker.mdxapps/web/examples/datepicker/datepicker.showOutsideDays.tsxapps/web/examples/datepicker/index.tspackages/ui/src/components/Datepicker/Datepicker.tsxpackages/ui/src/components/Datepicker/DatepickerContext.tsxpackages/ui/src/components/Datepicker/Views/Days.tsxpackages/ui/src/components/Datepicker/theme.ts
| disabled: "cursor-not-allowed text-gray-300 hover:bg-transparent dark:hover:bg-transparent", | ||
| outside: "text-gray-300", | ||
| hidden: "cursor-default opacity-0 hover:bg-transparent dark:hover:bg-transparent", |
There was a problem hiding this comment.
Dark mode de-emphasis is currently overridden for disabled/outside days.
Because the base class has dark:text-white (Line 49), disabled/outside states stay too bright in dark mode. Add explicit dark:text-* overrides for those states.
🎨 Suggested fix
- disabled: "cursor-not-allowed text-gray-300 hover:bg-transparent dark:hover:bg-transparent",
- outside: "text-gray-300",
+ disabled: "cursor-not-allowed text-gray-300 hover:bg-transparent dark:text-gray-500 dark:hover:bg-transparent",
+ outside: "text-gray-300 dark:text-gray-500",
hidden: "cursor-default opacity-0 hover:bg-transparent dark:hover:bg-transparent",📝 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.
| disabled: "cursor-not-allowed text-gray-300 hover:bg-transparent dark:hover:bg-transparent", | |
| outside: "text-gray-300", | |
| hidden: "cursor-default opacity-0 hover:bg-transparent dark:hover:bg-transparent", | |
| disabled: "cursor-not-allowed text-gray-300 hover:bg-transparent dark:text-gray-500 dark:hover:bg-transparent", | |
| outside: "text-gray-300 dark:text-gray-500", | |
| hidden: "cursor-default opacity-0 hover:bg-transparent dark:hover:bg-transparent", |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/ui/src/components/Datepicker/theme.ts` around lines 51 - 53, The
disabled/outside/hidden state class strings in the Datepicker theme object still
inherit the base "dark:text-white" and stay too bright in dark mode; update the
object entries for the keys disabled, outside, and hidden to include explicit
dark-mode de-emphasis (e.g., add a "dark:text-gray-500" or similar muted dark
token) so those states override the base dark:text-white — modify the strings
for disabled, outside, and hidden in the theme.ts Datepicker theme object
accordingly.
Changes
showOutsideDaysprop to control visibility of out-of-month days.Fixes
Fixes #1647
Summary by CodeRabbit
New Features
showOutsideDaysoption to Datepicker to toggle display of adjacent-month days.Styling
Documentation
showOutsideDays.Chores