1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-30 00:29:52 +02:00

Improve gradients

- Use a semitransparent gradient from light to dark which works on any background-color
- Store the gradient as a custom property (--bs-gradient)
- Remove `.bg-gradient-*` variants in favour of `.bg-gradient` which works even when `$enable-gradients` are enabled
- Add gradients to navbar, active page links and badges when gradients are enabled
This commit is contained in:
Martijn Cuppens
2020-04-14 17:28:20 +03:00
committed by XhmikosR
parent bbeda10e37
commit b531bda07c
16 changed files with 29 additions and 30 deletions

View File

@@ -14,6 +14,7 @@
white-space: nowrap;
vertical-align: baseline;
@include border-radius($badge-border-radius);
@include gradient-bg();
// Empty badges collapse automatically
&:empty {

View File

@@ -1,4 +1,3 @@
@import "helpers/background";
@import "helpers/clearfix";
@import "helpers/colored-links";
@import "helpers/embed";

View File

@@ -30,7 +30,6 @@
@import "mixins/table-variants";
// Skins
@import "mixins/background-variant";
@import "mixins/border-radius";
@import "mixins/box-shadow";
@import "mixins/gradients";

View File

@@ -82,7 +82,7 @@
.nav-link.active,
.show > .nav-link {
color: $nav-pills-link-active-color;
background-color: $nav-pills-link-active-bg;
@include gradient-bg($nav-pills-link-active-bg);
}
}

View File

@@ -24,6 +24,7 @@
padding-right: $navbar-padding-x; // default: null
padding-bottom: $navbar-padding-y;
padding-left: $navbar-padding-x; // default: null
@include gradient-bg();
// Because flex properties aren't inherited, we need to redeclare these first
// few properties so that content nested within behave properly.

View File

@@ -34,7 +34,7 @@
&.active .page-link {
z-index: 3;
color: $pagination-active-color;
background-color: $pagination-active-bg;
@include gradient-bg($pagination-active-bg);
border-color: $pagination-active-border-color;
}

View File

@@ -12,4 +12,5 @@
// See https://github.com/sass/sass/issues/2383#issuecomment-336349172
--bs-font-sans-serif: #{inspect($font-family-sans-serif)};
--bs-font-monospace: #{inspect($font-family-monospace)};
--bs-gradient: #{$gradient};
}

View File

@@ -416,6 +416,11 @@ $utilities: map-merge(
)
)
),
"gradient": (
property: background-image,
class: bg,
values: (gradient: var(--bs-gradient))
),
"white-space": (
property: white-space,
class: text,

View File

@@ -222,6 +222,11 @@ $enable-negative-margins: false !default;
$enable-deprecation-messages: true !default;
$enable-important-utilities: true !default;
// Gradient
//
// The gradient which is added to components if `$enable-gradients` is `true`
// This gradient is also added to elements with `.bg-gradient`
$gradient: linear-gradient(180deg, rgba($white, .15), rgba($white, 0)) !default;
// Spacing
//

View File

@@ -53,7 +53,7 @@
&[type="checkbox"] {
@if $enable-gradients {
background-image: escape-svg($form-check-input-checked-bg-image), linear-gradient(180deg, lighten($form-check-input-checked-bg-color, 10%), $form-check-input-checked-bg-color);
background-image: escape-svg($form-check-input-checked-bg-image), var(--bs-gradient);
} @else {
background-image: escape-svg($form-check-input-checked-bg-image);
}
@@ -61,7 +61,7 @@
&[type="radio"] {
@if $enable-gradients {
background-image: escape-svg($form-check-radio-checked-bg-image), linear-gradient(180deg, lighten($form-check-input-checked-bg-color, 10%), $form-check-input-checked-bg-color);
background-image: escape-svg($form-check-radio-checked-bg-image), var(--bs-gradient);
} @else {
background-image: escape-svg($form-check-radio-checked-bg-image);
}
@@ -73,7 +73,7 @@
border-color: $form-check-input-indeterminate-border-color;
@if $enable-gradients {
background-image: escape-svg($form-check-input-indeterminate-bg-image), linear-gradient(180deg, lighten($form-check-input-checked-bg-color, 10%), $form-check-input-checked-bg-color);
background-image: escape-svg($form-check-input-indeterminate-bg-image), var(--bs-gradient);
} @else {
background-image: escape-svg($form-check-input-indeterminate-bg-image);
}

View File

@@ -1,5 +0,0 @@
@if $enable-gradients {
@each $color, $value in $theme-colors {
@include bg-gradient-variant(".bg-gradient-#{$color}", $value);
}
}

View File

@@ -1,7 +0,0 @@
// stylelint-disable declaration-no-important
@mixin bg-gradient-variant($parent, $color) {
#{$parent} {
background-image: linear-gradient(180deg, mix($body-bg, $color, 15%), $color) !important;
}
}

View File

@@ -97,7 +97,7 @@
border-color: $color;
&:checked {
@include gradient-bg(lighten($color, 10%), escape-svg($form-check-input-checked-bg-image));
background-color: $color;
}
&:focus {

View File

@@ -1,14 +1,10 @@
// Gradients
@mixin gradient-bg($color, $foreground: null) {
@mixin gradient-bg($color: null) {
background-color: $color;
@if $enable-gradients {
@if $foreground {
background-image: $foreground, linear-gradient(180deg, mix($body-bg, $color, 15%), $color);
} @else {
background-image: linear-gradient(180deg, mix($body-bg, $color, 15%), $color);
}
} @else {
background-color: $color;
background-image: var(--bs-gradient);
}
}