From cdea25584dc7a074d099931c5be77fe3fb5fde20 Mon Sep 17 00:00:00 2001 From: "Patrick H. Lauke" Date: Fri, 31 Jul 2020 10:27:36 +0100 Subject: Cleanup/fix after the sr-only to visually-hidden renaming (#31359) * sr-only -> visually-hidden cleanup It seems the old screen-readers.md file was left behind, and forgot to rename the mixin * Fix broken mixins for visually-hidden --- scss/_mixins.scss | 2 +- scss/mixins/_screen-reader.scss | 28 ------------------------- scss/mixins/_visually-hidden.scss | 28 +++++++++++++++++++++++++ site/content/docs/5.0/helpers/screen-readers.md | 25 ---------------------- 4 files changed, 29 insertions(+), 54 deletions(-) delete mode 100644 scss/mixins/_screen-reader.scss create mode 100644 scss/mixins/_visually-hidden.scss delete mode 100644 site/content/docs/5.0/helpers/screen-readers.md diff --git a/scss/_mixins.scss b/scss/_mixins.scss index 8c00f31d2..7b06cd819 100644 --- a/scss/_mixins.scss +++ b/scss/_mixins.scss @@ -12,7 +12,7 @@ @import "mixins/breakpoints"; @import "mixins/image"; @import "mixins/resize"; -@import "mixins/screen-reader"; +@import "mixins/visually-hidden"; @import "mixins/reset-text"; @import "mixins/text-truncate"; diff --git a/scss/mixins/_screen-reader.scss b/scss/mixins/_screen-reader.scss deleted file mode 100644 index e5ee63c09..000000000 --- a/scss/mixins/_screen-reader.scss +++ /dev/null @@ -1,28 +0,0 @@ -// stylelint-disable declaration-no-important - -// Only display content to screen readers -// -// See: https://a11yproject.com/posts/how-to-hide-content/ -// See: https://hugogiraudel.com/2016/10/13/css-hide-and-seek/ - -@mixin visually-hidden { - position: absolute !important; - width: 1px !important; - height: 1px !important; - padding: 0 !important; - margin: -1px !important; // Fix for https://github.com/twbs/bootstrap/issues/25686 - overflow: hidden !important; - clip: rect(0, 0, 0, 0) !important; - white-space: nowrap !important; - border: 0 !important; -} - -// Use to only display content when it's focused. -// -// Useful for "Skip to main content" links; see https://www.w3.org/TR/2013/NOTE-WCAG20-TECHS-20130905/G1 - -@mixin visually-hidden-focusable { - &:not(:focus) { - @include visually-hidden(); - } -} diff --git a/scss/mixins/_visually-hidden.scss b/scss/mixins/_visually-hidden.scss new file mode 100644 index 000000000..26edfe84b --- /dev/null +++ b/scss/mixins/_visually-hidden.scss @@ -0,0 +1,28 @@ +// stylelint-disable declaration-no-important + +// Hide content visually while keeping it accessible to assistive technologies +// +// See: https://a11yproject.com/posts/how-to-hide-content/ +// See: https://hugogiraudel.com/2016/10/13/css-hide-and-seek/ + +@mixin visually-hidden() { + position: absolute !important; + width: 1px !important; + height: 1px !important; + padding: 0 !important; + margin: -1px !important; // Fix for https://github.com/twbs/bootstrap/issues/25686 + overflow: hidden !important; + clip: rect(0, 0, 0, 0) !important; + white-space: nowrap !important; + border: 0 !important; +} + +// Use to only display content when it's focused. +// +// Useful for "Skip to main content" links; see https://www.w3.org/TR/2013/NOTE-WCAG20-TECHS-20130905/G1 + +@mixin visually-hidden-focusable() { + &:not(:focus) { + @include visually-hidden(); + } +} diff --git a/site/content/docs/5.0/helpers/screen-readers.md b/site/content/docs/5.0/helpers/screen-readers.md deleted file mode 100644 index fd9ca8887..000000000 --- a/site/content/docs/5.0/helpers/screen-readers.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -layout: docs -title: Screen readers -description: Use screen reader utilities to hide elements on all devices except screen readers. -group: helpers ---- - -Hide an element to all devices **except screen readers** with `.visually-hidden`. Use `.visually-hidden-focusable` to show the element only when it's focused (e.g. by a keyboard-only user). Can also be used as mixins. - -{{< example >}} -

Title for screen readers

-Skip to main content -{{< /example >}} - -{{< highlight scss >}} -// Usage as a mixin - -.visually-hidden-title { - @include visually-hidden; -} - -.skip-navigation { - @include visually-hidden-focusable; -} -{{< /highlight >}} -- cgit v1.2.3