Skip to content

Commit

Permalink
Merge pull request #9 from irohalab/bugfix/ssr-support
Browse files Browse the repository at this point in the history
Fix darkThemeService in server
  • Loading branch information
EverettSummer authored Jul 28, 2024
2 parents d479f11 + 623d957 commit d15f92e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "deneb-ui",
"version": "4.0.1",
"version": "4.1.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"start": "ng serve --project Deneb-UI-Demo",
"build": "npm run build:deneb-ui",
"build:deneb-ui": "ng build --project @irohalab/Deneb-UI",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
Expand Down
2 changes: 1 addition & 1 deletion projects/irohalab/deneb-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@irohalab/deneb-ui",
"version": "4.0.1",
"version": "4.1.0",
"description": "Building blocks for mira-ui",
"author": "Everett Summer",
"license": "Apache-2.0",
Expand Down
11 changes: 7 additions & 4 deletions projects/irohalab/deneb-ui/src/dark-theme.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Injectable, OnDestroy } from '@angular/core';
import { Inject, Injectable, OnDestroy, PLATFORM_ID } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs';
import { isPlatformBrowser } from '@angular/common';

export const DARK_THEME = 'dark_theme';
export const LIGHT_THEME = 'light_theme';
Expand All @@ -17,9 +18,11 @@ export class DarkThemeService implements OnDestroy {
return this._themeChangeSubject.asObservable();
}

constructor() {
this.checkTheme();
this.initGlobalListener();
constructor(@Inject(PLATFORM_ID) platformId: object) {
if (isPlatformBrowser(platformId)) {
this.checkTheme();
this.initGlobalListener();
}
}

public changeTheme(theme: ThemeName): void {
Expand Down

0 comments on commit d15f92e

Please sign in to comment.