Skip to content

Commit 0338128

Browse files
committed
fix: ensure that the CSS variables are correctly initialized
1 parent eb09807 commit 0338128

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

projects/material-css-vars/src/lib/material-css-vars.module.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {ModuleWithProviders, NgModule} from '@angular/core';
22
import {CommonModule} from '@angular/common';
33
import {MaterialCssVariablesConfig} from './model';
44
import {MATERIAL_CSS_VARS_CFG} from '../mat-css-config-token.const';
5+
import {MaterialCssVarsService} from './material-css-vars.service';
56

67
@NgModule({
78
declarations: [],
@@ -16,4 +17,8 @@ export class MaterialCssVarsModule {
1617
providers: [{provide: MATERIAL_CSS_VARS_CFG, useValue: config}]
1718
};
1819
}
20+
21+
// This is necessary so the service is constructed, even if the service is never injected
22+
constructor(private materialCssVarsService: MaterialCssVarsService) {
23+
}
1924
}

projects/material-css-vars/src/lib/material-css-vars.service.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ export class MaterialCssVarsService {
5555
};
5656
this.isAutoContrast = this.cfg.isAutoContrast;
5757

58-
if (this.cfg.isDarkTheme) {
59-
this.setDarkTheme(this.cfg.isDarkTheme);
60-
}
58+
this.setDarkTheme(this.cfg.isDarkTheme ?? false);
6159
if (this.cfg.primary) {
6260
this.setPrimaryColor(this.cfg.primary);
6361
}

0 commit comments

Comments
 (0)