diff --git a/app/pages/examples.njk b/app/pages/examples.njk index c8093d5c1..9c689dc47 100644 --- a/app/pages/examples.njk +++ b/app/pages/examples.njk @@ -127,6 +127,12 @@
  • Warning callout
  • Warning callout with custom heading
  • + +

    Styles

    + + {% endblock %} {% block footer %} @@ -156,4 +162,4 @@ ] })}} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/app/styles/typography.njk b/app/styles/typography.njk new file mode 100644 index 000000000..4ba5535a1 --- /dev/null +++ b/app/styles/typography.njk @@ -0,0 +1,83 @@ +{% set title = 'Typography' %} + +{% extends 'page.njk' %} + +{% block header %} + {{ super() }} +{% endblock %} + +{% block breadcrumb %} + {{ breadcrumb({ + items: [ + { + href: "../../", + text: "NHS.UK frontend" + }, + { + href: "../pages/examples.html", + text: "Examples" + } + ] + }) }} +{% endblock %} + +{% block content %} + +

    Typography

    + + +

    Visually-hidden text

    + +

    Heading with visually hidden text at the beginning

    + +

    Countries starting with A

    + +

    Heading with visually hidden text at the end

    + +

    Search all content

    + +

    Heading that is visually hidden

    + +

    Navigation menu

    + +
    + +

    Paragraph that contains visually hidden text

    + +

    This is a paragraph with some visually hidden text.

    + +
    + +

    Table with visually hidden text

    + + + + + + + + + + + + + + + + + + + + + + +
    2019
    + Date + + Day + + Name +
    19 AprilFridayGood Friday
    22 AprilMondayEaster Monday
    + + +{% endblock %} diff --git a/packages/core/tools/_mixins.scss b/packages/core/tools/_mixins.scss index 6febbbde5..fe77ddca0 100644 --- a/packages/core/tools/_mixins.scss +++ b/packages/core/tools/_mixins.scss @@ -38,6 +38,20 @@ // @mixin visually-hidden() { + position: absolute; + + // Absolute positioning has the unintended consequence of removing any + // whitespace surrounding visually hidden text from the accessibility tree. + // Insert a space character before and after visually hidden text to separate + // it from any visible text surrounding it. + &::before { + content: "\00a0"; + } + + &::after { + content: "\00a0"; + } + border: 0; clip: rect(0 0 0 0); -webkit-clip-path: inset(50%); @@ -46,7 +60,6 @@ margin: 0; overflow: hidden; padding: 0; - position: absolute; white-space: nowrap; width: 1px; }