Skip to content

Commit 607ca76

Browse files
authored
Merge pull request #2880 from IgniteUI/snovoselski/grid-finjs-dock-manager-vnext
fix(dock-manager): update logic for toggle dark theme
2 parents 12624ec + 97b2948 commit 607ca76

3 files changed

Lines changed: 22 additions & 8 deletions

File tree

projects/app-lob/src/app/grid-finjs-dock-manager/grid-finjs-dock-manager.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<igc-dockmanager #dock class="dock-m-position igx-scrollbar" [layout]="docLayout">
2-
<div slot="actionPane" style="height: 100%; padding: 20px;">
2+
<div class="actionPane" slot="actionPane" style="height: 100%; padding: 20px;">
33
<div class="actionItem">
4-
Change theme: <br/> <igx-switch [(ngModel)]="theme">Dark Mode</igx-switch>
4+
Change theme: <br/> <igx-switch [(ngModel)]="isDarkTheme">Dark Mode</igx-switch>
55
</div>
66
<div class="actionItem">
77
Start/Stop live data: <igx-switch [(ngModel)]="liveData" (change)="streamData($event)">{{ liveData ===
@@ -166,4 +166,4 @@
166166
<ng-template #host gridHost>
167167
</ng-template>
168168
</igc-dockmanager>
169-
<div class="{{theme ? 'dark-theme' : 'light-theme'}}" #filteringOverlayOutlet="overlay-outlet" igxOverlayOutlet></div>
169+
<div class="dark-theme" #filteringOverlayOutlet="overlay-outlet" igxOverlayOutlet></div>

projects/app-lob/src/app/grid-finjs-dock-manager/grid-finjs-dock-manager.component.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable max-len */
2-
import { AfterViewInit, ChangeDetectorRef, Component, ComponentFactoryResolver, ElementRef, HostBinding, OnDestroy, OnInit, TemplateRef, ViewChild, ViewContainerRef, ViewEncapsulation } from '@angular/core';
2+
import { AfterViewInit, ChangeDetectorRef, Component, ComponentFactoryResolver, ElementRef, Renderer2, OnDestroy, OnInit, DoCheck, TemplateRef, ViewChild, ViewContainerRef, ViewEncapsulation } from '@angular/core';
33
import { AbsoluteScrollStrategy, ConnectedPositioningStrategy, DefaultSortingStrategy, IgxColumnComponent, IgxGridComponent, IgxOverlayOutletDirective, IgxSelectComponent, OverlaySettings, SortingDirection } from 'igniteui-angular';
44
import { IgcDockManagerLayout, IgcDockManagerPaneType, IgcSplitPane, IgcSplitPaneOrientation } from 'igniteui-dockmanager';
55
import { Subject } from 'rxjs';
@@ -14,7 +14,7 @@ import { DockSlotComponent, GridHostDirective } from './dock-slot.component';
1414
templateUrl: './grid-finjs-dock-manager.component.html',
1515
styleUrls: ['./grid-finjs-dock-manager.component.scss']
1616
})
17-
export class GridFinJSDockManagerComponent implements OnInit, OnDestroy, AfterViewInit {
17+
export class GridFinJSDockManagerComponent implements OnInit, OnDestroy, AfterViewInit, DoCheck {
1818
@ViewChild('grid1', { static: true }) public grid1: IgxGridComponent;
1919
@ViewChild('grid2', { static: true }) public grid2: IgxGridComponent;
2020
@ViewChild(GridHostDirective) public host: GridHostDirective;
@@ -25,8 +25,7 @@ export class GridFinJSDockManagerComponent implements OnInit, OnDestroy, AfterVi
2525
@ViewChild('freq', { read: IgxSelectComponent }) public selectFrequency: IgxSelectComponent;
2626
@ViewChild(IgxOverlayOutletDirective) outlet: IgxOverlayOutletDirective;
2727

28-
@HostBinding('class')
29-
public theme = 'dark-theme';
28+
public isDarkTheme = true;
3029

3130
public frequencyItems: number[] = [300, 600, 900];
3231
public frequency = this.frequencyItems[1];
@@ -143,7 +142,7 @@ export class GridFinJSDockManagerComponent implements OnInit, OnDestroy, AfterVi
143142

144143
private destroy$ = new Subject<any>();
145144

146-
constructor(public dataService: SignalRService, private paneService: FloatingPanesService, private cdr: ChangeDetectorRef, private componentFactoryResolver: ComponentFactoryResolver) {}
145+
constructor(public dataService: SignalRService, private paneService: FloatingPanesService, private cdr: ChangeDetectorRef, private componentFactoryResolver: ComponentFactoryResolver, private elementRef: ElementRef, private renderer:Renderer2) {}
147146

148147
public ngOnInit() {
149148
this.dataService.startConnection(this.frequency, this.dataVolume, true, false);
@@ -161,6 +160,17 @@ export class GridFinJSDockManagerComponent implements OnInit, OnDestroy, AfterVi
161160
this.destroy$.complete();
162161
}
163162

163+
public ngDoCheck() {
164+
if (this.isDarkTheme) {
165+
this.renderer.removeClass(this.elementRef.nativeElement, 'light-theme');
166+
this.renderer.addClass(this.elementRef.nativeElement, 'dark-theme');
167+
}
168+
else {
169+
this.renderer.removeClass(this.elementRef.nativeElement, 'dark-theme');
170+
this.renderer.addClass(this.elementRef.nativeElement, 'light-theme');
171+
}
172+
}
173+
164174
public ngAfterViewInit() {
165175
// This 500ms timeout is used as a workaround for StackBlitz ExpressionChangedAfterItHasBeenChecked Error
166176
setTimeout(() => {

projects/app-lob/src/styles.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ $dark-grid-theme: igx-grid-theme(
4343
.grid-chart-contextmenu-wrapper {
4444
@include igx-fluent-dark-theme($fluent-excel-palette);
4545
}
46+
47+
.actionPane {
48+
background-color: #212121;
49+
}
4650
}
4751

4852
.fin-dark-theme {

0 commit comments

Comments
 (0)