Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalerba committed May 12, 2020
1 parent 4e60ff3 commit 9843b59
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions src/material-experimental/mdc-list/list-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ import {RippleConfig, RippleRenderer, RippleTarget, setLines} from '@angular/mat
import {Subscription} from 'rxjs';
import {startWith} from 'rxjs/operators';

function toggleClass(el: Element, className: string, on: boolean) {
if (on) {
el.classList.add(className);
} else {
el.classList.remove(className);
}
}

@Directive()
/** @docs-private */
export abstract class MatListBase {
Expand Down Expand Up @@ -69,9 +77,9 @@ export abstract class MatListItemBase implements AfterContentInit, OnDestroy, Ri
this._subscriptions.add(this.lines.changes.pipe(startWith(this.lines))
.subscribe((lines: QueryList<ElementRef<Element>>) => {
lines.forEach((line: ElementRef<Element>, index: number) => {
line.nativeElement.classList
.toggle('mdc-list-item__primary-text', index === 0 && lines.length > 1);
line.nativeElement.classList.toggle('mdc-list-item__secondary-text', index !== 0);
toggleClass(line.nativeElement,
'mdc-list-item__primary-text', index === 0 && lines.length > 1);
toggleClass(line.nativeElement, 'mdc-list-item__secondary-text', index !== 0);
});
setLines(lines, this._element, 'mat-mdc');
}));
Expand Down
2 changes: 1 addition & 1 deletion src/material-experimental/mdc-list/list-item.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
If lines were not explicitly given, assume the remaining content is the text, otherwise assume it
is an action that belongs in the "meta" section.
-->
<span [class.mdc-list-item__text]="!lines.length" [class.mdc-list-item__meta]="!!lines.length">
<span [class.mdc-list-item__text]="!lines.length" [class.mdc-list-item__meta]="lines.length">
<ng-content></ng-content>
</span>

Expand Down

0 comments on commit 9843b59

Please sign in to comment.