Skip to content

Commit

Permalink
fixed a theme bug
Browse files Browse the repository at this point in the history
  • Loading branch information
hasith committed Sep 8, 2024
1 parent 848edae commit 5e1deda
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
11 changes: 3 additions & 8 deletions packages/@productled/core/src/theme/ThemeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export interface Theme {

export class ThemeManager {


private currentTheme: Theme;

constructor() {
Expand All @@ -32,17 +31,13 @@ export class ThemeManager {
return this.currentTheme;
}

// Fetch theme values from CSS variables, fallback to default if not found
getCSSVariable(variable: string): string {
const value = getComputedStyle(document.documentElement).getPropertyValue(`--${variable}`).trim();
return value || this.currentTheme[variable];
}

// Apply the theme, picking from CSS variables or default values
applyTheme(): void {
Object.keys(defaultTheme).forEach((key) => {
const themeValue = this.getCSSVariable(key);
document.documentElement.style.setProperty(`--${key}`, themeValue);
const value = getComputedStyle(document.documentElement).getPropertyValue(`--${key}`).trim();
this.currentTheme[key] = value || defaultTheme[key];
document.documentElement.style.setProperty(`--${key}`, this.currentTheme[key]);
});
}

Expand Down
4 changes: 2 additions & 2 deletions packages/@productled/tooltip/src/TooltipPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class TooltipPlugin implements Plugin {
create(element: HTMLElement, hook: Hook, theme: Theme): void {
const conf: TooltipConf = hook.config;
if (element) {
const spotlight = new Tooltip(element, theme);
spotlight.create(conf);
const tooltip = new Tooltip(element, theme);
tooltip.create(conf);
}
}
removeAll(): void {
Expand Down

0 comments on commit 5e1deda

Please sign in to comment.