Skip to content

Commit 0daf274

Browse files
committed
fix(Close): display issues of the close button in contextual light and dark modes
1 parent 081874b commit 0daf274

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

scss/_close.scss

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
@use "mixins/border-radius" as *;
33
@use "mixins/color-mode" as *;
44
@use "variables" as *;
5+
@use "variables-dark" as *;
56

67
// Transparent background and border properties included for button version.
78
// iOS requires the button element instead of an anchor tag.
@@ -17,7 +18,6 @@
1718
--#{$prefix}btn-close-focus-shadow: #{$btn-close-focus-shadow};
1819
--#{$prefix}btn-close-focus-opacity: #{$btn-close-focus-opacity};
1920
--#{$prefix}btn-close-disabled-opacity: #{$btn-close-disabled-opacity};
20-
--#{$prefix}btn-close-white-filter: #{$btn-close-white-filter};
2121
// scss-docs-end close-css-vars
2222

2323
box-sizing: content-box;
@@ -26,6 +26,7 @@
2626
padding: $btn-close-padding-y $btn-close-padding-x;
2727
color: var(--#{$prefix}btn-close-color);
2828
background: transparent var(--#{$prefix}btn-close-bg) center / $btn-close-width auto no-repeat; // include transparent for button elements
29+
filter: var(--#{$prefix}btn-close-filter);
2930
border: 0; // for button elements
3031
@include border-radius();
3132
opacity: var(--#{$prefix}btn-close-opacity);
@@ -52,18 +53,20 @@
5253
}
5354

5455
@mixin btn-close-white() {
55-
filter: var(--#{$prefix}btn-close-white-filter);
56+
--#{$prefix}btn-close-filter: #{$btn-close-filter-dark};
5657
}
5758

58-
.btn-close[data#{$data-infix}theme="dark"],
5959
.btn-close-white {
6060
@include btn-close-white();
6161
}
6262

63+
:root,
64+
[data-coreui-theme="light"] {
65+
--#{$prefix}btn-close-filter: #{$btn-close-filter};
66+
}
67+
6368
@if $enable-dark-mode {
64-
@include color-mode(dark) {
65-
.btn-close {
66-
@include btn-close-white();
67-
}
69+
@include color-mode(dark, true) {
70+
@include btn-close-white();
6871
}
6972
}

scss/_variables-dark.scss

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ $accordion-icon-active-color-dark: $primary-text-emphasis-dark !default;
146146

147147
$accordion-button-icon-dark: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='#{$accordion-icon-color-dark}'><path fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708'/></svg>") !default;
148148
$accordion-button-active-icon-dark: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='#{$accordion-icon-active-color-dark}'><path fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708'/></svg>") !default;
149-
// scss-docs-end sass-dark-mode-vars
150149

151150

152151
//
@@ -155,4 +154,12 @@ $accordion-button-active-icon-dark: url("data:image/svg+xml,<svg xmlns='http://
155154

156155
$carousel-indicator-active-bg-dark: $carousel-dark-indicator-active-bg !default;
157156
$carousel-caption-color-dark: $carousel-dark-caption-color !default;
158-
$carousel-control-icon-filter-dark: $carousel-dark-control-icon-filter !default;
157+
$carousel-control-icon-filter-dark: $carousel-dark-control-icon-filter !default;
158+
159+
160+
//
161+
// Close button
162+
//
163+
164+
$btn-close-filter-dark: $btn-close-white-filter !default;
165+
// scss-docs-end sass-dark-mode-vars

scss/_variables.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2032,7 +2032,8 @@ $btn-close-opacity: .5 !default;
20322032
$btn-close-hover-opacity: .75 !default;
20332033
$btn-close-focus-opacity: 1 !default;
20342034
$btn-close-disabled-opacity: .25 !default;
2035-
$btn-close-white-filter: invert(1) grayscale(100%) brightness(200%) !default;
2035+
$btn-close-filter: null !default;
2036+
$btn-close-white-filter: invert(1) grayscale(100%) brightness(200%) !default; // Deprecated in v5.3.2
20362037
// scss-docs-end close-variables
20372038

20382039

0 commit comments

Comments
 (0)