Skip to content

Commit

Permalink
fix: solara theming not respecting theme.js file
Browse files Browse the repository at this point in the history
  • Loading branch information
iisakkirotko committed Mar 4, 2024
1 parent d7e0daf commit c202ebd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
11 changes: 10 additions & 1 deletion solara/lab/components/theming.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Callable, cast
from typing import Callable, Dict, Union, cast

import ipyvuetify.Themes
from ipyvuetify.Themes import Theme
Expand All @@ -11,6 +11,15 @@
ipyvuetify.Themes.theme = cast(ipyvuetify.Themes.Theme, theme)


def _set_theme(themes: Union[Dict[str, Dict[str, str]], None]):
if themes is None:
return

for theme_type in themes.keys():
for k, v in themes[theme_type].items():
setattr(getattr(theme.themes, theme_type), k, v)


@component_vue("theming.vue")
def _ThemeToggle(
theme_dark: str,
Expand Down
4 changes: 3 additions & 1 deletion solara/server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,12 @@ def on_msg(msg):
app = apps[app_name]
context = kernel_context.get_current_context()
dark = args.get("dark", False)
themes = args.get("themes", None)
import ipyvuetify

from solara.lab import theme
from solara.lab.components.theming import _set_theme, theme

_set_theme(themes)
# While this usually gets set from the frontend, in solara (server) we want to know this directly at the first
# render. Also, using the same trait allows us to write code which works on all widgets platforms, instead
# or using something different when running under solara server
Expand Down
2 changes: 1 addition & 1 deletion solara/server/static/main-vuetify.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ async function solaraInit(mountId, appName) {
if (kernelId && widgetModelId) {
await widgetManager.fetchAll();
} else {
widgetModelId = await widgetManager.run(appName, {path, dark: inDarkMode()});
widgetModelId = await widgetManager.run(appName, {path, dark: inDarkMode(), themes: vuetifyThemes});
}
await solaraMount(widgetManager, mountId || 'content', widgetModelId);
skipReconnectedCheck = false;
Expand Down

0 comments on commit c202ebd

Please sign in to comment.