Skip to content

Commit

Permalink
fix(HCM): update Firefox HCM focus styles (#7314)
Browse files Browse the repository at this point in the history
* fix(HCM): update Firefox HCM focus styles

* chore(code-snippet): remove extra comment

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
tw15egan and kodiakhq[bot] authored Nov 20, 2020
1 parent 12294f9 commit ab61506
Show file tree
Hide file tree
Showing 17 changed files with 128 additions and 53 deletions.
24 changes: 24 additions & 0 deletions packages/components/src/components/code-snippet/_code-snippet.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
&:focus {
border: 2px solid $focus;
outline: none;

// Firefox HCM fix
@media screen and (prefers-contrast) {
border-style: dotted;
}
}

&::before {
Expand Down Expand Up @@ -118,6 +123,12 @@
max-width: rem(760px);
height: $carbon--spacing-08;
padding-right: $carbon--spacing-08;

// Windows, Firefox HCM Fix
@media screen and (-ms-high-contrast: active),
screen and (prefers-contrast) {
outline: 2px solid transparent;
}
}

.#{$prefix}--snippet--single.#{$prefix}--snippet--no-copy {
Expand Down Expand Up @@ -156,6 +167,12 @@
min-width: rem(320px);
max-width: 100%;
padding: $carbon--spacing-05;

// Windows, Firefox HCM Fix
@media screen and (-ms-high-contrast: active),
screen and (prefers-contrast) {
outline: 2px solid transparent;
}
}

//closed snippet container
Expand Down Expand Up @@ -222,6 +239,13 @@
height: rem(16px);
transition: all $duration--fast-01 motion(standard, productive);
fill: $icon-01;

// Windows, Firefox HCM Fix
@media screen and (-ms-high-contrast: active),
screen and (prefers-contrast) {
// `ButtonText` is a CSS2 system color to help improve colors in HCM
fill: ButtonText;
}
}

.#{$prefix}--snippet-button {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@

.#{$prefix}--table-expand__button:focus .#{$prefix}--table-expand__svg {
box-shadow: inset 0 0 0 2px $focus;

// Windows, Firefox HCM Fix
@media screen and (-ms-high-contrast: active),
screen and (prefers-contrast) {
outline: 2px solid transparent;
}
}

.#{$prefix}--table-expand__svg {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@
transform: translateY(-50%);
cursor: pointer;
fill: $icon-01;

// Windows, Firefox HCM Fix
@media screen and (-ms-high-contrast: active),
screen and (prefers-contrast) {
// `ButtonText` is a CSS2 system color to help improve colors in HCM
fill: ButtonText;
}
}

.#{$prefix}--date-picker__icon ~ .#{$prefix}--date-picker__input {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@
white-space: nowrap;
text-overflow: ellipsis;
}

// Windows, Firefox HCM Fix
@media screen and (-ms-high-contrast: active),
screen and (prefers-contrast) {
outline: 2px solid transparent;
}
}

.#{$prefix}--file__selected-file--field {
Expand Down Expand Up @@ -278,6 +284,13 @@

.#{$prefix}--file__state-container .#{$prefix}--file-close svg path {
fill: $icon-01;

// Windows, Firefox HCM Fix
@media screen and (-ms-high-contrast: active),
screen and (prefers-contrast) {
// `ButtonText` is a CSS2 system color to help improve colors in HCM
fill: ButtonText;
}
}

.#{$prefix}--file__state-container .#{$prefix}--inline-loading__animation {
Expand Down
7 changes: 3 additions & 4 deletions packages/components/src/components/list-box/_list-box.scss
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,9 @@ $list-box-menu-width: rem(300px);
.#{$prefix}--list-box__field:focus {
@include focus-outline('outline');

@media screen and (-ms-high-contrast: active),
screen and (prefers-contrast) {
// `ButtonText` is a CSS2 system color to help improve colors in HCM
border: 2px solid ButtonText;
// Firefox HCM fix
@media screen and (prefers-contrast) {
border-style: dotted;
}
}

Expand Down
13 changes: 13 additions & 0 deletions packages/components/src/components/modal/_modal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,14 @@
}
}

.#{$prefix}--modal-footer button.#{$prefix}--btn:focus {
// Firefox HCM Fix
@media screen and (prefers-contrast) {
border: none;
outline-style: dotted;
}
}

.#{$prefix}--modal-close {
position: absolute;
top: 0;
Expand All @@ -342,6 +350,11 @@
&:focus {
border-color: $focus;
outline: none;

// Firefox HCM Fix
@media screen and (prefers-contrast) {
border-style: dotted;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@
outline: 2px solid $inverse-focus-ui;
outline-offset: -2px;
box-shadow: none;

// Firefox HCM Fix
@media screen and (prefers-contrast) {
border-style: dotted;
outline-style: dotted;
}
}

.#{$prefix}--inline-notification--low-contrast
Expand Down Expand Up @@ -264,6 +270,11 @@
&:focus {
outline: 2px solid $inverse-focus-ui;
outline-offset: -2px;

// Firefox HCM fix
@media screen and (prefers-contrast) {
outline-style: dotted;
}
}

.#{$prefix}--inline-notification__close-icon {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@
&:focus {
outline: 2px solid $inverse-focus-ui;
outline-offset: -2px;

// Firefox HCM fix
@media screen and (prefers-contrast) {
outline-style: dotted;
}
}

.#{$prefix}--toast-notification__close-icon {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@

&:focus {
@include focus-outline('outline');

// Windows, Firefox HCM Fix
@media screen and (-ms-high-contrast: active),
screen and (prefers-contrast) {
outline: 3px solid transparent;
outline-offset: -3px;
}
}

&:hover {
Expand Down Expand Up @@ -274,13 +267,6 @@

&:focus {
@include focus-outline('outline');

// Windows, Firefox HCM Fix
@media screen and (-ms-high-contrast: active),
screen and (prefers-contrast) {
outline: 3px solid transparent;
outline-offset: -3px;
}
}

&::-moz-focus-inner {
Expand Down
7 changes: 0 additions & 7 deletions packages/components/src/components/select/_select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,6 @@
@include focus-outline('outline');

color: $text-01;

// Windows, Firefox HCM Fix
@media screen and (-ms-high-contrast: active),
screen and (prefers-contrast) {
outline: 3px solid transparent;
outline-offset: -3px;
}
}

&:disabled,
Expand Down
5 changes: 5 additions & 0 deletions packages/components/src/components/slider/_slider.scss
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@
box-shadow: inset 0 0 0 2px $interactive-04, inset 0 0 0 3px $ui-01;
// 20px / 14px = 1.4286
transform: translate(-50%, -50%) scale(1.4286);

// Firefox HCM Fix
@media screen and (prefers-contrast) {
outline-style: dotted;
}
}

&:active {
Expand Down
7 changes: 7 additions & 0 deletions packages/components/src/components/tag/_tag.scss
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@
border-radius: 50%;
outline: none;
box-shadow: inset 0 0 0 2px $focus;

// Windows, Firefox HCM Fix
@media screen and (-ms-high-contrast: active),
screen and (prefers-contrast) {
// `ButtonText` is a CSS2 system color to help improve colors in HCM
outline: 1px solid ButtonText;
}
}

.#{$prefix}--tag--high-contrast .#{$prefix}--tag__close-icon:focus {
Expand Down
7 changes: 0 additions & 7 deletions packages/components/src/components/tile/_tile.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@

&:focus {
@include focus-outline('outline');

// Windows, Firefox HCM Fix
@media screen and (-ms-high-contrast: active),
screen and (prefers-contrast) {
outline: 3px solid transparent;
outline-offset: -3px;
}
}
}

Expand Down
7 changes: 7 additions & 0 deletions packages/components/src/components/toggle/_toggle.scss
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,13 @@
+ .#{$prefix}--toggle-input__label
> .#{$prefix}--toggle__switch::before {
box-shadow: 0 0 0 1px $ui-02, 0 0 0 3px $focus;

// Windows, Firefox HCM Fix
@media screen and (-ms-high-contrast: active),
screen and (prefers-contrast) {
// `ButtonText` is a CSS2 system color to help improve colors in HCM
outline: 1px solid ButtonText;
}
}

//----------------------------------------------
Expand Down
18 changes: 11 additions & 7 deletions packages/components/src/components/ui-shell/_header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,9 @@
border-color: $shell-header-focus;
outline: none;

// Windows, Firefox HCM Fix
@media screen and (-ms-high-contrast: active),
screen and (prefers-contrast) {
outline: 3px solid transparent;
outline-offset: -3px;
// Firefox HCM Fix
@media screen and (prefers-contrast) {
border-style: dotted;
}
}

Expand Down Expand Up @@ -125,6 +123,13 @@

a.#{$prefix}--header__name:focus {
border-color: $shell-header-focus;

// Windows, Firefox HCM Fix
@media screen and (-ms-high-contrast: active),
screen and (prefers-contrast) {
// `ButtonText` is a CSS2 system color to help improve colors in HCM
border-style: dotted;
}
}

.#{$prefix}--header__name--prefix {
Expand Down Expand Up @@ -216,8 +221,7 @@
// Windows, Firefox HCM Fix
@media screen and (-ms-high-contrast: active),
screen and (prefers-contrast) {
outline: 3px solid transparent;
outline-offset: -3px;
border-style: dotted;
}
}

Expand Down
14 changes: 0 additions & 14 deletions packages/components/src/components/ui-shell/_side-nav.scss
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,6 @@

.#{$prefix}--side-nav__submenu:focus {
@include focus-outline('outline');

// Windows, Firefox HCM Fix
@media screen and (-ms-high-contrast: active),
screen and (prefers-contrast) {
outline: 3px solid transparent;
outline-offset: -3px;
}
}

.#{$prefix}--side-nav__submenu-title {
Expand Down Expand Up @@ -515,13 +508,6 @@
a.#{$prefix}--side-nav__link:focus,
.#{$prefix}--side-nav a.#{$prefix}--header__menu-item:focus {
@include focus-outline('outline');

// Windows, Firefox HCM Fix
@media screen and (-ms-high-contrast: active),
screen and (prefers-contrast) {
outline: 3px solid transparent;
outline-offset: -3px;
}
}

a.#{$prefix}--side-nav__link[aria-current='page'],
Expand Down
16 changes: 16 additions & 0 deletions packages/components/src/globals/scss/_helper-mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
@mixin focus-outline($type: 'border') {
@if ($type == 'border') {
outline: 1px solid $focus;

@media screen and (prefers-contrast) {
outline-style: dotted;
}
}

@if ($type == 'blurred') {
Expand All @@ -76,16 +80,28 @@
@if ($type == 'outline') {
outline: 2px solid $focus;
outline-offset: -2px;

@media screen and (prefers-contrast) {
outline-style: dotted;
}
}

@if ($type == 'outline-compat') {
box-sizing: border-box;
border: 2px solid $focus;

@media screen and (prefers-contrast) {
border-style: dotted;
}
}

@if ($type == 'invalid') {
outline: 2px solid $support-01;
outline-offset: -2px;

@media screen and (prefers-contrast) {
outline-style: dotted;
}
}

@if ($type == 'reset') {
Expand Down

0 comments on commit ab61506

Please sign in to comment.