-
Notifications
You must be signed in to change notification settings - Fork 285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Improve accessibility of the theme switcher #160
Conversation
Side-notes: This is a requirement from https://github.com/gohugoio/hugoThemes#resources |
I think that a CSS-only solution with |
Done. The downside here is: whitespace isn't allowed either, or it won't be hidden. The other solution would be not emitting the list item in the first place, something like:
|
This! 🤯 |
Ok, I take it that this is your preferred solution. Done. |
* fix: Improve accessibility of the theme switcher * Added some styles back, these aren't redundant in "center" header mode * Restore data-hide attribute * chore: update resources folder with example config.toml * Hide theme switcher's parent via CSS when theme switcher isn't visible * chore: Fixed whitespace * Don't emit the theme switcher's parent at all if theme switcher is hidden Co-authored-by: reuixiy <reuixiy@gmail.com>
The keyboard accessibility of the theme switcher isn't great right now. When you press Tab to go through menu entries, the focus gets to the theme switcher but no focus ring appears - you don't see where the focus is. Also, pressing Enter (which is what you would do with the other menu items) doesn't do anything, you have to press Space because it is a checkbox which isn't exactly obvious.
So I made the theme switcher a link like the other entries, this makes its behavior consistent. If we are worried about screen readers, we might want to add some hidden text to it as well. Given that this is the switch for the visual theme however, adding
aria-hidden="true"
to the entire element might make more sense.