Adding accessibility features
Made the theme button toggable by keyboard Added aria-label to many <a> without any text (usually, they contains Font Awesome icons) Added aria-hidden whenever necessary Labelled the "Copy URL and Description" contained in footer Added an hidden label for the menu toggle for mobile accessibility Changed some colors to meet the Color Contrast AA level: https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html
This commit is contained in:
@ -36,6 +36,7 @@ function navSectionsClose(event) {
|
||||
// Dark/Light color scheme switch button
|
||||
document.querySelector("#nav-switch-theme").style.display = "inline";
|
||||
document.querySelector("#nav-switch-theme").addEventListener("click", changeColorScheme);
|
||||
document.querySelector("#nav-switch-theme").addEventListener("keydown", handleBtnKeyDown);
|
||||
|
||||
function changeColorScheme() {
|
||||
// Use whatever users want
|
||||
@ -91,3 +92,12 @@ if (
|
||||
) {
|
||||
fixThemeImages();
|
||||
}
|
||||
|
||||
function handleBtnKeyDown(event) {
|
||||
// Check to see if space or enter were pressed
|
||||
if (event.key === " " || event.key === "Enter" || event.key === "Spacebar") { // "Spacebar" for IE11 support
|
||||
// Prevent the default action to stop scrolling when space is pressed
|
||||
event.preventDefault();
|
||||
changeColorScheme();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user