Skip to content

Commit b19e591

Browse files
committed
- Adds focus styles for all the inputs
- linting
1 parent a9bc8dd commit b19e591

File tree

7 files changed

+109
-61
lines changed

7 files changed

+109
-61
lines changed

scss/bitstyles/base/forms/_index.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ label {
2525
gap: settings.$label-gap;
2626
align-items: baseline;
2727
margin-bottom: settings.$label-gap;
28-
cursor: pointer;
2928
font-weight: settings.$label-font-weight;
29+
cursor: pointer;
3030

31-
&[aria-disabled="true"] {
31+
&[aria-disabled='true'] {
3232
color: settings.$label-disabled-color;
3333
}
3434
}

scss/bitstyles/base/input-checkbox/_index.scss

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,16 @@
55
@use 'sass:math';
66

77
[type='checkbox'] {
8-
display: inline-block;
98
position: relative;
9+
top: calc(settings.$gap / 2);
1010
flex-shrink: 0;
1111
width: 1em;
1212
height: 1em;
1313
margin: settings.$gap;
14+
outline-offset: 0;
1415
font-size: settings.$size;
15-
vertical-align: middle;
1616
cursor: pointer;
1717
appearance: none;
18-
top: calc(settings.$gap / 2);
19-
20-
&:focus-visible {
21-
outline: focus.$outline-color solid focus.$outline-width;
22-
outline-offset: focus.$outline-offset;
23-
}
2418
}
2519

2620
@supports (-webkit-appearance: none) or (-moz-appearance: none) or
@@ -35,12 +29,17 @@
3529
&:hover,
3630
&:focus {
3731
border-color: settings.$border-color-hover;
38-
outline: none;
32+
outline-width: 0;
3933
background-color: settings.$background-color-hover;
4034
box-shadow: settings.$box-shadow-hover;
4135
color: settings.$color-hover;
4236
}
4337

38+
&:focus-visible {
39+
outline: focus.$outline-color solid focus.$outline-width;
40+
outline-offset: focus.$outline-offset;
41+
}
42+
4443
&:active {
4544
border-color: settings.$border-color-active;
4645
background-color: settings.$background-color-active;
@@ -57,7 +56,9 @@
5756
transition: opacity math.div(animation.$transition-duration, 2)
5857
animation.$transition-duration animation.$transition-easing,
5958
transform math.div(animation.$transition-duration, 2)
60-
animation.$transition-duration animation.$transition-easing;
59+
animation.$transition-duration animation.$transition-easing,
60+
outline-offset animation.$transition-duration
61+
animation.$transition-easing;
6162
opacity: 0;
6263
background-image: settings.$background-image-checked;
6364
background-repeat: no-repeat;
@@ -77,21 +78,6 @@
7778
}
7879
}
7980

80-
&:checked:hover,
81-
&:checked:focus {
82-
border-color: settings.$border-color-checked-hover;
83-
background-color: settings.$background-color-checked-hover;
84-
box-shadow: settings.$box-shadow-checked-hover;
85-
color: settings.$color-checked-hover;
86-
}
87-
88-
&:checked:active {
89-
border-color: settings.$border-color-checked-active;
90-
background-color: settings.$background-color-checked-active;
91-
box-shadow: settings.$box-shadow-checked-active;
92-
color: settings.$color-checked-active;
93-
}
94-
9581
&:invalid,
9682
&[aria-invalid='true'] {
9783
border-color: settings.$border-color-invalid;
@@ -113,5 +99,23 @@
11399
color: settings.$color-disabled-checked;
114100
}
115101
}
102+
103+
&:checked:hover:not(:invalid),
104+
&:checked:focus:not(:invalid),
105+
&:checked:hover:not([aria-invalid='true']),
106+
&:checked:focus:not([aria-invalid='true']) {
107+
border-color: settings.$border-color-checked-hover;
108+
background-color: settings.$background-color-checked-hover;
109+
box-shadow: settings.$box-shadow-checked-hover;
110+
color: settings.$color-checked-hover;
111+
}
112+
113+
&:checked:active:not(:invalid),
114+
&:checked:active:not([aria-invalid='true']) {
115+
border-color: settings.$border-color-checked-active;
116+
background-color: settings.$background-color-checked-active;
117+
box-shadow: settings.$box-shadow-checked-active;
118+
color: settings.$color-checked-active;
119+
}
116120
}
117121
}

scss/bitstyles/base/input-checkbox/_settings.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ $box-shadow-disabled: none !default;
8181
//
8282
// Disabled-checked colors ////////////////////////////////////////
8383
$color-disabled-checked: palette.get('grayscale', 'white') !default;
84-
$background-color-disabled-checked: palette.get('grayscale', 'light-1') !default;
84+
$background-color-disabled-checked: palette.get(
85+
'grayscale',
86+
'light-1'
87+
) !default;
8588
$border-color-disabled-checked: palette.get('grayscale', 'light-1') !default;
8689
$box-shadow-disabled-checked: none !default;

scss/bitstyles/base/input-radio/_index.scss

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,15 @@
55

66
[type='radio'] {
77
position: relative;
8+
top: calc(settings.$gap / 2);
89
flex-shrink: 0;
910
width: 1em;
1011
height: 1em;
1112
margin: settings.$gap;
13+
outline-offset: 0;
1214
font-size: settings.$size;
1315
cursor: pointer;
1416
appearance: none;
15-
top: calc(settings.$gap / 2);
16-
17-
&:focus-visible {
18-
outline: focus.$outline-color solid focus.$outline-width;
19-
outline-offset: focus.$outline-offset;
20-
}
2117
}
2218

2319
@supports (-webkit-appearance: none) or (-moz-appearance: none) or
@@ -37,7 +33,9 @@
3733
transform: scale(0.5);
3834
transition: opacity animation.$transition-duration
3935
animation.$transition-easing,
40-
transform animation.$transition-duration animation.$transition-easing;
36+
transform animation.$transition-duration animation.$transition-easing,
37+
outline-offset animation.$transition-duration
38+
animation.$transition-easing;
4139
border-radius: settings.$border-radius;
4240
opacity: 0;
4341
background: settings.$color-checked;
@@ -46,11 +44,17 @@
4644
&:hover,
4745
&:focus {
4846
border-color: settings.$border-color-hover;
47+
outline-width: 0;
4948
background-color: settings.$background-color-hover;
5049
box-shadow: settings.$box-shadow-hover;
5150
color: settings.$color-hover;
5251
}
5352

53+
&:focus-visible {
54+
outline: focus.$outline-color solid focus.$outline-width;
55+
outline-offset: focus.$outline-offset;
56+
}
57+
5458
&:active {
5559
border-color: settings.$border-color-active;
5660
background-color: settings.$background-color-active;
@@ -70,21 +74,6 @@
7074
}
7175
}
7276

73-
&:checked:hover,
74-
&:checked:focus {
75-
border-color: settings.$border-color-checked-hover;
76-
background-color: settings.$background-color-checked-hover;
77-
box-shadow: settings.$box-shadow-checked-hover;
78-
color: settings.$color-checked-hover;
79-
}
80-
81-
&:checked:active {
82-
border-color: settings.$border-color-checked-active;
83-
background-color: settings.$background-color-checked-active;
84-
box-shadow: settings.$box-shadow-checked-active;
85-
color: settings.$color-checked-active;
86-
}
87-
8877
&:invalid,
8978
&[aria-invalid='true'] {
9079
border-color: settings.$border-color-invalid;
@@ -110,5 +99,27 @@
11099
background: settings.$color-disabled-checked;
111100
}
112101
}
102+
103+
&:focus:not(:focus-visible) {
104+
outline-width: 0;
105+
}
106+
107+
&:checked:hover:not(:invalid),
108+
&:checked:focus:not(:invalid),
109+
&:checked:hover:not([aria-invalid='true']),
110+
&:checked:focus:not([aria-invalid='true']) {
111+
border-color: settings.$border-color-checked-hover;
112+
background-color: settings.$background-color-checked-hover;
113+
box-shadow: settings.$box-shadow-checked-hover;
114+
color: settings.$color-checked-hover;
115+
}
116+
117+
&:checked:active:not(:invalid),
118+
&:checked:active:not([aria-invalid='true']) {
119+
border-color: settings.$border-color-checked-active;
120+
background-color: settings.$background-color-checked-active;
121+
box-shadow: settings.$box-shadow-checked-active;
122+
color: settings.$color-checked-active;
123+
}
113124
}
114125
}

scss/bitstyles/base/input-text/_index.scss

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@forward 'settings';
22
@use './settings';
33
@use '../../settings/animation';
4+
@use '../../settings/focus';
45
@use 'sass:math';
56
@use '../../tools/custom-property';
67

@@ -9,7 +10,9 @@ textarea,
910
input {
1011
transition: color animation.$transition-duration animation.$transition-easing,
1112
background-color animation.$transition-duration animation.$transition-easing,
12-
border animation.$transition-duration animation.$transition-easing;
13+
border animation.$transition-duration animation.$transition-easing,
14+
outline-offset animation.$transition-duration animation.$transition-easing;
15+
outline-offset: 0;
1316
resize: vertical;
1417

1518
&::placeholder {
@@ -43,7 +46,7 @@ textarea {
4346
width: 100%;
4447
padding: settings.$padding-vertical settings.$padding-horizontal;
4548
border: settings.$border-width solid settings.$border-color;
46-
border-radius:
49+
border-radius:
4750
var(#{custom-property.get($items: ('input-text', 'border-top-left-radius'))})
4851
var(#{custom-property.get($items: ('input-text', 'border-top-right-radius'))})
4952
var(#{custom-property.get($items: ('input-text', 'border-bottom-right-radius'))})
@@ -53,7 +56,8 @@ textarea {
5356
color: settings.$color;
5457
font: settings.$font;
5558

56-
&:hover {
59+
&:hover,
60+
&:focus {
5761
border-color: settings.$border-color-hover;
5862
background-color: settings.$background-hover;
5963
box-shadow: settings.$box-shadow-hover;
@@ -64,10 +68,14 @@ textarea {
6468
}
6569
}
6670

67-
&:active,
68-
&:focus {
71+
&:focus-visible {
72+
outline: focus.$outline-color solid focus.$outline-width;
73+
outline-offset: focus.$outline-offset;
74+
}
75+
76+
&:active {
6977
border-color: settings.$border-color-active;
70-
outline: none;
78+
outline-width: 0;
7179
background-color: settings.$background-active;
7280
box-shadow: settings.$box-shadow-active;
7381
color: settings.$color-active;
@@ -100,5 +108,9 @@ textarea {
100108
color: settings.$placeholder-color-disabled;
101109
}
102110
}
111+
112+
&:focus:not(:focus-visible) {
113+
outline-width: 0;
114+
}
103115
}
104116
/* stylelint-enable selector-max-type */

scss/bitstyles/base/select/_index.scss

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@forward 'settings';
22
@use 'settings';
33
@use '../../settings/animation';
4+
@use '../../settings/focus';
45
@use '../../settings/typography';
56

67
@supports (-webkit-appearance: none) or (-moz-appearance: none) or
@@ -19,11 +20,13 @@
1920
border animation.$transition-duration animation.$transition-easing;
2021
border: settings.$border-width solid settings.$border-color;
2122
border-radius: settings.$border-radius;
23+
outline-offset: 0;
2224
background-color: settings.$background-color;
2325
background-image: settings.$background-image;
2426
background-repeat: no-repeat;
2527
background-position: right 0.75em top 50%;
2628
background-size: 1em;
29+
box-shadow: settings.$box-shadow;
2730
color: settings.$color;
2831
font-weight: settings.$font-weight;
2932
text-overflow: ellipsis;
@@ -34,19 +37,26 @@
3437
display: none;
3538
}
3639

37-
&:hover {
40+
&:hover,
41+
&:focus {
3842
border-color: settings.$border-color-hover;
3943
background-color: settings.$background-color-hover;
4044
background-image: settings.$background-image-hover;
45+
box-shadow: settings.$box-shadow-hover;
4146
color: settings.$color-hover;
4247
}
4348

44-
&:focus,
49+
&:focus-visible {
50+
outline: focus.$outline-color solid focus.$outline-width;
51+
outline-offset: focus.$outline-offset;
52+
}
53+
4554
&:active {
4655
border-color: settings.$border-color-active;
4756
outline: none;
4857
background-color: settings.$background-color-active;
4958
background-image: settings.$background-image-active;
59+
box-shadow: settings.$box-shadow-active;
5060
color: settings.$color-active;
5161
}
5262

@@ -55,16 +65,22 @@
5565
border-color: settings.$border-color-invalid;
5666
background-color: settings.$background-color-invalid;
5767
background-image: settings.$background-image-invalid;
68+
box-shadow: settings.$box-shadow-invalid;
5869
color: settings.$color-invalid;
5970
}
6071

6172
&[disabled] {
6273
border-color: settings.$border-color-disabled;
6374
background-color: settings.$background-color-disabled;
6475
background-image: settings.$background-image-disabled;
76+
box-shadow: settings.$box-shadow-disabled;
6577
color: settings.$color-disabled;
6678
cursor: default;
6779
}
80+
81+
&:focus:not(:focus-visible) {
82+
outline-width: 0;
83+
}
6884
}
6985
/* stylelint-enable selector-max-type */
7086
}

0 commit comments

Comments
 (0)