Upgrade to Pro — share decks privately, control downloads, hide ads and more …

A11Y & React : This is for Everyone

Shaun D
April 22, 2015

A11Y & React : This is for Everyone

Talk about A11Y and tackling some things with React.js. Talk given at the London React Meetup April 2015

Shaun D

April 22, 2015
Tweet

More Decks by Shaun D

Other Decks in Programming

Transcript

  1. @shaundunne When sites are correctly designed, developed and edited, all

    users have equal access to information and functionality. - Wikipedia, Web Accessibility
  2. @shaundunne When sites are correctly designed, developed and edited, all

    users have equal access to information and functionality. - Wikipedia, Web Accessibility
  3. @shaundunne 285 million people are estimated to be visually impaired

    worldwide. 39 million are blind. WHO | Visual impairment and blindness. http:/ /www.who.int/mediacentre/factsheets/fs282/en/#
  4. @shaundunne // presentational <img src="USSEnterprise1701-D.png" alt=""> // Part of the

    content <img src="USSEnterprise1701-D.png" alt="Image of The Galaxy Class Federation Ship USS Enterprise"> alt tag
  5. @shaundunne <table> <tr> <td class="label">username</td> <td class='username-input'><input type="text" name="username"></td> </tr>

    </table> <div> <label for="username">username</label> <input name="username" id="username"></input> </div> labels
  6. @shaundunne <table> <tr> <td> class="label">username</td> <td class='username-input'><input type="text" name="username"></td> </tr>

    </table> <div> <label for="username">username</label> <input name="username" id="username"></input> </div> labels
  7. @shaundunne Good Ol’ HTML Use Native Elements var WarpButton =

    React.createClass({displayName: "WarpButton", render: function() { return React.createElement("button", null, "Engage!"); } });
  8. @shaundunne var WarpButton = React.createClass({displayName: "WarpButton", render: function() { return

    React.createElement("span", { onClick: this.engage }, "Engage!"); } });
  9. @shaundunne ARIA to the rescue var WarpButton = React.createClass({displayName: "WarpButton",

    render: function() { return React.createElement("span",{ onClick: this.engage, tabindex: "0" }, "Engage!"); } });
  10. @shaundunne ARIA to the rescue var WarpButton = React.createClass({displayName: "WarpButton",

    render: function() { return React.createElement("span",{ onClick: this.engage, tabindex: "0", role: "button" }, "Engage!"); } });
  11. @shaundunne ARIA to the rescue var WarpButton = React.createClass({displayName: "WarpButton",

    render: function() { return React.createElement("span",{ onClick: this.engage, onKeyUp: this.keyUp, tabindex: "0", role: "button" }, "Engage!"); } });
  12. @shaundunne ARIA Roles alert alertdialog application article banner button checkbox

    columnheader combobox command [abstract] complementary composite [abstract] contentinfo definition dialog directory document form grid gridcell group heading img input [abstract] landmark [abstract] link list listbox listitem log main marquee math menu seperator slider spinbutton status structure [abstract] tab tablist tabpanel textbox timer toolbar tooltip tree treegrid treeitem widget [abstract] window [abstract] navigation note option presentation progressbar radio radiogroup range [abstract] region roletype [abstract] row rowgroup rowheader scrollbar search section [abstract] sectionhead [abstract] select [abstract] http://www.w3.org/TR/wai-aria/roles
  13. @shaundunne ARIA States & Properties aria-atomic aria-busy (state) aria-controls aria-describedby

    aria-disabled (state) aria-dropeffect aria-flowto aria-grabbed (state) aria-haspopup aria-hidden (state) aria-invalid (state) aria-label aria-labelledby aria-live aria-owns aria-relevant aria-autocomplete aria-checked (state) aria-disabled (state) aria-expanded (state) aria-haspopup aria-hidden (state) aria-invalid (state) aria-label aria-level aria-multiline aria-multiselectable aria-orientation aria-pressed (state) aria-readonly aria-required aria-selected (state) aria-sort aria-valuemax aria-valuemin aria-valuenow aria-valuetext http://www.w3.org/TR/wai-aria/states_and_properties
  14. @shaundunne ARIA States & Properties aria-atomic aria-busy (state) aria-controls aria-describedby

    aria-disabled (state) aria-dropeffect aria-flowto aria-grabbed (state) aria-haspopup aria-hidden (state) aria-invalid (state) aria-label aria-labelledby aria-live aria-owns aria-relevant aria-autocomplete aria-checked (state) aria-disabled (state) aria-expanded (state) aria-haspopup aria-hidden (state) aria-invalid (state) aria-label aria-level aria-multiline aria-multiselectable aria-orientation aria-pressed (state) aria-readonly aria-required aria-selected (state) aria-sort aria-valuemax aria-valuemin aria-valuenow aria-valuetext http://www.w3.org/TR/wai-aria/states_and_properties
  15. @shaundunne ARIA States & Properties aria-atomic aria-busy (state) aria-controls aria-describedby

    aria-disabled (state) aria-dropeffect aria-flowto aria-grabbed (state) aria-haspopup aria-hidden (state) aria-invalid (state) aria-label aria-labelledby aria-live aria-owns aria-relevant aria-autocomplete aria-checked (state) aria-disabled (state) aria-expanded (state) aria-haspopup aria-hidden (state) aria-invalid (state) aria-label aria-level aria-multiline aria-multiselectable aria-orientation aria-pressed (state) aria-readonly aria-required aria-selected (state) aria-sort aria-valuemax aria-valuemin aria-valuenow aria-valuetext http://www.w3.org/TR/wai-aria/states_and_properties
  16. @shaundunne const React = require('react'); const AppStore = require('../stores/app_store.js'); function

    cartItems(){ return{items: AppStore.getCart()} } let LiveRegion = React.createClass({ getInitialState: function(){ return cartItems(); }, componentWillMount: function(){ AppStore.addChangeListener(this._onChange); }, _onChange:function(){ this.setState({ a11y: 'Cart Updated. You have' + this.state.items.length + 'items in your cart' }); }, render(){ return ( <div role="region" aria-live="assertive" aria-atomic="true">{this.state.a11y}</div> ); } }); module.exports = LiveRegion;
  17. @shaundunne const React = require('react'); const AppStore = require('../stores/app_store.js'); function

    cartItems(){ return{items: AppStore.getCart()} } let LiveRegion = React.createClass({ getInitialState: function(){ return cartItems(); }, componentWillMount: function(){ AppStore.addChangeListener(this._onChange); }, _onChange:function(){ this.setState({ a11y: 'Cart Updated. You have' + this.state.items.length + 'items in your cart' }); }, render(){ return ( <div role="region" aria-live="assertive" aria-atomic="true">{this.state.a11y}</div> ); } }); module.exports = LiveRegion;
  18. @shaundunne .sr-only { position: absolute; width: 1px; height: 1px; padding:

    0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
  19. @shaundunne Talks Marcy Sutton : Javascript For Everyone Léonie Watson

    : ”Rock & roll guide to HTML5 & ARIA" Jörn Zaefferer : Talk to me Accessibility is a Feature You Can Build Talk playlist : http://j.mp/a11y-vids