Skip to content

Commit b4032e7

Browse files
authored
Infra: Make colour theme cycler button accessible (#2619)
1 parent 2849a58 commit b4032e7

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

pep_sphinx_extensions/pep_theme/static/style.css

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/* Styles for PEPs */
33

44
/*
5-
* `initial` works like undefined variables, so `var(intial, x)` will resolve to `x`.
5+
* `initial` works like undefined variables, so `var(initial, x)` will resolve to `x`.
66
* A space means an empty value, so `var( , x) y` will resolve to `y`.
77
*/
88
@media (prefers-color-scheme: dark) {
@@ -359,3 +359,15 @@ dl.footnote > dd {
359359
.reference.external > strong {
360360
font-weight: normal; /* Fix strong links for :pep: and :rfc: roles */
361361
}
362+
363+
.visually-hidden {
364+
position: absolute !important;
365+
width: 1px !important;
366+
height: 1px !important;
367+
padding: 0 !important;
368+
margin: -1px !important;
369+
overflow: hidden !important;
370+
clip: rect(0,0,0,0) !important;
371+
white-space: nowrap !important;
372+
border: 0 !important;
373+
}

pep_sphinx_extensions/pep_theme/templates/page.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ <h1>Python Enhancement Proposals</h1>
3131
<li>{{ title.split("–")[0].strip() }}</li>
3232
</ul>
3333
<button id="colour-scheme-cycler" onClick="setColourScheme(nextColourScheme())">
34-
<svg class="colour-scheme-icon-when-auto"><use href="#svg-sun-half"></use></svg>
35-
<svg class="colour-scheme-icon-when-dark"><use href="#svg-moon"></use></svg>
36-
<svg class="colour-scheme-icon-when-light"><use href="#svg-sun"></use></svg>
34+
<svg aria-hidden="true" class="colour-scheme-icon-when-auto"><use href="#svg-sun-half"></use></svg>
35+
<svg aria-hidden="true" class="colour-scheme-icon-when-dark"><use href="#svg-moon"></use></svg>
36+
<svg aria-hidden="true" class="colour-scheme-icon-when-light"><use href="#svg-sun"></use></svg>
37+
<span class="visually-hidden">Toggle light / dark / auto colour theme</span>
3738
</button>
3839
</header>
3940
<article>

0 commit comments

Comments
 (0)