Skip to content

Commit

Permalink
style: convert focus to focus-within (#1985)
Browse files Browse the repository at this point in the history
  • Loading branch information
monicawheeler authored and kajabi-bot committed Oct 2, 2024
1 parent a2ef8c6 commit ae01d8e
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 39 deletions.
4 changes: 2 additions & 2 deletions packages/sage-assets/lib/stylesheets/components/_alert.scss
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ $-alert-border-colors: (
text-decoration: underline;
}

&:focus {
&:focus-visible {
@include sage-focus-outline--update-color(sage-color(purple, 30));
}
}
Expand All @@ -199,7 +199,7 @@ $-alert-border-colors: (
text-decoration: none;
}

&:focus {
&:focus-visible {
@include sage-focus-outline--update-color(sage-color(purple, 30));
}
}
Expand Down
24 changes: 14 additions & 10 deletions packages/sage-assets/lib/stylesheets/components/_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ a.sage-btn {
}
}
@else if ($-style-type-name == focus) {
&:focus,
&:focus-visible,
&:active {
color: map-get($-style-type-configs, color);
background-color: map-get($-style-type-configs, background-color);
Expand Down Expand Up @@ -562,10 +562,10 @@ a.sage-btn {
box-shadow: map-get($sage-toolbar-button-borders, hover);
}

.sage-toolbar > &:focus,
.sage-toolbar > .sage-dropdown .sage-dropdown__trigger &:focus,
.sage-toolbar__group > &:focus,
.sage-toolbar__group > .sage-dropdown .sage-dropdown__trigger &:focus {
.sage-toolbar > &:focus-visible,
.sage-toolbar > .sage-dropdown .sage-dropdown__trigger &:focus-visible,
.sage-toolbar__group > &:focus-visible,
.sage-toolbar__group > .sage-dropdown .sage-dropdown__trigger &:focus-visible {
z-index: sage-z-index(default, 2);
box-shadow: map-get($sage-toolbar-button-borders, focus);
}
Expand All @@ -580,8 +580,8 @@ a.sage-btn {
.sage-toolbar__group > .sage-search ~ &:not(.sage-btn--subtle):not(:disabled):not([aria-disabled="true"]):hover {
box-shadow: map-get($sage-toolbar-button-borders, hover-large);
}
.sage-toolbar__group > .sage-input ~ &:not(.sage-btn--subtle):not(:disabled):not([aria-disabled="true"]):focus,
.sage-toolbar__group > .sage-search ~ &:not(.sage-btn--subtle):not(:disabled):not([aria-disabled="true"]):focus {
.sage-toolbar__group > .sage-input ~ &:not(.sage-btn--subtle):not(:disabled):not([aria-disabled="true"]):focus-visible,
.sage-toolbar__group > .sage-search ~ &:not(.sage-btn--subtle):not(:disabled):not([aria-disabled="true"]):focus-visible {
box-shadow: map-get($sage-toolbar-button-borders, focus);
}
}
Expand All @@ -597,7 +597,11 @@ a.sage-btn {
border-color: sage-color(charcoal, 100);
}

&:focus,
&:focus {
outline: none;
}

&:focus-visible,
&:active {
color: sage-color(charcoal, 300);
background-color: sage-color(white);
Expand Down Expand Up @@ -755,7 +759,7 @@ a.sage-btn {
color: sage-color(white);
}

&:focus {
&:focus-visible {
color: sage-color(white);
}
}
Expand All @@ -765,7 +769,7 @@ a.sage-btn {
&.sage-banner__close.sage-btn--primary {
color: inherit;

&:focus,
&:focus-visible,
&:active {
color: inherit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ $-checkbox-focus-outline-color: sage-color(purple, 30);
background-color: sage-color(grey, 100);
}

&:focus:not(:disabled),
&:focus-visible:not(:disabled),
&:active:not(:disabled) {
outline: none;
border-color: $-checkbox-focus-outline-color;
Expand Down Expand Up @@ -264,7 +264,7 @@ $-checkbox-focus-outline-color: sage-color(purple, 30);
background-color: $-checkbox-color-error;
}

&:focus:not(:disabled),
&:focus-visible:not(:disabled),
&:active:not(:disabled) {
border-color: $-checkbox-color-error;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ $-choice-radio-color-checked-inner: map-get($sage-radio-colors, checked-inner);
color: $-choice-color-active;
}

&:focus {
&:focus-visible {
border-color: sage-color(purple, 30);
outline: none;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ $-dropdown-trigger-dropdown-offset: rem(16px) + sage-spacing(xs);
background-color: sage-color(white);
}

&:focus,
&:focus-visible,
&:focus-within {
z-index: sage-z-index(default, 2);
box-shadow: map-get($sage-toolbar-button-borders, focus);
Expand Down Expand Up @@ -123,6 +123,7 @@ $-dropdown-trigger-dropdown-offset: rem(16px) + sage-spacing(xs);
@extend %t-sage-body;

&:active,
&:focus-visible,
&:focus-within {
outline: none;

Expand Down
26 changes: 13 additions & 13 deletions packages/sage-assets/lib/stylesheets/components/_link.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ $-link-base-styles: (
hover: (
color: sage-color(primary, 400),
),
focus: (
focus-visible: (
color: sage-color(primary, 300),
),
),
Expand All @@ -28,7 +28,7 @@ $-link-base-styles: (
hover: (
color: sage-color(black),
),
focus: (
focus-visible: (
color: sage-color(charcoal, 400),
),
),
Expand All @@ -39,7 +39,7 @@ $-link-base-styles: (
hover: (
color: sage-color(grey, 100),
),
focus: (
focus-visible: (
color: sage-color(white),
),
),
Expand All @@ -50,7 +50,7 @@ $-link-base-styles: (
hover: (
color: sage-color(red, 400),
),
focus: (
focus-visible: (
color: sage-color(red, 300),
focus-outline: sage-color(red, 200),
),
Expand All @@ -74,7 +74,7 @@ $-link-base-styles: (
cursor: pointer;
}

&:focus {
&:focus-visible {
color: sage-color(primary, 300);

@include sage-focus-outline--update-color(sage-color(purple, 30));
Expand All @@ -99,8 +99,8 @@ $-link-base-styles: (
box-shadow: sage-border-interactive(hover);
}

&:focus::before {
box-shadow: sage-border-interactive(focus);
&:focus-visible::before {
box-shadow: sage-border-interactive(focus-visible);
}

&:active::before {
Expand All @@ -111,11 +111,11 @@ $-link-base-styles: (
box-shadow: sage-border-interactive(error);
}

&:focus:invalid::before {
&:focus-visible:invalid::before {
box-shadow: sage-border-interactive(error-focus);
}

&:focus::after {
&:focus-visible::after {
border: 0;
}

Expand All @@ -137,9 +137,9 @@ $-link-base-styles: (
}
/* stylelint-enable max-nesting-depth */
}
@else if ($-style-type-name == focus) {
@else if ($-style-type-name == focus-visible) {
/* stylelint-disable max-nesting-depth */
&:focus,
&:focus-visible,
&:active {
color: map-get($-style-type-configs, color);

Expand Down Expand Up @@ -178,7 +178,7 @@ $-link-base-styles: (

&:hover,
&:active,
&:focus {
&:focus-visible {
color: inherit;
outline: 0;

Expand Down Expand Up @@ -239,7 +239,7 @@ $-link-base-styles: (
text-decoration: underline;
}

&:focus {
&:focus-visible {
color: $-link-subtext-color-hover;
text-decoration: none;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ $-media-tile-breakpoints: (
color: inherit;
}

&:focus {
&:focus-visible {
outline: 0;

&::after {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ $-radio-focus-outline-color: currentColor;
}
}

&:focus:not(:disabled),
&:focus-visible:not(:disabled),
&:active:not(:disabled) {
outline: none;

Expand Down
10 changes: 7 additions & 3 deletions packages/sage-assets/lib/stylesheets/components/_tab.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ $-tab-color-disabled: map-get($sage-tab-colors, disabled);
}

&:focus {
outline: none;
}

&:focus-visible {
@include sage-focus-ring();
border-radius: sage-border(radius-small);

Expand Down Expand Up @@ -95,11 +99,11 @@ $-tab-color-disabled: map-get($sage-tab-colors, disabled);
opacity: 0;
}

&:focus {
&:focus-visible {
border-radius: sage-border(radius-small);
}

&:focus::after,
&:focus-visible::after,
&.sage-tab--active::after {
opacity: 1;
}
Expand All @@ -124,7 +128,7 @@ $-tab-color-disabled: map-get($sage-tab-colors, disabled);
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;

&:focus {
&:focus-visible {
border-radius: sage-border(radius-small);
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/sage-assets/lib/stylesheets/components/_tag.scss
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ $-tag-button-icon-mobile-size: rem(24px);
color: $-tag-button-color;
}

&:focus {
&:focus-visible {
color: $-tag-button-color;
border-color: sage-color(primary, 200);
}
Expand All @@ -73,12 +73,12 @@ $-tag-button-icon-mobile-size: rem(24px);
height: $-tag-button-icon-mobile-size;
}

&:not(:focus):hover {
&:not(:focus-visible):hover {
color: inherit;
background-color: transparent;
}

&:not(:focus):hover::after {
&:not(:focus-visible):hover::after {
background-color: transparent;
}
}
Expand Down
5 changes: 3 additions & 2 deletions packages/sage-assets/lib/stylesheets/core/mixins/_sage.scss
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
$focus-width-inner: 1px,
$focus-width-outter: 3px
) {
&:focus {
&:focus-visible {
z-index: sage-z-index(default, 1);
outline: none;
box-shadow: 0 0 0 $focus-width-inner #fff, 0 0 0 $focus-width-outter $focus-shadow;
Expand All @@ -208,6 +208,7 @@
position: relative;

&:focus,
&:focus-visible,
&:focus-within {
outline: none;
}
Expand All @@ -234,7 +235,7 @@
will-change: transform;
}

&:focus:not(:disabled):not([aria-disabled="true"]),
&:focus-visible:not(:disabled):not([aria-disabled="true"]),
&:active:not(:disabled):not([aria-disabled="true"]) {
&::after {
transform: translate3d(-50%, -50%, 0) scale(1);
Expand Down

0 comments on commit ae01d8e

Please sign in to comment.