Skip to content

Commit a9dd552

Browse files
committed
fix(card): fixed the bordered background color when the dark elevation flag is enabled
Closes #1053
1 parent 9e78454 commit a9dd552

File tree

3 files changed

+47
-16
lines changed

3 files changed

+47
-16
lines changed

packages/card/src/_mixins.scss

+7
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@
8585
}
8686

8787
&--bordered {
88+
@include rmd-theme-dark-elevation-styles {
89+
@include rmd-theme-update-var(
90+
surface,
91+
$rmd-card-dark-elevation-bordered-background-color
92+
);
93+
}
94+
8895
border: $rmd-card-border-width solid $rmd-card-border-color;
8996
}
9097

packages/card/src/_variables.scss

+13
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,19 @@ $rmd-card-border-color: rmd-divider-theme-var(background-color) !default;
9090
/// @type Number
9191
$rmd-card-border-width: $rmd-divider-size !default;
9292

93+
/// The background color to use for bordered cards when the
94+
/// `$rmd-theme-dark-elevation` variable is set to `true`. This basically
95+
/// overrides the `surface` color to be this value.
96+
///
97+
/// @see $rmd-theme-dark-elevation
98+
/// @require $rmd-theme-dark-elevation-colors
99+
/// @type Color
100+
/// @since 2.5.4
101+
$rmd-card-dark-elevation-bordered-background-color: map-get(
102+
$rmd-theme-dark-elevation-colors,
103+
$rmd-card-elevation
104+
);
105+
93106
/// A Map of all the "themeable" parts of the card package. Every key in this
94107
/// map will be used to create a css variable to dynamically update the values
95108
/// of the icon as needed.

packages/theme/src/_mixins.scss

+27-16
Original file line numberDiff line numberDiff line change
@@ -60,42 +60,53 @@
6060
);
6161
}
6262

63-
/// This mixin should normally be used with the `rmd-elevation` mixin to change
64-
/// the background color based on the current elevation in dark themes.
63+
/// Conditionally adds styles only when the `$rmd-theme-dark-elevation`
64+
/// variable is set to `true`. This will also work with the
65+
/// `$rmd-theme-dark-class` variable to either set the styles with a media
66+
/// query or only when the dark class has been enabled on a parent element.
6567
///
66-
/// @since 2.1.0
67-
/// @param {Number} z-value - This should be a number between 0 and 24
68-
/// representing the current elevation.
68+
/// @since 2.5.4
6969
/// @param {Boolean} css-modules [false] - Boolean if this is being used within
7070
/// CSS Modules which will update the selector to work correctly by wrapping
7171
/// different parts with `:global` and `:local`.
72-
@mixin rmd-theme-dark-elevation($z-value, $css-modules: false) {
72+
@mixin rmd-theme-dark-elevation-styles($css-modules: false) {
7373
@if $rmd-theme-dark-elevation {
7474
@if $rmd-theme-dark-class == 'prefers-color-scheme' {
7575
@media (prefers-color-scheme: dark) {
7676
& {
77-
@include rmd-theme-update-var(
78-
background,
79-
map-get($rmd-theme-dark-elevation-colors, $z-value)
80-
);
81-
@include rmd-theme(background-color, background);
77+
@content;
8278
}
8379
}
8480
} @else {
8581
@include rmd-utils-optional-css-modules(
8682
$rmd-theme-dark-class,
8783
$css-modules
8884
) {
89-
@include rmd-theme-update-var(
90-
background,
91-
map-get($rmd-theme-dark-elevation-colors, $z-value)
92-
);
93-
@include rmd-theme(background-color, background);
85+
@content;
9486
}
9587
}
9688
}
9789
}
9890

91+
/// This mixin should normally be used with the `rmd-elevation` mixin to change
92+
/// the background color based on the current elevation in dark themes.
93+
///
94+
/// @since 2.1.0
95+
/// @param {Number} z-value - This should be a number between 0 and 24
96+
/// representing the current elevation.
97+
/// @param {Boolean} css-modules [false] - Boolean if this is being used within
98+
/// CSS Modules which will update the selector to work correctly by wrapping
99+
/// different parts with `:global` and `:local`.
100+
@mixin rmd-theme-dark-elevation($z-value, $css-modules: false) {
101+
@include rmd-theme-dark-elevation-styles($css-modules) {
102+
@include rmd-theme-update-var(
103+
background,
104+
map-get($rmd-theme-dark-elevation-colors, $z-value)
105+
);
106+
@include rmd-theme(background-color, background);
107+
}
108+
}
109+
99110
/// This mixin can be used to apply the light theme by updating **every** color
100111
/// theme variable across all react-md packages.
101112
///

0 commit comments

Comments
 (0)