pydata / pydata-sphinx-theme

A clean, three-column Sphinx theme with Bootstrap for the PyData community
https://pydata-sphinx-theme.readthedocs.io
BSD 3-Clause "New" or "Revised" License
557 stars 300 forks source link

Add hook on theme change to allow extensions to adapt their themes. #1900

Open Carreau opened 1 week ago

Carreau commented 1 week ago

Mostly thinking of jupyter-lite-sphinx which wants to sync the JupyterLab theme with pydata one.

I'm not sure this is the right approach, but at least that should get the discussion started.

Carreau commented 1 week ago

This should allow something like:

    if (window.pst_theme_change_hooks == undefined) {
        window.pst_theme_change_hooks = [];
    }
    window.pst_theme_change_hooks.push(function(evt){console.log('switched to theme', evt)});

Or should we have a register_hook function that ensure that the hook re triggered at least once when they are registered after the mode has already be set ?