nikgraf / belle

Configurable React Components with great UX
http://nikgraf.github.io/belle/
MIT License
2.51k stars 104 forks source link

DatePicker (brainstorming) #122

Closed nikgraf closed 8 years ago

nikgraf commented 9 years ago

Open question:

Todos:

The reason for keep the focus state independent from DOM focus was WAI-ARIA specification that current date should be focused as date picker of focused. And focus behavior while tabbling which was not achievable with DOM focus.

LucaColonnello commented 9 years ago

Have someone a sketch or psd or jpeg for the ui?

jpuri commented 9 years ago

References: https://github.com/JedWatson/react-date-input https://github.com/Rudeg/react-input-calendar

dmitry commented 9 years ago

Most powerful react date picker: https://github.com/gpbl/react-day-picker

I've checked around 5 different date pickers. This one is powerful, because it gives ability to a user modify dates depending on requirements, plus it has most powerful support of i18n (possible to push own localization keys into a component, instead of moment.js).

jpuri commented 9 years ago

Yep @dmitry , this one is real good. Thanks.

nikgraf commented 9 years ago

Today @jpuri & I did some brainstorming. We thought about providing two components:

<DatePicker>

The datepicker component is just the component to select a date. In mobile situations people might want to use it directly. It's also great to just show a calendar in case no event listeners are bound. This also allows people to cover more complex date/range selections with custom components.

<DateInput>

The dateinput looks like an input field. By default we put a calendar icon next it. But clicking the calendar icon a datepicker will open. The text is still editable, but is going to be validated like in this example: http://rudeg.github.io/react-input-calendar/

jpuri commented 9 years ago

Collecting couple of design / api thoughts about the component:

  1. The component will have 2 properties month, year. They will be by default current month and current year. The component will by default show that month and year to user to select date from.
  2. Current date (today) will be highlighted on the component but not selected.
  3. User can give a default date to the component using - defaultValue, value or valueLink props. Once a new date is selected onUpdate will be called and also component will be updated depending on which property -> "defaultValue, value or valueLink" is used.
  4. Like rating we should provide some api method for user to be able to unset the date.
jpuri commented 9 years ago

Rating component will support these 3 states:

  1. Enabled and can be modified: Component is enabled and value can be changed:
  2. Disabled: http://www.w3.org/TR/html401/interact/forms.html#h-17.12.1
  3. Read-Only: http://www.w3.org/TR/html401/interact/forms.html#h-17.12.2

ARIA-properties supported:

  1. aria-label
  2. aria-current
  3. aria-selected
  4. aria-disabled
  5. aria-readonly

Reference for localization data: https://github.com/jquery/jquery-ui/tree/master/ui/i18n

When using date-picker with input box - date input, focus styles of date picker should be totally disabled and CTRL + keys can then be used for kayboard navigation. This might mean much complexity for keyboard handling :(

For days in datePicker it will be better to have a new state (in addition to focus state), so that both mouse and keyboard events can be handled seemlessly. This state may not have any styling associated with it.

Reference: https://jqueryui.com/datepicker/

Highlighting weekend in calendar will be an optional feature. Though many calendar's do no include weekend information as locale data. I think locale data is good place to do that. There will be a property 'styleWeekend' which when true will result in highlighting weekend.

luisrudge commented 9 years ago

please don't forget to add a date range picker :heart:

luisrudge commented 9 years ago

I tried a lot of date pickers. From a library consumer perspective, I ended up using this one: http://zippyui.com/react-date-picker/

The api is very simple and I created a date range picker on top of it pretty easily.

dmitry commented 9 years ago

@luisrudge I've also tried a lot of date pickers, and found https://github.com/gpbl/react-day-picker very simple to read, to modify and implement a features. On the first sight looks like not possible to implement some features like range of dates, blocking dates etc., but after looking into the modifiers feature you can find out that the power of this date picker is huge. Also almost all the date pickers force you to use moment.js, but only this one gives you option to implement your own i18n interface.

luisrudge commented 9 years ago

@dmitry awesome! Thanks! This is date picker is really great. It has range as well!

nikgraf commented 9 years ago

@jpuri interesting read regarding focus behaviour: http://ux.stackexchange.com/questions/52849/datepicker-behavior

nikgraf commented 9 years ago

@jpuri I thought about the ctrl+up as well, but the issue here is that even on OSX these keyboard short cuts are used for different things by default.

look what I found: http://www.w3.org/TR/wai-aria-practices/#datepicker - I suggest to exactly use the keyboard short cuts as they propose.

This also has some nice hints regarding behaviour: https://www.w3.org/WAI/PF/HTML/wiki/Datepickers

jpuri commented 9 years ago

KeyStrokes to be implemented:

Implemented ones:

  1. Shift+Tab - reverses the direction of the tab order.
  2. Up Arrow and Down Arrow - goes to the same day of the week in the previous or next week respectively.
  3. Left Arrow and Right Arrow - advances one day to the next, also in a continuum.
  4. Enter - Enter confirms the selected date(s).
jpuri commented 9 years ago

WAI-ARIA support:

jpuri commented 9 years ago
nikgraf commented 8 years ago

@jpuri I updated the sub-tasks on top (added suggestions & bugs I found)

jpuri commented 8 years ago

Nice @nikgraf , I plan to work on all the bugs you highlighted, lets also catchup some time to discuss the suggestions.

jpuri commented 8 years ago

My feedback: Great component :) But I am doubtful about merged hover and focus states. This can create unexpected behaviors like someone can hover over a date and press enter to select it - something which will never work for simple button.