Skip to content

Conversation

@gnato
Copy link
Contributor

@gnato gnato commented Dec 3, 2025

Summary

This PR introduces a new monthHeaderPosition prop that allows developers to control the placement of the month header within the calendar. The header can now be positioned at the top (default), middle (between day names and calendar days), or bottom of the calendar.

Motivation

Provides greater flexibility for calendar layout customization, enabling developers to create more diverse calendar designs while maintaining all existing functionality.

Changes

Component Updates

  • DatePicker: Added monthHeaderPosition prop and passed it to PopperComponent
  • PopperComponent: Accepts monthHeaderPosition and applies corresponding CSS classes
  • Calendar: Implements conditional rendering logic for three header positions
  • Month: Added monthHeader and monthFooter props for content injection

Styling

  • Added .react-datepicker-popper--header-middle and .react-datepicker-popper--header-bottom classes
  • Implemented .react-datepicker__header-wrapper for proper navigation button positioning
  • Added triangle color styling for different header positions and popper placements
  • Added .react-datepicker__header--middle and .react-datepicker__header--bottom modifier classes

Documentation

  • Created comprehensive documentation in docs/month_header_position.md
  • Added interactive example to docs-site with radio buttons to toggle between positions
  • Included usage examples for all three positions

Testing

  • Added dedicated test file: month_header_position.test.tsx (6 tests)
  • Enhanced popper_component.test.tsx with 4 new tests for CSS class application
  • Enhanced calendar_test.test.tsx with 3 new tests for navigation button positioning
  • All 167 tests passing with maintained coverage

API

monthHeaderPosition?: "top" | "middle" | "bottom"

Usage Example

<DatePicker
  selected={selectedDate}
  onChange={setSelectedDate}
  monthHeaderPosition="middle"
/>

Breaking Changes

None. This is a fully backward-compatible addition with top as the default value.

Screenshots/Demo

The interactive example can be viewed in the docs-site, allowing users to toggle between all three header positions.

@gnato gnato force-pushed the feature/month-header-placement branch from 0612bbf to 452bef6 Compare December 3, 2025 13:01
@martijnrusschen
Copy link
Member

Test Suites: 1 failed

Add new monthHeaderPosition prop that allows positioning the month header
in three locations: top (default), middle (between day names and calendar),
or bottom (at calendar bottom). This feature provides greater flexibility
for calendar layout customization.

Changes:
- Add monthHeaderPosition prop to DatePicker, PopperComponent, and Calendar components
- Implement conditional rendering logic in Calendar.renderDefaultHeader()
- Add monthHeader and monthFooter props to Month component for content injection
- Add CSS classes for middle/bottom header positions with proper triangle styling
- Add .react-datepicker__header-wrapper for navigation button positioning
- Include comprehensive test coverage for new functionality
- Add documentation and live example to docs-site

Technical implementation:
- PropperComponent applies CSS classes based on header position
- Calendar wraps header with navigation buttons for middle/bottom positions
- Month component renders header/footer content at appropriate locations
- SCSS handles triangle colors and navigation button positioning per position

Test coverage includes unit tests for all three positions across components:
calendar_test.test.tsx, month_header_position.test.tsx, and
popper_component.test.tsx. All 167 tests passing with maintained coverage.
@gnato gnato force-pushed the feature/month-header-placement branch from 452bef6 to 38ed65a Compare December 4, 2025 10:07
@codecov
Copy link

codecov bot commented Dec 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.23%. Comparing base (11aeae6) to head (09e92cc).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6092   +/-   ##
=======================================
  Coverage   99.22%   99.23%           
=======================================
  Files          30       30           
  Lines        3622     3644   +22     
  Branches     1553     1556    +3     
=======================================
+ Hits         3594     3616   +22     
  Misses         27       27           
  Partials        1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

- Add test for middle position with navigation buttons potentially hidden
- Add test for bottom position with custom header
- Improves branch coverage from 93.52% to 93.56%
@gnato
Copy link
Contributor Author

gnato commented Dec 4, 2025

Test Suites: 1 failed

@martijnrusschen they are passing now, thanks

@martijnrusschen martijnrusschen merged commit 0e13929 into Hacker0x01:main Dec 4, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants