Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a overlayWrapper prop to DayPicker for greater customization. #486

Closed
wants to merge 1 commit into from

Conversation

wldcordeiro
Copy link

@wldcordeiro wldcordeiro commented Aug 22, 2017

This PR tries to address #477 by adding a overlayWrapper prop that allows you to customize the component wrapping the DayPicker within DayPickerInput

@codecov
Copy link

codecov bot commented Aug 22, 2017

Codecov Report

Merging #486 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #486   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          15     15           
  Lines         531    534    +3     
  Branches      109    109           
=====================================
+ Hits          531    534    +3
Impacted Files Coverage Δ
src/DayPickerInput.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update efd1d6f...8f98e98. Read the comment docs.

src/DayPicker.js Outdated
{this.renderNavbar()}
{this.renderMonths()}
</div>,
containerProps.children ? containerProps.children : null
Copy link
Owner

Choose a reason for hiding this comment

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

🤔 what if the calendar should be placed after the containerProps.children?

@gpbl
Copy link
Owner

gpbl commented Aug 23, 2017

Hi, thanks for this PR 🙏

I was thinking to add a new prop to DayPickerInput, not implementing it into DayPicker.

Indeed, wrapping DayPicker inside a component can be already done without using the containerProps' children:

<MyWrapper>
   <DayPicker />
</MyWrapper>

What we need is a different wrapper for the overlay, here where we are rendering the DayPicker in DayPickerInput.js:

<div className={this.props.classNames.overlay}>
<DayPicker
ref={el => (this.daypicker = el)}
fixedWeeks
{...this.props.dayPickerProps}
month={this.state.month}
selectedDays={selectedDay}
onDayClick={this.handleDayClick}
numberOfMonths={1}
/>
</div>

For example, I was thinking the prop to be a function and working this way:

<DayPickerInput
  wrapperComponent={ ({children, ...props)} => 
     <div {...props}>
        <p>This is placed before the calendar</p>
        <div>{ children }</div> /* this will render the calendar */
        <p>This is placed after the calendar</p>
     </div>
  }
/>

What do you think?

PS. Maybe it's better call the prop overlayWrapper instead?

@wldcordeiro
Copy link
Author

Updated the PR, the prop is now called overlayWrapper and it's on the DayPickerInput. I've added a basic test along with a documentation entry for it.

@wldcordeiro wldcordeiro changed the title Add a wrapperComponent prop to DayPicker for greater customization. Add a overlayWrapper prop to DayPicker for greater customization. Aug 24, 2017
@gpbl gpbl added this to the v6.2.0 milestone Sep 27, 2017
@gpbl gpbl modified the milestones: v6.2.0, v6.3.0 Oct 14, 2017
@gpbl gpbl mentioned this pull request Nov 24, 2017
@gpbl
Copy link
Owner

gpbl commented Nov 24, 2017

Hey, thanks for this – I've fixed some parts in #563. Sorry for the delay...

@gpbl gpbl closed this Nov 24, 2017
@gpbl gpbl modified the milestones: v6.3.0, v7.0.0 Nov 25, 2017
@gpbl
Copy link
Owner

gpbl commented Nov 25, 2017

Thanks @wldcordeiro for your help! I’ve published the new prop in the v7.

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