Skip to content

Commit

Permalink
feat(components): added mixin for focus outline style
Browse files Browse the repository at this point in the history
  • Loading branch information
splashdust committed Mar 8, 2019
1 parent 5eb2715 commit 69add01
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,11 @@
transform: rotate(#{$rotation + "deg"});
transition: transform 250ms;
}

/// Add focus outline to element
///
/// @access public
@mixin vanilla-focus-outline() {
box-shadow: 0px 0px 0px 3px rgba($vanilla-color-component-selected, 0.2);
transition: box-shadow 250ms;
}
2 changes: 2 additions & 0 deletions src/components/buttons/_button-mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
@import "../../functions";
@import "../../utilities";
@import "../../icons";
@import "../../mixins";

/// The left and right padding in buttons
$vanilla-button-padding: vanilla-px-to-em(16) !default;
Expand Down Expand Up @@ -57,6 +58,7 @@ $_button_disabled-color-light: $vanilla-color-component-disabled-light;
background-color: $_button_color-bg-focus;
border-color: $_button_color-bg-focus;
text-decoration: none;
@include vanilla-focus-outline();
}
&:active {
background-color: $_button_color-bg-pressed;
Expand Down
7 changes: 4 additions & 3 deletions src/components/inputs/_input-mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
}
&:focus {
border-color: $vanilla-color-component-selected;
@include vanilla-focus-outline();
}
&:active {
border-color: $_border-color-normal;
Expand Down Expand Up @@ -200,7 +201,7 @@
}
input:focus + label:before {
border-color: $vanilla-color-component-selected;
box-shadow: 0 0 0 vanilla-px-to-em(3px) rgba($vanilla-color-component-selected, 0.2);
@include vanilla-focus-outline();
}

input[disabled] {
Expand Down Expand Up @@ -378,7 +379,7 @@
input:focus + label,
input:focus + &__label,
&__label--focus {
box-shadow: 0px 0px 0px 3px rgba($vanilla-color-component-selected, 0.2);
@include vanilla-focus-outline();
}

&--expanded,
Expand Down Expand Up @@ -433,7 +434,7 @@

input:focus + label,
.-focus &__label {
box-shadow: 0px 0px 0px 3px rgba($vanilla-color-component-selected, 0.2);
@include vanilla-focus-outline();
}

input:disabled + label,
Expand Down

0 comments on commit 69add01

Please sign in to comment.