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 23, 2023
1 parent 1cf6560 commit db284f5
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
6 changes: 6 additions & 0 deletions 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;
}
}
16 changes: 16 additions & 0 deletions src/govuk/helpers/_focused.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,19 @@
// 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;
box-shadow:
0 0 0 4px $govuk-focus-colour,
0 0 0 8px $govuk-focus-text-colour;
}
22 changes: 22 additions & 0 deletions 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 db284f5

Please sign in to comment.