Skip to content

Commit

Permalink
feat(bg-utilities): .bg-{success|warning|danger|info} now uses suppor…
Browse files Browse the repository at this point in the history
…ting colours instead of functionnal ones
  • Loading branch information
ffoodd committed Dec 20, 2019
1 parent 1ecdbe0 commit f2b11dd
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
12 changes: 12 additions & 0 deletions scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,18 @@ $theme-colors: map-merge(
);

// Boosted mod
$supporting-colors: () !default;
// stylelint-disable-next-line scss/dollar-variable-default
$supporting-colors: map-merge(
(
"success": $teal,
"info": $cyan,
"warning": $yellow-2,
"danger": $pink,
"purple": $purple
),
$supporting-colors
);
$chevron-icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 14'><path d='M9 2L7 0 0 7l7 7 2-2-5-5 5-5z'/></svg>") !default;
$chevron-icon-hover: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 14'><path fill='#{$white}' d='M9 2L7 0 0 7l7 7 2-2-5-5 5-5z'/></svg>") !default;
$chevron-icon-active: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 14'><path fill='#{$primary}' d='M9 2L7 0 0 7l7 7 2-2-5-5 5-5z'/></svg>") !default;
Expand Down
16 changes: 15 additions & 1 deletion scss/utilities/_background.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
// stylelint-disable declaration-no-important

@each $color, $value in $theme-colors {
@include bg-variant(".bg-#{$color}", $value, true);
// Boosted mod: disallow functionnal colors for background
@if ($value != $success) and ($value != $danger) and ($value != $info) and ($value != $warning) {
@include bg-variant(".bg-#{$color}", $value, true);
}
}

// Boosted mod: supporting colour as background
@each $color, $value in $supporting-colors {
@include bg-variant(".bg-#{$color}", $value);
}

.bg-teal { @extend .bg-success; }
.bg-cyan { @extend .bg-info; }
.bg-yellow { @extend .bg-warning; }
.bg-pink { @extend .bg-danger; }
// end mod

@if $enable-gradients {
@each $color, $value in $theme-colors {
@include bg-gradient-variant(".bg-gradient-#{$color}", $value);
Expand Down
14 changes: 10 additions & 4 deletions site/docs/4.4/utilities/colors.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,16 @@ Similar to the contextual text color classes, easily set the background of an el

{% capture example %}
<!-- Boosted mod -->
{% for color in site.data.theme-colors %}
<div class="p-3 mb-2 bg-{{ color.name }}">.bg-{{ color.name }}</div>{% endfor %}
<div class="p-3 mb-2 bg-white text-dark">.bg-white</div>
<div class="p-3 mb-2 bg-transparent text-dark">.bg-transparent</div>
<div class="p-3 mb-2 bg-primary">.bg-primary</div>
<div class="p-3 mb-2 bg-secondary">.bg-secondary</div>
<div class="p-3 mb-2 bg-success">.bg-success or .bg-teal</div>
<div class="p-3 mb-2 bg-danger">.bg-danger or .bg-pink</div>
<div class="p-3 mb-2 bg-warning">.bg-warning or .bg-yellow</div>
<div class="p-3 mb-2 bg-info">.bg-info or .bg-cyan</div>
<div class="p-3 mb-2 bg-purple">.bg-purple</div>
<div class="p-3 mb-2 bg-light">.bg-light</div>
<div class="p-3 mb-2 bg-white">.bg-white</div>
<div class="p-3 mb-2 bg-transparent">.bg-transparent</div>
<!-- end mod -->
{% endcapture %}
{% include example.html content=example %}
Expand Down

0 comments on commit f2b11dd

Please sign in to comment.