break-stuff / dia-date-picker

An accessible and intuitive date picker build with standards-based web components
9 stars 0 forks source link

[ Question ] Month/Year selection controls #5

Open michaelwarren1106 opened 2 years ago

michaelwarren1106 commented 2 years ago

month select

Currently the month and year selects have a super minimal approach, so I wanted to ask your thoughts on how a new design for those controls might improve user experience (and also help me be able to implement my own date picker input design using this calendar component :) )

The month select is a simple select box, but I have also seen design and options where the month selection is a group of buttons that the user can click to select the month they want.

image

IMO, there's not a major design issue with using a select, other than its hard to style a native select, so it might stick out as being "plain" in an otherwise modern looking style when implemented by a consumer. A group of buttons (along with relevant css vars/parts) would allow for a clean consistent style.

year select

IMO the year select being a <input type="number"> presents some more challenges and changing it up might offer some greater UX features to us consumers. if the year select was changed to a button group/list as well, that would enable new features like setting an allowed year range for the picker. Currently, with the input approach, there's no way I can see to disable certain years from being selected? Something like below would allow for more styling and also disabling years from be selected or paged to:

image

Another benefit to the button group approach is if the range of allowed years is super wide. Like if the calendar is used in a birthday input. Birthday years probably go all the way back to 1910 or something like that? Having all the year values from 1910-2022 in a <select> makes a silly tall select dropdown that has to be scrolled, etc. The button group approach, implemented with paging and possibly next/prev year buttons can allow for fast switching to years well in the past/future without ever creating a weirdly long select dropdown. I'd also wager that button groups are easier to parse/read for humans eyes, because they would be spaced out with more whitespace, etc.

Anyway, I just wanted to get your thoughts on these features!

break-stuff commented 2 years ago

Can you explain the design a bit? Would these button groups show up in a separate dialog that would overlay the calendar dialog?

michaelwarren1106 commented 2 years ago

sure!

i was thinking that when you click whatever control ends up being the “select year” function (maybe a button?) the grid of days (1-30 for the current month) would get replaced with the grid of current years in the range of enabled years. and the “next month” and “previous month” buttons (from the previous view of the grid of days) get replaced by the “next years grid” and “previous years grid” buttons.

same for the month select button except simpler. when the “choose month” button is clicked, the “grid of months” replaces the grid of days. but there’s no need for any “next months grid” or “prev month grid” buttons because there’s only ever one grid of months.

that’s what i’ve seen most often with calendars.

imo the grid of months is easy because it can be relatively static. the months are always in the same order and there’s always the same amount, so you could make that whole grid pretty much a constant.

the grid of years would need to be calculated depending on how many years you’d want to display per pane.

an example would be UI5 calendar from SAP: https://sap.github.io/ui5-webcomponents/playground/components/Calendar/

i hope that makes sense!

michaelwarren1106 commented 2 years ago

hey hey, bumping this (and the other) thread! Would you be open to accepting PRs for these features/redesigns?

break-stuff commented 2 years ago

I would like to keep this as simple as possible initially. My first thoughts are that this will create a decent amount of complexity to the component. My primary goal for this component has been to make it as light and as accessible as possible.

I'm worried this will dramatically increase the size of the component as well as make the accessibility and keyboard UX more difficult.

michaelwarren1106 commented 2 years ago

ya i get that! I think that the month selector wouldnt have to add much more complexity, since its just a static tabbable list of the same 12 months all the time. IMO the part to worry about is the year selection right?

My main concern with the year selections is the UX of selecting a single year from a super wide range of years via a