Skip to content

Commit 5b791c4

Browse files
committed
fix(FormCheck): change display flex to block
1 parent e46bdc3 commit 5b791c4

File tree

2 files changed

+45
-14
lines changed

2 files changed

+45
-14
lines changed

scss/_variables.scss

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ $input-transition: border-color .15s ease-in-out, box-shado
829829
// scss-docs-start form-check-variables
830830
$form-check-input-width: 1em !default;
831831
$form-check-min-height: $font-size-base * $line-height-base !default;
832-
$form-check-padding-start: .375em !default;
832+
$form-check-padding-start: $form-check-input-width + .5em !default;
833833
$form-check-margin-bottom: .125rem !default;
834834
$form-check-label-color: unset !default;
835835
$form-check-label-cursor: null !default;
@@ -865,7 +865,7 @@ $form-check-inline-margin-end: 1rem !default;
865865
// scss-docs-start form-switch-variables
866866
$form-switch-color: rgba(0, 0, 0, .25) !default;
867867
$form-switch-width: 1.5em !default;
868-
$form-switch-padding-start: .375em !default;
868+
$form-switch-padding-start: $form-switch-width + .5em !default;
869869
$form-switch-bg-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'><circle r='3' fill='#{$form-switch-color}'/></svg>") !default;
870870
$form-switch-border-radius: $form-switch-width !default;
871871
$form-switch-transition: background-position .15s ease-in-out !default;
@@ -878,8 +878,14 @@ $form-switch-checked-bg-image: url("data:image/svg+xml,<svg xmlns='http://www
878878
$form-switch-checked-bg-position: right center !default;
879879

880880
$form-switch-widths: (
881-
lg: 2em,
882-
xl: 2.5em
881+
lg: (
882+
width: 1.75em,
883+
height: 1.25em
884+
),
885+
xl: (
886+
width: 2em,
887+
height: 1.5em
888+
)
883889
) !default;
884890
// scss-docs-end form-switch-variables
885891

scss/forms/_form-check.scss

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,23 @@
33
//
44

55
.form-check {
6-
display: flex;
7-
align-items: center;
6+
display: block;
87
min-height: $form-check-min-height;
8+
@include ltr-rtl("padding-left", $form-check-padding-start);
99
margin-bottom: $form-check-margin-bottom;
1010

1111
.form-check-input {
12-
@include ltr-rtl("margin-right", $form-check-padding-start);
12+
// float: left;
13+
// margin-left: $form-check-padding-start * -1;
14+
@include ltr-rtl("float", left);
15+
@include ltr-rtl("margin-left", $form-check-padding-start * -1);
1316
}
1417
}
1518

1619
.form-check-input {
1720
width: $form-check-input-width;
1821
height: $form-check-input-width;
22+
margin-top: ($line-height-base - $form-check-input-width) / 2; // line-height minus check height
1923
vertical-align: top;
2024
background-color: var(--#{$variable-prefix}form-check-input-bg, $form-check-input-bg);
2125
background-repeat: no-repeat;
@@ -129,23 +133,44 @@
129133
}
130134
}
131135

132-
@each $width, $value in $form-switch-widths {
133-
$height: $value / 3 * 2;
136+
@each $size, $map in $form-switch-widths {
137+
$width: map-get($map, "width");
138+
$height: map-get($map, "height");
134139

135-
.form-switch-#{$width} {
140+
.form-switch-#{$size} {
136141
min-height: $height;
137-
@include ltr-rtl("padding-left", $value + .5em);
142+
@include ltr-rtl("padding-left", $width + .5em);
138143

139144
.form-check-input {
140-
width: $value;
145+
width: $width;
141146
height: $height;
142-
@include ltr-rtl("margin-left", ($value + .5em) * -1);
147+
@include ltr-rtl("margin-left", ($width + .5em) * -1);
148+
}
149+
150+
.form-check-label {
151+
// stylelint-disable-next-line function-disallowed-list
152+
padding-top: calc((#{$height} - #{$font-size-base}) / 2);
143153
}
144154
}
155+
156+
// $height: $value / 3 * 2;
157+
158+
// .form-switch-#{$width} {
159+
// min-height: $height;
160+
// @include ltr-rtl("padding-left", $value + .5em);
161+
162+
// .form-check-input {
163+
// width: $value;
164+
// height: $height;
165+
// @include ltr-rtl("margin-left", ($value + .5em) * -1);
166+
// }
167+
168+
// .form-check-label {}
169+
// }
145170
}
146171

147172
.form-check-inline {
148-
display: inline-flex;
173+
display: inline-block;
149174
@include ltr-rtl("margin-right", $form-check-inline-margin-end);
150175
}
151176

0 commit comments

Comments
 (0)