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

Use container width instead of device width #106

Closed
wants to merge 1 commit into from

Conversation

lukescott
Copy link

Currently the device width is used to calculate the width of the calendar, and then each day is /7 of that width. This is a problem on tablets that have large screens. You more than likely will want to reduce the size of the calendar to be less than the width of the screen, especially in landscape.

The following patch uses onLayout to figure out the width of the parent container and uses that instead of the device width. It then uses that /7 to for the day width. I had used flex:1 for the day width, but I also wanted the height to match the width - that way each day doesn't end up being a narrow rectangle depending on the container width.

I also fixed a bug where it would always select the current day, even though this.props.selectedDate is undefined. This happened because moment(undefined) returns the current date.

This patch also makes it easier to do 2 months side-by-side down the road. To do that you would likely: divide containerWidth by 2, update getMonthStack to render more months, and change the scroll functions to take 2 months into account.

@lukescott lukescott force-pushed the container-width branch 3 times, most recently from 3ebd468 to 5b1c302 Compare March 2, 2017 20:40
@christopherdro
Copy link
Owner

Closing for #107

@coderdave
Copy link
Collaborator

I bit the bullet and resolved the conflicts on this one. It works pretty well going back and forth between portrait and landscape, so that's good. The only thing that didn't make sense to me was the width/height that was added to the Day component. I took that out because it caused the days to be a lot taller than normal.

I encourage anyone (especially @christopherdro) to check out the webconnex-container-width branch and if everything is fine, I can merge it to dev.

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.

3 participants