Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 1 commit into from

Conversation

Carreau
Copy link
Collaborator

@Carreau Carreau commented Jun 24, 2024

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.

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
Copy link
Collaborator Author

Carreau commented Jun 24, 2024

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 ?

@Carreau Carreau changed the title Add hook on theme change to allow extensions to adapt theit themes. Add hook on theme change to allow extensions to adapt their themes. Jun 26, 2024
@Carreau Carreau requested a review from gabalafou August 15, 2024 12:30
@gabalafou
Copy link
Collaborator

@gabalafou
Copy link
Collaborator

If I understand this approach correctly, it requires code in jupyter-lite-sphinx or jupyterlite to register hooks with our code.

There are two reasons why I am opposed to this approach:

  1. I believe it is not in the PyData Theme's best interest to go down the path of having a JavaScript API (in some shape or form) to maintain. As this is a theme, I think our attention would be better focussed on working well with Sphinx, making sure that our HTML and CSS produces aesthetically pleasing and accessible web pages, as well as some other things that to me seem more properly related to shipping a good theme. Maintaining JavaScript that is intended to be called by others is adding maintenance costs that could distract from the core concerns of the theme.
  2. As JupyterLite is much, much more JavaScript heavy (and savvy) than PyData Theme, I think it makes sense for us to call them on dark/light mode change, not for them to call us.

As we discussed in yesterday's czi-scientific-python sync, I'm closing this issue in favor of exploring other alternatives that are being discussed in jupyterlite/jupyterlite-sphinx#69.

@gabalafou gabalafou closed this Sep 20, 2024
@gabalafou
Copy link
Collaborator

I should add that your PR did have the intended effect of generating discussion 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants