Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit f29cb70

Browse files
authored
feat(app-bar): Add isCollapsed() for checking collapsed state (#1230)
Returns whether or not the app bar is in a collapsed state. - Adds `isCollapsed: boolean`
1 parent 28fed21 commit f29cb70

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

demos/components/app-bar/app-bar-demo.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,20 @@ <h2>Design & API Documentation</h2>
5555
</tr>
5656
</tbody>
5757
</table>
58+
<table>
59+
<thead>
60+
<tr>
61+
<th>Methods</th>
62+
<th>Description</th>
63+
</tr>
64+
</thead>
65+
<tbody>
66+
<tr>
67+
<td>isCollapsed: boolean</td>
68+
<td>Whether or not the app bar is in a collapsed state.</td>
69+
</tr>
70+
</tbody>
71+
</table>
5872
<table>
5973
<thead>
6074
<tr>

packages/app-bar/app-bar.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,11 @@ export class MdcAppBar implements AfterContentInit, AfterViewInit, OnDestroy {
271271
}
272272
}
273273

274+
isCollapsed(): boolean {
275+
return this._getHostElement().classList.contains('mdc-top-app-bar--short-collapsed') ||
276+
this._getHostElement().classList.contains('mdc-top-app-bar--short-collapsed');
277+
}
278+
274279
initializeFoundation(): void {
275280
setTimeout(() => {
276281
this._foundation.destroy();

test/app-bar/app-bar.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ describe('MdcAppBar', () => {
8282
fixture.detectChanges();
8383
expect(testDebugElement.nativeElement.classList.contains('mdc-top-app-bar--fixed')).toBe(true);
8484
expect(testDebugElement.nativeElement.classList.contains('mdc-top-app-bar--short')).toBe(false);
85+
expect(testInstance.isCollapsed()).toBe(false);
8586
});
8687
});
8788
});

0 commit comments

Comments
 (0)