diff --git a/src/components/details/_details.scss b/src/components/details/_details.scss index 02845df47b..44c80ad587 100644 --- a/src/components/details/_details.scss +++ b/src/components/details/_details.scss @@ -42,6 +42,9 @@ // -1px offset fixes gap between background and outline in Firefox outline: ($govuk-focus-width + 1px) solid $govuk-focus-colour; outline-offset: -1px; + // When focussed, the text colour needs to be darker to ensure that colour + // contrast is still acceptable + color: $govuk-focus-text-colour; background: $govuk-focus-colour; } diff --git a/src/components/error-summary/_error-summary.scss b/src/components/error-summary/_error-summary.scss index 0f7fe54b14..81a38abd87 100644 --- a/src/components/error-summary/_error-summary.scss +++ b/src/components/error-summary/_error-summary.scss @@ -49,10 +49,14 @@ &:link, &:visited, &:hover, - &:active, - &:focus { + &:active { color: $govuk-error-colour; - text-decoration: underline; + } + + // When focussed, the text colour needs to be darker to ensure that colour + // contrast is still acceptable + &:focus { + color: $govuk-focus-text-colour; } // alphagov/govuk_template includes a specific a:link:focus selector diff --git a/src/components/footer/_footer.scss b/src/components/footer/_footer.scss index 30de5f5c49..e91801b04c 100644 --- a/src/components/footer/_footer.scss +++ b/src/components/footer/_footer.scss @@ -43,9 +43,10 @@ color: $govuk-footer-link-hover; } - // Use text colour when focussed + // When focussed, the text colour needs to be darker to ensure that colour + // contrast is still acceptable &:focus { - color: $govuk-text-colour; + color: $govuk-focus-text-colour; } // alphagov/govuk_template includes a specific a:link:focus selector diff --git a/src/components/header/_header.scss b/src/components/header/_header.scss index 780d29879b..751e21c70b 100644 --- a/src/components/header/_header.scss +++ b/src/components/header/_header.scss @@ -76,8 +76,10 @@ text-decoration: underline; } + // When focussed, the text colour needs to be darker to ensure that colour + // contrast is still acceptable &:focus { - color: govuk-colour("black"); + color: $govuk-focus-text-colour; } // alphagov/govuk_template includes a specific a:link:focus selector @@ -239,6 +241,12 @@ &:visited { color: $govuk-header-link-active; } + + // When focussed, the text colour needs to be darker to ensure that colour + // contrast is still acceptable + &:focus { + color: $govuk-focus-text-colour; + } } } diff --git a/src/core/_links.scss b/src/core/_links.scss index 8307dc0c96..9adedb5927 100644 --- a/src/core/_links.scss +++ b/src/core/_links.scss @@ -21,20 +21,7 @@ @include govuk-link-style-text; } - // 'No visited state' link mixin - // - // Used in cases where it is not helpful to distinguish between visited and - // non-visited links. - // - // For example, navigation links to pages with dynamic content like admin - // dashboards. The content on the page is changing all the time, so the fact - // that you’ve visited it before is not important. - // - // This is not abstracted as a mixin because it does not provide states for - // all pseudo-selectors so it does not make sense to use it in composition. .govuk-link--no-visited-state { - &:visited { - color: $govuk-link-colour; - } + @include govuk-link-style-no-visited-state; } } diff --git a/src/helpers/_links.scss b/src/helpers/_links.scss index 073b4df0aa..191a298b96 100644 --- a/src/helpers/_links.scss +++ b/src/helpers/_links.scss @@ -44,6 +44,12 @@ &:active { color: $govuk-link-active-colour; } + + // When focussed, the text colour needs to be darker to ensure that colour + // contrast is still acceptable + &:focus { + color: $govuk-focus-text-colour; + } } /// Muted style link mixin @@ -73,7 +79,7 @@ // When focussed, the text colour needs to be darker to ensure that colour // contrast is still acceptable &:focus { - color: $govuk-text-colour; + color: $govuk-focus-text-colour; } // alphagov/govuk_template includes a specific a:link:focus selector designed @@ -122,6 +128,51 @@ } } + +/// No visited state link mixin +/// +/// Used in cases where it is not helpful to distinguish between visited and +/// non-visited links. +/// +/// For example, navigation links to pages with dynamic content like admin +/// dashboards. The content on the page is changing all the time, so the fact +/// that you’ve visited it before is not important. +/// +/// If you use this mixin in a component you must also include the +/// govuk-link-common mixin in order to get the focus state. +/// +/// @example scss +/// .govuk-component__link { +/// @include govuk-link-common; +/// @include govuk-link-style-no-visited-state; +/// } +/// +/// @access public + +@mixin govuk-link-style-no-visited-state { + &:link { + color: $govuk-link-colour; + } + + &:visited { + color: $govuk-link-colour; + } + + &:hover { + color: $govuk-link-hover-colour; + } + + &:active { + color: $govuk-link-active-colour; + } + + // When focussed, the text colour needs to be darker to ensure that colour + // contrast is still acceptable + &:focus { + color: $govuk-focus-text-colour; + } +} + /// Print friendly link mixin /// /// When printing, append the the destination URL to the link text, as long diff --git a/src/settings/_colours-applied.scss b/src/settings/_colours-applied.scss index 59eea79fea..a08c168445 100644 --- a/src/settings/_colours-applied.scss +++ b/src/settings/_colours-applied.scss @@ -68,6 +68,16 @@ $govuk-secondary-text-colour: govuk-colour("grey-1") !default; $govuk-focus-colour: govuk-colour("yellow") !default; +/// Focused text colour +/// +/// Ensure that the contrast between the text and background colour passes +/// WCAG Level AA contrast requirements. +/// +/// @type Colour +/// @access public + +$govuk-focus-text-colour: govuk-colour("black") !default; + /// Error colour /// /// Used to highlight error messages and form controls in an error state