File tree Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -30,12 +30,15 @@ export class MdLineSetter {
30
30
this . _resetClasses ( ) ;
31
31
if ( count === 2 || count === 3 ) {
32
32
this . _setClass ( `md-${ count } -line` , true ) ;
33
+ } else if ( count > 3 ) {
34
+ this . _setClass ( `md-multi-line` , true ) ;
33
35
}
34
36
}
35
37
36
38
private _resetClasses ( ) : void {
37
39
this . _setClass ( 'md-2-line' , false ) ;
38
40
this . _setClass ( 'md-3-line' , false ) ;
41
+ this . _setClass ( 'md-multi-line' , false ) ;
39
42
}
40
43
41
44
private _setClass ( className : string , bool : boolean ) : void {
Original file line number Diff line number Diff line change @@ -50,10 +50,18 @@ $md-dense-three-line-height: 76px;
50
50
height : $two-line-height ;
51
51
}
52
52
53
+
53
54
& .md-3-line .md-list-item {
54
55
height : $three-line-height ;
55
56
}
56
57
58
+ // list items with more than 3 lines should expand to match
59
+ // the height of its contained text
60
+ & .md-multi-line .md-list-item {
61
+ height : 100% ;
62
+ padding : 8px $md-list-side-padding ;
63
+ }
64
+
57
65
.md-list-text {
58
66
@include md-line-wrapper-base ();
59
67
padding : 0 $md-list-side-padding ;
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ describe('MdList', () => {
18
18
ListWithItemWithCssClass ,
19
19
ListWithDynamicNumberOfLines ,
20
20
ListWithMultipleItems ,
21
+ ListWithManyLines ,
21
22
] ,
22
23
} ) ;
23
24
@@ -65,6 +66,15 @@ describe('MdList', () => {
65
66
expect ( listItems [ 1 ] . nativeElement . className ) . toBe ( 'md-3-line' ) ;
66
67
} ) ;
67
68
69
+ it ( 'should apply md-multi-line class to lists with more than 3 lines' , ( ) => {
70
+ let fixture = TestBed . createComponent ( ListWithManyLines ) ;
71
+ fixture . detectChanges ( ) ;
72
+
73
+ let listItems = fixture . debugElement . children [ 0 ] . queryAll ( By . css ( 'md-list-item' ) ) ;
74
+ expect ( listItems [ 0 ] . nativeElement . className ) . toBe ( 'md-multi-line' ) ;
75
+ expect ( listItems [ 1 ] . nativeElement . className ) . toBe ( 'md-multi-line' ) ;
76
+ } ) ;
77
+
68
78
it ( 'should apply md-list-avatar class to list items with avatars' , ( ) => {
69
79
let fixture = TestBed . createComponent ( ListWithAvatar ) ;
70
80
fixture . detectChanges ( ) ;
@@ -152,6 +162,17 @@ class ListWithTwoLineItem extends BaseTestList { }
152
162
</md-list>` } )
153
163
class ListWithThreeLineItem extends BaseTestList { }
154
164
165
+ @Component ( { template : `
166
+ <md-list>
167
+ <md-list-item *ngFor="let item of items">
168
+ <h3 md-line>Line 1</h3>
169
+ <p md-line>Line 2</p>
170
+ <p md-line>Line 3</p>
171
+ <p md-line>Line 4</p>
172
+ </md-list-item>
173
+ </md-list>` } )
174
+ class ListWithManyLines extends BaseTestList { }
175
+
155
176
@Component ( { template : `
156
177
<md-list>
157
178
<md-list-item>
You can’t perform that action at this time.
0 commit comments