widgetti / solara

A Pure Python, React-style Framework for Scaling Your Jupyter and Web Apps
https://solara.dev
MIT License
1.62k stars 105 forks source link

correct way to propagate theme for embeds #532

Open havok2063 opened 2 months ago

havok2063 commented 2 months ago

With solara 1.28.0 and either jdaviz 3.8.2 or main, the theme of jdaviz doesn't render fully when the app is sub-mounted in fastapi versus when run by solara server directly. I believe jdaviz uses voila for theming under the hood. What's the correct way to propagate the theme into Jdaviz?

With solara run --theme-variant="dark" jdaviz_embed.py, everything looks correct. Both light/dark themes render ok.

solara_server_1 28_jdaviz_main

When sub-mounted into a FastAPI app, uvicorn test:app --port 9000 --reload, parts of Jdaviz do not render correctly in either dark/light mode.

import os
from fastapi import FastAPI

os.environ['SOLARA_ROOT_PATH'] = '/solara'
os.environ['SOLARA_APP'] = 'sdss_solara.pages.jdaviz_embed'
os.environ['SOLARA_THEME_VARIANT'] = 'dark'

import solara.server.fastapi as solara_server

app = FastAPI()

@app.get("/")
def read_root():
    return {"Hello": "World"}

app.mount("/solara/", app=solara_server.app)
Screenshot 2024-03-01 at 1 22 03 PM Screenshot 2024-03-01 at 1 29 23 PM