adobe / react-spectrum

A collection of libraries and tools that help you build adaptive, accessible, and robust user experiences.
https://react-spectrum.adobe.com
Apache License 2.0
12.8k stars 1.1k forks source link

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

Open nmanumr opened 1 year ago

nmanumr commented 1 year ago

๐Ÿ™‹ 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:

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:

๐Ÿ’ป 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

LFDanLu commented 1 year ago

Thank you for your interest and contribution offer! Looking at the our internal Spectrum Design site, I'm not seeing any designs defining how we'd like these week/year/decade view to look or behave, so we'll have to bring this up with the design team first.

devongovett commented 1 year ago

btw you can already build a week view with the hooks by setting the visibleDuration option. There's an example linked from the docs.

nmanumr commented 1 year ago

@devongovett Exactly we don't need to change anything for the week view in the hooks but for the Calendar component from react-aria-components to work for the week view I guess we need to change a few things here. Meanwhile I can fix this if you want.

cssinate commented 1 year ago

Closely related to this discussion