amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

Custom date picker for date fields in AMP forms

Open rudygalfi opened this issue 10 years ago • 24 comments

This issue is opened to collect requirements and track development of being able to use a custom date picker in conjunction with the date field support in AMP forms.

rudygalfi avatar Dec 02 '16 21:12 rudygalfi

/cc @dandv @choumx @aghassemi

FYI This has been coming up more recently, now that a lot of the needs for e-commerce have been addressed. Chatted w/ Malte about the feature, and current thinking is that we may be able to take an approach similar to autocomplete, where we both

a) expose the events in bind to make this work and create an ABE that demos how folks could compose an advanced case, and b) create a simple, good-UX solution encapsulated as a higher-level component, as well

ericlindley-g avatar May 25 '17 23:05 ericlindley-g

Can't wait for autocomplete and this. 👍

vsiv avatar May 31 '17 02:05 vsiv

+1. Date range picking has been requested by travel partners - searching for hotel availability for example.

dandv avatar Jun 01 '17 21:06 dandv

I highly recommend we try to find an existing good open-source implementation and integrate it. A high quality, mobile friendly date picker with a11y and i18n support is a lot of work. Supporting non-Gregorian calendars adds a lot to it as well.

Looking at Airbnb's version (https://github.com/airbnb/react-dates): 500 commits, 57 contributors, thousands lines of code...

aghassemi avatar Jun 01 '17 23:06 aghassemi

UX Design Review

  • [ ] Allow typing (new version of ReactDate does).
  • [ ] @spacedino to come up with a base style for calendar (Decision is to have a "good" (instead of a "reset" that picks up browser default) base style)
  • [ ] @cvializ to "reset" the input styles back to browser defaults.
  • [ ] Modal for modal overlay for desktop.
  • [ ] @cvializ publish Demo link for @spacedino to use for styling.

aghassemi avatar Nov 16 '17 22:11 aghassemi

Final designs and spex. The final design we decided on was not actually a11y color compliant so I had to change. Open to discuss if there are issues but this should work for now. We might want to make it more obvious which are the start and end dates by changing the shape since the color is pretty dark now. Or we could decide that having the start and end dates as a dark color, but the middle dates with a lighter bg and black text is ok too (19).

FINAL

date_picker_final_empty_16 date_picker_final_full_17 OR date_picker_final_full_19 date_picker_single_18 final_spex_date_picker

/cc +aghassemi +cvializ +lswang1618

spacedino avatar Dec 15 '17 11:12 spacedino

from @cvializ demos :

  • https://ampcvializ.herokuapp.com/examples/date-picker.amp.html
  • [ AMP.toggleExperiment('amp-date-picker', true) to view ]

Next steps:

  • launch in experimental mode
  • update visual designs
  • final UX review

spacedino avatar Dec 15 '17 21:12 spacedino

This component is ready for experimenting. In lieu of full documentation, here are some details for experimentation. The component is called amp-date-picker with type=range or type=single for selecting a single date or a range of dates.

A placeholder is required for the component - for a single date, this can take the form:
<input amp-date-placeholder placeholder="Pick a date" id="date"/>

For a date range:

<input amp-date-placeholder-start placeholder="Start date" id="start" />
<input amp-date-placeholder-end placeholder="End date" id="end" />

The properties available for both include:

  • max: the latest date that the calendar will allow. The default is unlimited.
  • min: the earliest date that the calendar will allow. The default is the current date.
  • src: a link to a JSON file to configure the date picker.
  • locale: a locale string, e.g. "en", "fa", "zh".
  • format: a standard date string e.g. YYYY-MM-DD to use as the output for AMP Events. This will be formatted in the output locale, unless the output locale is Unix seconds or millis i.e. "X" or "x"
  • blocked: a space separated list of ISO 8601 dates and RFC 5545 RRULEs specifying disallowed dates. Does not require amp-mustache.
  • highlighted: a space separated list of ISO 8601 dates and RFC 5545 RRULEs specifying dates displayed with a highlight style. Does not require amp-mustache.

Properties that are inherited from the Airbnb library (https://github.com/airbnb/react-dates) include:

For both range and single

  • anchor-direction
  • auto-focus
  • disabled
  • enable-outside-days
  • first-day-of-week
  • horizontal-margin
  • initial-visible-month
  • keep-open-on-date-select
  • minimum-nights
  • month-format
  • number-of-months
  • orientation
  • reopen-picker-on-clear-date
  • required
  • screen-reader-input-message
  • show-default-input-icon
  • with-full-screen-portal
  • with-portal

For single

  • initial-date
  • show-clear-date

For range

  • auto-focus-end-date
  • initial-end-date
  • initial-start-date
  • show-clear-dates

You can also use amp-mustache to create templates for custom date markup and an info-panel below the calendar. Other features include tooltips, setDate(s) and clear actions, and change event listeners. Examples of these implementations can be found here:

  • https://github.com/ampproject/amphtml/blob/master/examples/date-picker.amp.html
  • https://github.com/ampproject/amphtml/blob/master/examples/travel.amp.html

lswang1618 avatar Dec 18 '17 23:12 lswang1618

I tried to follow all the steps and gave it a try, however it didn't work out. There's a 404 error occurred:

image

Is this a bug or did I do something wrong?

eric30 avatar Dec 27 '17 02:12 eric30

/cc @erwinmombay regarding last comment, looks like unversioned Canary is pointing to prod. Enabling Dev Channel seems to only impact cached resources and not origins.

aghassemi avatar Dec 28 '17 06:12 aghassemi

Update that this is now working in the Dev Channel.

lswang1618 avatar Jan 08 '18 22:01 lswang1618

Any timeline for when it will be out of experimental stage?

adnanyousafch avatar Jan 31 '18 07:01 adnanyousafch

@lswang1618 @cvializ Given default styles are now in, I personally feel comfortable moving this to at least a doc-level optin so folks can start shipping in 3-4 weeks, thoughts? (@cvializ I guess we still need the validation rules).

aghassemi avatar Jan 31 '18 18:01 aghassemi

Sure, sgtm.

lswang1618 avatar Feb 01 '18 21:02 lswang1618

Any update on this timeline?

vonkow avatar Mar 24 '18 00:03 vonkow

Should the calendars be hidden by default or do they need to be implemented inside of a lightbox?

This demo has the calendars hidden, but AMPByExample Demo displays them by default.

Which is expected?

mdiblasio avatar Mar 27 '18 14:03 mdiblasio

@mdiblasio Isn't it a user experience choice for the publisher? cc @lswang1618

rudygalfi avatar Mar 27 '18 16:03 rudygalfi

I'm more referring to the inconsistency between the 2 demos, which have nearly the same implementations.

Demo 1: demo 1

Demo 2: demo 2

Neither use a lightbox but the first demo doesn't display the calendar until the field is clicked. If the publisher doesn't want to show the calendar until clicked, is there an attribute or must they use a lightbox?

mdiblasio avatar Mar 27 '18 16:03 mdiblasio

It's an attribute - use mode:overlay

lswang1618 avatar Mar 27 '18 16:03 lswang1618

This issue hasn't been updated in awhile. @lswang1618 Do you have any updates?

ampprojectbot avatar Sep 11 '18 15:09 ampprojectbot