Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stateful darkmode #14471

Merged
merged 4 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions src/app/showcase/doc/chart/basicdoc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { isPlatformBrowser } from '@angular/common';
import { Component, Inject, OnInit, PLATFORM_ID } from '@angular/core';
import { ChangeDetectorRef, Component, Inject, OnInit, PLATFORM_ID } from '@angular/core';
import { Code } from '../../domain/code';
import { AppConfigService } from '../../service/appconfigservice';
import { Subscription, debounceTime } from 'rxjs';

@Component({
selector: 'chart-basic-demo',
Expand All @@ -22,9 +24,20 @@ export class BasicDoc implements OnInit {

basicOptions: any;

constructor(@Inject(PLATFORM_ID) private platformId: any) {}
subscription!: Subscription;

constructor(@Inject(PLATFORM_ID) private platformId: any, private configService: AppConfigService, private cd: ChangeDetectorRef) {
this.subscription = this.configService.configUpdate$.pipe(debounceTime(25)).subscribe((config) => {
this.initChart();
this.cd.markForCheck();
});
}

ngOnInit() {
this.initChart();
}

initChart() {
if (isPlatformBrowser(this.platformId)) {
const documentStyle = getComputedStyle(document.documentElement);
const textColor = documentStyle.getPropertyValue('--text-color');
Expand All @@ -48,22 +61,24 @@ export class BasicDoc implements OnInit {
plugins: {
legend: {
labels: {
color: textColor
fontColor: textColor
}
}
},
scales: {
y: {
beginAtZero: true,
x: {
ticks: {
color: textColorSecondary
color: textColorSecondary,
font: {
weight: 500
}
},
grid: {
color: surfaceBorder,
display: false,
drawBorder: false
}
},
x: {
y: {
ticks: {
color: textColorSecondary
},
Expand Down
18 changes: 15 additions & 3 deletions src/app/showcase/doc/chart/combodoc.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { isPlatformBrowser } from '@angular/common';
import { Component, Inject, OnInit, PLATFORM_ID } from '@angular/core';
import { Component, Inject, OnInit, PLATFORM_ID, ChangeDetectorRef } from '@angular/core';
import { Code } from '../../domain/code';

import { Subscription, debounceTime } from 'rxjs';
import { AppConfigService } from '../../service/appconfigservice';
@Component({
selector: 'chart-combo-demo',
template: `
Expand All @@ -19,9 +20,20 @@ export class ComboDoc implements OnInit {

options: any;

constructor(@Inject(PLATFORM_ID) private platformId: any) {}
subscription!: Subscription;

constructor(@Inject(PLATFORM_ID) private platformId: any, private configService: AppConfigService, private cd: ChangeDetectorRef) {
this.subscription = this.configService.configUpdate$.pipe(debounceTime(25)).subscribe((config) => {
this.initChart();
this.cd.markForCheck();
});
}

ngOnInit() {
this.initChart();
}

initChart() {
if (isPlatformBrowser(this.platformId)) {
const documentStyle = getComputedStyle(document.documentElement);
const textColor = documentStyle.getPropertyValue('--text-color');
Expand Down
19 changes: 15 additions & 4 deletions src/app/showcase/doc/chart/doughnutdoc.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { isPlatformBrowser } from '@angular/common';
import { Component, Inject, OnInit, PLATFORM_ID } from '@angular/core';
import { Component, Inject, OnInit, PLATFORM_ID, ChangeDetectorRef } from '@angular/core';
import { Code } from '../../domain/code';

import { Subscription, debounceTime } from 'rxjs';
import { AppConfigService } from '../../service/appconfigservice';
@Component({
selector: 'chart-doughnut-demo',
template: `
Expand All @@ -19,9 +20,20 @@ export class DoughnutDoc implements OnInit {

options: any;

constructor(@Inject(PLATFORM_ID) private platformId: any) {}
subscription!: Subscription;

constructor(@Inject(PLATFORM_ID) private platformId: any, private configService: AppConfigService, private cd: ChangeDetectorRef) {
this.subscription = this.configService.configUpdate$.pipe(debounceTime(25)).subscribe((config) => {
this.initChart();
this.cd.markForCheck();
});
}

ngOnInit() {
this.initChart();
}

initChart() {
if (isPlatformBrowser(this.platformId)) {
const documentStyle = getComputedStyle(document.documentElement);
const textColor = documentStyle.getPropertyValue('--text-color');
Expand Down Expand Up @@ -49,7 +61,6 @@ export class DoughnutDoc implements OnInit {
};
}
}

code: Code = {
basic: `<p-chart type="doughnut" [data]="data" [options]="options"></p-chart>`,
html: `
Expand Down
18 changes: 15 additions & 3 deletions src/app/showcase/doc/chart/horizontalbardoc.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { isPlatformBrowser } from '@angular/common';
import { Component, Inject, OnInit, PLATFORM_ID } from '@angular/core';
import { Component, Inject, OnInit, PLATFORM_ID, ChangeDetectorRef } from '@angular/core';
import { Code } from '../../domain/code';

import { Subscription, debounceTime } from 'rxjs';
import { AppConfigService } from '../../service/appconfigservice';
@Component({
selector: 'chart-horizontal-bar-demo',
template: `
Expand All @@ -19,9 +20,20 @@ export class HorizontalBarDoc implements OnInit {

options: any;

constructor(@Inject(PLATFORM_ID) private platformId: any) {}
subscription!: Subscription;

constructor(@Inject(PLATFORM_ID) private platformId: any, private configService: AppConfigService, private cd: ChangeDetectorRef) {
this.subscription = this.configService.configUpdate$.pipe(debounceTime(25)).subscribe((config) => {
this.initChart();
this.cd.markForCheck();
});
}

ngOnInit() {
this.initChart()
}

initChart(){
if (isPlatformBrowser(this.platformId)) {
const documentStyle = getComputedStyle(document.documentElement);
const textColor = documentStyle.getPropertyValue('--text-color');
Expand Down
18 changes: 15 additions & 3 deletions src/app/showcase/doc/chart/linedoc.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { isPlatformBrowser } from '@angular/common';
import { Component, Inject, OnInit, PLATFORM_ID } from '@angular/core';
import { Component, Inject, OnInit, PLATFORM_ID, ChangeDetectorRef } from '@angular/core';
import { Code } from '../../domain/code';

import { Subscription, debounceTime } from 'rxjs';
import { AppConfigService } from '../../service/appconfigservice';
@Component({
selector: 'chart-line-demo',
template: `
Expand All @@ -19,9 +20,20 @@ export class LineDoc implements OnInit {

options: any;

constructor(@Inject(PLATFORM_ID) private platformId: any) {}
subscription!: Subscription;

constructor(@Inject(PLATFORM_ID) private platformId: any, private configService: AppConfigService, private cd: ChangeDetectorRef) {
this.subscription = this.configService.configUpdate$.pipe(debounceTime(25)).subscribe((config) => {
this.initChart();
this.cd.markForCheck();
});
}

ngOnInit() {
this.initChart();
}

initChart() {
if (isPlatformBrowser(this.platformId)) {
const documentStyle = getComputedStyle(document.documentElement);
const textColor = documentStyle.getPropertyValue('--text-color');
Expand Down
18 changes: 15 additions & 3 deletions src/app/showcase/doc/chart/linestyledoc.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { isPlatformBrowser } from '@angular/common';
import { Component, Inject, OnInit, PLATFORM_ID } from '@angular/core';
import { Component, Inject, OnInit, PLATFORM_ID, ChangeDetectorRef } from '@angular/core';
import { Code } from '../../domain/code';

import { Subscription, debounceTime } from 'rxjs';
import { AppConfigService } from '../../service/appconfigservice';
@Component({
selector: 'chart-line-style-demo',
template: `
Expand All @@ -19,9 +20,20 @@ export class LineStyleDoc implements OnInit {

options: any;

constructor(@Inject(PLATFORM_ID) private platformId: any) {}
subscription!: Subscription;

constructor(@Inject(PLATFORM_ID) private platformId: any, private configService: AppConfigService, private cd: ChangeDetectorRef) {
this.subscription = this.configService.configUpdate$.pipe(debounceTime(25)).subscribe((config) => {
this.initChart();
this.cd.markForCheck();
});
}

ngOnInit() {
this.initChart();
}

initChart() {
if (isPlatformBrowser(this.platformId)) {
const documentStyle = getComputedStyle(document.documentElement);
const textColor = documentStyle.getPropertyValue('--text-color');
Expand Down
18 changes: 15 additions & 3 deletions src/app/showcase/doc/chart/multiaxisdoc.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { isPlatformBrowser } from '@angular/common';
import { Component, Inject, OnInit, PLATFORM_ID } from '@angular/core';
import { Component, Inject, OnInit, PLATFORM_ID, ChangeDetectorRef } from '@angular/core';
import { Code } from '../../domain/code';

import { Subscription, debounceTime } from 'rxjs';
import { AppConfigService } from '../../service/appconfigservice';
@Component({
selector: 'chart-multi-axis-demo',
template: `
Expand All @@ -19,9 +20,20 @@ export class MultiAxisDoc implements OnInit {

options: any;

constructor(@Inject(PLATFORM_ID) private platformId: any) {}
subscription!: Subscription;

constructor(@Inject(PLATFORM_ID) private platformId: any, private configService: AppConfigService, private cd: ChangeDetectorRef) {
this.subscription = this.configService.configUpdate$.pipe(debounceTime(25)).subscribe((config) => {
this.initChart();
this.cd.markForCheck();
});
}

ngOnInit() {
this.initChart();
}

initChart() {
if (isPlatformBrowser(this.platformId)) {
const documentStyle = getComputedStyle(document.documentElement);
const textColor = documentStyle.getPropertyValue('--text-color');
Expand Down
17 changes: 15 additions & 2 deletions src/app/showcase/doc/chart/piedoc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { isPlatformBrowser } from '@angular/common';
import { Component, Inject, OnInit, PLATFORM_ID } from '@angular/core';
import { ChangeDetectorRef, Component, Inject, OnInit, PLATFORM_ID } from '@angular/core';
import { Code } from '../../domain/code';
import { Subscription, debounceTime } from 'rxjs';
import { AppConfigService } from '../../service/appconfigservice';

@Component({
selector: 'chart-pie-demo',
Expand All @@ -19,9 +21,20 @@ export class PieDoc implements OnInit {

options: any;

constructor(@Inject(PLATFORM_ID) private platformId: any) {}
subscription!: Subscription;

constructor(@Inject(PLATFORM_ID) private platformId: any, private configService: AppConfigService, private cd: ChangeDetectorRef) {
this.subscription = this.configService.configUpdate$.pipe(debounceTime(25)).subscribe((config) => {
this.initChart();
this.cd.markForCheck();
});
}

ngOnInit() {
this.initChart();
}

initChart() {
if (isPlatformBrowser(this.platformId)) {
const documentStyle = getComputedStyle(document.documentElement);
const textColor = documentStyle.getPropertyValue('--text-color');
Expand Down
17 changes: 14 additions & 3 deletions src/app/showcase/doc/chart/polarareadoc.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { isPlatformBrowser } from '@angular/common';
import { Component, Inject, OnInit, PLATFORM_ID } from '@angular/core';
import { Component, Inject, OnInit, PLATFORM_ID, ChangeDetectorRef } from '@angular/core';
import { Code } from '../../domain/code';

import { Subscription, debounceTime } from 'rxjs';
import { AppConfigService } from '../../service/appconfigservice';
@Component({
selector: 'chart-polar-area-demo',
template: `
Expand All @@ -19,9 +20,19 @@ export class PolarAreaDoc implements OnInit {

options: any;

constructor(@Inject(PLATFORM_ID) private platformId: any) {}
subscription!: Subscription;

constructor(@Inject(PLATFORM_ID) private platformId: any, private configService: AppConfigService, private cd: ChangeDetectorRef) {
this.subscription = this.configService.configUpdate$.pipe(debounceTime(25)).subscribe((config) => {
this.initChart();
this.cd.markForCheck();
});
}

ngOnInit() {
this.initChart();
}
initChart() {
if (isPlatformBrowser(this.platformId)) {
const documentStyle = getComputedStyle(document.documentElement);
const textColor = documentStyle.getPropertyValue('--text-color');
Expand Down
18 changes: 15 additions & 3 deletions src/app/showcase/doc/chart/radardoc.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { isPlatformBrowser } from '@angular/common';
import { Component, Inject, OnInit, PLATFORM_ID } from '@angular/core';
import { Component, Inject, OnInit, PLATFORM_ID, ChangeDetectorRef } from '@angular/core';
import { Code } from '../../domain/code';

import { Subscription, debounceTime } from 'rxjs';
import { AppConfigService } from '../../service/appconfigservice';
@Component({
selector: 'chart-radar-demo',
template: `
Expand All @@ -19,9 +20,20 @@ export class RadarDoc implements OnInit {

options: any;

constructor(@Inject(PLATFORM_ID) private platformId: any) {}
subscription!: Subscription;

constructor(@Inject(PLATFORM_ID) private platformId: any, private configService: AppConfigService, private cd: ChangeDetectorRef) {
this.subscription = this.configService.configUpdate$.pipe(debounceTime(25)).subscribe((config) => {
this.initChart();
this.cd.markForCheck();
});
}

ngOnInit() {
this.initChart();
}

initChart() {
if (isPlatformBrowser(this.platformId)) {
const documentStyle = getComputedStyle(document.documentElement);
const textColor = documentStyle.getPropertyValue('--text-color');
Expand Down
18 changes: 15 additions & 3 deletions src/app/showcase/doc/chart/stackedbardoc.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { isPlatformBrowser } from '@angular/common';
import { Component, Inject, OnInit, PLATFORM_ID } from '@angular/core';
import { Component, Inject, OnInit, PLATFORM_ID, ChangeDetectorRef } from '@angular/core';
import { Code } from '../../domain/code';

import { Subscription, debounceTime } from 'rxjs';
import { AppConfigService } from '../../service/appconfigservice';
@Component({
selector: 'chart-stacked-bar-demo',
template: `
Expand All @@ -19,9 +20,20 @@ export class StackedBarDoc implements OnInit {

options: any;

constructor(@Inject(PLATFORM_ID) private platformId: any) {}
subscription!: Subscription;

constructor(@Inject(PLATFORM_ID) private platformId: any, private configService: AppConfigService, private cd: ChangeDetectorRef) {
this.subscription = this.configService.configUpdate$.pipe(debounceTime(25)).subscribe((config) => {
this.initChart();
this.cd.markForCheck();
});
}

ngOnInit() {
this.initChart();
}

initChart() {
if (isPlatformBrowser(this.platformId)) {
const documentStyle = getComputedStyle(document.documentElement);
const textColor = documentStyle.getPropertyValue('--text-color');
Expand Down
Loading
Loading