Skip to content

Commit

Permalink
Add linked image focus style
Browse files Browse the repository at this point in the history
  • Loading branch information
querkmachine committed Jun 19, 2023
1 parent 4ad27b0 commit c83acd5
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions packages/govuk-frontend/src/govuk/core/_links.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,10 @@
.govuk-link--no-visited-state {
@include govuk-link-style-no-visited-state;
}

// Links that only contain images

.govuk-link-image {
@include govuk-link-image;
}
}
17 changes: 17 additions & 0 deletions packages/govuk-frontend/src/govuk/helpers/_focused.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,20 @@
// box-shadow is applied to each fragment independently.
box-decoration-break: clone;
}

/// Focused box
///
/// Provides an outline to clearly indicate when the target element is focused.
/// Unlike govuk-focused-text, which only draws an underline below the element,
/// govuk-focused-box draws an outline around all sides of the element.
/// Best used for non-text content contained within links.
///
/// @access public

@mixin govuk-focused-box {
outline: $govuk-focus-width solid transparent;
background-color: $govuk-focus-colour;
box-shadow:
0 0 0 4px $govuk-focus-colour,
0 0 0 8px $govuk-focus-text-colour;
}
22 changes: 22 additions & 0 deletions packages/govuk-frontend/src/govuk/helpers/_links.scss
Original file line number Diff line number Diff line change
Expand Up @@ -362,3 +362,25 @@
}
}
}

/// Image link styles
///
/// Prepares and provides the focus state for links that only contain images
/// with no accompanying text.
///
/// @access public

@mixin govuk-link-image {
// Needed to draw the focus around the entire image
display: inline-block;

// Remove extra space at the bottom of the image that's added by line-height
line-height: 0;

// Don't render an underline
text-decoration: none;

&:focus {
@include govuk-focused-box;
}
}

0 comments on commit c83acd5

Please sign in to comment.