// Embedded icons from Open Iconic. // Released under MIT and copyright 2014 Waybury. // https://useiconic.com/open // Checkboxes and radios // // Base class takes care of all the key behavioral aspects. .custom-control { position: relative; z-index: 1; display: block; min-width: 30px; min-height: 16px; line-height: 21px; padding-left: 23px; padding-right: 0; margin-right: 10px; print-color-adjust: exact; // Keep themed appearance for print // Mod Glossary .simplesearchform & { margin: 10px 16px; } } .custom-control--xs { .custom-control-label { font-size: 0.688rem; line-height: 2; color: $body-color-light; .theme-dark & { color: $dm-body-color-light; } } } .custom-control-inline { display: inline-flex; margin-right: $custom-control-spacer-x; input[type="radio"] { margin: 0; } } .custom-control-input { position: absolute; left: 0; z-index: -1; // Put the input behind the label so it doesn't overlay text width: $custom-control-indicator-size; height: ($font-size-base * $line-height-base + $custom-control-indicator-size) * 0.5; opacity: 0; &.custom-control-input--xs { width: 25px; height: 16px; } &:checked ~ .custom-control-label::before { color: $custom-control-indicator-checked-color; border-color: $custom-control-indicator-checked-color; background-color: rgba($custom-control-indicator-checked-color, .3); @include box-shadow($custom-control-indicator-checked-box-shadow); } &:focus ~ .custom-control-label::before { // the mixin is not used here to make sure there is feedback @if $enable-shadows { box-shadow: $input-box-shadow, $custom-control-indicator-focus-box-shadow; } @else { box-shadow: $custom-control-indicator-focus-box-shadow; } } &:focus:not(:checked) ~ .custom-control-label::before { border-color: $custom-control-indicator-focus-border-color; } &:not(:disabled):active ~ .custom-control-label::before { color: $custom-control-indicator-active-color; background-color: $custom-control-indicator-active-bg; border-color: $custom-control-indicator-active-border-color; @include box-shadow($custom-control-indicator-active-box-shadow); } // Use [disabled] and :disabled to work around https://github.com/twbs/bootstrap/issues/28247 &[disabled], &:disabled { ~ .custom-control-label { color: $custom-control-label-disabled-color; .theme-dark & { color: $dm-custom-control-label-disabled-color; } &::before { background-color: $custom-control-indicator-disabled-bg; border-color: $custom-control-indicator-disabled-bg; .theme-dark & { background-color: $dm-custom-control-indicator-disabled-bg; border-color: $dm-custom-control-indicator-disabled-bg; } } } } } // Custom control indicators // // Build the custom controls out of pseudo-elements. .custom-control-label { position: relative; margin-bottom: 0; max-width: 280px; color: $custom-control-label-color; vertical-align: top; cursor: $custom-control-cursor; font-size: $font-size-sm; // Background-color and (when enabled) gradient &::before { position: absolute; top: 0; left: -30px; display: block; width: $custom-control-indicator-size; height: $custom-control-indicator-size; pointer-events: none; content: ""; background-color: transparent; border: $custom-control-indicator-border-color solid $custom-control-indicator-border-width; @include box-shadow($custom-control-indicator-box-shadow); .theme-dark & { border-color: $dm-custom-control-indicator-border-color; } } // Foreground (icon) &::after { position: absolute; top: 0; left: -30px; display: block; width: $custom-control-indicator-size; height: $custom-control-indicator-size; content: ""; background: 50% / #{$custom-control-indicator-bg-size} no-repeat; } } .custom-switch.custom-control--xs .custom-control-label::after { width: 8px; height: 8px; top: 7px; left: -28px; } .custom-switch.custom-control--xs .custom-control-label::before { width: 22px; height: 16px; top: 3px; left: -32px; } .custom-switch .custom-control-input.custom-control-input--xs:checked ~ .custom-control-label::after { transform: translateX(6px); } .dir-rtl .custom-switch .custom-control-input.custom-control-input--xs:checked~.custom-control-label::after { transform: translateX(-6px); } .custom-switch.custom-control--xs { padding-left: 37px; } // Checkboxes // // Tweak just a few things for checkboxes. .custom-checkbox { .custom-control-label::before { @include border-radius($custom-checkbox-indicator-border-radius); } .custom-control-input:checked ~ .custom-control-label { &::after { background-image: escape-svg($custom-checkbox-indicator-icon-checked); } } .custom-control-input:indeterminate ~ .custom-control-label { &::before { border-color: $custom-checkbox-indicator-indeterminate-border-color; @include gradient-bg($custom-checkbox-indicator-indeterminate-bg); @include box-shadow($custom-checkbox-indicator-indeterminate-box-shadow); } &::after { background-image: escape-svg($custom-checkbox-indicator-icon-indeterminate); } } .custom-control-input:disabled { &:checked ~ .custom-control-label::before { @include gradient-bg($custom-control-indicator-checked-disabled-bg); .theme-dark & { @include gradient-bg($dm-custom-control-indicator-checked-disabled-bg!important); } } &:indeterminate ~ .custom-control-label::before { @include gradient-bg($custom-control-indicator-checked-disabled-bg); .theme-dark & { @include gradient-bg($dm-custom-control-indicator-checked-disabled-bg!important); } } } } // Radios // // Tweak just a few things for radios. .custom-radio { margin: 5px 0; .custom-control-label::before { // stylelint-disable-next-line property-disallowed-list border-radius: $custom-radio-indicator-border-radius; } .custom-control-input:checked ~ .custom-control-label { &::after { background-image: escape-svg($custom-radio-indicator-icon-checked); } } .custom-control-input:disabled { &:checked ~ .custom-control-label::before { @include gradient-bg($custom-control-indicator-checked-disabled-bg); .theme-dark & { @include gradient-bg($dm-custom-control-indicator-checked-disabled-bg); } } } } // switches // // Tweak a few things for switches .custom-switch { padding-left: $custom-switch-width + $custom-control-gutter; .custom-control-input { width: 35px; height: 20px; } .custom-control-label { &::before { left: -($custom-switch-width + $custom-control-gutter); width: $custom-switch-width; pointer-events: all; // stylelint-disable-next-line property-disallowed-list border-radius: $custom-switch-indicator-border-radius; } &::after { top: calc(0.125rem + 2px); left: add(-($custom-switch-width + $custom-control-gutter), $custom-control-indicator-border-width * 2); width: $custom-switch-indicator-size; height: $custom-switch-indicator-size; background-color: $custom-control-indicator-border-color; // stylelint-disable-next-line property-disallowed-list border-radius: $custom-switch-indicator-border-radius; @include transition(transform .15s ease-in-out, $custom-forms-transition); } } .custom-control-input:checked ~ .custom-control-label { &::after { background-color: $custom-control-indicator-bg; transform: translateX($custom-switch-width - $custom-control-indicator-size); #admin-closecustomalert &, #admin-hideforgotpassword &, #admin-hidecourseindexnav &, #admin-turnoffdashboardlink &, #admin-hidedetails &, [id^="admin-turnoffsidebar"] & { background-color: #f81212; } } &::before { background-color: $custom-control-indicator-checked-color; #admin-closecustomalert &, #admin-hideforgotpassword &, #admin-hidecourseindexnav &, #admin-turnoffdashboardlink &, #admin-hidedetails &, [id^="admin-turnoffsidebar"] & { background-color: #ffb7b7; border-color: #ffb7b7; } } } .custom-control-input:disabled { &:checked ~ .custom-control-label::before { @include gradient-bg($custom-control-indicator-checked-disabled-bg); .theme-dark & { @include gradient-bg($dm-custom-control-indicator-checked-disabled-bg); } } } } // Select // // Replaces the browser default select with a custom one, mostly pulled from // https://primer.github.io/. // .custom-select, select.quickgrade { display: inline-block; width: 100%; max-width: 220px; height: $custom-select-height; padding: $custom-select-padding-y ($custom-select-padding-x + $custom-select-indicator-padding) $custom-select-padding-y $custom-select-padding-x; font-family: $custom-select-font-family; @include font-size($custom-select-font-size); font-weight: $custom-select-font-weight; line-height: $custom-select-line-height; color: $custom-select-color; vertical-align: middle; background: $custom-select-bg $custom-select-background; border: $custom-select-border-width solid $custom-select-border-color; @include border-radius($custom-select-border-radius, 0); @include box-shadow($custom-select-box-shadow); appearance: none; .theme-dark & { color: $dm-custom-select-color; background: $dm-custom-select-bg $dm-custom-select-background; border-color: $dm-custom-select-border-color; } &:focus { border-color: $custom-select-focus-border-color; outline: 0; @if $enable-shadows { @include box-shadow($custom-select-box-shadow, $custom-select-focus-box-shadow); } @else { // Avoid using mixin so we can pass custom focus shadow properly box-shadow: $custom-select-focus-box-shadow; } &::-ms-value { // For visual consistency with other platforms/browsers, // suppress the default white text on blue background highlight given to // the selected option text when the (still closed)