-
Notifications
You must be signed in to change notification settings - Fork 319
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
[Spike] Option 1: Replace existing mixins with new focus styles #1354
Changes from all commits
dcab584
4f924cc
40060d5
63ab9e9
67da8d9
272722f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,11 @@ | |
@include govuk-focusable; | ||
|
||
border: $govuk-border-width solid $govuk-error-colour; | ||
|
||
&:focus { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some components we have to override the new focusable state |
||
// Remove `box-shadow` inherited from `:focus`. | ||
box-shadow: none; | ||
} | ||
} | ||
|
||
.govuk-error-summary__title { | ||
|
@@ -38,7 +43,7 @@ | |
} | ||
|
||
.govuk-error-summary__list a { | ||
@include govuk-focusable-text-link; | ||
@include govuk-focusable-fill; | ||
@include govuk-typography-weight-bold; | ||
|
||
// Override default link styling to use error colour | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,7 +76,7 @@ | |
text-decoration: underline; | ||
} | ||
|
||
@include govuk-focusable-text-link; | ||
@include govuk-focusable-fill; | ||
|
||
// When focussed, the text colour needs to be darker to ensure that colour | ||
// contrast is still acceptable | ||
|
@@ -176,7 +176,7 @@ | |
margin-left: govuk-spacing(1); | ||
} | ||
|
||
@include govuk-focusable; | ||
@include govuk-focusable-fill; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #1346 |
||
|
||
@include mq ($from: tablet) { | ||
top: govuk-spacing(3); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ | |
.govuk-skip-link { | ||
@include govuk-visually-hidden-focusable; | ||
@include govuk-typography-common; | ||
@include govuk-focusable-fill; | ||
@include govuk-link-style-text; | ||
@include govuk-typography-responsive($size: 16); | ||
|
||
|
@@ -23,5 +22,11 @@ | |
padding-right: unquote("max(#{govuk-spacing(3)}, #{$padding-safe-area-right})"); | ||
padding-left: unquote("max(#{govuk-spacing(3)}, #{$padding-safe-area-left})"); | ||
} | ||
|
||
&:focus { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Skip link is different enough we remove the mixin entirely... |
||
outline: $govuk-focus-width solid $govuk-focus-colour; | ||
outline-offset: 0; | ||
background-color: $govuk-focus-colour; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,10 +10,18 @@ | |
/// | ||
/// @access public | ||
|
||
$govuk-focus-width-inner: 2px; | ||
|
||
@mixin govuk-focusable { | ||
&:focus { | ||
outline: $govuk-focus-width solid $govuk-focus-colour; | ||
outline-offset: 0; | ||
box-shadow: inset 0 0 0 $govuk-focus-width-inner $govuk-text-colour; | ||
|
||
@include govuk-if-ie8 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This feels too specific to the input components, and would likely break anything else. Perhaps IE8 could use user-agent styles instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Radios and checkboxes set the width for their styles so it'd be a bit weird to not do it on inputs. |
||
// IE8 doesn't support `box-shadow` so add an actual border | ||
border: $govuk-focus-width-inner solid $govuk-text-colour; | ||
} | ||
} | ||
} | ||
|
||
|
@@ -27,13 +35,11 @@ | |
|
||
@mixin govuk-focusable-fill { | ||
&:focus { | ||
outline: $govuk-focus-width solid $govuk-focus-colour; | ||
outline-offset: 0; | ||
background-color: $govuk-focus-colour; | ||
@include govuk-focusable-fill-css; | ||
} | ||
} | ||
|
||
@mixin govuk-focusable-text { | ||
@mixin govuk-focusable-fill-css { | ||
// When colours are overridden, for example when users have a dark mode, | ||
// backgrounds and box-shadows disappear, so we need to ensure there's a | ||
// transparent outline which will be set to a visible colour. | ||
|
@@ -55,16 +61,3 @@ | |
// box shadow adds the "underline" | ||
text-decoration: none; | ||
} | ||
|
||
/// Focusable with box-shadow | ||
/// | ||
/// Removes the visible outline and replace with box-shadow and background colour. | ||
/// Used for interactive text-based elements. | ||
/// | ||
/// @access public | ||
|
||
@mixin govuk-focusable-text-link { | ||
&:focus { | ||
@include govuk-focusable-text; | ||
} | ||
} |
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.
The original mixins assume you always want the state on a regular
:focus
but you can see here It is useful to be able to customise when to show the focus.At the moment we'd have to have an additional mixin without the
:focus
selector.You can also see this in the file upload component.