Skip to content

Commit bb504ad

Browse files
crisbetojelbourn
authored andcommitted
fix(list): multi-line list item spacing (#8339)
* Fixes the spacing on multi-line list items being off. * Fixes a couple of declarations with the exact same styles being duplicated, adding some bloat to the final output. Fixes #8333
1 parent b437b45 commit bb504ad

File tree

1 file changed

+14
-26
lines changed

1 file changed

+14
-26
lines changed

src/lib/list/list.scss

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ $mat-list-avatar-height: 56px;
1515
// spec requires two- and three-line lists be taller
1616
$mat-list-two-line-height: 72px;
1717
$mat-list-three-line-height: 88px;
18+
$mat-list-multi-line-padding: 16px;
1819
$mat-list-icon-size: 24px;
1920

2021
// Dense list variables
@@ -23,12 +24,13 @@ $mat-dense-base-height: 40px;
2324
$mat-dense-avatar-height: 48px;
2425
$mat-dense-two-line-height: 60px;
2526
$mat-dense-three-line-height: 76px;
27+
$mat-dense-multi-line-padding: 16px;
2628
$mat-dense-list-icon-size: 20px;
2729

2830
// This mixin provides all list-item styles, changing font size and height
2931
// based on whether the list is in dense mode.
30-
@mixin mat-list-item-base($base-height, $avatar-height,
31-
$two-line-height, $three-line-height, $icon-size) {
32+
@mixin mat-list-item-base($base-height, $avatar-height, $two-line-height,
33+
$three-line-height, $multi-line-padding, $icon-size) {
3234

3335
// Prevents the wrapper `mat-list-item-content` from collapsing due to it
3436
// being `inline` by default.
@@ -78,8 +80,12 @@ $mat-dense-list-icon-size: 20px;
7880
// list items with more than 3 lines should expand to match
7981
// the height of its contained text
8082
&.mat-multi-line {
81-
height: 100%;
82-
padding: 8px $mat-list-side-padding;
83+
height: auto;
84+
85+
.mat-list-item-content {
86+
padding-top: $multi-line-padding;
87+
padding-bottom: $multi-line-padding;
88+
}
8389
}
8490

8591
.mat-list-text {
@@ -145,22 +151,13 @@ $mat-dense-list-icon-size: 20px;
145151
@include mat-subheader-spacing($mat-list-top-padding, $mat-list-base-height);
146152
}
147153

148-
.mat-list-item {
149-
@include mat-list-item-base(
150-
$mat-list-base-height,
151-
$mat-list-avatar-height,
152-
$mat-list-two-line-height,
153-
$mat-list-three-line-height,
154-
$mat-list-icon-size
155-
);
156-
}
157-
158-
.mat-list-option {
154+
.mat-list-item, .mat-list-option {
159155
@include mat-list-item-base(
160156
$mat-list-base-height,
161157
$mat-list-avatar-height,
162158
$mat-list-two-line-height,
163159
$mat-list-three-line-height,
160+
$mat-list-multi-line-padding,
164161
$mat-list-icon-size
165162
);
166163
}
@@ -176,22 +173,13 @@ $mat-dense-list-icon-size: 20px;
176173
@include mat-subheader-spacing($mat-dense-top-padding, $mat-dense-base-height);
177174
}
178175

179-
.mat-list-item {
180-
@include mat-list-item-base(
181-
$mat-dense-base-height,
182-
$mat-dense-avatar-height,
183-
$mat-dense-two-line-height,
184-
$mat-dense-three-line-height,
185-
$mat-dense-list-icon-size
186-
);
187-
}
188-
189-
.mat-list-option {
176+
.mat-list-item, .mat-list-option {
190177
@include mat-list-item-base(
191178
$mat-dense-base-height,
192179
$mat-dense-avatar-height,
193180
$mat-dense-two-line-height,
194181
$mat-dense-three-line-height,
182+
$mat-dense-multi-line-padding,
195183
$mat-dense-list-icon-size
196184
);
197185
}

0 commit comments

Comments
 (0)