Skip to content

Commit d01ccb6

Browse files
committed
fix(finjs): add option to hide theme switch for sample
1 parent 904398f commit d01ccb6

7 files changed

Lines changed: 81 additions & 5 deletions

File tree

projects/app-lob/src/app/grid-finjs/controllers.component.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<div class="controls-wrapper">
22
<div class="controls-holder">
33
<div class="switches">
4+
<div class="test" *ngIf="isThemeSwitchVisible">
5+
<div class="control-item" >
6+
<igx-switch class="theme-switch" [checked]="false" [(ngModel)]="theme" (change)="onChange('theme', $event)">Dark</igx-switch>
7+
</div>
8+
</div>
49
<div class="control-item">
510
<igx-switch [checked]="true" (change)="onChange('grouped', $event)" color="blue"
611
cssClass="finjs-sample-switch">
@@ -33,4 +38,4 @@
3338
~{{volume/5}} records updated.</span>
3439
</div>
3540
<igx-toast #toast (onClosed)="handleHidden()"></igx-toast>
36-
</div>
41+
</div>

projects/app-lob/src/app/grid-finjs/controllers.component.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Component, EventEmitter, OnDestroy, OnInit, Output, ViewChild } from '@angular/core';
1+
import { Component, ElementRef, EventEmitter, OnDestroy, OnInit, Output, ViewChild } from '@angular/core';
2+
import { ActivatedRoute } from '@angular/router';
23
import {
34
IButtonGroupEventArgs, IChangeSwitchEventArgs, IgxButtonGroupComponent,
45
IgxSliderComponent, IgxToastComponent, ISliderValueChangeEventArgs, VerticalAlignment }
@@ -23,6 +24,8 @@ export class ControllerComponent implements OnInit, OnDestroy {
2324
@Output() public playAction = new EventEmitter<{ action: string }>();
2425

2526
public volume = 1000;
27+
public theme = false;
28+
public isThemeSwitchVisible = true;
2629
public frequency = 500;
2730
public controls = [
2831
{
@@ -51,6 +54,8 @@ export class ControllerComponent implements OnInit, OnDestroy {
5154
private frequencyChanged$: Observable<ISliderValueChangeEventArgs>;
5255
private frequencyChangedSubscription: Subscription;
5356

57+
constructor(private router: ActivatedRoute, private elRef: ElementRef) {}
58+
5459
public ngOnInit(): void {
5560
this.volumeChanged$ = this.volumeSlider.valueChange.pipe(debounce(() => timer(200)));
5661
this.volumeChangedSubscription = this.volumeChanged$.subscribe(x => this.volumeChanged.emit(this.volumeSlider.value as number));
@@ -60,6 +65,11 @@ export class ControllerComponent implements OnInit, OnDestroy {
6065
.subscribe(() => this.frequencyChanged.emit(this.intervalSlider.value as number));
6166

6267
this.toast.positionSettings.verticalDirection = VerticalAlignment.Middle;
68+
69+
// Hide theme switcher
70+
if (this.router.snapshot.queryParamMap.get('theme-switch')) {
71+
this.isThemeSwitchVisible = false;
72+
}
6373
}
6474

6575
public ngOnDestroy(): void {

projects/app-lob/src/app/grid-finjs/main.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="main__wrapper igx-scrollbar">
1+
<div class="main__wrapper igx-scrollbar" [class.fin-dark-theme]="darkTheme">
22
<app-finjs-controllers #controllers
33
(switchChanged)="onSwitchChanged($event)"
44
(volumeChanged)="onVolumeChanged($event)"

projects/app-lob/src/app/grid-finjs/main.component.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { AfterViewInit, Component, HostBinding, OnDestroy, ViewChild } from '@angular/core';
2+
import { Router } from '@angular/router';
23
import { IgxDialogComponent, IgxOverlayOutletDirective, OverlaySettings } from 'igniteui-angular';
34
import { IgxCategoryChartComponent } from 'igniteui-angular-charts';
45
import { Stock } from '../data/financialData';
@@ -22,12 +23,17 @@ export class FinJSDemoComponent implements OnDestroy, AfterViewInit {
2223
closeOnOutsideClick: true
2324
};
2425

26+
@HostBinding('class.dark-theme')
27+
public darkTheme = false;
28+
29+
2530
public properties = ['price', 'country'];
2631
public chartData: Stock[] = [];
2732
public volume = 1000;
2833
public frequency = 500;
2934
private _timer: ReturnType<typeof setInterval>;
3035

36+
3137
public onSwitchChanged(event: { action: string; value: boolean }): void {
3238
switch (event.action) {
3339
case 'toolbar': {
@@ -38,6 +44,10 @@ export class FinJSDemoComponent implements OnDestroy, AfterViewInit {
3844
this.finGrid.toggleGrouping();
3945
break;
4046
}
47+
case 'theme': {
48+
this.darkTheme = event.value;
49+
break;
50+
}
4151
default: break;
4252
}
4353
}

projects/app-lob/src/app/treegrid-finjs/tree-grid-finjs-sample.component.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
@use '../../variables' as *;
22

33
:host ::ng-deep {
4+
.fin-dark-theme {
5+
.finjs-slider,
6+
.sample-toolbar,
7+
.group-drop-area {
8+
color: contrast-color(null, 'gray', 900);
9+
}
10+
11+
.group-drop-area {
12+
background: color(null, 'surface', 500);
13+
}
14+
}
15+
416
.finjs-icons {
517
display: flex;
618
align-items: center;

projects/app-lob/src/app/treegrid-finjs/tree-grid-finjs-sample.component.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ export class TreeGridFinJSComponent implements OnDestroy, OnInit {
2121
@ViewChild('slider2', { static: true }) public intervalSlider!: IgxSliderComponent;
2222
@ViewChild(IgxOverlayOutletDirective, { static: true }) public outlet!: IgxOverlayOutletDirective;
2323

24+
@HostBinding('class.dark-theme')
25+
public theme = false;
26+
2427
public showToolbar = true;
2528
public selectionMode = 'multiple';
2629
public volume = 1000;
@@ -159,6 +162,19 @@ export class TreeGridFinJSComponent implements OnDestroy, OnInit {
159162
return value ? '$' + value.toFixed(3) : '';
160163
}
161164

165+
/**
166+
* the below code is needed when accessing the sample through the navigation
167+
* it will style all the space below the sample component element, but not the navigation menu
168+
*/
169+
public onThemeChanged(event: any) {
170+
const parentEl = this.parentComponentEl();
171+
if (event.checked && parentEl.classList.contains('main')) {
172+
parentEl.classList.add('fin-dark-theme');
173+
} else {
174+
parentEl.classList.remove('fin-dark-theme');
175+
}
176+
}
177+
162178
public ngOnDestroy() {
163179
this.stopFeed();
164180
}

projects/app-lob/src/styles.scss

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,41 @@
11
@use 'igniteui-angular/theming' as *;
22
@use 'variables' as *;
33
@use 'app-layout';
4-
54
/* autoprefixer grid: on */
65
html,
76
body {
87
height: 100%;
98
overflow: hidden;
109
margin: 0;
1110
}
12-
1311
@include core();
1412
@include typography();
1513
@include theme(
1614
$palette: $palette,
1715
$schema: $schema
1816
);
17+
:root {
18+
@include palette($palette);
19+
}
20+
.light-theme {
21+
@include light-theme($palette);
22+
}
23+
.dark-theme {
24+
background: #333;
25+
color: #fff;
26+
@include dark-theme(
27+
$palette: $green-palette
28+
);
29+
.grid-chart-contextmenu-wrapper {
30+
@include fluent-dark-theme($fluent-excel-palette);
31+
}
32+
}
33+
34+
.fin-dark-theme {
35+
@include dark-theme($green-palette);
36+
background: #333;
37+
38+
::-moz-placeholder {
39+
opacity: 1;
40+
}
41+
}

0 commit comments

Comments
 (0)