Skip to content
This repository was archived by the owner on May 20, 2023. It is now read-only.

Commit 7f0afa5

Browse files
har79nshahan
authored andcommitted
Previously some material-content styling was only applied if there was a drawer preceding. If there were two drawers, the second would miss some styling and the content would miss the adjustment from the first drawer.
Changed to use the general sibling selector instead of the adjacent sibling selector to be less dependent on a specific number and order of elements, and to use conditional styling (a {...} !a {...}) instead of relying on overrides ({... a {...} }). PiperOrigin-RevId: 192269258
1 parent ebb45c6 commit 7f0afa5

File tree

2 files changed

+48
-47
lines changed

2 files changed

+48
-47
lines changed

lib/app_layout/_mixins.scss

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,39 @@
1818
&[permanent] {
1919
width: $width;
2020

21-
+ material-content,
22-
+ .material-content {
23-
margin-left: $width;
21+
&:not([end]) {
22+
~ material-content,
23+
~ .material-content {
24+
margin-left: $width;
25+
}
2426
}
2527

2628
&[end] {
27-
+ material-content,
28-
+ .material-content {
29-
margin-left: 0;
29+
~ material-content,
30+
~ .material-content {
3031
margin-right: $width;
3132
}
3233
}
3334
}
3435

3536
&[persistent].mat-drawer-collapsed {
36-
transform: translateX(-100%);
37+
&:not([end]) {
38+
transform: translateX(-100%);
3739

38-
// If the drawer is collapsed, which needs to be the element directly
39-
// before the content, set the content to the left edge.
40-
+ material-content,
41-
+ .material-content {
42-
margin-left: 0;
40+
// If the drawer is collapsed, which needs to be an element before the
41+
// content, set the content to the left edge.
42+
~ material-content,
43+
~ .material-content {
44+
margin-left: 0;
45+
}
4346
}
4447

4548
&[end] {
4649
transform: translateX(100%);
4750

4851
// [end] drawer is positioned on the opposite side
49-
+ material-content,
50-
+ .material-content {
52+
~ material-content,
53+
~ .material-content {
5154
margin-right: 0;
5255
}
5356
}

lib/app_layout/layout.scss

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,18 @@ material-drawer {
3939
}
4040

4141
&[persistent] {
42-
transition-property: transform, width;
43-
transition-duration: $mat-transition-desktop;
44-
transition-timing-function: $mat-transition-standard;
45-
46-
+ material-content,
47-
+ .material-content {
48-
transition: margin-left $mat-transition-desktop $mat-transition-standard;
42+
transition: {
43+
duration: $mat-transition-desktop;
44+
property: transform, width;
45+
timing-function: $mat-transition-standard;
4946
}
5047

51-
&[end] {
52-
+ material-content,
53-
+ .material-content {
54-
transition-property: margin-right;
48+
~ material-content,
49+
~ .material-content {
50+
transition: {
51+
duration: $mat-transition-desktop;
52+
property: margin-left, margin-right;
53+
timing-function: $mat-transition-standard;
5554
}
5655
}
5756
}
@@ -90,45 +89,44 @@ $mat-header-dense-height: 48px;
9089
width: 100%;
9190
z-index: 0;
9291

93-
// Dense header spec for desktop and mouse heavy interfaces.
94-
&.dense-header {
95-
height: $mat-header-dense-height;
96-
97-
.material-header-row {
98-
height: $mat-header-dense-height;
99-
}
100-
}
101-
10292
// Add shadow to the header
10393
&.shadow {
10494
@include shadow-elevation(4);
10595
}
10696

10797
// Header is taking the full top row.
108-
+ material-drawer {
98+
~ material-drawer {
10999
// Position the drawer lower to fit the header.
110100
&[permanent],
111101
&[persistent] {
112102
top: $mat-header-height;
113103
}
104+
}
114105

115-
// Reduce the min size of the content.
116-
+ material-content,
117-
+ .material-content {
118-
min-height: calc(100% - #{$mat-header-height});
119-
}
106+
// Reduce the min size of the content.
107+
~ material-content,
108+
~ .material-content {
109+
min-height: calc(100% - #{$mat-header-height});
120110
}
121111

122-
// Dense header is taking the full top row.
123-
&.dense-header + material-drawer {
124-
&[permanent],
125-
&[persistent] {
126-
top: $mat-header-dense-height;
112+
// Dense header spec for desktop and mouse heavy interfaces.
113+
&.dense-header {
114+
height: $mat-header-dense-height;
115+
116+
.material-header-row {
117+
height: $mat-header-dense-height;
118+
}
119+
120+
~ material-drawer {
121+
&[permanent],
122+
&[persistent] {
123+
top: $mat-header-dense-height;
124+
}
127125
}
128126

129127
// Reduce the min size of the content.
130-
+ material-content,
131-
+ .material-content {
128+
~ material-content,
129+
~ .material-content {
132130
min-height: calc(100% - #{$mat-header-dense-height});
133131
}
134132
}

0 commit comments

Comments
 (0)