Open TedGoas opened 5 years ago
This is the final design spec: https://stackexchange.invisionapp.com/share/MTP7KOWEZ7R#/332358366_SO-Stacks--v01__Design-Spec__Date-Picker
I linked to a Jira issue and decided to put my notes there. That doesn't make much sense considering this is a Stacks component discussion we're having.
The next few comments are my notes (and some helpful input from @bnickel) ported from the Jira issue.
From Jira, @dancormier commented 5 days ago:
A quick search lead me to vanillajs-datepicker, which looks pretty badass* overall.
*badass in this context means accessible, configurable, and full featured.
I did a back-of-the-napkin calculation and found the minified CSS + JS to land around 10-11KB†
†I need to verify this and this may depend on which features we’d like to include in our component.
<input type=”text” />
. Seems like a type=”date”
would make more sense (I assume it’s to avoid fighting with native date pickers).<span>
s for the date items. Feels like that should be <button>
s.From Jira, @dancormier commented 5 days ago:
From Jira, @bnickel commented 5 days ago:
For awareness, here’s some places where we use date pickers today and ones with nuance. We generally, but not always, deal with date ranges.
This is the only scenario I know of where time is involved. Also the only one where we display in local timezone.
This one only lets you pick Tuesdays.
This one uses the native date input.
These ones support an unbounded date.
Enterprise has some date pickers and I believe a custom component, but I’ve not looked into those.
Then I thanked Brian.
From Jira, @dancormier commented 3 days ago:
<input type="date">
So, yeah we might be better off starting with a good, old fashioned <input type="date">
. Seems like it would do the job when it comes to most of the date inputs we already have littered across the site.
If we went this route, we could start with this native input and bring in a different solution when it’s needed. I’d consider this the YAGNI approach.
<input type="date">
- HTML: HyperText Markup Language | MDNfilter: invert
for dark mode.
display: none
; on it because it’s the only way to trigger the calendar widget.min
and max
attributes, they seems to only limit selection on the calendar widget the input provides in some cases. Keyboard input can get around those attributes.
Thanks for gathering this info, @dancormier. Seems like we could refactor to native date inputs on the way to something more fully-featured / customizable. Leaning toward Vanilla?
@aaronshekey yep, leaning vanilla for sure. I think it will meet most of our needs and can be extended if we absolutely need it*. If we're okay with working with a simplified picker to start, vanilla is probably the flavor we want.
*I'm thinking in the case of the one date picker at /cm/elections/add
that only allows Tuesdays.
TL;DR: I advise we implement the date picker without third party libraries and stick with a native <input type="date" />
.
Based mostly on the existing implementations provided by @bnickel, it seems like our requirements largely overlap from one implementation to another.
Here are some features implemented in individual existing date pickers on our products:
I'd advise replacing current date picker implementations with <input type="date">
in the interum (at least). This way, we can provide the user with a consistent, dependable, lightweight date picker and extend (or replace) it at a later date if the need arises.
Using a native input with no third party libraries has clear advantages over third party implementations:
It seems a native input will excel at:
There are a few compromises if we go with a native input:
Many third-party JS date pickers include an option add time selection to the date input. If we go the vanilla route, we might be able to get away with the picker just being HTML and CSS. We have a couple options if we go the vanilla route:
<input type="datetime-local" />
This could be an input type we support and endorse in addition to date
. At the time of this writing, it's supported in all browsers Stacks supports except Firefox... BUT, after digging into a 5 year old bug report, it looks like Firefox support is on it's way (as of 2 days ago 😮).
See also Date and time input types | Can I use...
<input type="date" />
and <input type="time" />
inputsThis is probably the best vanilla option initially. It would allow us to replace existing date and time pickers with a lightweight, well-supported option.
Is your feature request related to a problem? Please describe. Stack Overflow has a few instances of a data picker. The current solutions are all different (jQuery UI) and not very robust.
Describe the solution you'd like A date picker in Stacks that includes:
Describe alternatives you've considered jQuery
Additional context @UXPiper worked on a few mockups here and here: