Skip to content

Commit a76e84c

Browse files
committed
fix avatars and dividers
1 parent f38f0e6 commit a76e84c

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
<ng-content select="[mat-list-avatar],[matListAvatar],[mat-list-icon],[matListIcon]"></ng-content>
22
<span class="mdc-list-item__text"><ng-content></ng-content></span>
3+
<ng-content select="mat-divider"></ng-content>

src/material-experimental/mdc-list/list.scss

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@import '@material/list/mixins.import';
2+
@import '@material/list/variables.import';
23
@import '../mdc-helpers/mdc-helpers';
34

45
@include mdc-list-without-ripple($query: $mat-base-styles-query);
@@ -40,8 +41,8 @@
4041
}
4142

4243

43-
// MDC does have 2-line support, but it applies to the entire list, whereas ours applies to
44-
// individual items. Therefore, we need to add our own styles.
44+
// MDC does have 2-line support, but it's a per-list setting, whereas ours applies to individual
45+
// items. Therefore, we need to add our own styles.
4546
.mat-mdc-2-line {
4647
height: 72px;
4748

@@ -58,3 +59,43 @@
5859
align-self: flex-start;
5960
}
6061
}
62+
63+
// MDC supports avatars, but it's a per-list setting, whereas ours applies to individual
64+
// items. Therefore, we need to add our own styles.
65+
.mat-mdc-list-avatar {
66+
// Styles here come from `$mdc-list-graphic-size_`:
67+
// https://github.com/material-components/material-components-web/blob/3ca8c4c45a3d2a654ef3cb8fc7525bcde37badf0/packages/mdc-list/_mixins.scss#L538
68+
$size: 40px;
69+
$margin-value: 72px - $mdc-list-side-padding - $size;
70+
71+
margin-left: 0;
72+
margin-right: $margin-value;
73+
width: $size;
74+
height: $size;
75+
border-radius: 50%;
76+
77+
// `.mdc-list-item` added for extra specificity to override MDC's built in styles.
78+
[dir="rtl"] .mdc-list-item & {
79+
margin-left: $margin-value;
80+
margin-right: 0;
81+
}
82+
}
83+
84+
// MDC doesn't have list dividers, so we use mat-divider and style appropriately.
85+
.mat-mdc-list-item,
86+
.mat-mdc-list-option {
87+
.mat-divider-inset {
88+
position: absolute;
89+
left: 0;
90+
right: 0;
91+
bottom: 0;
92+
}
93+
94+
.mat-mdc-list-avatar ~ .mat-divider-inset {
95+
margin-left: 72px;
96+
97+
[dir="rtl"] & {
98+
margin-right: 72px;
99+
}
100+
}
101+
}

0 commit comments

Comments
 (0)