Coder Social home page Coder Social logo

ca11y's People

Contributors

averyvery avatar cwmanning avatar greypants avatar nhunzaker avatar solomonhawk avatar waffle-iron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ca11y's Issues

Improve Tests and Coverage

#23 Added testing infrastructure. It's time to flesh out the tests, get a coverage report, hook up Circle CI and ensure these stay updated.

Allow Configuration of Disabled/Enabled Dates

Purpose:

Allow users to control whether any given date is selectable or not.

Implementation:

We could expose whitelist/blacklist or include/exclude options that accept an array of strings.

When opened, should ca11y show the month of the "selected" date?

Noticed that even though I have a date in the future "selected", ca11y opens to the current month by default. Is this the desired behavior? It's kind of annoying, because if the date is next year and I want to move it by one day, I have to click 12 times to get to the month.

If my change makes sense (and it's not something I've just messed up on my end), I'll issue a PR.

Expose more Lifecycle Hooks

Related to #13

If this package goes the route of #13 and the DOM glue is left as an external concern then we don't need to worry about proxying handlers for things like onBlur, onFocus, etc. because that can be left to user-land code.

Purpose:

Allow users to tie their code into more of the internal events that Ca11y uses.

Could include some of the following events:
onPrevMonth()
onNextMonth()
onDaySelected()
onClose()
onOpen()

I think these callbacks should all be configured under options.

Expose dateFormat option.

With #32, we have access to strftime date parsing. As a shortcut we should provide an option for users to provide a strftime compatible format string to be applied during the formatting phase.

Feature Parity with other Libs

Despite the title, I'm not convinced we need complete feature parity with any other specific datepicker libs.

Thoughts:

Referencing some other datepicker libraries to get a sense for the options they expose. I'm not certain about which of these we want to implement. Further discussion on the direction and philosophy behind Ca11y is required. Discussions in #13 and #20 seems to indicate that there is some interest in having Ca11y not be directly responsible for manipulating DOM outside it's own tree. It may also be nice to allow a user to control into which container the Ca11yndar markup get's rendered (option called render or container)?

Possible Options to Add:

container || render: per above, container could be a string selector or node. render would be a function
autoClose: auto hide the datepicker when a date is selected
clearButton: display a button that clears the selected date
disableTouchKeyboard: no keyboard will display on mobile (call blur on the input when the calendar is shown)

Links:

http://bootstrap-datepicker.readthedocs.org/en/stable/options.html

Default colors should pass WCAG AA standards

  • all text on background color combinations
  • all button color combinations
  • all hover, focus, and active state color combinations
  • ideally, sample page's input box would have better contrast too

Placement of Next/Prev Buttons

screen shot 2015-12-23 at 5 04 48 pm

Because the next and previous buttons are in the lower left corner, when switching between months that have a different number of week rows, the next and previous buttons shift up and down which makes it frustrating when navigating them with the mouse (clicking on next/prev repeatedly.)

Add callback param

For doing things like custom date parsing. We probably shouldn't even touch the date input... let the implementer do that in the callback. Ideally I'd like the setup to be something like:

import Ca11y  from 'ca11y'
import options from 'ca11y/defaults'
import parse   from 'ca11y/parse'

const someInput = document.querySelector('#some-input')

function callback(selectedDateObject) {
  someInput.value = parse(selectedDateObject, 'mm/dd/yyyy')
}

const datePicker = new Ca11y(options, callback)

Allow Configurable `Parse` and `Format` Methods

Related to #13

Purpose:

Allow users to override the default date parsing and formatting that Ca11y does.

Implementation:

This could be entirely left to userland code as Dan outlined in #13.

import Ca11y     from 'ca11y'
import strftime  from 'strftime'

const myInput = document.querySelector('.input')

// user defines format/parse methods and is responsible for calling them
function format(date) {
  return strftime('%F %T', date) // simple e.g.
}

function parse(str) {
  const date = new Date(str) // simple e.g.

  return { 
    valid: !isNaN(date), // basic validation
    date: date
  }
}

function createChangeHandler(instance) {
  return function onChange(e) {
    const result = parse(e.target.value)

    if (result.valid) {
      instance.setDate(result.date)
    }
  }
}

const options = {
  // when a day is selected, propagate the change back to the input
  onDaySelected(date) {
    myInput.value = format(date)
  }
}

// create a new Ca11y instance, lib is responsible for merging defaults with options
const calendar = new Ca11y(options)

// tie changes to the input back to Ca11y
myInput.addEventListener('change', createChangeHandler(calendar), false)

Trap Focus

If tabbing past the last date, focus should return to the prev/next month buttons

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.