Comments (2)
Oh wow, awesome. Thanks so much for this trove of info!
Sounds pretty straightforward, and about what I expected. While in my own projects I haven't made the counter update after initial render, presumably others who use this project might!
Live regions seem really neat! This counter is just presentational, so presumably some folks might want to have it auto-update? I think I'll wait and see if this counter is used anywhere outside my own projects (which don't auto-update).
Thanks again for the info :)
from react-retro-hit-counter.
First of all, awesome to see you're thinking a11y @joshwcomeau!
Since the React Retro Hit Counter is intentionally presentational, with no user action expected, your work for serving a readable version for assistive tech can be pretty simple.
For a good, solid start, you'll want to have a textual version of the counter value available in the DOM. This could be as simple as a <p>1234</p>
somewhere in your main wrapper. Though, I would definitely suggest a little more context - something like <p>This site has had 1234 visitors!</p>
- to round out the cues that sighted users would grok automatically.
To visually hide the alternative text, you can use a similar approach to Bootstrap's .sr-only
class, meant to retain the text as machine-readable. Something like this (grabbed from this handy post on the subject):
.screen-reader-only {
position: absolute;
height: 1px;
width: 1px;
clip: rect(1px 1px 1px 1px); // IE 6 and 7
clip: rect(1px,1px,1px,1px);
clip-path: polygon(0px 0px, 0px 0px, 0px 0px);
-webkit-clip-path: polygon(0px 0px, 0px 0px, 0px 0px);
overflow: hidden !important;
}
Since the counter itself provides no content for non-sighted users and machines, I would even consider employing aria-hidden
on a wrapper (that doesn't include the text element) to ensure that screen readers that follow the ARIA spec will skip it entirely. Something like this:
<div>
<p class="screen-reader-only">This site may or may not have had 1234 visitors!</p>
<div aria-hidden="true">...</div>
<canvas aria-hidden="true">...</canvas>
</div>
If you're looking to mod the counter to change it's value while it is mounted (eg. syncing ongoing traffic while a user is mid-session), you could get into some fun with ARIA's live region options as well.
from react-retro-hit-counter.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-retro-hit-counter.