GitLab steht aufgrund wichtiger Wartungsarbeiten am Montag, den 8. März, zwischen 17:00 und 19:00 Uhr nicht zur Verfügung.

Adds additional environment settings to set the default theme and to toggle the dark mode check

parent 856de022
......@@ -54,7 +54,7 @@ export const DefaultSettings = {
restrictToCasLogin: false,
selectedNicks: [],
},
theme: environment.availableQuizThemes[0],
theme: environment.defaultTheme,
readingConfirmationEnabled: true,
showResponseProgress: true,
confidenceSliderEnabled: true,
......
......@@ -23,4 +23,6 @@ export interface IEnvironment {
loginMechanism: Array<LoginMechanism>;
persistQuizzes: boolean;
availableQuizThemes: Array<QuizTheme>;
defaultTheme: QuizTheme;
darkModeCheckEnabled: boolean;
}
......@@ -56,7 +56,7 @@ export class RootComponent implements OnInit, AfterViewInit {
) {
this.themeService.themeChanged.pipe(takeUntil(this._destroy), distinctUntilChanged(), filter(t => !!t)).subscribe(themeName => {
if (String(themeName) === 'default') {
themeName = environment.availableQuizThemes[0];
themeName = environment.defaultTheme;
}
this.loadExternalStyles(`/theme-${themeName}.css`).then(() => {
this.initializeCookieConsent(themeName);
......
......@@ -20,9 +20,6 @@ export class ThemesService {
public readonly themeChanged: EventEmitter<QuizTheme> = new EventEmitter<QuizTheme>();
private _currentTheme: QuizTheme;
get themes(): Array<ITheme> {
return this._themes;
}
get currentTheme(): QuizTheme {
return this._currentTheme;
......@@ -33,6 +30,11 @@ export class ThemesService {
}
private _themes: Array<ITheme> = environment.availableQuizThemes.map(t => themes.find(theme => theme.id === t));
get themes(): Array<ITheme> {
return this._themes;
}
private readonly _defaultTheme: QuizTheme;
constructor(
......@@ -43,7 +45,9 @@ export class ThemesService {
private storageService: StorageService,
private i18nService: I18nService,
) {
this._defaultTheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? QuizTheme.Blackbeauty : environment.availableQuizThemes[0];
this._defaultTheme = environment.darkModeCheckEnabled && //
window.matchMedia('(prefers-color-scheme: dark)').matches ? //
QuizTheme.Blackbeauty : environment.defaultTheme;
this.storageService.stateNotifier.pipe(filter(val => val === DbState.Initialized)).subscribe(() => {
this.initTheme();
......@@ -70,7 +74,7 @@ export class ThemesService {
const themeConfig = await Promise.all(themePromises);
let usedTheme = themeConfig[0] ? themeConfig[0].value : themeConfig[1] ? themeConfig[1].value : themeConfig[2];
if (usedTheme === 'default') {
usedTheme = environment.availableQuizThemes[0];
usedTheme = environment.defaultTheme;
}
const themeDataset = document.getElementsByTagName('html').item(0).dataset['theme'];
......
......@@ -33,6 +33,8 @@ export const environment: IEnvironment = {
QuizTheme.MaterialBlue,
QuizTheme.SpiritualPurple, QuizTheme.GreyBlueLime,
],
defaultTheme: QuizTheme.Material,
darkModeCheckEnabled: true,
};
export enum DEVICE_TYPES {
......
......@@ -27,6 +27,8 @@ export const environment: IEnvironment = {
showPublicQuizzes: false,
persistQuizzes: false,
availableQuizThemes: [QuizTheme.WestermannBlue, QuizTheme.Blackbeauty],
defaultTheme: QuizTheme.WestermannBlue,
darkModeCheckEnabled: false,
};
export enum DEVICE_TYPES {
......
......@@ -31,6 +31,8 @@ export const environment: IEnvironment = {
QuizTheme.DecentBlue, QuizTheme.MaterialHope, QuizTheme.MaterialBlue, QuizTheme.SpiritualPurple,
QuizTheme.GreyBlueLime,
],
defaultTheme: QuizTheme.Material,
darkModeCheckEnabled: true,
};
export enum DEVICE_TYPES {
......
......@@ -32,6 +32,8 @@ export const environment: IEnvironment = {
showPublicQuizzes: false,
persistQuizzes: false,
availableQuizThemes: [QuizTheme.WestermannBlue, QuizTheme.Material, QuizTheme.Blackbeauty],
defaultTheme: QuizTheme.WestermannBlue,
darkModeCheckEnabled: true,
};
export enum DEVICE_TYPES {
......
......@@ -27,6 +27,8 @@ export const environment: IEnvironment = {
showPublicQuizzes: false,
persistQuizzes: false,
availableQuizThemes: [QuizTheme.WestermannBlue, QuizTheme.Blackbeauty],
defaultTheme: QuizTheme.WestermannBlue,
darkModeCheckEnabled: false,
};
export enum DEVICE_TYPES {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment