Skip to content

Commit ef2f774

Browse files
committed
feat: add radio button
1 parent 594cdbd commit ef2f774

File tree

4 files changed

+360
-3
lines changed

4 files changed

+360
-3
lines changed

scss/_variables.scss

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@ $form-check-label-cursor: pointer !default; // OUDS mod: instead
10711071
// ouds mod: no `$form-check-input-color`
10721072
// OUDS mod: no `$form-check-input-border`
10731073
$form-check-input-border-radius: $ouds-checkbox-border-radius !default; // OUDS mod: instead of `0`
1074-
// OUDS mod: no `$form-check-radio-border-radius`
1074+
$form-check-radio-border-radius: $ouds-radio-button-border-radius !default; // OUDS mod: instead of `0`
10751075
// OUDS mod: no `$form-check-input-focus-border`
10761076
// OUDS mod: no `$form-check-input-focus-box-shadow`
10771077

@@ -1087,13 +1087,21 @@ $ouds-checkbox-calc-border-width-indeterminate: calc(strip-units($ouds-checkbox-
10871087
$ouds-checkbox-calc-width-indeterminate: calc($ouds-checkbox-calc-viewbox - strip-units($ouds-checkbox-border-width-selected) * $ouds-checkbox-calc-multiplicator) !default; // stylelint-disable-line function-disallowed-list
10881088
$ouds-checkbox-calc-border-width-selected: calc(strip-units($ouds-checkbox-border-width-selected) * $ouds-checkbox-calc-multiplicator) !default; // stylelint-disable-line function-disallowed-list
10891089
$ouds-checkbox-calc-width-selected: calc($ouds-checkbox-calc-viewbox - strip-units($ouds-checkbox-border-width-selected) * $ouds-checkbox-calc-multiplicator) !default; // stylelint-disable-line function-disallowed-list
1090+
1091+
$ouds-radio-button-calc-multiplicator: 2 !default; // Here to avoid float numbers in svg
1092+
$ouds-radio-button-calc-viewbox: calc(strip-units($ouds-radio-button-size-indicator) * $ouds-radio-button-calc-multiplicator) !default; // stylelint-disable-line function-disallowed-list
1093+
$ouds-radio-button-calc-border-radius: calc(strip-units($form-check-radio-border-radius) * $ouds-radio-button-calc-multiplicator) !default; // stylelint-disable-line function-disallowed-list
1094+
$ouds-radio-button-calc-border-width-unselected: calc(strip-units($ouds-radio-button-border-width-unselected) * $ouds-radio-button-calc-multiplicator) !default; // stylelint-disable-line function-disallowed-list
1095+
$ouds-radio-button-calc-width-unselected: calc($ouds-radio-button-calc-viewbox - strip-units($ouds-radio-button-border-width-unselected) * $ouds-radio-button-calc-multiplicator) !default; // stylelint-disable-line function-disallowed-list
1096+
$ouds-radio-button-calc-border-width-selected: calc(strip-units($ouds-radio-button-border-width-selected) * $ouds-radio-button-calc-multiplicator) !default; // stylelint-disable-line function-disallowed-list
1097+
$ouds-radio-button-calc-width-selected: calc($ouds-radio-button-calc-viewbox - strip-units($ouds-radio-button-border-width-selected) * $ouds-radio-button-calc-multiplicator) !default; // stylelint-disable-line function-disallowed-list
10901098
// End mod
10911099

10921100
// OUDS mod: no `$form-check-input-checked-color`
10931101
// OUDS mod: no `$form-check-input-checked-bg-color`
10941102
// OUDS mod: no `$form-check-input-checked-border-color`
10951103
$form-check-input-checked-bg-image: "<svg viewBox='0 0 20 20' width='#{$ouds-checkbox-calc-viewbox}' height='#{$ouds-checkbox-calc-viewbox}' x='0' y='0'><path fill='#000' d='m15.262 7.047-6.034 7a.97.97 0 0 1-.737.328.97.97 0 0 1-.736-.329l-3.017-3.5A.833.833 0 0 1 4.53 10c0-.242.106-.46.276-.619l.378-.35a.978.978 0 0 1 .666-.256c.235 0 .449.08.614.21l1.838 1.89 5.578-5.013a.98.98 0 0 1 .645-.237c.52 0 .943.392.943.875a.833.833 0 0 1-.207.547Z'/></svg>" !default; // OUDS mod: custom SVG
1096-
// OUDS mod: no `$form-check-radio-checked-bg-image`
1104+
$form-check-radio-checked-bg-image: "<svg viewBox='0 0 20 20' width='#{$ouds-radio-button-calc-viewbox}' height='#{$ouds-radio-button-calc-viewbox}' x='0' y='0'><path fill='#000' d='M14.0635 10C14.0635 12.2437 12.2446 14.0625 10.001 14.0625C7.75732 14.0625 5.93848 12.2437 5.93848 10C5.93848 7.75634 7.75732 5.9375 10.001 5.9375C12.2446 5.9375 14.0635 7.75634 14.0635 10Z'/></svg>" !default; // OUDS mod: custom SVG
10971105

10981106
// OUDS mod: no `$form-check-input-indeterminate-color`
10991107
// OUDS mod: no `$form-check-input-indeterminate-bg-color`
@@ -1111,6 +1119,9 @@ $ouds-checkbox-unselected-icon: url("data:image/svg+xml,<svg xmlns='http://www.w
11111119
$ouds-checkbox-unselected-hover-icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 #{$ouds-checkbox-calc-viewbox} #{$ouds-checkbox-calc-viewbox}'><rect x='#{calc($ouds-checkbox-calc-border-width-unselected-hover / 2)}' y='#{calc($ouds-checkbox-calc-border-width-unselected-hover / 2)}' width='#{$ouds-checkbox-calc-width-unselected-hover}' height='#{$ouds-checkbox-calc-width-unselected-hover}' rx='#{$ouds-checkbox-calc-border-radius}' ry='#{$ouds-checkbox-calc-border-radius}' fill='none' stroke='#000' stroke-width='#{$ouds-checkbox-calc-border-width-unselected-hover}'/></svg>") !default;
11121120
$ouds-checkbox-selected-icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 #{$ouds-checkbox-calc-viewbox} #{$ouds-checkbox-calc-viewbox}'><rect x='#{calc($ouds-checkbox-calc-border-width-selected / 2)}' y='#{calc($ouds-checkbox-calc-border-width-selected / 2)}' width='#{$ouds-checkbox-calc-width-selected}' height='#{$ouds-checkbox-calc-width-selected}' rx='#{$ouds-checkbox-calc-border-radius}' ry='#{$ouds-checkbox-calc-border-radius}' fill='none' stroke='#000' stroke-width='#{$ouds-checkbox-calc-border-width-selected}'/>#{$form-check-input-checked-bg-image}</svg>") !default;
11131121
$ouds-checkbox-indeterminate-icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 #{$ouds-checkbox-calc-viewbox} #{$ouds-checkbox-calc-viewbox}'><rect x='#{calc($ouds-checkbox-calc-border-width-indeterminate / 2)}' y='#{calc($ouds-checkbox-calc-border-width-indeterminate / 2)}' width='#{$ouds-checkbox-calc-width-indeterminate}' height='#{$ouds-checkbox-calc-width-indeterminate}' rx='#{$ouds-checkbox-calc-border-radius}' ry='#{$ouds-checkbox-calc-border-radius}' fill='none' stroke='#000' stroke-width='#{$ouds-checkbox-calc-border-width-indeterminate}'/>#{$form-check-input-indeterminate-bg-image}</svg>") !default;
1122+
1123+
$ouds-radio-button-unselected-icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 #{$ouds-radio-button-calc-viewbox} #{$ouds-radio-button-calc-viewbox}'><rect x='#{calc($ouds-radio-button-calc-border-width-unselected / 2)}' y='#{calc($ouds-radio-button-calc-border-width-unselected / 2)}' width='#{$ouds-radio-button-calc-width-unselected}' height='#{$ouds-radio-button-calc-width-unselected}' rx='#{$ouds-radio-button-calc-border-radius}' ry='#{$ouds-radio-button-calc-border-radius}' fill='none' stroke='#000' stroke-width='#{$ouds-radio-button-calc-border-width-unselected}'/></svg>") !default;
1124+
$ouds-radio-button-selected-icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 #{$ouds-radio-button-calc-viewbox} #{$ouds-radio-button-calc-viewbox}'><rect x='#{calc($ouds-radio-button-calc-border-width-selected / 2)}' y='#{calc($ouds-radio-button-calc-border-width-selected / 2)}' width='#{$ouds-radio-button-calc-width-selected}' height='#{$ouds-radio-button-calc-width-selected}' rx='#{$ouds-radio-button-calc-border-radius}' ry='#{$ouds-radio-button-calc-border-radius}' fill='none' stroke='#000' stroke-width='#{$ouds-radio-button-calc-border-width-selected}'/>#{$form-check-radio-checked-bg-image}</svg>") !default;
11141125
// End mod
11151126

11161127
// OUDS mod: Star rating

scss/forms/_control-item.scss

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@
141141
mask: escape-svg($ouds-checkbox-unselected-icon);
142142
}
143143

144+
&[type="radio"] {
145+
mask: escape-svg($ouds-radio-button-unselected-icon);
146+
}
147+
144148
&:hover,
145149
&:focus-visible,
146150
&:active {
@@ -163,6 +167,10 @@
163167
&[type="checkbox"] {
164168
mask: escape-svg($ouds-checkbox-selected-icon);
165169
}
170+
171+
&[type="radio"] {
172+
mask: escape-svg($ouds-radio-button-selected-icon);
173+
}
166174
}
167175

168176
&:hover {
@@ -201,7 +209,6 @@
201209
min-height: $ouds-checkbox-size-min-height;
202210
}
203211

204-
205212
//
206213
// Checkbox
207214
//
@@ -214,6 +221,18 @@
214221
@extend %control-item-standalone;
215222
}
216223

224+
//
225+
// Radio button
226+
//
227+
228+
.radio-button-item {
229+
@extend %control-item;
230+
}
231+
232+
.radio-button-standalone {
233+
@extend %control-item-standalone;
234+
}
235+
217236
//
218237
// Bootstrap compatibility
219238
//

0 commit comments

Comments
 (0)