Skip to content

Commit 40c7657

Browse files
committed
fix(list): align avatar size in dense list with spec
* Fixes the dense list avatar being slightly larger than the spec. * Removes an unnecessary setter from the `MatListItem` class. Fixes #10019.
1 parent 45399c6 commit 40c7657

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

src/lib/list/list.scss

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@ $mat-dense-two-line-height: 60px;
2828
$mat-dense-three-line-height: 76px;
2929
$mat-dense-multi-line-padding: 16px;
3030
$mat-dense-list-icon-size: 20px;
31+
$mat-dense-avatar-size: 36px;
3132

3233
$mat-list-item-inset-divider-offset: 72px;
3334

3435
// This mixin provides all list-item styles, changing font size and height
3536
// based on whether the list is in dense mode.
36-
@mixin mat-list-item-base($base-height, $avatar-height, $two-line-height,
37-
$three-line-height, $multi-line-padding, $icon-size) {
37+
@mixin mat-list-item-base($base-height, $has-avatar-height, $two-line-height,
38+
$three-line-height, $multi-line-padding, $icon-size, $avatar-size) {
3839

3940
// Prevents the wrapper `mat-list-item-content` from collapsing due to it
4041
// being `inline` by default.
@@ -69,7 +70,7 @@ $mat-list-item-inset-divider-offset: 72px;
6970
}
7071

7172
&.mat-list-item-avatar {
72-
height: $avatar-height;
73+
height: $has-avatar-height;
7374
}
7475

7576
&.mat-2-line {
@@ -128,12 +129,12 @@ $mat-list-item-inset-divider-offset: 72px;
128129

129130
.mat-list-avatar {
130131
flex-shrink: 0;
131-
width: $mat-list-avatar-size;
132-
height: $mat-list-avatar-size;
132+
width: $avatar-size;
133+
height: $avatar-size;
133134
border-radius: 50%;
134135

135136
~ .mat-divider-inset {
136-
@include mat-inset-divider-offset($mat-list-avatar-size, $mat-list-side-padding);
137+
@include mat-inset-divider-offset($avatar-size, $mat-list-side-padding);
137138
}
138139
}
139140

@@ -210,7 +211,8 @@ $mat-list-item-inset-divider-offset: 72px;
210211
$mat-list-two-line-height,
211212
$mat-list-three-line-height,
212213
$mat-list-multi-line-padding,
213-
$mat-list-icon-size
214+
$mat-list-icon-size,
215+
$mat-list-avatar-size
214216
);
215217
}
216218
}
@@ -232,7 +234,8 @@ $mat-list-item-inset-divider-offset: 72px;
232234
$mat-dense-two-line-height,
233235
$mat-dense-three-line-height,
234236
$mat-dense-multi-line-padding,
235-
$mat-dense-list-icon-size
237+
$mat-dense-list-icon-size,
238+
$mat-dense-avatar-size
236239
);
237240
}
238241
}

src/lib/list/list.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export class MatListSubheaderCssMatStyler {}
9898
exportAs: 'matListItem',
9999
host: {
100100
'class': 'mat-list-item',
101+
'[class.mat-list-item-avatar]': '_avatar',
101102
'(focus)': '_handleFocus()',
102103
'(blur)': '_handleBlur()',
103104
},
@@ -113,15 +114,7 @@ export class MatListItem extends _MatListItemMixinBase implements AfterContentIn
113114
private _isNavList: boolean = false;
114115

115116
@ContentChildren(MatLine) _lines: QueryList<MatLine>;
116-
117-
@ContentChild(MatListAvatarCssMatStyler)
118-
set _hasAvatar(avatar: MatListAvatarCssMatStyler) {
119-
if (avatar != null) {
120-
this._element.nativeElement.classList.add('mat-list-item-avatar');
121-
} else {
122-
this._element.nativeElement.classList.remove('mat-list-item-avatar');
123-
}
124-
}
117+
@ContentChild(MatListAvatarCssMatStyler) _avatar: MatListAvatarCssMatStyler;
125118

126119
constructor(private _element: ElementRef,
127120
@Optional() private _navList: MatNavList) {

0 commit comments

Comments
 (0)