Skip to content

Commit e918550

Browse files
fix(utilities): use the right orange color for texts based on the light/dark variant (#872)
Signed-off-by: louismaximepiton <louismaxime.piton@orange.com> Co-authored-by: Julien Déramond <julien.deramond@orange.com>
1 parent 8d4e2bf commit e918550

File tree

5 files changed

+10
-3
lines changed

5 files changed

+10
-3
lines changed

scss/_root.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
--#{$prefix}#{$color}-rgb: #{$value};
2222
}
2323

24+
--#{$prefix}primary-text-rgb: #{to-rgb($accessible-orange)}; // Boosted mod
2425
--#{$prefix}white-rgb: #{to-rgb($white)};
2526
--#{$prefix}black-rgb: #{to-rgb($black)};
2627
--#{$prefix}body-color-rgb: #{to-rgb($body-color)};
@@ -84,6 +85,7 @@
8485
[class*="bg-black"],
8586
[class*="-dark"]:not(.border-dark):not(.text-dark),
8687
[class*="bg-secondary"] {
88+
--#{$prefix}primary-text-rgb: #{to-rgb($brand-orange)};
8789
--#{$prefix}link-color: #{$link-color-dark};
8890
--#{$prefix}link-hover-color: #{$link-hover-color-dark};
8991
--#{$boosted-prefix}caption-color: #{$table-caption-color-dark};
@@ -96,6 +98,7 @@
9698

9799
// stylelint-disable-next-line scss/selector-no-redundant-nesting-selector
98100
[class*="bg-"]:not(&):not(.bg-transparent) {
101+
--#{$prefix}primary-text-rgb: #{to-rgb($accessible-orange)};
99102
--#{$prefix}link-color: #{$link-color};
100103
--#{$prefix}link-hover-color: #{$link-hover-color};
101104
--#{$boosted-prefix}caption-color: #{$table-caption-color};

scss/_utilities.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@ $utilities: map-merge(
542542
"black-50": rgba($black, .5), // deprecated
543543
"white-50": rgba($white, .5), // deprecated
544544
"reset": inherit,
545+
"primary": rgba(var(--#{$prefix}primary-text-rgb), var(--#{$prefix}text-opacity)), // Boosted mod: redefine primary value
545546
)
546547
)
547548
),

scss/mixins/_utilities.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
}
118118
}
119119
}
120-
@if "inherit" != inspect($value) and $accessible-orange != $value and $primary != $value and $text-muted != $value {
120+
@if "inherit" != inspect($value) and $accessible-orange != $value and $primary != $value and $text-muted != $value and "rgba(var(--#{$prefix}primary-text-rgb), var(--#{$prefix}text-opacity))" != $value {
121121
background-color: color-contrast($value);
122122
}
123123
}

site/content/docs/5.2/migration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ If you need more details about the changes, please refer to the [v5.2.2 release]
5353
<summary><span class="badge bg-success">New</span> CSS variables:</summary>
5454
<ul>
5555
<li><code>--bs-btn-letter-spacing</code></li>
56+
<li><code>--bs-primary-text-rgb</code></li>
5657
</ul>
5758
</details>
5859

site/content/docs/5.2/utilities/colors.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ Consider our default `.text-primary` utility.
4848
```css
4949
.text-primary {
5050
--bs-text-opacity: 1;
51-
color: rgba(var(--bs-primary-rgb), var(--bs-text-opacity)) !important;
51+
color: rgba(var(--bs-primary-text-rgb), var(--bs-text-opacity)) !important;
5252
}
5353
```
5454

55-
We use an RGB version of our `--bs-primary` (with the value of `13, 110, 253`) CSS variable and attached a second CSS variable, `--bs-text-opacity`, for the alpha transparency (with a default value `1` thanks to a local CSS variable). That means anytime you use `.text-primary` now, your computed `color` value is `rgba(13, 110, 253, 1)`. The local CSS variable inside each `.text-*` class avoids inheritance issues so nested instances of the utilities don't automatically have a modified alpha transparency.
55+
We use an RGB version of our `$accessible-orange` (with the value of `241, 110, 0`) Sass variable as a CSS variable and attached a second CSS variable, `--bs-text-opacity`, for the alpha transparency (with a default value `1` thanks to a local CSS variable). That means anytime you use `.text-primary` now, your computed `color` value is `rgba(241, 110, 0, 1)`. The local CSS variable inside each `.text-*` class avoids inheritance issues so nested instances of the utilities don't automatically have a modified alpha transparency.
56+
57+
When used in a dark variant context, `--bs-primary-text-rgb` will use the value of `$brand-orange` (with the value of `255, 121, 0`).
5658

5759
### Example
5860

0 commit comments

Comments
 (0)