Skip to content

Commit

Permalink
Improve a11y for template counter component (#1150)
Browse files Browse the repository at this point in the history
* Hide out-of-view count from assistive tech

* Add changeset
  • Loading branch information
geoffrich authored Apr 20, 2021
1 parent 59f9277 commit 872d734
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/ten-plants-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-svelte': patch
---

Hide out-of-view counter from assistive tech
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,20 @@

<div class="counter">
<button on:click={() => (count -= 1)} aria-label="Decrease the counter by one">
<svg role="img" aria-label="Minus" viewBox="0 0 1 1">
<svg aria-hidden="true" viewBox="0 0 1 1">
<path d="M0,0.5 L1,0.5"></path>
</svg>
</button>

<div class="counter-viewport">
<div class="counter-digits" style="transform: translate(0, {100 * offset}%)">
<strong style="top: -100%">{Math.floor($displayed_count + 1)}</strong>
<strong style="top: -100%" aria-hidden="true">{Math.floor($displayed_count + 1)}</strong>
<strong>{Math.floor($displayed_count)}</strong>
</div>
</div>

<button on:click={() => (count += 1)} aria-label="Increase the counter by one">
<!-- <img src={plus} alt="Plus icon"> -->
<svg role="img" aria-label="Plus" viewBox="0 0 1 1">
<svg aria-hidden="true" viewBox="0 0 1 1">
<path d="M0,0.5 L1,0.5 M0.5,0 L0.5,1"></path>
</svg>
</button>
Expand Down

1 comment on commit 872d734

@vercel
Copy link

@vercel vercel bot commented on 872d734 Apr 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.