Skip to content

Add more calendar views (i.e., week view, year view, decade view) #4652

Open
@nmanumr

Description

@nmanumr

🙋 Feature Request

Currently, the Adobe Spectrum React calendar component only supports a single view, which is the month view. This feature request proposes adding additional views to the calendar component, including year, decade, and week views.

🤔 Expected Behavior

There can a view prop which can be used to change the view of the calendar for example

<Calendar view="week" /> // a view with dates of a specific week
<Calendar view="month" /> // the default and current view, where all the dates of specific month are listed
<Calendar view="year" /> // a view with list of months
<Calendar view="decade" /> // a view with list of years in a decade

😯 Current Behavior

Currently calendar component only supports the month view.

💁 Possible Solution

I already implemented this feature internally for my team (detail in context section), and here's how I did it:

  • I left the whole interaction logic as it is.
  • and I only have to patch the rendering logic, which includes:
    • date formatting for calendar cells
    • state provided by useCalendarState and useRangeCalendarState
    • and some changes to make the Calendar logic more abstract, which will allow us to support more calendar views

Although the current implementation is quite cranky, I'm willing to contribute to this feature. Just let me know If what I did aligns with adobe spectrum design's philosophy.

🔦 Context

I had been working on a date picker component. The current implementation of the date picker component does not have a year or decade view. This means that users have to click through many months to select a date that is a few years from the past.

To fix this issue, I internally patched the current implementation of the calendar component for my team to add support for month, year, and week views. This allows users to select dates more easily, regardless of how far in the past or future they are.

For this, I had to patch:

  • @react-stately/useCalendarState
  • @react-stately/useRangeCalendarState
  • @react-aria/useCalendar
  • @react-aria/useRangeCalendar
  • @react-aria/useCalendarCell
  • @react-aria/useCalendarGrid
  • and the whole calendar component from react-aria-components.

💻 Examples

These are the screenshots of my implementation.

Screenshot 2023-06-11 at 1 11 31 PM
Screenshot 2023-06-11 at 1 11 37 PM

🧢 Your Company/Team

CarteBlanche.tech / Hirecinch

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions