diff --git a/src/app/app.component.html b/src/app/app.component.html index 7107236c76..6200aafa81 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,7 +1,10 @@ - + - {{item.icon}}{{item.title}} + {{item.icon}}{{item.title}} diff --git a/src/app/app.component.ts b/src/app/app.component.ts index dc92ef04b6..be03bf9864 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,7 +1,7 @@ -import { Component } from '@angular/core'; +import { Component, AfterViewInit, ChangeDetectorRef } from '@angular/core'; import { DomSanitizer } from '@angular/platform-browser'; import { MdIconRegistry } from '@angular/material'; - +import { TdMediaService } from '@covalent/core'; import { TranslateService } from '@ngx-translate/core'; import { getSelectedLanguage } from './utilities/translate'; @@ -11,7 +11,7 @@ import { getSelectedLanguage } from './utilities/translate'; templateUrl: './app.component.html', styleUrls: ['./app.component.scss'], }) -export class DocsAppComponent { +export class DocsAppComponent implements AfterViewInit { routes: Object[] = [{ icon: 'home', @@ -38,6 +38,8 @@ export class DocsAppComponent { constructor(private _iconRegistry: MdIconRegistry, private _domSanitizer: DomSanitizer, + private _changeDetectorRef: ChangeDetectorRef, + public media: TdMediaService, translateService: TranslateService) { // Set fallback language translateService.setDefaultLang('en'); @@ -63,4 +65,9 @@ export class DocsAppComponent { this._iconRegistry.addSvgIconInNamespace('assets', 'querygrid', this._domSanitizer.bypassSecurityTrustResourceUrl('app/assets/icons/querygrid.svg')); } + + ngAfterViewInit(): void { + this.media.broadcast(); + this._changeDetectorRef.detectChanges(); + } } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index cb73a34a10..c299d22a71 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -12,7 +12,8 @@ import { appRoutes, appRoutingProviders } from './app.routes'; import { MdButtonModule, MdListModule, MdIconModule, MdCardModule, MdCoreModule, MdMenuModule } from '@angular/material'; -import { CovalentLayoutModule, CovalentExpansionPanelModule, CovalentNotificationsModule, CovalentMenuModule } from '../platform/core'; +import { CovalentLayoutModule, CovalentExpansionPanelModule, CovalentNotificationsModule, CovalentMenuModule, + CovalentMediaModule } from '../platform/core'; import { CovalentHighlightModule } from '../platform/highlight'; import { CovalentHttpModule } from '../platform/http'; import { CovalentMarkdownModule } from '../platform/markdown'; @@ -49,6 +50,7 @@ import { getSelectedLanguage, createTranslateLoader } from './utilities/translat CovalentHighlightModule, CovalentMarkdownModule, CovalentDynamicFormsModule, + CovalentMediaModule, TranslateModule.forRoot({ loader: { provide: TranslateLoader, diff --git a/src/platform/core/layout/README.md b/src/platform/core/layout/README.md index da68042cbe..1f47399cdb 100644 --- a/src/platform/core/layout/README.md +++ b/src/platform/core/layout/README.md @@ -3,6 +3,30 @@ `` is a blank main sidenav component that gets hooked as parent of all the other layouts. (triggered by their menu buttons) +## API Summary + +| Name | Type | Description | +| --- | --- | --- | +| mode | 'over', 'side' or 'push' | The mode or styling of the sidenav. Defaults to 'over'. +| opened | boolean | Whether or not the sidenav is opened. Use this binding to open/close the sidenav. Defaults to 'false'. +| sidenavWidth | string | Sets the 'width' of the sidenav in either 'px' or '%' ('%' is not well supported yet as stated in the layout docs). Defaults to '320px'. + + +## Usage + +`[td-sidenav-content]` is used to include content in the main sidenav. + +Example for Main Layout: + +```html + +
+ .. more sidenav content +
+ .. main content +
+``` + ## Installation This component can be installed as npm package. diff --git a/src/platform/core/layout/_layout-theme.scss b/src/platform/core/layout/_layout-theme.scss index 36801afc9f..6463f55a40 100644 --- a/src/platform/core/layout/_layout-theme.scss +++ b/src/platform/core/layout/_layout-theme.scss @@ -20,6 +20,9 @@ z-index: 1; } } + .mat-sidenav-side.td-layout-sidenav { + @include mat-elevation(2); + } .td-layout-footer { background: mat-color($background, app-bar); color: mat-color($foreground, text); diff --git a/src/platform/core/layout/layout-manage-list/layout-manage-list.component.ts b/src/platform/core/layout/layout-manage-list/layout-manage-list.component.ts index eb6acf79c8..6fd020b984 100644 --- a/src/platform/core/layout/layout-manage-list/layout-manage-list.component.ts +++ b/src/platform/core/layout/layout-manage-list/layout-manage-list.component.ts @@ -56,7 +56,7 @@ export class TdLayoutManageListComponent { * Proxy toggle method to access sidenav from outside (from td-layout template). */ public toggle(): Promise { - return this._sideNav.toggle(); + return this._sideNav.toggle(!this._sideNav.opened); } /** diff --git a/src/platform/core/layout/layout-nav-list/layout-nav-list.component.ts b/src/platform/core/layout/layout-nav-list/layout-nav-list.component.ts index 9f973c9f43..9b5dfaaf6f 100644 --- a/src/platform/core/layout/layout-nav-list/layout-nav-list.component.ts +++ b/src/platform/core/layout/layout-nav-list/layout-nav-list.component.ts @@ -117,7 +117,7 @@ export class TdLayoutNavListComponent { * Proxy toggle method to access sidenav from outside (from td-layout template). */ public toggle(): Promise { - return this._sideNav.toggle(); + return this._sideNav.toggle(!this._sideNav.opened); } /** @@ -138,7 +138,7 @@ export class TdLayoutNavListComponent { * If main sidenav is available, it will open the sidenav of the parent [TdLayoutComponent]. */ openMainSidenav(): void { - this._layout.open(); + this._layout.toggle(); } } diff --git a/src/platform/core/layout/layout-nav/layout-nav.component.ts b/src/platform/core/layout/layout-nav/layout-nav.component.ts index 5039c2d07a..502fa14c88 100644 --- a/src/platform/core/layout/layout-nav/layout-nav.component.ts +++ b/src/platform/core/layout/layout-nav/layout-nav.component.ts @@ -73,6 +73,6 @@ export class TdLayoutNavComponent { * If main sidenav is available, it will open the sidenav of the parent [TdLayoutComponent]. */ openMainSidenav(): void { - this._layout.open(); + this._layout.toggle(); } } diff --git a/src/platform/core/layout/layout.component.html b/src/platform/core/layout/layout.component.html index 34013ac955..a2b7160e5d 100644 --- a/src/platform/core/layout/layout.component.html +++ b/src/platform/core/layout/layout.component.html @@ -1,5 +1,10 @@ - + diff --git a/src/platform/core/layout/layout.component.ts b/src/platform/core/layout/layout.component.ts index bbbc7c906d..8f2e30d514 100644 --- a/src/platform/core/layout/layout.component.ts +++ b/src/platform/core/layout/layout.component.ts @@ -11,11 +11,52 @@ export class TdLayoutComponent { @ViewChild(MdSidenav) sidenav: MdSidenav; + /** + * mode?: 'side', 'push' or 'over' + * + * The mode or styling of the sidenav. + * Defaults to "over". + * See "MdSidenav" documentation for more info. + * + * https://github.com/angular/material2/tree/master/src/lib/sidenav + */ + @Input('mode') mode: 'side' | 'push' | 'over' = 'over'; + + /** + * opened?: boolean + * + * Whether or not the sidenav is opened. Use this binding to open/close the sidenav. + * Defaults to "false". + * + * See "MdSidenav" documentation for more info. + * + * https://github.com/angular/material2/tree/master/src/lib/sidenav + */ + @Input('opened') opened: boolean = false; + + /** + * sidenavWidth?: string + * + * Sets the "width" of the sidenav in either "px" or "%" ("%" is not well supported yet as stated in the layout docs) + * Defaults to "320px". + * + * https://github.com/angular/material2/tree/master/src/lib/sidenav + */ + @Input('sidenavWidth') sidenavWidth: string = '320px'; + + /** + * Checks if `ESC` should close the sidenav + * Should only close it for `push` and `over` modes + */ + get disableClose(): boolean { + return this.mode === 'side'; + } + /** * Proxy toggle method to access sidenav from outside (from td-layout template). */ public toggle(): Promise { - return this.sidenav.toggle(); + return this.sidenav.toggle(!this.sidenav.opened); } /**