fix(list): ensure multi-line lists expand to fill space (#1466)

This commit is contained in:
Kara
2016-10-11 09:02:58 -07:00
committed by GitHub
parent 0b5b6f2fda
commit e7b872ac2a
3 changed files with 32 additions and 0 deletions
+3
View File
@@ -30,12 +30,15 @@ export class MdLineSetter {
this._resetClasses();
if (count === 2 || count === 3) {
this._setClass(`md-${count}-line`, true);
} else if (count > 3) {
this._setClass(`md-multi-line`, true);
}
}
private _resetClasses(): void {
this._setClass('md-2-line', false);
this._setClass('md-3-line', false);
this._setClass('md-multi-line', false);
}
private _setClass(className: string, bool: boolean): void {
+8
View File
@@ -50,10 +50,18 @@ $md-dense-three-line-height: 76px;
height: $two-line-height;
}
&.md-3-line .md-list-item {
height: $three-line-height;
}
// list items with more than 3 lines should expand to match
// the height of its contained text
&.md-multi-line .md-list-item {
height: 100%;
padding: 8px $md-list-side-padding;
}
.md-list-text {
@include md-line-wrapper-base();
padding: 0 $md-list-side-padding;
+21
View File
@@ -18,6 +18,7 @@ describe('MdList', () => {
ListWithItemWithCssClass,
ListWithDynamicNumberOfLines,
ListWithMultipleItems,
ListWithManyLines,
],
});
@@ -65,6 +66,15 @@ describe('MdList', () => {
expect(listItems[1].nativeElement.className).toBe('md-3-line');
});
it('should apply md-multi-line class to lists with more than 3 lines', () => {
let fixture = TestBed.createComponent(ListWithManyLines);
fixture.detectChanges();
let listItems = fixture.debugElement.children[0].queryAll(By.css('md-list-item'));
expect(listItems[0].nativeElement.className).toBe('md-multi-line');
expect(listItems[1].nativeElement.className).toBe('md-multi-line');
});
it('should apply md-list-avatar class to list items with avatars', () => {
let fixture = TestBed.createComponent(ListWithAvatar);
fixture.detectChanges();
@@ -152,6 +162,17 @@ class ListWithTwoLineItem extends BaseTestList { }
</md-list>`})
class ListWithThreeLineItem extends BaseTestList { }
@Component({template: `
<md-list>
<md-list-item *ngFor="let item of items">
<h3 md-line>Line 1</h3>
<p md-line>Line 2</p>
<p md-line>Line 3</p>
<p md-line>Line 4</p>
</md-list-item>
</md-list>`})
class ListWithManyLines extends BaseTestList { }
@Component({template: `
<md-list>
<md-list-item>