Skip to content

Commit

Permalink
Add theme to root
Browse files Browse the repository at this point in the history
  • Loading branch information
cagataycivici committed Nov 27, 2023
1 parent 615613d commit 64b4b05
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/app/showcase/layout/app.main.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { AppTopBarComponent } from './topbar/app.topbar.component';
@Component({
selector: 'app-main',
template: `
<div class="layout-wrapper" [ngClass]="containerClass">
<div class="layout-wrapper" [ngClass]="containerClass" [attr.data-p-theme]="theme">
<app-news></app-news>
<app-topbar (onDarkModeSwitch)="toggleDarkMode()"></app-topbar>
<app-config (onDarkModeSwitch)="toggleDarkMode()"></app-config>
Expand Down Expand Up @@ -52,6 +52,10 @@ export class AppMainComponent {
return this.configService.state.menuActive;
}

get theme(): string {
return this.configService.config.theme;
}

get containerClass() {
return {
'layout-news-active': this.isNewsActive,
Expand Down
13 changes: 9 additions & 4 deletions src/app/showcase/layout/doc/app.docapitable.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Location } from '@angular/common';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, ViewContainerRef } from '@angular/core';
import { ChangeDetectionStrategy, Component, Input, ViewContainerRef } from '@angular/core';
import { Router } from '@angular/router';
import { AppConfigService } from '../../service/appconfigservice';

@Component({
selector: 'app-docapitable',
Expand Down Expand Up @@ -53,8 +54,8 @@ import { Router } from '@angular/router';
</ng-container>
<span
[ngClass]="{
'doc-option-dark': config.darkMode && entry[0] === 'default',
'doc-option-light': !config.darkMode && entry[0] === 'default',
'doc-option-dark': isDarkMode && entry[0] === 'default',
'doc-option-light': !isDarkMode && entry[0] === 'default',
'doc-option-default': entry[0] === 'default',
'doc-option-description': entry[0] === 'description'
}"
Expand Down Expand Up @@ -105,7 +106,11 @@ export class AppDocApiTable {

@Input() isInterface: boolean = false;

constructor(public viewContainerRef: ViewContainerRef, public router: Router, public location: Location, private cd: ChangeDetectorRef) {}
constructor(public viewContainerRef: ViewContainerRef, public router: Router, public location: Location, private configService: AppConfigService) {}

isDarkMode(): boolean {
return this.configService.config.darkMode;
}

navigate(event, param) {
if (typeof window !== undefined) {
Expand Down

0 comments on commit 64b4b05

Please sign in to comment.