flowbite-react icon indicating copy to clipboard operation
flowbite-react copied to clipboard

feat(datepicker): add showOutsideDays prop and css fixes

Open Karan5656 opened this issue 7 months ago β€’ 3 comments

Changes

  • Added showOutsideDays prop to control visibility of out-of-month days.
  • Updated styles for out-of-month and disabled days.
  • Handled view change when out-of-month days are clicked.

Fixes

Fixes #1647

Summary by CodeRabbit

  • New Features

    • Added a showOutsideDays option to Datepicker to toggle display of adjacent-month days.
    • Calendar view now auto-synchronizes to the selected date so the displayed month matches your choice.
  • Styling

    • Improved appearance and behavior for outside, hidden, and disabled day states for clearer visual cues.
  • Documentation

    • Added docs, interactive example, and updated Storybook stories demonstrating showOutsideDays.
  • Chores

    • Added a release changeset for the datepicker update.

Karan5656 avatar Apr 14 '26 09:04 Karan5656

@Karan5656 is attempting to deploy a commit to the Bergside Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Apr 14 '26 09:04 vercel[bot]

πŸ¦‹ Changeset detected

Latest commit: feb354463d47f4f9d57ee2f9cfc10bbeab8753c1

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

changeset-bot[bot] avatar Apr 14 '26 09:04 changeset-bot[bot]

No actionable comments were generated in the recent review. πŸŽ‰

ℹ️ Recent review info
βš™οΈ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c155ae18-29d8-43cd-8278-e8fa72eb4897

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 22413a6b740238f613f226b963e1984677aaafe4 and feb354463d47f4f9d57ee2f9cfc10bbeab8753c1.

πŸ“’ Files selected for processing (1)
  • .changeset/flat-spoons-double.md
βœ… Files skipped from review due to trivial changes (1)
  • .changeset/flat-spoons-double.md

πŸ“ Walkthrough

Walkthrough

Added a new Datepicker prop showOutsideDays (default true), propagated through context to Views/Days; Days now detects outside-month days and can hide or style them. Selection now syncs viewDate with selected date. Storybook, docs, and examples updated to demonstrate the feature.

Changes

Cohort / File(s) Summary
Storybook Stories
apps/storybook/src/Datepicker.stories.tsx
Added showOutsideDays: true to multiple story .args for consistent rendering.
Docs & Examples
apps/web/content/docs/components/datepicker.mdx, apps/web/examples/datepicker/datepicker.showOutsideDays.tsx, apps/web/examples/datepicker/index.ts
Added "Outside days" docs section, new example datepicker.showOutsideDays.tsx demonstrating showOutsideDays={false}, and re-exported the example.
Datepicker Component
packages/ui/src/components/Datepicker/Datepicker.tsx
Added prop showOutsideDays?: boolean (default true) and passed it into context; changeSelectedDate() now calls setViewDate(date) when a date is selected.
Context & Views
packages/ui/src/components/Datepicker/DatepickerContext.tsx, packages/ui/src/components/Datepicker/Views/Days.tsx, packages/ui/src/components/Datepicker/theme.ts
Extended context with showOutsideDays; Days uses isMonthEqual to detect outside-month days, computes isHidden = outside && !showOutsideDays, prevents clicks on hidden days, adjusts disabled logic, and adds outside/hidden theme keys; theme strings updated for disabled/outside/hidden states.
Changeset
.changeset/flat-spoons-double.md
New changeset declaring the feature release for datepicker and related CSS fixes.

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

  • #1627: Modifies Datepicker day rendering and theme keys; touches similar theme and day-rendering logic.
  • #1457: Adds or uses isMonthEqual utilities for month-level comparisons used in Days view.
  • #1587: Alters Datepicker day-rendering/disable logic and prop propagation; overlaps with showOutsideDays behavior.

Suggested Reviewers

  • rluders
  • SutuSebastian
  • robert1508

Poem

🐰 I hopped through code to dim some days,
Outside-month numbers now fade their rays.
A prop, a theme, a gentler sightβ€”
Calendars breathe in softer light.
Hop, hop, hooray β€” the months feel right!

πŸš₯ Pre-merge checks | βœ… 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
βœ… Passed checks (4 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check βœ… Passed The title 'feat(datepicker): add showOutsideDays prop and css fixes' accurately summarizes the main changes: adding a new prop to control out-of-month day visibility and updating related CSS styling.
Linked Issues check βœ… Passed The PR fully addresses issue #1647 requirements: adds showOutsideDays prop to control visibility, implements visual de-emphasis of out-of-month days, provides theme tokens (outside/hidden), keeps days interactive, and ensures selected styling overrides.
Out of Scope Changes check βœ… Passed All changes are directly scoped to implementing the showOutsideDays feature and its styling requirements; no unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
πŸ§ͺ Generate unit tests (beta)
  • [ ] Create PR with unit tests

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.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Apr 14 '26 09:04 coderabbitai[bot]

Superseded by #1682, which covers this scope and passes checks. Thanks for the attempt - please rebase onto #1682 if anything is missing there.

SutuSebastian avatar Oct 28 '26 11:10 SutuSebastian