diff --git a/src/app/@core/data/data.module.ts b/src/app/@core/data/data.module.ts index 0c6d774d..2d3d978b 100644 --- a/src/app/@core/data/data.module.ts +++ b/src/app/@core/data/data.module.ts @@ -3,10 +3,12 @@ import { CommonModule } from '@angular/common'; import { UserService } from './users.service'; import { ElectricityService } from './electricity.service'; +import { StateService } from './state.service'; const SERVICES = [ UserService, ElectricityService, + StateService, ]; @NgModule({ diff --git a/src/app/@core/data/electricity.service.ts b/src/app/@core/data/electricity.service.ts index e578f80e..6bfcc091 100644 --- a/src/app/@core/data/electricity.service.ts +++ b/src/app/@core/data/electricity.service.ts @@ -61,6 +61,7 @@ export class ElectricityService { constructor() { } + // TODO: observables getData() { return this.data; } diff --git a/src/app/@core/data/state.service.ts b/src/app/@core/data/state.service.ts new file mode 100644 index 00000000..ae13f192 --- /dev/null +++ b/src/app/@core/data/state.service.ts @@ -0,0 +1,74 @@ +import { Injectable } from '@angular/core'; + +import { Observable } from 'rxjs/Observable'; +import { BehaviorSubject } from 'rxjs/BehaviorSubject'; +import 'rxjs/add/observable/of'; + +@Injectable() +export class StateService { + + protected layouts: any = [ + { + name: 'One Column', + icon: 'ion ion-grid', + id: 'one-column', + selected: true, + }, + { + name: 'Two Column', + icon: 'ion ion-grid', + id: 'two-column', + }, + { + name: 'Three Column', + icon: 'ion ion-grid', + id: 'three-column', + }, + { + name: 'Center Column', + icon: 'ion ion-grid', + id: 'center-column', + }, + ]; + + protected sidebars: any = [ + { + name: 'Left Sidebar', + icon: 'ion ion-grid', + id: 'left', + selected: true, + }, + { + name: 'Right Sidebar', + icon: 'ion ion-grid', + id: 'right', + }, + ]; + + protected layoutState$ = new BehaviorSubject(this.layouts[0]); + protected sidebarState$ = new BehaviorSubject(this.sidebars[0]); + + setLayoutState(state: any): any { + this.layoutState$.next(state); + } + + getLayoutStates(): Observable { + return Observable.of(this.layouts); + } + + onLayoutState(): Observable { + return this.layoutState$.asObservable(); + } + + setSidebarState(state: any): any { + this.sidebarState$.next(state); + } + + getSidebarStates(): Observable { + return Observable.of(this.sidebars); + } + + onSidebarState(): Observable { + return this.sidebarState$.asObservable(); + } +} diff --git a/src/app/@theme/components/header/header.component.scss b/src/app/@theme/components/header/header.component.scss index 9fc5883e..ac67619d 100644 --- a/src/app/@theme/components/header/header.component.scss +++ b/src/app/@theme/components/header/header.component.scss @@ -5,7 +5,16 @@ justify-content: space-between; width: 100%; - .left-container { + .left { + order: 0; + flex-direction: row; + } + .right { + order: 1; + flex-direction: row-reverse; + } + + .header-container { display: flex; align-items: center; diff --git a/src/app/@theme/components/header/header.component.ts b/src/app/@theme/components/header/header.component.ts index 5c4f4d0c..d49e5083 100644 --- a/src/app/@theme/components/header/header.component.ts +++ b/src/app/@theme/components/header/header.component.ts @@ -1,6 +1,6 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, Input, OnInit } from '@angular/core'; -import { NgaSidebarService, NgaMenuService } from '@akveo/nga-theme'; +import { NgaMenuService, NgaSidebarService } from '@akveo/nga-theme'; import { NgaThemeService } from '@akveo/nga-theme/services/theme.service'; import { UserService } from '../../../@core/data/users.service'; @@ -8,7 +8,7 @@ import { UserService } from '../../../@core/data/users.service'; selector: 'ngx-header', styleUrls: ['./header.component.scss'], template: ` -
+
@@ -18,19 +18,28 @@ import { UserService } from '../../../@core/data/users.service';
- - - - + + - + + + + + `, }) export class HeaderComponent implements OnInit { + + @Input() position: string = 'normal'; + user: any; userMenu = [ @@ -54,7 +63,12 @@ export class HeaderComponent implements OnInit { } toggleSidebar(): boolean { - this.sidebarService.toggle(true); + this.sidebarService.toggle(true, 'menu-sidebar'); + return false; + } + + toggleSettings(): boolean { + this.sidebarService.toggle(false, 'settings-sidebar'); return false; } diff --git a/src/app/@theme/components/index.ts b/src/app/@theme/components/index.ts index 09d415ce..d0930e40 100644 --- a/src/app/@theme/components/index.ts +++ b/src/app/@theme/components/index.ts @@ -2,3 +2,4 @@ export * from './header/header.component'; export * from './footer/footer.component'; export * from './search-input/search-input.component'; export * from './tiny-mce/tiny-mce.component'; +export * from './theme-settings/theme-settings.component'; diff --git a/src/app/@theme/components/theme-settings/theme-settings.component.scss b/src/app/@theme/components/theme-settings/theme-settings.component.scss new file mode 100644 index 00000000..096002ac --- /dev/null +++ b/src/app/@theme/components/theme-settings/theme-settings.component.scss @@ -0,0 +1,22 @@ +@import '../../styles/variables'; + +@include nga-install-component() { + .settings-row { + display: flex; + flex-direction: row; + justify-content: space-between; + padding-bottom: 0.5rem; + flex-wrap: wrap; + + a { + font-size: 2rem; + margin-right: 1rem; + color: nga-theme(color-white); + + &.selected { + color: nga-theme(color-success); + } + } + } +} + diff --git a/src/app/@theme/components/theme-settings/theme-settings.component.ts b/src/app/@theme/components/theme-settings/theme-settings.component.ts new file mode 100644 index 00000000..6ce1d3bd --- /dev/null +++ b/src/app/@theme/components/theme-settings/theme-settings.component.ts @@ -0,0 +1,65 @@ +import { Component, Input, OnInit } from '@angular/core'; + +import { StateService } from '../../../@core/data/state.service'; + +@Component({ + selector: 'ngx-theme-settings', + styleUrls: ['./theme-settings.component.scss'], + template: ` + LAYOUTS +
+ + + +
+ SIDEBAR +
+ + + +
+ `, +}) +export class ThemeSettingsComponent { + + layouts = []; + sidebars = []; + + constructor(protected stateService: StateService) { + this.stateService.getLayoutStates() + .subscribe((layouts: any[]) => this.layouts = layouts); + + this.stateService.getSidebarStates() + .subscribe((sidebars: any[]) => this.sidebars = sidebars); + } + + layoutSelect(layout: any): boolean { + this.layouts = this.layouts.map((l: any) => { + l.selected = false; + return l; + }); + + layout.selected = true; + this.stateService.setLayoutState(layout); + return false; + } + + sidebarSelect(sidebars: any): boolean { + this.sidebars = this.sidebars.map((s: any) => { + s.selected = false; + return s; + }); + + sidebars.selected = true; + this.stateService.setSidebarState(sidebars); + return false; + } +} diff --git a/src/app/@theme/layouts/index.ts b/src/app/@theme/layouts/index.ts index fab07255..812e427d 100644 --- a/src/app/@theme/layouts/index.ts +++ b/src/app/@theme/layouts/index.ts @@ -1 +1,4 @@ export * from './one-column/one-column.layout'; +export * from './two-columns/two-columns.layout'; +export * from './three-columns/three-columns.layout'; +export * from './sample/sample.layout'; 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 1cda072c..3a9d8295 100644 --- a/src/app/@theme/layouts/one-column/one-column.layout.scss +++ b/src/app/@theme/layouts/one-column/one-column.layout.scss @@ -2,12 +2,13 @@ @include nga-install-root-component() { - nga-sidebar { + nga-sidebar.menu-sidebar { margin-top: nga-theme(sidebar-header-gap); /deep/ .main-container { - height: calc(#{nga-theme(sidebar-height)} - #{nga-theme(header-height)} - #{nga-theme(sidebar-header-gap)})!important; + height: + calc(#{nga-theme(sidebar-height)} - #{nga-theme(header-height)} - #{nga-theme(sidebar-header-gap)}) !important; border-top-right-radius: 0.75rem; } diff --git a/src/app/@theme/layouts/one-column/one-column.layout.ts b/src/app/@theme/layouts/one-column/one-column.layout.ts index 33290faf..bf6c1af3 100644 --- a/src/app/@theme/layouts/one-column/one-column.layout.ts +++ b/src/app/@theme/layouts/one-column/one-column.layout.ts @@ -10,7 +10,7 @@ import { Component } from '@angular/core'; - + + + + + + + + + + + + + + + + + + + + + + + + + + `, +}) +export class SampleLayoutComponent implements OnDestroy { + + subMenu: List = List( + [ + { + title: 'PAGE LEVEL MENU', + group: true, + }, + { + title: 'Buttons', + icon: 'ion ion-android-radio-button-off', + link: '/pages/ui-features/buttons', + }, + { + title: 'Grid', + icon: 'ion ion-android-radio-button-off', + link: '/pages/ui-features/grid', + }, + { + title: 'Icons', + icon: 'ion ion-android-radio-button-off', + link: '/pages/ui-features/icons', + }, + { + title: 'Modals', + icon: 'ion ion-android-radio-button-off', + link: '/pages/ui-features/modals', + }, + { + title: 'Typography', + icon: 'ion ion-android-radio-button-off', + link: '/pages/ui-features/typography', + }, + { + title: 'Animated Searches', + icon: 'ion ion-android-radio-button-off', + link: '/pages/ui-features/search-fields', + }, + { + title: 'Tabs', + icon: 'ion ion-android-radio-button-off', + link: '/pages/ui-features/tabs', + }, + ], + ); + layout: any = {}; + sidebar: any = {}; + + protected layoutState$: Subscription; + protected sidebarState$: Subscription; + + constructor(protected stateService: StateService) { + this.layoutState$ = this.stateService.onLayoutState() + .subscribe((layout: string) => this.layout = layout); + + this.sidebarState$ = this.stateService.onSidebarState() + .subscribe((sidebar: string) => { + this.sidebar = sidebar + }); + } + + ngOnDestroy() { + this.layoutState$.unsubscribe(); + this.sidebarState$.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 new file mode 100644 index 00000000..a190d4fc --- /dev/null +++ b/src/app/@theme/layouts/three-columns/three-columns.layout.scss @@ -0,0 +1,65 @@ +@import '../../styles/variables'; + +@include nga-install-root-component() { + + nga-layout-column.small { + flex: 0.15 !important; + } + + nga-sidebar.menu-sidebar { + + margin-top: nga-theme(sidebar-header-gap); + + /deep/ .main-container { + height: + calc(#{nga-theme(sidebar-height)} - #{nga-theme(header-height)} - #{nga-theme(sidebar-header-gap)}) !important; + border-top-right-radius: 0.75rem; + } + + /deep/ nga-sidebar-header { + padding-bottom: 0.5rem; + text-align: center; + } + + background: transparent; + + .main-btn { + padding: 0.75rem 2.5rem; + margin-top: -2rem; + font-weight: bold; + transition: padding 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.48); + + i { + font-size: 2rem; + text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2); + } + span { + padding-left: 0.25rem; + } + + i, span { + vertical-align: middle; + } + } + + &.compacted { + + /deep/ nga-sidebar-header { + padding-left: 0; + padding-right: 0; + } + + .main-btn { + width: 46px; + height: 44px; + padding: 0; + border-radius: 5px; + transition: none; + + span { + display: none; + } + } + } + } +} diff --git a/src/app/@theme/layouts/three-columns/three-columns.layout.ts b/src/app/@theme/layouts/three-columns/three-columns.layout.ts new file mode 100644 index 00000000..80df0dde --- /dev/null +++ b/src/app/@theme/layouts/three-columns/three-columns.layout.ts @@ -0,0 +1,39 @@ +import { Component } from '@angular/core'; + +// TODO: move layouts into the framework +@Component({ + selector: 'ngx-three-columns-layout', + styleUrls: ['./three-columns.layout.scss'], + template: ` + + + + + + + + + + + + + + + + + + + + + + + + + + + `, +}) +export class ThreeColumnsLayoutComponent { +} diff --git a/src/app/@theme/layouts/two-columns/two-columns.layout.scss b/src/app/@theme/layouts/two-columns/two-columns.layout.scss new file mode 100644 index 00000000..a190d4fc --- /dev/null +++ b/src/app/@theme/layouts/two-columns/two-columns.layout.scss @@ -0,0 +1,65 @@ +@import '../../styles/variables'; + +@include nga-install-root-component() { + + nga-layout-column.small { + flex: 0.15 !important; + } + + nga-sidebar.menu-sidebar { + + margin-top: nga-theme(sidebar-header-gap); + + /deep/ .main-container { + height: + calc(#{nga-theme(sidebar-height)} - #{nga-theme(header-height)} - #{nga-theme(sidebar-header-gap)}) !important; + border-top-right-radius: 0.75rem; + } + + /deep/ nga-sidebar-header { + padding-bottom: 0.5rem; + text-align: center; + } + + background: transparent; + + .main-btn { + padding: 0.75rem 2.5rem; + margin-top: -2rem; + font-weight: bold; + transition: padding 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.48); + + i { + font-size: 2rem; + text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2); + } + span { + padding-left: 0.25rem; + } + + i, span { + vertical-align: middle; + } + } + + &.compacted { + + /deep/ nga-sidebar-header { + padding-left: 0; + padding-right: 0; + } + + .main-btn { + width: 46px; + height: 44px; + padding: 0; + border-radius: 5px; + transition: none; + + span { + display: none; + } + } + } + } +} diff --git a/src/app/@theme/layouts/two-columns/two-columns.layout.ts b/src/app/@theme/layouts/two-columns/two-columns.layout.ts new file mode 100644 index 00000000..95b79e4e --- /dev/null +++ b/src/app/@theme/layouts/two-columns/two-columns.layout.ts @@ -0,0 +1,37 @@ +import { Component } from '@angular/core'; + +// TODO: move layouts into the framework +@Component({ + selector: 'ngx-two-columns-layout', + styleUrls: ['./two-columns.layout.scss'], + template: ` + + + + + + + + + + + + + + + + + + + + + + + + + `, +}) +export class TwoColumnsLayoutComponent { +} diff --git a/src/app/@theme/styles/variables.scss b/src/app/@theme/styles/variables.scss index 16bc07c2..30de24cb 100644 --- a/src/app/@theme/styles/variables.scss +++ b/src/app/@theme/styles/variables.scss @@ -10,16 +10,19 @@ $nga-themes: nga-register-theme(( // app wise variables for each theme sidebar-header-gap: 2rem, sidebar-header-height: initial, + layout-content-width: 1400px, ), default, default); $nga-themes: nga-register-theme(( // app wise variables for each theme sidebar-header-gap: 2rem, sidebar-header-height: initial, + layout-content-width: 1400px, ), cosmic, cosmic); $nga-themes: nga-register-theme(( // app wise variables for each theme sidebar-header-gap: 2rem, sidebar-header-height: initial, + layout-content-width: 1400px, ), light, light); diff --git a/src/app/@theme/theme.module.ts b/src/app/@theme/theme.module.ts index b378b9f1..fb4352e9 100644 --- a/src/app/@theme/theme.module.ts +++ b/src/app/@theme/theme.module.ts @@ -15,12 +15,23 @@ import { NgaUserModule, } from '@akveo/nga-theme'; -import { FooterComponent, HeaderComponent, SearchInputComponent, TinyMCEComponent } from './components'; +import { + FooterComponent, + HeaderComponent, + SearchInputComponent, + ThemeSettingsComponent, + TinyMCEComponent, +} from './components'; import { CapitalizePipe, PluralPipe, RoundPipe } from './pipes'; -import { OneColumnLayoutComponent } from './layouts'; +import { + OneColumnLayoutComponent, + SampleLayoutComponent, + ThreeColumnsLayoutComponent, + TwoColumnsLayoutComponent, +} from './layouts'; const BASE_MODULES = [ CommonModule, @@ -45,7 +56,11 @@ const COMPONENTS = [ FooterComponent, SearchInputComponent, TinyMCEComponent, + ThemeSettingsComponent, OneColumnLayoutComponent, + TwoColumnsLayoutComponent, + ThreeColumnsLayoutComponent, + SampleLayoutComponent, ]; const PIPES = [ @@ -56,8 +71,8 @@ const PIPES = [ const NGA_THEME_PROVIDERS = [ ...NgaThemeModule.forRoot({ - name: 'cosmic', - }, + name: 'cosmic', + }, [ { name: 'default', diff --git a/src/app/pages/pages.component.ts b/src/app/pages/pages.component.ts index 0a6d9698..c0bf2812 100644 --- a/src/app/pages/pages.component.ts +++ b/src/app/pages/pages.component.ts @@ -6,10 +6,10 @@ import { MENU_ITEMS } from './pages-menu'; @Component({ selector: 'ngx-pages', template: ` - + - + `, }) export class PagesComponent {