aboutsummaryrefslogtreecommitdiff
path: root/scss/_custom-forms.scss
diff options
context:
space:
mode:
Diffstat (limited to 'scss/_custom-forms.scss')
-rw-r--r--scss/_custom-forms.scss105
1 files changed, 52 insertions, 53 deletions
diff --git a/scss/_custom-forms.scss b/scss/_custom-forms.scss
index c752a9f11..e66638ba3 100644
--- a/scss/_custom-forms.scss
+++ b/scss/_custom-forms.scss
@@ -9,9 +9,13 @@
.custom-control {
position: relative;
- display: inline-flex;
+ display: block;
min-height: (1rem * $line-height-base);
padding-left: $custom-control-gutter;
+}
+
+.custom-control-inline {
+ display: inline-flex;
margin-right: $custom-control-spacer-x;
}
@@ -20,51 +24,61 @@
z-index: -1; // Put the input behind the label so it doesn't overlay text
opacity: 0;
- &:checked ~ .custom-control-indicator {
+ &:checked ~ .custom-control-label::before {
color: $custom-control-indicator-checked-color;
@include gradient-bg($custom-control-indicator-checked-bg);
@include box-shadow($custom-control-indicator-checked-box-shadow);
}
- &:focus ~ .custom-control-indicator {
+ &:focus ~ .custom-control-label::before {
// the mixin is not used here to make sure there is feedback
box-shadow: $custom-control-indicator-focus-box-shadow;
}
- &:active ~ .custom-control-indicator {
+ &:active ~ .custom-control-label::before {
color: $custom-control-indicator-active-color;
background-color: $custom-control-indicator-active-bg;
@include box-shadow($custom-control-indicator-active-box-shadow);
}
&:disabled {
- ~ .custom-control-indicator {
- background-color: $custom-control-indicator-disabled-bg;
- }
+ ~ .custom-control-label {
+ color: $custom-control-label-disabled-color;
- ~ .custom-control-description {
- color: $custom-control-description-disabled-color;
+ &::before {
+ background-color: $custom-control-indicator-disabled-bg;
+ }
}
}
}
-// Custom indicator
+// Custom control indicators
//
-// Generates a shadow element to create our makeshift checkbox/radio background.
+// Build the custom controls out of psuedo-elements.
-.custom-control-indicator {
- position: absolute;
- top: (($line-height-base - $custom-control-indicator-size) / 2);
- left: 0;
- display: block;
- width: $custom-control-indicator-size;
- height: $custom-control-indicator-size;
- pointer-events: none;
- user-select: none;
- background-color: $custom-control-indicator-bg;
- @include box-shadow($custom-control-indicator-box-shadow);
+.custom-control-label {
+ margin-bottom: 0;
+ // Background-color and (when enabled) gradient
&::before {
+ position: absolute;
+ top: (($line-height-base - $custom-control-indicator-size) / 2);
+ left: 0;
+ display: block;
+ width: $custom-control-indicator-size;
+ height: $custom-control-indicator-size;
+ pointer-events: none;
+ content: "";
+ user-select: none;
+ background-color: $custom-control-indicator-bg;
+ @include box-shadow($custom-control-indicator-box-shadow);
+ }
+
+ // Foreground (icon)
+ &::after {
+ position: absolute;
+ top: (($line-height-base - $custom-control-indicator-size) / 2);
+ left: 0;
display: block;
width: $custom-control-indicator-size;
height: $custom-control-indicator-size;
@@ -75,28 +89,31 @@
}
}
+
// Checkboxes
//
// Tweak just a few things for checkboxes.
.custom-checkbox {
- .custom-control-indicator {
+ .custom-control-label::before {
@include border-radius($custom-checkbox-indicator-border-radius);
}
- .custom-control-input:checked ~ .custom-control-indicator {
- @include gradient-bg($custom-control-indicator-checked-bg);
-
+ .custom-control-input:checked ~ .custom-control-label {
&::before {
+ @include gradient-bg($custom-control-indicator-checked-bg);
+ }
+ &::after {
background-image: $custom-checkbox-indicator-icon-checked;
}
}
- .custom-control-input:indeterminate ~ .custom-control-indicator {
- @include gradient-bg($custom-checkbox-indicator-indeterminate-bg);
- @include box-shadow($custom-checkbox-indicator-indeterminate-box-shadow);
-
+ .custom-control-input:indeterminate ~ .custom-control-label {
&::before {
+ @include gradient-bg($custom-checkbox-indicator-indeterminate-bg);
+ @include box-shadow($custom-checkbox-indicator-indeterminate-box-shadow);
+ }
+ &::after {
background-image: $custom-checkbox-indicator-icon-indeterminate;
}
}
@@ -107,34 +124,16 @@
// Tweak just a few things for radios.
.custom-radio {
- .custom-control-indicator {
+ .custom-control-label::before {
border-radius: $custom-radio-indicator-border-radius;
}
- .custom-control-input:checked ~ .custom-control-indicator {
- @include gradient-bg($custom-control-indicator-checked-bg);
-
+ .custom-control-input:checked ~ .custom-control-label {
&::before {
- background-image: $custom-radio-indicator-icon-checked;
+ @include gradient-bg($custom-control-indicator-checked-bg);
}
- }
-}
-
-
-// Layout options
-//
-// By default radios and checkboxes are `inline-block` with no additional spacing
-// set. Use these optional classes to tweak the layout.
-
-.custom-controls-stacked {
- display: flex;
- flex-direction: column;
-
- .custom-control {
- margin-bottom: $custom-control-spacer-y;
-
- + .custom-control {
- margin-left: 0;
+ &::after {
+ background-image: $custom-radio-indicator-icon-checked;
}
}
}