Skip to content

Commit c32f389

Browse files
committed
feat: create control-item-standalone and -indicator to mutualise it for radio button
1 parent 4f60aca commit c32f389

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
@@ -32,17 +32,7 @@
3232
//
3333

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

4737
&[type="checkbox"] {
4838
mask: escape-svg($ouds-checkbox-unselected-icon);
@@ -57,40 +47,16 @@
5747
}
5848

5949
&:indeterminate {
60-
background-color: $ouds-color-action-selected;
61-
6250
&[type="checkbox"] {
6351
mask: escape-svg($ouds-checkbox-indeterminate-icon);
6452
}
6553
}
6654

6755
&:checked {
68-
background-color: $ouds-color-action-selected;
69-
7056
&[type="checkbox"] {
7157
mask: escape-svg($ouds-checkbox-selected-icon);
7258
}
7359
}
74-
75-
&:hover {
76-
background-color: $ouds-color-action-hover;
77-
}
78-
79-
&:focus-visible {
80-
background-color: $ouds-color-action-focus;
81-
}
82-
83-
&:active {
84-
background-color: $ouds-color-action-pressed;
85-
}
86-
87-
// Use disabled attribute in addition of :disabled pseudo-class
88-
// See: https://github.com/twbs/bootstrap/issues/28247
89-
&[disabled],
90-
&:disabled {
91-
pointer-events: none;
92-
background-color: $ouds-color-action-disabled;
93-
}
9460
}
9561

9662
//
@@ -110,12 +76,7 @@
11076
//
11177

11278
.checkbox-standalone {
113-
@extend .checkbox-item;
114-
@extend .checkbox-label;
115-
display: inline-flex;
116-
gap: 0;
117-
align-items: center;
118-
justify-content: center;
79+
@extend %control-item-standalone;
11980
min-width: $ouds-checkbox-size-min-width;
12081
min-height: $ouds-checkbox-size-min-height;
12182
}

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)