Skip to content

Commit f20e4ed

Browse files
authored
refactor(material-experimental/theming): align sidenav with M3 (#28518)
Aligns the sidenav styles with the M3 spec.
1 parent d947ab5 commit f20e4ed

File tree

5 files changed

+12
-9
lines changed

5 files changed

+12
-9
lines changed

src/dev-app/dev-app/dev-app-layout.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ body {
1515
}
1616

1717
.mat-sidenav {
18-
min-width: 15vw;
1918
position: fixed;
2019

2120
.mat-mdc-button {

src/dev-app/theme-m3.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ dev-app {
108108
left: 50%;
109109
transform: translateX(-50%);
110110
padding: 8px;
111+
border-radius: 8px 8px 0 0;
111112
background: red;
112113
color: white;
113114
}

src/material-experimental/theming/_custom-tokens.scss

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,12 +1034,14 @@
10341034
/// @return {Map} A set of custom tokens for the mat-sidenav
10351035
@function sidenav($systems, $exclude-hardcoded) {
10361036
@return (
1037-
container-shape: 16px,
1038-
container-divider-color: map.get($systems, md-sys-color, outline),
1037+
container-elevation-shadow: _hardcode(none, $exclude-hardcoded),
1038+
container-divider-color: _hardcode(transparent, $exclude-hardcoded),
1039+
container-width: _hardcode(360px, $exclude-hardcoded),
1040+
container-shape: map.get($systems, md-sys-shape, corner-large),
10391041
container-background-color: map.get($systems, md-sys-color, surface),
10401042
container-text-color: map.get($systems, md-sys-color, on-surface-variant),
1041-
content-background-color: _hardcode(inherit, $exclude-hardcoded),
1042-
content-text-color: _hardcode(inherit, $exclude-hardcoded),
1043+
content-background-color: map.get($systems, md-sys-color, background),
1044+
content-text-color: map.get($systems, md-sys-color, on-background),
10431045
scrim-color: mat.private-safe-color-change(
10441046
map.get($systems, md-ref-palette, neutral-variant20), $alpha: 0.4),
10451047
);

src/material/core/tokens/m2/mat/_sidenav.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@use '@material/elevation/elevation-theme' as mdc-elevation;
12
@use 'sass:color';
23
@use 'sass:meta';
34
@use '../../token-utils';
@@ -14,6 +15,8 @@ $prefix: (mat, sidenav);
1415
// Currently zero, but it appears to be relevant for M3.
1516
// See: https://m3.material.io/components/navigation-drawer/overview
1617
container-shape: 0,
18+
container-elevation-shadow: mdc-elevation.elevation-box-shadow(16),
19+
container-width: auto,
1720
);
1821
}
1922

src/material/sidenav/drawer.scss

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
@use '../core/tokens/token-utils';
55
@use '../core/style/variables';
66
@use '../core/style/layout-common';
7-
@use '../core/style/elevation';
87

98
$drawer-content-z-index: 1;
109
$drawer-side-drawer-z-index: 2;
@@ -122,17 +121,16 @@ $drawer-over-drawer-z-index: 4;
122121
.mat-drawer {
123122
$high-contrast-border: solid 1px currentColor;
124123

125-
// The elevation of z-16 is noted in the design specifications.
126-
// See https://material.io/design/components/navigation-drawer.html
127-
@include elevation.elevation(16);
128124
@include drawer-stacking-context($drawer-over-drawer-z-index);
129125

130126
@include token-utils.use-tokens(
131127
tokens-mat-sidenav.$prefix, tokens-mat-sidenav.get-token-slots()) {
132128
@include token-utils.create-token-slot(color, container-text-color);
129+
@include token-utils.create-token-slot(box-shadow, container-elevation-shadow);
133130
@include token-utils.create-token-slot(background-color, container-background-color);
134131
@include token-utils.create-token-slot(border-top-right-radius, container-shape);
135132
@include token-utils.create-token-slot(border-bottom-right-radius, container-shape);
133+
@include token-utils.create-token-slot(width, container-width);
136134
}
137135

138136
display: block;

0 commit comments

Comments
 (0)