mirror of
https://github.com/akveo/ngx-admin.git
synced 2026-01-27 19:56:10 +01:00
feat: RTL support (#1634)
This commit is contained in:
parent
06d2197583
commit
3b63759e84
40 changed files with 660 additions and 196 deletions
|
|
@ -1,10 +1,11 @@
|
|||
import { Injectable, OnDestroy } from '@angular/core';
|
||||
import { of as observableOf, Observable, BehaviorSubject } from 'rxjs';
|
||||
import { takeWhile } from 'rxjs/operators';
|
||||
|
||||
import { of as observableOf, Observable , BehaviorSubject } from 'rxjs';
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { NbLayoutDirectionService, NbLayoutDirection } from '@nebular/theme';
|
||||
|
||||
@Injectable()
|
||||
export class StateService {
|
||||
export class StateService implements OnDestroy {
|
||||
|
||||
protected layouts: any = [
|
||||
{
|
||||
|
|
@ -27,21 +28,44 @@ export class StateService {
|
|||
|
||||
protected sidebars: any = [
|
||||
{
|
||||
name: 'Left Sidebar',
|
||||
name: 'Sidebar at layout start',
|
||||
icon: 'nb-layout-sidebar-left',
|
||||
id: 'left',
|
||||
id: 'start',
|
||||
selected: true,
|
||||
},
|
||||
{
|
||||
name: 'Right Sidebar',
|
||||
name: 'Sidebar at layout end',
|
||||
icon: 'nb-layout-sidebar-right',
|
||||
id: 'right',
|
||||
id: 'end',
|
||||
},
|
||||
];
|
||||
|
||||
protected layoutState$ = new BehaviorSubject(this.layouts[0]);
|
||||
protected sidebarState$ = new BehaviorSubject(this.sidebars[0]);
|
||||
|
||||
alive = true;
|
||||
|
||||
constructor(directionService: NbLayoutDirectionService) {
|
||||
directionService.onDirectionChange()
|
||||
.pipe(takeWhile(() => this.alive))
|
||||
.subscribe(direction => this.updateSidebarIcons(direction));
|
||||
|
||||
this.updateSidebarIcons(directionService.getDirection());
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.alive = false;
|
||||
}
|
||||
|
||||
private updateSidebarIcons(direction: NbLayoutDirection) {
|
||||
const [ startSidebar, endSidebar ] = this.sidebars;
|
||||
const isLtr = direction === NbLayoutDirection.LTR;
|
||||
const startIconClass = isLtr ? 'nb-layout-sidebar-left' : 'nb-layout-sidebar-right';
|
||||
const endIconClass = isLtr ? 'nb-layout-sidebar-right' : 'nb-layout-sidebar-left';
|
||||
startSidebar.icon = startIconClass;
|
||||
endSidebar.icon = endIconClass;
|
||||
}
|
||||
|
||||
setLayoutState(state: any): any {
|
||||
this.layoutState$.next(state);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue