Skip to content

Commit

Permalink
Use focus design token on radios, checkboxes, selects
Browse files Browse the repository at this point in the history
  • Loading branch information
angelikatyborska committed Aug 19, 2024
1 parent 0b33bd1 commit 42e3988
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
10 changes: 10 additions & 0 deletions scss/bitstyles/base/input-checkbox/_index.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@forward 'settings';
@use './settings';
@use '../../tools/design-token';
@use '../../design-tokens/focus';

[type='checkbox'] {
display: inline-block;
Expand Down Expand Up @@ -31,6 +32,11 @@
color: settings.$color-hover;
}

&:focus-visible {
outline: focus.$outline-color solid focus.$outline-width;
outline-offset: focus.$outline-offset;
}

&::after {
content: '';
display: block;
Expand All @@ -43,8 +49,12 @@
var(design-token.get('transition', 'default', 'easing')),
transform
calc(var(design-token.get('transition', 'default', 'duration')) / 2)
var(design-token.get('transition', 'default', 'duration'))
var(design-token.get('transition', 'default', 'easing')),
outline-offset
var(design-token.get('transition', 'default', 'duration'))
var(design-token.get('transition', 'default', 'easing'));
outline-offset: 0;
opacity: 0;
background-image: settings.$background-image-checked;
background-repeat: no-repeat;
Expand Down
6 changes: 6 additions & 0 deletions scss/bitstyles/base/input-radio/_index.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@forward 'settings';
@use './settings';
@use '../../tools/design-token';
@use '../../design-tokens/focus';

[type='radio'] {
display: inline-block;
Expand Down Expand Up @@ -47,6 +48,11 @@
color: settings.$color-hover;
}

&:focus-visible {
outline: focus.$outline-color solid focus.$outline-width;
outline-offset: focus.$outline-offset;
}

&:checked {
border-color: settings.$border-color-checked;
background-color: settings.$background-color-checked;
Expand Down
3 changes: 3 additions & 0 deletions scss/bitstyles/base/input-text/_index.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@forward 'settings';
@use './settings';
@use '../../tools/design-token';
@use '../../design-tokens/focus';

/* stylelint-disable selector-max-type */
textarea,
Expand All @@ -10,6 +11,8 @@ input {
background-color var(design-token.get('transition', 'default', 'duration'))
var(design-token.get('transition', 'default', 'easing')),
border var(design-token.get('transition', 'default', 'duration'))
var(design-token.get('transition', 'default', 'easing')),
outline-offset var(design-token.get('transition', 'default', 'duration'))
var(design-token.get('transition', 'default', 'easing'));
resize: vertical;

Expand Down
9 changes: 9 additions & 0 deletions scss/bitstyles/base/select/_index.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@forward 'settings';
@use 'settings';
@use '../../tools/design-token';
@use '../../design-tokens/focus';

@supports (-webkit-appearance: none) or (-moz-appearance: none) or
(appearance: none) {
Expand All @@ -17,9 +18,12 @@
var(design-token.get('transition', 'default', 'duration'))
var(design-token.get('transition', 'default', 'easing')),
border var(design-token.get('transition', 'default', 'duration'))
var(design-token.get('transition', 'default', 'easing')),
outline-offset var(design-token.get('transition', 'default', 'duration'))
var(design-token.get('transition', 'default', 'easing'));
border: settings.$border-width solid settings.$border-color;
border-radius: settings.$border-radius;
outline-offset: 0;
background-color: settings.$background-color;
background-image: settings.$background-image;
background-repeat: no-repeat;
Expand Down Expand Up @@ -51,6 +55,11 @@
color: settings.$color-active;
}

&:focus-visible {
outline: focus.$outline-color solid focus.$outline-width;
outline-offset: focus.$outline-offset;
}

&:invalid {
border-color: settings.$border-color-invalid;
background-color: settings.$background-color-invalid;
Expand Down

0 comments on commit 42e3988

Please sign in to comment.