Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use focus design token on radios, checkboxes, selects #827

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test/scss/fixtures/
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ yarn format:mdx

## Testing

After adding or changing anything that affects the final output CSS, you’ll need to update the fixtures. These record the expected state of the CSS output by the entire library in its default state, and when some configuration is being overidden.
After adding or changing anything that affects the final output CSS, you’ll need to update the fixtures. These record the expected state of the CSS output by the entire library in its default state, and when some configuration is being overridden.

Run the build & comparison:

Expand Down
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
23 changes: 23 additions & 0 deletions test/scss/fixtures/bitstyles-overrides.css
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,11 @@ img {
color: var(--bscpn-color-brand-1);
outline: none;
}
[type='checkbox']:focus-visible {
outline: var(--bscpn-color-brand-2) solid
calc(var(--bscpn-size-s7) + var(--bscpn-size-s7) / 2);
outline-offset: var(--bscpn-size-s7);
}
[type='checkbox']:after {
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='20' height='20' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='%23fff' d='M83.07 11.71 38.66 56.3 16.93 34.49 1 50.48l37.65 37.81L99 27.7z'/%3E%3C/svg%3E");
background-position: 50% 50%;
Expand All @@ -478,12 +483,15 @@ img {
display: block;
height: 100%;
opacity: 0;
outline-offset: 0;
transform: scale(0.7);
transition: opacity calc(var(--bscpn-transition-default-duration) / 2)
var(--bscpn-transition-default-duration)
var(--bscpn-transition-default-easing),
transform calc(var(--bscpn-transition-default-duration) / 2)
var(--bscpn-transition-default-duration)
var(--bscpn-transition-default-easing),
outline-offset var(--bscpn-transition-default-duration)
var(--bscpn-transition-default-easing);
width: 100%;
}
Expand Down Expand Up @@ -551,6 +559,11 @@ img {
color: var(--bscpn-color-brand-1);
outline: none;
}
[type='radio']:focus-visible {
outline: var(--bscpn-color-brand-2) solid
calc(var(--bscpn-size-s7) + var(--bscpn-size-s7) / 2);
outline-offset: var(--bscpn-size-s7);
}
[type='radio']:checked {
background-color: var(--bscpn-color-grayscale-white);
border-color: var(--bscpn-color-brand-1);
Expand Down Expand Up @@ -582,6 +595,8 @@ textarea {
background-color var(--bscpn-transition-default-duration)
var(--bscpn-transition-default-easing),
border var(--bscpn-transition-default-duration)
var(--bscpn-transition-default-easing),
outline-offset var(--bscpn-transition-default-duration)
var(--bscpn-transition-default-easing);
}
input::-moz-placeholder,
Expand Down Expand Up @@ -767,6 +782,7 @@ textarea:disabled {
cursor: pointer;
display: block;
font: inherit;
outline-offset: 0;
overflow: hidden;
padding: var(--bscpn-size-s5) calc(var(--bscpn-size-s1) * 2)
var(--bscpn-size-s5) var(--bscpn-size-s1);
Expand All @@ -776,6 +792,8 @@ textarea:disabled {
background-color var(--bscpn-transition-default-duration)
var(--bscpn-transition-default-easing),
border var(--bscpn-transition-default-duration)
var(--bscpn-transition-default-easing),
outline-offset var(--bscpn-transition-default-duration)
var(--bscpn-transition-default-easing);
width: 100%;
}
Expand All @@ -796,6 +814,11 @@ textarea:disabled {
color: var(--bscpn-color-grayscale-dark-1);
outline: none;
}
select:focus-visible {
outline: var(--bscpn-color-brand-2) solid
calc(var(--bscpn-size-s7) + var(--bscpn-size-s7) / 2);
outline-offset: var(--bscpn-size-s7);
}
select:invalid {
background-color: var(--bscpn-color-grayscale-white);
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='20' height='20' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath fill='var(--bscpn-color-warning)' d='M6.64 34.23a5.57 5.57 0 0 1 7.87-7.89l35.41 35.57 35.57-35.57a5.57 5.57 0 0 1 7.87 7.89L53.94 73.66a5.58 5.58 0 0 1-7.88 0Z'/%3E%3C/svg%3E");
Expand Down
25 changes: 24 additions & 1 deletion test/scss/fixtures/bitstyles.css
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,11 @@ img {
color: var(--bs-color-brand-1);
outline: none;
}
[type='checkbox']:focus-visible {
outline: var(--bs-color-brand-2) solid
calc(var(--bs-size-s7) + var(--bs-size-s7) / 2);
outline-offset: var(--bs-size-s7);
}
[type='checkbox']:after {
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='20' height='20' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='%23fff' d='M83.07 11.71 38.66 56.3 16.93 34.49 1 50.48l37.65 37.81L99 27.7z'/%3E%3C/svg%3E");
background-position: 50% 50%;
Expand All @@ -725,12 +730,15 @@ img {
display: block;
height: 100%;
opacity: 0;
outline-offset: 0;
transform: scale(0.7);
transition: opacity calc(var(--bs-transition-default-duration) / 2)
var(--bs-transition-default-duration)
var(--bs-transition-default-easing),
transform calc(var(--bs-transition-default-duration) / 2)
var(--bs-transition-default-duration)
var(--bs-transition-default-easing),
outline-offset var(--bs-transition-default-duration)
var(--bs-transition-default-easing);
width: 100%;
}
Expand Down Expand Up @@ -798,6 +806,11 @@ img {
color: var(--bs-color-brand-1);
outline: none;
}
[type='radio']:focus-visible {
outline: var(--bs-color-brand-2) solid
calc(var(--bs-size-s7) + var(--bs-size-s7) / 2);
outline-offset: var(--bs-size-s7);
}
[type='radio']:checked {
background-color: var(--bs-color-grayscale-white);
border-color: var(--bs-color-brand-1);
Expand Down Expand Up @@ -825,10 +838,12 @@ input,
textarea {
resize: vertical;
transition: color var(--bs-transition-default-duration)
var(--bs-transition-default-easing),
var(--bs-transition-default-easing),
angelikatyborska marked this conversation as resolved.
Show resolved Hide resolved
background-color var(--bs-transition-default-duration)
var(--bs-transition-default-easing),
border var(--bs-transition-default-duration)
var(--bs-transition-default-easing),
outline-offset var(--bs-transition-default-duration)
var(--bs-transition-default-easing);
}
input::-moz-placeholder,
Expand Down Expand Up @@ -1011,6 +1026,7 @@ textarea:disabled {
cursor: pointer;
display: block;
font: inherit;
outline-offset: 0;
overflow: hidden;
padding: var(--bs-size-s5) calc(var(--bs-size-s1) * 2) var(--bs-size-s5)
var(--bs-size-s1);
Expand All @@ -1020,6 +1036,8 @@ textarea:disabled {
background-color var(--bs-transition-default-duration)
var(--bs-transition-default-easing),
border var(--bs-transition-default-duration)
var(--bs-transition-default-easing),
outline-offset var(--bs-transition-default-duration)
var(--bs-transition-default-easing);
width: 100%;
}
Expand All @@ -1040,6 +1058,11 @@ textarea:disabled {
color: var(--bs-color-grayscale-dark-1);
outline: none;
}
select:focus-visible {
outline: var(--bs-color-brand-2) solid
calc(var(--bs-size-s7) + var(--bs-size-s7) / 2);
outline-offset: var(--bs-size-s7);
}
select:invalid {
background-color: var(--bs-color-grayscale-white);
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='20' height='20' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath fill='var(--bs-color-warning)' d='M6.64 34.23a5.57 5.57 0 0 1 7.87-7.89l35.41 35.57 35.57-35.57a5.57 5.57 0 0 1 7.87 7.89L53.94 73.66a5.58 5.58 0 0 1-7.88 0Z'/%3E%3C/svg%3E");
Expand Down
Loading