From b735650fbf6a3cefeea43e90bb8c446859e84f23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Copin?= Date: Sun, 17 Apr 2016 01:49:32 +0200 Subject: [PATCH] feat: make visibility input available for sidenav (#173) --- ng2-material/components/backdrop/backdrop.ts | 2 +- ng2-material/components/sidenav/sidenav.ts | 12 ++++++++++++ test/components/sidenav/sidenav_spec.ts | 9 +++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/ng2-material/components/backdrop/backdrop.ts b/ng2-material/components/backdrop/backdrop.ts index 0e6d5008..a9684b41 100644 --- a/ng2-material/components/backdrop/backdrop.ts +++ b/ng2-material/components/backdrop/backdrop.ts @@ -86,7 +86,7 @@ export class MdBackdrop { this.toggle(value); } - private _visible: boolean = false; + protected _visible: boolean = false; private _transitioning: boolean = false; private _previousOverflow: string = null; private _body: HTMLElement = null; diff --git a/ng2-material/components/sidenav/sidenav.ts b/ng2-material/components/sidenav/sidenav.ts index 0336e80d..71ede9c9 100644 --- a/ng2-material/components/sidenav/sidenav.ts +++ b/ng2-material/components/sidenav/sidenav.ts @@ -121,6 +121,18 @@ export class MdSidenav extends MdBackdrop implements OnInit, OnDestroy { private _align: string = SidenavAlignment.LEFT; private _style: string = SidenavStyle.OVER; + /** + * allow backdrop visibility Input + */ + get visible(): boolean { + return this._visible; + } + + @Input() + set visible(value: boolean) { + this.toggle(value); + } + /** * The backdrop element the container provides. */ diff --git a/test/components/sidenav/sidenav_spec.ts b/test/components/sidenav/sidenav_spec.ts index f630d70f..edd401c7 100644 --- a/test/components/sidenav/sidenav_spec.ts +++ b/test/components/sidenav/sidenav_spec.ts @@ -120,6 +120,15 @@ export function main() { })); }); + + describe('visible', () => { + it('should accept "true" for content pushing', injectAsync([], () => { + return setup(``).then((api: ITestFixture) => { + expect(api.component.visible).toBe(true); + }); + })); + + }); }); describe('md-sidenav-container', () => { let template = `