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

Dynamic sync of dark mode with plotly plots #1248

Closed
Alexboiboi opened this issue Mar 14, 2023 · 2 comments
Closed

Dynamic sync of dark mode with plotly plots #1248

Alexboiboi opened this issue Mar 14, 2023 · 2 comments
Labels
needs: more information Needs more information from the author before we can move forward

Comments

@Alexboiboi
Copy link

Alexboiboi commented Mar 14, 2023

Hi there,

Thank you for the really nice work done here. This theme looks great ;)

Since the new darkmode feature has become really common among sphinx themes, it would be nice if there would be possible to sync the page theme with the plotly plot template. This is what plotly is doing on their on page, this looks so nice^^

The dark-mode toggle fires off some simple javascript which crawls the page looking for divs that look like they were produced with Plotly.js and then calls Plotly.react() on those divs to change some basic template parameters: https://github.com/plotly/graphing-library-docs/blob/master/all_static/javascripts/improve.js

the .js you linked to has ~340 lines of styling and IMO it doesn't make sense for us to duplicate that and try to keep it in sync with changes to plotly). But there might be a way to incorporate that .js file directly (probably with some minimal changes).

As I am not versed in javascript at all, I am not able to adapt this to another theme and I rely on the community to help out here!

Sincerely, Alex -

@12rambau
Copy link
Collaborator

That would be nice if we were able to do the same directly in the lib so if you come up with a solution please open a PR, I'll be happy to make a review. Unfortunatelly I think for maintainers that's very low priority compared to other JS devs that needs to be done (refactor colors, search as you type, etc...) So I think you'll need to dive in.

In short what you are looking for is a trigger. In our theme everything can be done listening to the html tag data-mode and data-theme attrributes.

Some examples can be found here:

@drammock
Copy link
Collaborator

As I am not versed in javascript at all, I am not able to adapt this to another theme and I rely on the community to help out here!

you might actually have better luck asking on one of the plotly forums: https://community.plotly.com/, some variant of "how can I get light/dark theming like on plotly.com when the plots are embedded in my own site?"

@12rambau 12rambau added the needs: more information Needs more information from the author before we can move forward label May 18, 2023
@12rambau 12rambau closed this as not planned Won't fix, can't repro, duplicate, stale Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: more information Needs more information from the author before we can move forward
Projects
None yet
Development

No branches or pull requests

3 participants