-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for multiple skip links in header #189
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
$important: true; | ||
|
||
// This is basically a copy of the Design System govuk-visually-hidden-focusable mixin | ||
// except it targets the :focus-within pseudo selector rather than :focus | ||
@mixin visually-hidden-focus-withinable { | ||
position: absolute if($important, !important, null); | ||
|
||
width: 1px if($important, !important, null); | ||
height: 1px if($important, !important, null); | ||
// If margin is set to a negative value it can cause text to be announced in | ||
// the wrong order in VoiceOver for OSX | ||
margin: 0 if($important, !important, null); | ||
|
||
overflow: hidden if($important, !important, null); | ||
clip: rect(0 0 0 0) if($important, !important, null); | ||
clip-path: inset(50%) if($important, !important, null); | ||
|
||
// For long content, line feeds are not interpreted as spaces and small width | ||
// causes content to wrap 1 word per line: | ||
// https://medium.com/@jessebeach/beware-smushed-off-screen-accessible-text-5952a4c2cbfe | ||
white-space: nowrap if($important, !important, null); | ||
|
||
&:focus-within:active, | ||
&:focus-within { | ||
position: static if($important, !important, null); | ||
|
||
width: auto if($important, !important, null); | ||
height: auto if($important, !important, null); | ||
margin: inherit if($important, !important, null); | ||
|
||
overflow: visible if($important, !important, null); | ||
clip: auto if($important, !important, null); | ||
clip-path: none if($important, !important, null); | ||
|
||
white-space: inherit if($important, !important, null); | ||
} | ||
} | ||
|
||
// The :focus parts of @mixin govuk-visually-hidden-focusable and .govuk-skip-link | ||
@mixin clear-visually-hidden-focusable { | ||
position: static if($important, !important, null); | ||
|
||
width: auto if($important, !important, null); | ||
height: auto if($important, !important, null); | ||
margin: inherit if($important, !important, null); | ||
|
||
overflow: visible if($important, !important, null); | ||
clip: auto if($important, !important, null); | ||
clip-path: none if($important, !important, null); | ||
|
||
white-space: inherit if($important, !important, null); | ||
} | ||
|
||
// Selecting :focus-within and :not(:focus-within) together should mean this rule only | ||
// applies to browsers that support the :focus-within pseudo property. | ||
// Using this instead of @supports as it doens’t support pseudo properties well yet. | ||
// Many of the styles within are from the .govuk-skip-link class | ||
.app-skip-link--container:focus-within, .app-skip-link--container:not(:focus-within) { | ||
@include visually-hidden-focus-withinable; | ||
display: block; | ||
padding: govuk-spacing(2) govuk-spacing(3); | ||
|
||
// Respect 'display cutout' safe area (avoids notches and rounded corners) | ||
@supports (padding: unquote("max(calc(0px))")) { | ||
$padding-safe-area-right: calc(#{govuk-spacing(3)} + env(safe-area-inset-right)); | ||
$padding-safe-area-left: calc(#{govuk-spacing(3)} + env(safe-area-inset-left)); | ||
|
||
// Use max() to pick largest padding, default or with safe area | ||
// Escaped due to Sass max() vs. CSS native max() | ||
padding-right: unquote("max(#{govuk-spacing(3)}, #{$padding-safe-area-right})"); | ||
padding-left: unquote("max(#{govuk-spacing(3)}, #{$padding-safe-area-left})"); | ||
} | ||
|
||
// Override default .govuk-skip-link styles | ||
.govuk-skip-link { | ||
display: inline-block; | ||
padding: 0; | ||
outline: $govuk-focus-width solid $govuk-focus-colour; | ||
outline-offset: 0; | ||
background-color: $govuk-focus-colour; | ||
@include clear-visually-hidden-focusable; // Override design system styles | ||
|
||
&:focus { | ||
@include govuk-focused-text; // Thick black underline on focus | ||
} | ||
} | ||
|
||
.app-skip-link--item { | ||
padding: govuk-spacing(1); | ||
} | ||
} | ||
|
||
// Same styling as .govuk-skip-link | ||
.app-skip-link--container:focus-within { | ||
outline: $govuk-focus-width solid $govuk-focus-colour; | ||
outline-offset: 0; | ||
background-color: $govuk-focus-colour; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not related to your code but I find a bunch of the design system css so hard to read. 🧐