Skip to content
This repository is currently being migrated. It's locked while the migration is in progress.

Commit 3a6a902

Browse files
authored
Update focus styles (#822)
* Add new gold color & use it in base focus-outline * Update mixin name * Remove apparently unused mixin * Update focus outline of .menu-item-container This doesn't seem like a class that's used anymore * Update outline focus color of "Skip to Content" Not sure if this is a change that we will keep * Switch to box-shadow approach * Remove offset argument * Bump major version * Tweak link focus styles We're sticking with the double box-shadow for links in the header & footer, but going with the outline approach for links in the main content area due to the possibility of wrapping
1 parent e3a3b02 commit 3a6a902

6 files changed

Lines changed: 29 additions & 19 deletions

File tree

packages/formation/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@department-of-veterans-affairs/formation",
3-
"version": "7.0.1",
3+
"version": "8.0.0",
44
"description": "The VA design system",
55
"keywords": [
66
"va",

packages/formation/sass/base/_b-mixins.scss

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,13 @@
8787
}
8888
}
8989

90-
@mixin focus-gold-light-outline($offset: 2) {
91-
outline: $focus-outline;
92-
outline-offset: #{$offset}px;
93-
}
94-
95-
@mixin focus-gold-lighter-highlight {
96-
background: $color-gold-lighter;
97-
outline: 2px solid $color-gold-lighter;
98-
outline-offset: 0;
90+
@mixin focus-gold-vivid-outline {
91+
box-shadow: 0 0 0 3px $color-white, 0 0 4px 6px $color-gold-50v;
92+
outline: none;
9993
}
10094

10195
@mixin focus {
102-
@include focus-gold-light-outline;
96+
@include focus-gold-vivid-outline;
10397
}
10498

10599
@mixin color-transition {
@@ -153,8 +147,7 @@
153147
background: $color-link-default-hover;
154148
}
155149
&:focus {
156-
@include focus-gold-light-outline;
157-
outline-offset: 0;
150+
@include focus-gold-vivid-outline;
158151
}
159152
&:disabled {
160153
text-decoration: none;

packages/formation/sass/base/_b-variables.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,17 @@ $color-green-light: #4aa564;
8383
$color-gold-lightest: #fff1d2;
8484
$color-gold-lighter: #fad980;
8585
$color-gold-light: #f9c642;
86+
$color-gold-50v: #936F38; // This is something that's not in USWDS 1.6
8687

8788
$color-visited: $color-purple;
8889
$color-focus: #3e94cf;
8990

90-
$focus-outline: 2px solid $color-gold-light;
91+
// The focus outline is only used for anchor links in the main body
92+
// See this article for details:
93+
// https://adhoc.team/2022/02/08/creating-focus-style-for-themable-design-system/
94+
// A double `box-shadow` is used for other focus styling, including
95+
// links in the header & footer since they are unlikely to wrap
96+
$focus-outline: 2px solid $color-gold-50v;
9197

9298
$color-cool-blue: #205493;
9399
$color-cool-blue-light: #4773aa;

packages/formation/sass/base/_va.scss

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ body {
3535
&:focus {
3636
position: inherit;
3737
top: auto;
38-
outline: 2px solid $color-gold;
38+
@include focus-gold-vivid-outline;
3939
}
4040
}
4141

@@ -97,6 +97,18 @@ a {
9797
}
9898
}
9999

100+
// Use outline focus styling for links in the main content area
101+
// since box-shadow styling doesn't look good on wrapped links
102+
main [href],
103+
va-banner [href] {
104+
&:focus {
105+
outline: $focus-outline;
106+
background: $color-white;
107+
color: $color-link-default;
108+
box-shadow: unset;
109+
}
110+
}
111+
100112
// ====== Headings
101113

102114
// H1 should only be used once at the top-level, so we can safely remove the margin-top.

packages/formation/sass/modules/_m-form-process.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@
214214
}
215215

216216
.schemaform-array-row-title:focus {
217-
@include focus-gold-light-outline;
217+
@include focus-gold-vivid-outline;
218218
display: inline-block;
219219
}
220220

packages/formation/sass/modules/_m-nav-sidebar.scss

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,7 @@ $level-3-hover-padding: 8px 12px 8px 30px;
206206
}
207207

208208
&:focus {
209-
outline: 2px solid $color-gold;
210-
outline-offset: 3px;
209+
@include focus-gold-vivid-outline;
211210
}
212211
}
213212

@@ -286,7 +285,7 @@ $level-3-hover-padding: 8px 12px 8px 30px;
286285
font-size: 15px;
287286

288287
&:focus {
289-
@include focus-gold-light-outline(0);
288+
@include focus-gold-vivid-outline;
290289
}
291290

292291
&:hover, &:focus {

0 commit comments

Comments
 (0)