How to Build an Inaccessible App
How to Build an Inaccessible App
- Clicker has been tested
- I live in Perth, Australia, which means that I have to travel for at least 20 hours to get
anywhere
- And this time was no different, it took me almost
- a whole minute to get here, due to a dog in the middle of the hallway
- I'm really excited to get to speak at NDC Porto this year as well
- Although I'm not a fan of your weather
- It feels pretty much just like Perth
- I may as well have stayed home
- And although I may be the first session for you this morning, somehow I've still managed to get a
Friday afternoon slot
- I'm a freelance front end developer, which means I spend most of my time at the beach and the rest
of it working from home in my pyjamas
- I'm also heavily involved in the Perth tech community, help run a user group for front end
developers, am on the committee for the DDD Perth conference, attend all the Perth tech meetups and
work as an evangelist for YOW conferences
- Last year I also became a Twilio champion and a Microsoft MVP
- I also have a beautiful grey and white border collie who sits next to me wherever I'm working from
home
- Although he's getting very confused about all my video calls, whenever I start a call and say
hello, he can tell I'm talking to someone so goes to the front door because he assumes there's
someone come to visit
How to Build an Inaccessible App
- But today I'm here to talk about accessibility
- And rather than do what every other accessibility talk does,
- Today I'm going to teach you how to make things less accessible
- I'm also going to talk about some of the aria attributes
- And deciphering warnings you get from testing tools or as part of your build pipeline
https://cdpn.io/yLYgLGY
button
Keyboard Accessible
Clickable
Tabbable
Focusable
div
Keyboard Accessible
Clickable
Tabbable
Focusable
https://cdpn.io/jObyEqq
document.querySelectorAll("form input").forEach((i) => {
i.addEventListener("input", (e) => {
console.log(e.target.value);
if (e.target.value && e.target.value !== "") {
e.target.previousElementSibling.classList.add("active");
}
});
});
form label {
pointer-events: none;
position: relative;
top: 30px;
left: 10px;
&.active {
top: -5px;
transition: all 0.01s;
}
}
https://cdpn.io/JjYEEVr
a span {
position: absolute;
right: -200vw;
}
https://cdpn.io/ExVZWyw
- Hover effects are used to indicate that an element can be clicked
- And usually involve changing a colour
- ANd we can see here, the colour is changing on hover, which means this must be clickable
- But what if the user has a vision deficiency, and is unable to differentiate between colours as
well
- Can you see the difference between the colours?
- Using something other than a colour change
- Like changing a background, border or the underline
- No longer relies on differentiating between colours
- So users can more easily tell the difference
- Although I'd only recommend using the border as an option if the element has a bit of space around
it
https://cdpn.io/abvJOqM
0 : Can be navigated to via keyboard
-1 : Cannot be navigated to via keyboard
1 : Will be navigated to in order
aria
attributes
- Aria is often grabbed for when you know something has to be accessible
- But most of the time they're not necessary
- Earlier this year I was working on a project that needed to be accessible
- Developer ran a testing tool, which told him to add
Button, Checkbox, Link, Radio, Searchbox, Slider, Scrollbar, Tab, Textbox, Menu, Article, Heading,
Img, List, Row, Tablet, Banner, Complementary, Form, Main, Navigation, Alert, Status...
https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques
- Developer added "presentation" as the role
- This element's role is "presentation" but contains child elements with semantic meaning.
- All that was needed to do was add an empty alt tag
- To show that the image was presentational
Many of these widgets were later incorporated into HTML5, and developers should prefer using
the correct semantic HTML element over using ARIA, if such an element exists
https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA
- Label defines a string that labels the current element
- Used to describe where there isn't text to describe it
- Similar to the icons
- Alternative could have been to add `aria-label`s to the links
- however as a HTML attribute
- It doesn't get translated in the browser
Testing
- While there are several automated tests
- And tools that you can use
- To properly test for a11y, need to run user testing
- With people who use this every day
- Difference between us opening a screen reader to run a test
- And someone who uses it every day
https://pa11y.org
Web Content Accessibility GuidelinesWCAG
- Tests against the web content accessibility Guidelines
https://www.w3.org/WAI/standards-guidelines/wcag
https://github.com/dequelabs/axe-core
https://whocanuse.com
https://abc.useallfive.com
https://github.com/hail2u/color-blindness-emulation
.element {
filter: url('filters.svg#protanopia');
filter: url('filters.svg#protanomaly');
filter: url('filters.svg#deuteranopia');
filter: url('filters.svg#deuteranomaly');
filter: url('filters.svg#tritanopia');
filter: url('filters.svg#tritanomaly');
filter: url('filters.svg#achromatopsia');
filter: url('filters.svg#achromatomaly');
}
- Include the SVG file in your project
- Apply the relevant filter when you need to
https://24ways.org/2019/twelve-days-of-front-end-testing/
https://www.javascriptjanuary.com/blog/getting-started-with-front-end-testing
https://youtu.be/-__TNwVR110
https://inclusive-components.design
https://codepen.io/collection/AypYaP
twitter.com/amys_kapers
amyskapers.dev
blog.amyskapers.dev
speaking.amyskapers.dev
github.com/amykapernick
twitch.tv/amyskapers