Skip to content

fix(list): multi-line list item spacing #8339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 20, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 14 additions & 26 deletions src/lib/list/list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ $mat-list-avatar-height: 56px;
// spec requires two- and three-line lists be taller
$mat-list-two-line-height: 72px;
$mat-list-three-line-height: 88px;
$mat-list-multi-line-padding: 16px;
$mat-list-icon-size: 24px;

// Dense list variables
Expand All @@ -23,12 +24,13 @@ $mat-dense-base-height: 40px;
$mat-dense-avatar-height: 48px;
$mat-dense-two-line-height: 60px;
$mat-dense-three-line-height: 76px;
$mat-dense-multi-line-padding: 16px;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the dense padding here is the same as the regular one, however the spec doesn't seem to mention exactly how to handle more than three lines. I based this number on the spacing between the text and the element top for three-line items.

$mat-dense-list-icon-size: 20px;

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

// Prevents the wrapper `mat-list-item-content` from collapsing due to it
// being `inline` by default.
Expand Down Expand Up @@ -78,8 +80,12 @@ $mat-dense-list-icon-size: 20px;
// list items with more than 3 lines should expand to match
// the height of its contained text
&.mat-multi-line {
height: 100%;
padding: 8px $mat-list-side-padding;
height: auto;

.mat-list-item-content {
padding-top: $multi-line-padding;
padding-bottom: $multi-line-padding;
}
}

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

.mat-list-item {
@include mat-list-item-base(
$mat-list-base-height,
$mat-list-avatar-height,
$mat-list-two-line-height,
$mat-list-three-line-height,
$mat-list-icon-size
);
}

.mat-list-option {
.mat-list-item, .mat-list-option {
@include mat-list-item-base(
$mat-list-base-height,
$mat-list-avatar-height,
$mat-list-two-line-height,
$mat-list-three-line-height,
$mat-list-multi-line-padding,
$mat-list-icon-size
);
}
Expand All @@ -176,22 +173,13 @@ $mat-dense-list-icon-size: 20px;
@include mat-subheader-spacing($mat-dense-top-padding, $mat-dense-base-height);
}

.mat-list-item {
@include mat-list-item-base(
$mat-dense-base-height,
$mat-dense-avatar-height,
$mat-dense-two-line-height,
$mat-dense-three-line-height,
$mat-dense-list-icon-size
);
}

.mat-list-option {
.mat-list-item, .mat-list-option {
@include mat-list-item-base(
$mat-dense-base-height,
$mat-dense-avatar-height,
$mat-dense-two-line-height,
$mat-dense-three-line-height,
$mat-dense-multi-line-padding,
$mat-dense-list-icon-size
);
}
Expand Down