An open API service indexing awesome lists of open source software.

https://github.com/jpdevries/availability-grid

An accessible HTML Component for accepting weekly availability.
https://github.com/jpdevries/availability-grid

Last synced: 2 months ago
JSON representation

An accessible HTML Component for accepting weekly availability.

Awesome Lists containing this project

README

          

## HTML–first
`AvailabilityGrid` is progressively enhanced from a semantic HTML `` made up of a `` of `

document.addEventListener('DOMContentLoaded',function(){
var grid = new AvailabilityGrid();
});

```

### Methods
When a new `AvailabilityGrid` is created the instance automatically initializes itself. `AvailabilityGrid` instances can be destroyed via `.destroy()` and re-awoken from the dead with `.init()`.

```js
grid.destroy(); // remove listeners
// mutate the DOM or whatever...
grid.init(); // re-add listeners
```

When calling `.init()` you may pass in a fresh set of options.

```js
grid.init({
element:document.getElementById('new-grid')
});
```

Calling `.destroy()` will remove all listeners and references to `element` but options like `inputSelector` will persist and do not need to be reset when reawakening an instance by later calling `.init()`.

_Note: As AvailabilityGrid instances `.destroy()` themselves they look for an `id` on `element`. If found, `element` will be set to the string `id` so as to remove references to that element while still being able to query the DOM for it if `.init()` is later called without passing in an element._

The current selection can be inverted using the `.inverse()` method.

```js
var grid = new AvailabilityGrid();
grid.inverse(); // inverse the selection
```

### Options
| key | default | description |
| ---- | ---- | ---- |
| `element` | `'availability-grid'` | The HTML Element or `id` of the HTML element |
| `inputSelector` | `'input[type="checkbox"]'` | Selector used when querying DOM for checkbox inputs |
| `whenTextSelector` | `'span.a11y-hidden'` | Selector used when querying DOM to change hidden text for screen readers |

## Weigh–In
| Type | Un–minified (kB) | Minified (kB) | GZIP (kB)
| ------------- | ------------- | --- | --- |
| CSS | 7.14 | 6.01 | 0.846 |
| JavaScript | 12.32 | 5.77 | 1.96 |

## Screencasts

- [AvailabilityGrid VoiceOver Preview](https://vimeo.com/170844798)
- [AvailabilityGrid Demo + Shift Selection](https://vimeo.com/170857351)

## HTML Architecture
See [the Wiki](https://github.com/jpdevries/availability-grid/wiki/HTML-Architecture).

## Keyboard Accessibility
In addition to the inherent keyboard accessibility that comes with the ability to tab through a table of `` elements and use space bar to check or un–check them, AvailabilityGrid adds the following keyboard considerations:
- Arrow Keys

### Arrow Keys
While focused on a cell, the up, right, down, and left arrow keys can be used to shift focus to a neighboring cell.

![](http://j4p.us/3N3M38273H1F/arrow-key.gif)

## Usability Considerations
The main usability consideration currently made is:

- range selection
- inverse selection
- VoiceOver usage

### Range Selection
The Shift key can be used to select ranges of inputs. When focused on a cell, hold Shift while clicking another to toggle a range of time slots.

![](http://j4p.us/3h0f071i2F04/shift-selection.gif)

### Inverse Selection
`AvailabilityGrid` exposes a `.inverse()` method that inverts the checked property of each option. This user consideration can be used as a shortcut to make particular selections.

![](http://j4p.us/0i3l3S3F3I1B/inverse-selection.gif)

### VoiceOver Usage
Accessibly hidden text is used to make screen readers read aloud a question like "Are you available Mondays at 9am?" or a statement like "You are available Mondays at 9am." accordingly. It will also read aloud keyboard shorcuts and tips.

![](http://j4p.us/0N2J0K0S1202/Screen%20Shot%202016-06-15%20at%204.14.30%20PM.png)

See the [VoiceOver Screencast](https://vimeo.com/170844798).

## Styles
The default styles for `AvailabilityGrid` consist of [some simple Sass](https://github.com/jpdevries/availability-grid/blob/master/_build/scss/main.scss).

```html

```

You can include the default styles and/or override them with your own.

## Techniques
See [the Wiki](https://github.com/jpdevries/availability-grid/wiki/Techniques).

## Contribution Guidelines
Trying to follow the guidelines at [frend/frend.co](https://github.com/frend/frend.co#javascript). However, support for multiple "JS Drivers" is on the roadmap. The same style guide for the VanillaJS driver would not necessarily apply to a React or Angular driver. To suggest a feature or report a bug feel free to [open an issue](https://github.com/jpdevries/availability-grid/issues/new).

## Accessibility Proclaimer
This component strives for WCAG 2.0 Guidelines Level AA. Please [open an issue](https://github.com/jpdevries/availability-grid/issues/new) for any accessibility issue, feedback, or concern.