question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for custom days in the Calendar component

See original GitHub issue

Requested Behavior

The developer would have the ability use their own component in each day block in the Calendar. The component should also have access to the current day it is rendering, the selected date(s) on the calendar, and if the Calendar is handling range selection.

Example

calendar-example

Implementation

The Select component solves similar problems, and it does so by providing a function as the child for the component. I believe this is a good solution for the Calendar also.

The Calendar would now have a children prop that accepts a function. The function is passed 3 arguments :

  1. day - the current day being rendered (string in ISO8601 format)
  2. selected - the day(s) that is selected (string in ISO8601 format or array of strings in ISO8601 format)
  3. inRange - whether the calendar is using range selection (boolean)

The Calendar would now have a fill prop which is a boolean. This tells the calendar to fill the width and height of the container, and that the days should have a width of 14.3%.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
cliffpylescommented, Sep 8, 2020

I’ve taken a shot at it in PR #4508 . Please let me know if I’ve missed anything, or if there are additional changes you want me to make.

I was drawing a blank on what the correct treatment should be when using the fill property with daysOfWeek. The spacing for the days of the week are a little off. You should be able to see what I mean by navigating to the “Fill” Calendar story, or you can checkout the screenshot in the PR. Please let me know if you have any ideas.

In the Calendar I noticed the box-sizing isn’t currently set to border-box. Is that on purpose? If not would it be an issue to set it to border-box. I would think it would help with the style of the custom borders. Currently borders get cut off if they are applied.

Would an isAlternate property be helpful also? This would allow the developer to do things like apply alternating backgrounds on the cells.

1reaction
cliffpylescommented, Sep 21, 2020

@ShimiSun Thanks again for all of your help! It can be closed!

Read more comments on GitHub >

github_iconTop Results From Across the Web

React-Calendar: Build and customize a simple calendar
React-Calendar is a simple calendar library that provides the ability to pick days, months, years, or even decades. It also supports date ...
Read more >
React Calendar: How to Build a Reusable Cal
This lesson will show you how to create a simple reusable calendar component that you can use in any React application using React-Calendar....
Read more >
Customization in React Calendar component
Calendar allows you to customize the entire appearance by using the custom CSS and renderDayCell event to customize the each day cell.
Read more >
Angular Calendar: Displaying Custom Set of Days
Angular project that displays an event calendar component with day, week and month views that share the same data and can be easily...
Read more >
Create a custom calendar in React
We are going to build simple calendar component in which you will be able to select a date from an active month. While...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found