jupyterlite-sphinx icon indicating copy to clipboard operation
jupyterlite-sphinx copied to clipboard

Provide a theme toggle plugin by default

Open martinRenou opened this issue 1 year ago • 2 comments

Problem

As suggested in https://github.com/pydata/pydata-sphinx-theme/issues/745#issuecomment-1905560716

@jtpio just linked this in another thread https://jupyterlite.readthedocs.io/en/stable/howto/configure/advanced/iframe.html

It showcases an example making a jupyterlite plugin allowing to set the theme from outside of the iframe.

We could provide such a plugin by default in jupyterlite-sphinx, allowing pydata-sphinx-theme to notify jupytelite iframes of a potential theme change.

Not only We could support setting the theme using a theme name, but the message could probably also contain css variable values as a dictionary.

martinRenou avatar Jan 23 '24 08:01 martinRenou

I think this is possible via the jupyterlab-theme-toggler extension now in the JupyterLite UI. But I don't think it provides a hook to set the theme from outside the iframe yet...?

agriyakhetarpal avatar Jan 13 '25 16:01 agriyakhetarpal

From outside the IFrame there is the theme parameter, which can specified when embedding the IFrame: https://jupyterlite.readthedocs.io/en/stable/quickstart/embed-repl.html#themes

Then when it comes to changing the theme after the IFrame is displayed, we can indeed use the approach linked above, or a helper package like https://github.com/TileDB-Inc/jupyter-iframe-commands to execute arbitrary commands in the IFrame, from a host page.

jtpio avatar Jan 13 '25 17:01 jtpio