Skip to content

Commit

Permalink
feat: rename SCSS mixin fakeFocus to focusRing (#2110)
Browse files Browse the repository at this point in the history
BREAKING CHANGE:

SCSS mixin was renamed from `fakeFocus` to `focusRing` as well as `removeFakeFocus` to `removeFocusRing`.
  • Loading branch information
tujoworker committed May 31, 2023
1 parent b0649d5 commit 47b5e47
Show file tree
Hide file tree
Showing 23 changed files with 42 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ Stopped supporting Internet Explorer (IE), as Microsoft formally ended support f
- Updated multiple types from `string | boolean` to `boolean`, as there was a lot of properties who should only support boolean values and not strings.
Examples of changes to do would be to find Eufemia components using `"false"` or `"true"`, and replace it with boolean values. i.e., `vertical="false"` to `vertical={false}` or `selectall="true"` to `selectall={true}`.

### SCSS

Find the SCSS @mixin `fakeFocus` and replace it with `focusRing`.
Find the SCSS @mixin `removeFakeFocus` and replace it with `removeFocusRing`.

### Deprecations

- Helper class `.dnb-sr-only--inline` and SCSS mixin `srOnlyInline` was removed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,15 @@ You can import Eufemia _mixins_ directly into your SCSS styles:
@include defaultDropShadow();

/** Eufemia Border helpers */
@include fakeFocus(
@include focusRing(
/* $whatinput: 'keyboard', $color: var(--color-emerald-green), $inset: inset */
);
@include extendFocusRing(
/* $first-color: null, $second-color: null, width: 0.0625rem */
);
@include fakeBorder(
/* $color: var(--color-emerald-green), $width: 0.0625rem, $inset: inset */
);
@include extendFakeFocus(
/* $first-color: null, $second-color: null, width: 0.0625rem */
);

/** Scroll behavior */
@include scrollY(/* $mode: scroll */);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
}
&__variant--outlined#{&}--expanded
> &__header:not([disabled]):not(:active):not(:hover):focus {
@include fakeFocus(null, var(--color-emerald-green), inset);
@include focusRing(null, var(--color-emerald-green), inset);
}

&__variant--outlined#{&}--expanded
Expand All @@ -91,7 +91,7 @@

// we have this hover variant, because of the default html focus/hover handling
&__variant--outlined#{&}--expanded > &__header#{&}--hover:not(:active) {
@include hover () {
@include hover() {
color: var(--color-white);
background-color: var(--color-sea-green);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@

&:not([disabled]):focus,
&:not([disabled]):active {
@include fakeFocus();
@include focusRing();
}

html[data-whatinput='mouse'] &:not([disabled]):focus,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
*/
@mixin buttonHoverStyle($color, $background-color, $border-color) {
// NB: to get "over" sibling, because of the extendFakeFocus
// NB: to get "over" sibling, because of the extendFocusRing
// But if we would use it,
// then then we have to take care of places we use position="absolute", like the Modal Close button
// position: relative;
Expand Down Expand Up @@ -58,7 +58,7 @@
background-color: $background-color;
}

@include fakeFocus(null, $focus-color, inset);
@include focusRing(null, $focus-color, inset);

@content;
}
Expand All @@ -80,7 +80,7 @@
height: inherit;
border-radius: inherit;

@include fakeFocus($whatinput);
@include focusRing($whatinput);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
}

@include focus() {
@include removeFakeFocus();
@include removeFocusRing();
@include buttonFocusRing();

// underline
Expand All @@ -142,7 +142,7 @@
}

@include active() {
@include removeFakeFocus();
@include removeFocusRing();

// underline
.dnb-button__text::after {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
&__focus {
display: none;

@include fakeFocus();
@include focusRing();
}

&__focus,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@
margin: 0;

&.dnb-no-focus:focus {
@include fakeFocus();
@include focusRing();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
&__focus {
display: none;

@include fakeFocus();
@include focusRing();
}

&__focus,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
color: var(--color-white);

&::before {
@include fakeFocus(null, var(--color-white));
@include focusRing(null, var(--color-white));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
position: absolute;
inset: #{var(--focus-ring-width)};

@include fakeFocus();
@include focusRing();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
}

&__button-helper:not(:disabled):focus ~ .dnb-button {
@include fakeFocus();
@include focusRing();
}

> .dnb-form-label {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
50% 85%
);

@include fakeFocus();
@include focusRing();
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
}
&__input:not([disabled]):focus ~ &__background,
&__input:not([disabled]):active ~ &__background {
@include fakeFocus();
@include focusRing();
}
&__input:not([disabled]):focus ~ &__button &__focus,
&__input:not([disabled]):active ~ &__button &__focus {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
flex: 0 1 auto;

&:focus {
@include fakeFocus();
@include focusRing();
}

@include scrollX(auto);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

border-radius: 0.5rem;

@include fakeFocus();
@include focusRing();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
}
html[data-whatinput='keyboard']
&:not([disabled]):not(:active):not(:hover):focus {
@include fakeFocus(null, var(--color-emerald-green), inset);
@include focusRing(null, var(--color-emerald-green), inset);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
);

&:focus {
@include fakeFocus();
@include focusRing();
}

&--focusring {
@include fakeFocus('mouse');
@include focusRing('mouse');
}
}

Expand Down Expand Up @@ -206,7 +206,7 @@

&--selected &__item {
.dnb-anchor:focus {
@include fakeFocus(null, var(--color-white));
@include focusRing(null, var(--color-white));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
&:focus {
outline: none;

@include fakeFocus();
@include focusRing();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
outline: none;

&:focus {
@include fakeFocus('keyboard');
@include focusRing('keyboard');
}
}

.dnb-mouse-focus {
outline: none;

&:focus {
@include fakeFocus('mouse');
@include focusRing('mouse');
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

background-color: var(--color-white);

@include fakeFocus('mouse');
@include focusRing('mouse');
}

&:hover::before {
Expand All @@ -65,7 +65,7 @@

// focus
&:focus:not(:active)::before {
@include fakeFocus();
@include focusRing();
}

// focus
Expand Down
6 changes: 3 additions & 3 deletions packages/dnb-eufemia/src/style/core/utilities.scss
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
}
}

@mixin fakeFocus($whatinput: null, $color: null, $inset: null) {
@mixin focusRing($whatinput: null, $color: null, $inset: null) {
outline: none;

@if $whatinput == null {
Expand All @@ -69,7 +69,7 @@
@include fakeBorder($color, var(--focus-ring-width), $inset);
}
}
@mixin removeFakeFocus($whatinput: null) {
@mixin removeFocusRing($whatinput: null) {
outline: initial;
@if $whatinput == null {
$whatinput: 'keyboard';
Expand Down Expand Up @@ -122,7 +122,7 @@
}
}

@mixin extendFakeFocus(
@mixin extendFocusRing(
$first-color: null,
$second-color: null,
$width: 0.0625rem /*1px*/
Expand Down
6 changes: 3 additions & 3 deletions packages/dnb-eufemia/src/style/elements/anchor-mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@
}

@if $whatinput {
@include fakeFocus($whatinput);
@include focusRing($whatinput);
} @else {
@include fakeFocus();
@include focusRing();
}
border-radius: 0.25em;
}
Expand All @@ -138,7 +138,7 @@
color: var(--color-white);
background-color: transparent;

@include fakeFocus(null, var(--color-white));
@include focusRing(null, var(--color-white));
}
}

Expand Down

0 comments on commit 47b5e47

Please sign in to comment.