Skip to content

Commit 52c752d

Browse files
committed
fix(menu): fixed menu color when dark theme elevation is enabled
Ref #1075
1 parent 99cc271 commit 52c752d

3 files changed

Lines changed: 56 additions & 7 deletions

File tree

packages/menu/src/_mixins.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
@include rmd-utils-hide-focus-outline;
5252
@include rmd-utils-scroll;
5353
@include rmd-elevation($rmd-menu-elevation);
54-
@include rmd-theme-dark-elevation($rmd-menu-elevation);
5554
@include rmd-menu-theme(background-color);
5655
@include rmd-menu-theme(color);
5756
@include rmd-menu-theme(min-width);

packages/menu/src/_variables.scss

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,48 @@
66
@import '~@react-md/list/dist/functions';
77
@import '~@react-md/utils/dist/variables';
88

9+
/// The elevation for menus. This should be a number from 0 to 24 (inclusive) as
10+
/// it gets passed to the `rmd-elevation` mixin.
11+
/// @type Number
12+
$rmd-menu-elevation: 8 !default;
13+
14+
/// The background color for a menu in light themes.
15+
///
16+
/// @type Color
17+
/// @since 2.7.0
18+
$rmd-menu-light-background-color: rmd-theme-var(surface) !default;
19+
20+
/// The background color for a menu in dark themes when the
21+
/// `$rmd-theme-dark-elevation` feature flag is also enabled.
22+
///
23+
/// @see $rmd-theme-dark-elevation
24+
/// @see $rmd-menu-dark-background-color
25+
/// @require $rmd-theme-dark-elevation-colors
26+
/// @type Color
27+
/// @since 2.7.0
28+
$rmd-menu-dark-elevation-background-color: map-get(
29+
$rmd-theme-dark-elevation-colors,
30+
$rmd-menu-elevation
31+
) !default;
32+
33+
/// The background color for a menu in dark themes.
34+
/// @type Color
35+
/// @since 2.7.0
36+
$rmd-menu-dark-background-color: if(
37+
$rmd-theme-dark-elevation and $rmd-menu-dark-elevation-background-color,
38+
$rmd-menu-dark-elevation-background-color,
39+
rmd-theme-var(surface)
40+
) !default;
41+
942
/// The background color to use for menus
1043
///
1144
/// @require rmd-theme-var
1245
/// @type Color
13-
$rmd-menu-background-color: rmd-theme-var(surface) !default;
46+
$rmd-menu-background-color: if(
47+
$rmd-theme-light,
48+
$rmd-menu-light-background-color,
49+
$rmd-menu-dark-background-color
50+
) !default;
1451

1552
/// The text color to use for menus
1653
///
@@ -24,11 +61,6 @@ $rmd-menu-color: rmd-theme-var(on-surface) !default;
2461
/// @type Number
2562
$rmd-menu-z-index: $rmd-utils-temporary-element-z-index !default;
2663

27-
/// The elevation for menus. This should be a number from 0 to 24 (inclusive) as
28-
/// it gets passed to the `rmd-elevation` mixin.
29-
/// @type Number
30-
$rmd-menu-elevation: 8 !default;
31-
3264
/// The min-width to apply to menus.
3365
/// @type Number
3466
$rmd-menu-min-width: 7rem !default;

packages/theme/src/_mixins.scss

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,15 @@
216216
);
217217
}
218218

219+
@if mixin-exists(rmd-menu-theme-update-var) {
220+
@if $rmd-menu-light-background-color != $rmd-menu-dark-background-color {
221+
@include rmd-menu-theme-update-var(
222+
background-color,
223+
$rmd-menu-light-background-color
224+
);
225+
}
226+
}
227+
219228
@if mixin-exists(rmd-states-theme-update-var) {
220229
@include rmd-states-theme-update-var(
221230
hover-color,
@@ -374,6 +383,15 @@
374383
);
375384
}
376385

386+
@if mixin-exists(rmd-menu-theme-update-var) {
387+
@if $rmd-menu-light-background-color != $rmd-menu-dark-background-color {
388+
@include rmd-menu-theme-update-var(
389+
background-color,
390+
$rmd-menu-dark-background-color
391+
);
392+
}
393+
}
394+
377395
@if mixin-exists(rmd-states-theme-update-var) {
378396
@include rmd-states-theme-update-var(
379397
hover-color,

0 commit comments

Comments
 (0)