Skip to content

Commit

Permalink
Fix incorrect theme regexp
Browse files Browse the repository at this point in the history
  • Loading branch information
Rochmar Nicolas (DevExpress) committed Apr 19, 2024
1 parent 53f9b67 commit d01f366
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 30 deletions.
12 changes: 2 additions & 10 deletions packages/angular/src/app/services/theme.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,15 @@ export class ThemeService {
this.currentTheme = theme;
this.isDark.next(this.currentTheme === 'dark');

currentVizTheme(this.getNewVizTheme(theme));
const regexTheme = new RegExp(`${themes.join('|')}`, 'g');
currentVizTheme(currentVizTheme().replace(regexTheme, theme));
refreshTheme();
}

getCurrentTheme() {
return this.currentTheme;
}

private getNewVizTheme(theme: Theme) {
const themeArr = currentVizTheme().split('.');
return themeArr.reduce((prev, curr) => {
if (!prev) return themeArr[0];
if (themes.includes(curr as Theme)) return `${prev}.${theme}`;
return `${prev}.${curr}`;
}, '');
}

isFluent(): boolean {
return current().includes('fluent');
}
Expand Down
12 changes: 2 additions & 10 deletions packages/react/src/theme/theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@ function getCurrentTheme(): Theme {
return window.localStorage[storageKey] || getNextTheme();
}

function getNewVizTheme(theme: Theme) {
const themeArr = currentVizTheme().split('.');
return themeArr.reduce((prev, curr) => {
if (!prev) return themeArr[0];
if (themes.includes(curr as Theme)) return `${prev}.${theme}`;
return `${prev}.${curr}`;
}, '');
}

function isThemeStyleSheet(styleSheet, theme: Theme) {
const themeMarker = `${themePrefix}${theme}`;
// eslint-disable-next-line no-undef
Expand All @@ -61,7 +52,8 @@ async function setAppTheme(newTheme?: Theme) {

switchThemeStyleSheets(themeName);

currentVizTheme(getNewVizTheme(themeName));
const regexTheme = new RegExp(`${themes.join('|')}`, 'g');
currentVizTheme(currentVizTheme().replace(regexTheme, themeName));
refreshTheme();
}

Expand Down
12 changes: 2 additions & 10 deletions packages/vue/src/theme/theme-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@ class ThemeService {
return current().includes('fluent');
}

private getNewVizTheme(theme: Theme) {
const themeArr = currentVizTheme().split('.');
return themeArr.reduce((prev, curr) => {
if (!prev) return themeArr[0];
if (themes.includes(curr as Theme)) return `${prev}.${theme}`;
return `${prev}.${curr}`;
}, '');
}

getCurrentTheme(): Theme {
return window.localStorage[this.storageKey] || getNextTheme();
}
Expand All @@ -48,7 +39,8 @@ class ThemeService {
});

this.currentTheme.value = theme;
currentVizTheme(this.getNewVizTheme(theme));
const regexTheme = new RegExp(`${themes.join('|')}`, 'g');
currentVizTheme(currentVizTheme().replace(regexTheme, theme));
refreshTheme();
}

Expand Down

0 comments on commit d01f366

Please sign in to comment.