diff --git a/src/app/@theme/layouts/one-column/one-column.layout.scss b/src/app/@theme/layouts/one-column/one-column.layout.scss index 3eaf398f..7ccf7b77 100644 --- a/src/app/@theme/layouts/one-column/one-column.layout.scss +++ b/src/app/@theme/layouts/one-column/one-column.layout.scss @@ -1,6 +1,47 @@ @import '../../styles/themes'; +@import '~bootstrap/scss/mixins/breakpoints'; +@import '~@nebular/theme/styles/global/bootstrap/breakpoints'; @include nb-install-component() { + nb-layout-column.small { + flex: 0.15 !important; + } + + nb-sidebar.settings-sidebar { + $sidebar-width: 7.5rem; + + transition: width 0.3s ease; + width: $sidebar-width; + overflow: hidden; + + &.collapsed { + width: 0; + + /deep/ .main-container { + width: 0; + + .scrollable { + width: $sidebar-width; + padding: 1.25rem; + } + } + } + + /deep/ .main-container { + width: $sidebar-width; + background: nb-theme(color-bg); + transition: width 0.3s ease; + overflow: hidden; + + .scrollable { + width: $sidebar-width; + } + + @include nb-for-theme(cosmic) { + background: nb-theme(layout-bg); + } + } + } nb-sidebar.menu-sidebar { @@ -58,4 +99,32 @@ } } } + + @include media-breakpoint-down(xs) { + .main-content { + padding: 0.75rem !important; + + } + } + + @include media-breakpoint-down(sm) { + + nb-sidebar.menu-sidebar { + + margin-top: 0; + + /deep/ .main-container { + height: calc(#{nb-theme(sidebar-height)} - #{nb-theme(header-height)}) !important; + border-top-right-radius: 0; + + .scrollable { + padding-top: 0; + } + } + } + + .main-btn { + display: none; + } + } } diff --git a/src/app/@theme/layouts/sample/sample.layout.scss b/src/app/@theme/layouts/sample/sample.layout.scss index 525cf51b..7ccf7b77 100644 --- a/src/app/@theme/layouts/sample/sample.layout.scss +++ b/src/app/@theme/layouts/sample/sample.layout.scss @@ -106,4 +106,25 @@ } } + + @include media-breakpoint-down(sm) { + + nb-sidebar.menu-sidebar { + + margin-top: 0; + + /deep/ .main-container { + height: calc(#{nb-theme(sidebar-height)} - #{nb-theme(header-height)}) !important; + border-top-right-radius: 0; + + .scrollable { + padding-top: 0; + } + } + } + + .main-btn { + display: none; + } + } } diff --git a/src/app/@theme/layouts/sample/sample.layout.ts b/src/app/@theme/layouts/sample/sample.layout.ts index ae46172f..031713ca 100644 --- a/src/app/@theme/layouts/sample/sample.layout.ts +++ b/src/app/@theme/layouts/sample/sample.layout.ts @@ -1,9 +1,19 @@ import { Component, OnDestroy } from '@angular/core'; -import { NbMenuItem } from '@nebular/theme'; -import { Subscription } from 'rxjs/Subscription'; +import { + NbMediaBreakpoint, + NbMediaBreakpointsService, + NbMenuItem, + NbMenuService, + NbSidebarService, + NbThemeService, +} from '@nebular/theme'; import { StateService } from '../../../@core/data/state.service'; +import { Subscription } from 'rxjs/Subscription'; +import 'rxjs/add/operator/withLatestFrom'; +import 'rxjs/add/operator/delay'; + // TODO: move layouts into the framework @Component({ selector: 'ngx-sample-layout', @@ -100,8 +110,13 @@ export class SampleLayoutComponent implements OnDestroy { protected layoutState$: Subscription; protected sidebarState$: Subscription; + protected menuClick$: Subscription; - constructor(protected stateService: StateService) { + constructor(protected stateService: StateService, + protected menuService: NbMenuService, + protected themeService: NbThemeService, + protected bpService: NbMediaBreakpointsService, + protected sidebarService: NbSidebarService) { this.layoutState$ = this.stateService.onLayoutState() .subscribe((layout: string) => this.layout = layout); @@ -109,10 +124,22 @@ export class SampleLayoutComponent implements OnDestroy { .subscribe((sidebar: string) => { this.sidebar = sidebar }); + + const isBp = this.bpService.getByName('is'); + this.menuClick$ = this.menuService.onItemSelect() + .withLatestFrom(this.themeService.onMediaQueryChange()) + .delay(20) + .subscribe(([item, [bpFrom, bpTo]]: [any, [NbMediaBreakpoint, NbMediaBreakpoint]]) => { + + if (bpTo.width <= isBp.width) { + this.sidebarService.collapse('menu-sidebar'); + } + }); } ngOnDestroy() { this.layoutState$.unsubscribe(); this.sidebarState$.unsubscribe(); + this.menuClick$.unsubscribe(); } } diff --git a/src/app/@theme/layouts/three-columns/three-columns.layout.scss b/src/app/@theme/layouts/three-columns/three-columns.layout.scss index e7feb212..7ccf7b77 100644 --- a/src/app/@theme/layouts/three-columns/three-columns.layout.scss +++ b/src/app/@theme/layouts/three-columns/three-columns.layout.scss @@ -1,11 +1,48 @@ @import '../../styles/themes'; +@import '~bootstrap/scss/mixins/breakpoints'; +@import '~@nebular/theme/styles/global/bootstrap/breakpoints'; @include nb-install-component() { - nb-layout-column.small { flex: 0.15 !important; } + nb-sidebar.settings-sidebar { + $sidebar-width: 7.5rem; + + transition: width 0.3s ease; + width: $sidebar-width; + overflow: hidden; + + &.collapsed { + width: 0; + + /deep/ .main-container { + width: 0; + + .scrollable { + width: $sidebar-width; + padding: 1.25rem; + } + } + } + + /deep/ .main-container { + width: $sidebar-width; + background: nb-theme(color-bg); + transition: width 0.3s ease; + overflow: hidden; + + .scrollable { + width: $sidebar-width; + } + + @include nb-for-theme(cosmic) { + background: nb-theme(layout-bg); + } + } + } + nb-sidebar.menu-sidebar { margin-top: nb-theme(sidebar-header-gap); @@ -62,4 +99,32 @@ } } } + + @include media-breakpoint-down(xs) { + .main-content { + padding: 0.75rem !important; + + } + } + + @include media-breakpoint-down(sm) { + + nb-sidebar.menu-sidebar { + + margin-top: 0; + + /deep/ .main-container { + height: calc(#{nb-theme(sidebar-height)} - #{nb-theme(header-height)}) !important; + border-top-right-radius: 0; + + .scrollable { + padding-top: 0; + } + } + } + + .main-btn { + display: none; + } + } } diff --git a/src/app/@theme/layouts/two-columns/two-columns.layout.scss b/src/app/@theme/layouts/two-columns/two-columns.layout.scss index e7feb212..7ccf7b77 100644 --- a/src/app/@theme/layouts/two-columns/two-columns.layout.scss +++ b/src/app/@theme/layouts/two-columns/two-columns.layout.scss @@ -1,11 +1,48 @@ @import '../../styles/themes'; +@import '~bootstrap/scss/mixins/breakpoints'; +@import '~@nebular/theme/styles/global/bootstrap/breakpoints'; @include nb-install-component() { - nb-layout-column.small { flex: 0.15 !important; } + nb-sidebar.settings-sidebar { + $sidebar-width: 7.5rem; + + transition: width 0.3s ease; + width: $sidebar-width; + overflow: hidden; + + &.collapsed { + width: 0; + + /deep/ .main-container { + width: 0; + + .scrollable { + width: $sidebar-width; + padding: 1.25rem; + } + } + } + + /deep/ .main-container { + width: $sidebar-width; + background: nb-theme(color-bg); + transition: width 0.3s ease; + overflow: hidden; + + .scrollable { + width: $sidebar-width; + } + + @include nb-for-theme(cosmic) { + background: nb-theme(layout-bg); + } + } + } + nb-sidebar.menu-sidebar { margin-top: nb-theme(sidebar-header-gap); @@ -62,4 +99,32 @@ } } } + + @include media-breakpoint-down(xs) { + .main-content { + padding: 0.75rem !important; + + } + } + + @include media-breakpoint-down(sm) { + + nb-sidebar.menu-sidebar { + + margin-top: 0; + + /deep/ .main-container { + height: calc(#{nb-theme(sidebar-height)} - #{nb-theme(header-height)}) !important; + border-top-right-radius: 0; + + .scrollable { + padding-top: 0; + } + } + } + + .main-btn { + display: none; + } + } } diff --git a/src/tsconfig.app.json b/src/tsconfig.app.json index 569f154c..dea3bfea 100644 --- a/src/tsconfig.app.json +++ b/src/tsconfig.app.json @@ -11,6 +11,9 @@ ], "@nebular/*": [ "../node_modules/@nebular/*" + ], + "rxjs/*": [ + "../node_modules/rxjs/*" ] } },