Skip to content

Commit 13c7d99

Browse files
committed
feat: create control-item-standalone and -indicator to mutualise it for radio button
1 parent e9eb1a4 commit 13c7d99

File tree

2 files changed

+61
-41
lines changed

2 files changed

+61
-41
lines changed

scss/forms/_checkbox.scss

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,7 @@
3636
//
3737

3838
.checkbox-indicator {
39-
flex-shrink: 0;
40-
width: $form-check-input-width;
41-
height: $form-check-input-width;
42-
vertical-align: middle;
43-
appearance: none;
44-
cursor: $form-check-label-cursor;
45-
background-color: $ouds-color-border-emphasized;
46-
mask-repeat: no-repeat;
47-
mask-position: center;
48-
mask-size: $form-check-input-width;
49-
print-color-adjust: exact;
39+
@extend %control-item-indicator;
5040

5141
&[type="checkbox"] {
5242
mask: escape-svg($ouds-checkbox-unselected-icon);
@@ -61,40 +51,16 @@
6151
}
6252

6353
&:indeterminate {
64-
background-color: $ouds-color-action-selected;
65-
6654
&[type="checkbox"] {
6755
mask: escape-svg($ouds-checkbox-indeterminate-icon);
6856
}
6957
}
7058

7159
&:checked {
72-
background-color: $ouds-color-action-selected;
73-
7460
&[type="checkbox"] {
7561
mask: escape-svg($ouds-checkbox-selected-icon);
7662
}
7763
}
78-
79-
&:hover {
80-
background-color: $ouds-color-action-hover;
81-
}
82-
83-
&:focus-visible {
84-
background-color: $ouds-color-action-focus;
85-
}
86-
87-
&:active {
88-
background-color: $ouds-color-action-pressed;
89-
}
90-
91-
// Use disabled attribute in addition of :disabled pseudo-class
92-
// See: https://github.com/twbs/bootstrap/issues/28247
93-
&[disabled],
94-
&:disabled {
95-
pointer-events: none;
96-
background-color: $ouds-color-action-disabled;
97-
}
9864
}
9965

10066
//
@@ -114,12 +80,7 @@
11480
//
11581

11682
.checkbox-standalone {
117-
@extend .checkbox-item;
118-
@extend .checkbox-label;
119-
display: inline-flex;
120-
gap: 0;
121-
align-items: center;
122-
justify-content: center;
83+
@extend %control-item-standalone;
12384
min-width: $ouds-checkbox-size-min-width;
12485
min-height: $ouds-checkbox-size-min-height;
12586
}

scss/forms/_control-item.scss

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,62 @@
119119
color: $ouds-color-content-muted;
120120
@include get-font-size("label-medium");
121121
}
122+
123+
//
124+
// Checkbox & radio indicator
125+
//
126+
127+
%control-item-indicator {
128+
flex-shrink: 0;
129+
width: $form-check-input-width;
130+
height: $form-check-input-width;
131+
vertical-align: middle;
132+
appearance: none;
133+
cursor: $form-check-label-cursor;
134+
background-color: $ouds-color-border-emphasized;
135+
mask-repeat: no-repeat;
136+
mask-position: center;
137+
mask-size: $form-check-input-width;
138+
print-color-adjust: exact;
139+
140+
&:indeterminate {
141+
background-color: $ouds-color-action-selected;
142+
}
143+
144+
&:checked {
145+
background-color: $ouds-color-action-selected;
146+
}
147+
148+
&:hover {
149+
background-color: $ouds-color-action-hover;
150+
}
151+
152+
&:focus-visible {
153+
background-color: $ouds-color-action-focus;
154+
}
155+
156+
&:active {
157+
background-color: $ouds-color-action-pressed;
158+
}
159+
160+
// Use disabled attribute in addition of :disabled pseudo-class
161+
// See: https://github.com/twbs/bootstrap/issues/28247
162+
&[disabled],
163+
&:disabled {
164+
pointer-events: none;
165+
background-color: $ouds-color-action-disabled;
166+
}
167+
}
168+
169+
//
170+
// Control item standalone
171+
//
172+
173+
%control-item-standalone {
174+
@extend %control-item;
175+
@extend .control-item-form-label;
176+
display: inline-flex;
177+
gap: 0;
178+
align-items: center;
179+
justify-content: center;
180+
}

0 commit comments

Comments
 (0)