Share
Embed
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
Transcript
49 slides
-
@shaundunne When sites are correctly designed, developed and edited, all
users have equal access to information and functionality. - Wikipedia, Web Accessibility -
@shaundunne When sites are correctly designed, developed and edited, all
users have equal access to information and functionality. - Wikipedia, Web Accessibility -
@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/# -
@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 -
@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 -
@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 -
@shaundunne Good Ol’ HTML Use Native Elements var WarpButton =
React.createClass({displayName: "WarpButton", render: function() { return React.createElement("button", null, "Engage!"); } }); -
@shaundunne var WarpButton = React.createClass({displayName: "WarpButton", render: function() { return
React.createElement("span", { onClick: this.engage }, "Engage!"); } }); -
@shaundunne ARIA to the rescue var WarpButton = React.createClass({displayName: "WarpButton",
render: function() { return React.createElement("span",{ onClick: this.engage, tabindex: "0" }, "Engage!"); } }); -
@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!"); } }); -
@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!"); } }); -
@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 -
@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 -
@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 -
@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 -
@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; -
@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; -
@shaundunne .sr-only { position: absolute; width: 1px; height: 1px; padding:
0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; } -
@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