From 5e1deda8d44347e2327e329ceb57ec5bf4eb5d26 Mon Sep 17 00:00:00 2001 From: Hasith Yaggahavita Date: Sun, 8 Sep 2024 17:35:27 +0530 Subject: [PATCH] fixed a theme bug --- packages/@productled/core/src/theme/ThemeManager.ts | 11 +++-------- packages/@productled/tooltip/src/TooltipPlugin.ts | 4 ++-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/packages/@productled/core/src/theme/ThemeManager.ts b/packages/@productled/core/src/theme/ThemeManager.ts index fc5298d..d66e908 100644 --- a/packages/@productled/core/src/theme/ThemeManager.ts +++ b/packages/@productled/core/src/theme/ThemeManager.ts @@ -20,7 +20,6 @@ export interface Theme { export class ThemeManager { - private currentTheme: Theme; constructor() { @@ -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]); }); } diff --git a/packages/@productled/tooltip/src/TooltipPlugin.ts b/packages/@productled/tooltip/src/TooltipPlugin.ts index 1e06749..831cc54 100644 --- a/packages/@productled/tooltip/src/TooltipPlugin.ts +++ b/packages/@productled/tooltip/src/TooltipPlugin.ts @@ -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 {