diff --git a/src/sageworks/utils/theme_manager.py b/src/sageworks/utils/theme_manager.py index 0a6545f86..3aeed2c5c 100644 --- a/src/sageworks/utils/theme_manager.py +++ b/src/sageworks/utils/theme_manager.py @@ -100,13 +100,17 @@ def set_theme(self, theme_name: str): pio.templates.default = "custom_template" # Update current theme and log - self.current_theme = theme_name + self.current_theme = {"name": theme_name, "plotly_template": template} self.log.info(f"Theme set to '{theme_name}'") - def get_current_theme(self) -> str: + def get_current_theme(self) -> dict: """Get the name of the current theme.""" return self.current_theme + def get_current_template(self) -> dict: + """Get the current Plotly template.""" + return self.current_theme["plotly_template"] + def get_current_css_files(self) -> list[str]: """ Get the list of CSS files for the current theme. @@ -115,10 +119,11 @@ def get_current_css_files(self) -> list[str]: list[str]: List of CSS files for the current theme. """ # Bootstrap CDN and dbc.min.css - base_css = [self.bootstrap_themes[self.current_theme], self.dbc_css] + theme_name = self.current_theme["name"] + base_css = [self.bootstrap_themes[theme_name], self.dbc_css] # Use Flask route for custom.css if it exists - theme = self.available_themes[self.current_theme] + theme = self.available_themes[theme_name] custom_css = ["/custom.css"] if theme["custom_css"] else [] return base_css + custom_css @@ -130,6 +135,7 @@ def register_css_route(self, app): Args: app: The Dash app (to access the Flask server). """ + @app.server.route("/custom.css") def serve_custom_css(): theme = self.available_themes[self.current_theme] @@ -154,4 +160,4 @@ def _reload_css(self, css_file: Path): theme_manager.set_theme("light") print("Theme switched to:", theme_manager.get_current_theme()) - print("CSS Files for Current Theme:", theme_manager.get_current_css_files()) \ No newline at end of file + print("CSS Files for Current Theme:", theme_manager.get_current_css_files())