Skip to content

Commit e24586c

Browse files
committed
Rewrite custom form check backgrounds
Previously, this was all just a background-color and background-image. When we restored the gradients though, we had two background-images competing on the same element, causing rendering glitches. This refactors that code, creating a mixin to simplify things, so we can we easily use two background-images (SVG icon and gradient) when -gradients is set to true. Fixes #24598
1 parent b42a38b commit e24586c

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

scss/_custom-forms.scss

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
&:active ~ .custom-control-indicator {
3535
color: $custom-control-indicator-active-color;
36-
@include gradient-bg($custom-control-indicator-active-bg);
36+
background-color: $custom-control-indicator-active-bg;
3737
@include box-shadow($custom-control-indicator-active-box-shadow);
3838
}
3939

@@ -78,12 +78,11 @@
7878
}
7979

8080
.custom-control-input:checked ~ .custom-control-indicator {
81-
background-image: $custom-checkbox-indicator-icon-checked;
81+
@include custom-check-bg($custom-control-indicator-checked-bg, $custom-checkbox-indicator-icon-checked);
8282
}
8383

8484
.custom-control-input:indeterminate ~ .custom-control-indicator {
85-
background-color: $custom-checkbox-indicator-indeterminate-bg;
86-
background-image: $custom-checkbox-indicator-icon-indeterminate;
85+
@include custom-check-bg($custom-checkbox-indicator-indeterminate-bg, $custom-checkbox-indicator-icon-indeterminate);
8786
@include box-shadow($custom-checkbox-indicator-indeterminate-box-shadow);
8887
}
8988
}
@@ -98,7 +97,7 @@
9897
}
9998

10099
.custom-control-input:checked ~ .custom-control-indicator {
101-
background-image: $custom-radio-indicator-icon-checked;
100+
@include custom-check-bg($custom-control-indicator-checked-bg, $custom-radio-indicator-icon-checked);
102101
}
103102
}
104103

scss/_variables.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ $yiq-text-light: $white !default;
9898

9999
$enable-caret: true !default;
100100
$enable-rounded: true !default;
101-
$enable-shadows: false !default;
102-
$enable-gradients: false !default;
101+
$enable-shadows: true !default;
102+
$enable-gradients: true !default;
103103
$enable-transitions: true !default;
104104
$enable-hover-media-query: false !default;
105105
$enable-grid-classes: true !default;

scss/mixins/_forms.scss

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,21 @@
114114
}
115115
}
116116
}
117+
118+
// Custom check backgrounds
119+
//
120+
// We use this for multiple form checks (radio and checkbox) and multiple states
121+
// (checked and active).
122+
123+
@mixin custom-check-bg($bg-color, $bg-image) {
124+
background-color: $bg-color;
125+
126+
@if $enable-gradients {
127+
background-image: $bg-image, linear-gradient(180deg, mix($body-bg, $bg-color, 15%), $bg-color);
128+
background-repeat: no-repeat, repeat-x;
129+
background-position: center center;
130+
background-size: $custom-control-indicator-bg-size, 100% 100%;
131+
} @else {
132+
background-image: $bg-image;
133+
}
134+
}

0 commit comments

Comments
 (0)