1
0
mirror of https://github.com/flarum/core.git synced 2025-08-19 06:41:44 +02:00

[A11Y] Make checkboxes focusable (#3014)

* Add extra feature to a11y focusring mixin

* Add visually hidden CSS class and mixin

* Visually hide checkboxes (keep in focus/a11y tree)

* Place checkbox focus ring around display element

* Improve mobile checkbox/switch accessibility
This commit is contained in:
David Wheatley
2021-08-16 11:56:10 +02:00
committed by GitHub
parent 51ce89b61f
commit 83529e23de
4 changed files with 75 additions and 7 deletions

View File

@@ -39,13 +39,13 @@
*
* For example...
*
*? button { .addKeyboardFocusRing(":focus-within") }
*? button { .add-keyboard-focus-ring(":focus-within") }
* becomes
*? button:focus-within { <styles> }
*
* AND
*
*? button { .addKeyboardFocusRing(" :focus-within") }
*? button { .add-keyboard-focus-ring(" :focus-within") }
* becomes
*? button :focus-within { <styles> }
*/
@@ -57,6 +57,38 @@
}
}
/**
* This mixin allows support for a custom element nearby the focused one
* to have a focus style applied to it
*
* For example...
*
*? button { .add-keyboard-focus-ring-nearby("+ .myOtherElement") }
* becomes
*? button:-moz-focusring + .myOtherElement { <styles> }
*? button:focus-within + .myOtherElement { <styles> }
*/
.add-keyboard-focus-ring-nearby(@nearbySelector) {
@realNearbySelector: ~"@{nearbySelector}";
// We need to declare these separately, otherwise
// browsers will ignore `:focus-visible` as they
// don't understand `:-moz-focusring`
// These are the keyboard-only versions of :focus
&:-moz-focusring {
@{realNearbySelector} {
#private.__focus-ring-styles();
}
}
&:focus-visible {
@{realNearbySelector} {
#private.__focus-ring-styles();
}
}
}
/**
* Allows an offset to be supplied for an a11y
* outline.