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

feature/theme-toggle fixes #2909 #2996

Merged
merged 9 commits into from
Jul 24, 2024

Conversation

elkcityhazard
Copy link
Contributor

a crack at adding theme toggle for underscores documentation website

@elkcityhazard
Copy link
Contributor Author

minor fixes for firefox

@elkcityhazard
Copy link
Contributor Author

@jgonggrijp I am open to feedback for improvements as well.

@elkcityhazard elkcityhazard changed the title feature/theme-toggle feature/theme-toggle fixes 2909 Jul 23, 2024
@elkcityhazard elkcityhazard changed the title feature/theme-toggle fixes 2909 feature/theme-toggle fixes #2909 Jul 23, 2024
Copy link
Collaborator

@jgonggrijp jgonggrijp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for jumping onto this so eagerly, @elkcityhazard!

I wonder whether a manual toggle is really needed. With the (prefers-color-scheme: dark) media query, doesn't everyone automatically get what they want? That being said, I like the way it looks and the fact that it remembers the setting on reload.

Of all the styling being applied in dark mode, only the filter on the logo image seems to be taking effect, and the wrong effect at that. This is what I see:

Computer set to prefer light, toggle set to light

Schermafbeelding 2024-07-23 om 23 49 43

Computer set to prefer light, toggle set to dark

Schermafbeelding 2024-07-23 om 23 49 58

Computer set to prefer dark, toggle set to dark

Schermafbeelding 2024-07-23 om 23 50 15

Computer set to prefer dark, toggle set to light

Schermafbeelding 2024-07-23 om 23 50 28

These screenshots were taken with Firefox. With Safari, I see the same thing, except that the toggle isn't visible.

I would suggest saving yourself some complexity. Remove the toggle and just rely on the media queries. If you really want to hold on to the toggle, however, I think it still needs some refinements:

  • Make sure the toggle is set to the actual mode initially. I opened the page while the computer was set to dark mode. The logo image was all white (i.e., "dark", not as intended but as expected from the above screenshots). So the page was assuming "dark", but the toggle was switched to the left side with the sun icon.
  • Keep the toggle in sight when users scroll down, for example with position: fixed. There are direct on-page links to each function, so a user landing on the page by following such a link will not see the toggle otherwise.

static/css/theme-toggle.css Outdated Show resolved Hide resolved
static/css/theme-toggle.css Outdated Show resolved Hide resolved
static/css/theme-toggle.css Outdated Show resolved Hide resolved
static/js/themeToggle.js Outdated Show resolved Hide resolved
static/css/theme-toggle.css Outdated Show resolved Hide resolved
@elkcityhazard
Copy link
Contributor Author

@jgonggrijp are you loading just the index.html? I moved the static assets into a static dir and am running locally using python http.server to serve the files.

loading index.html with firefox isn't working out for me either.

If it's easier I can refactor out the toggle and just use prefers-color-scheme:dark

here is what I am seeing for dark mode on firefox at least:

image

@elkcityhazard
Copy link
Contributor Author

@jgonggrijp removed unnecessary Javascript, removed unnecessary static dir, moved stylesheet into head of html.

awaiting feedback.

Copy link
Collaborator

@jgonggrijp jgonggrijp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better!

I didn't think of running a http server. It is good that you removed this requirement. @jashkenas designed this project (and related ones from the same era such as Backbone) with a low-tech attitude: people should need as few steps as possible to view the documentation on their own computer, run the tests, try the bleeding-edge version etcetera. I would not make that choice if I were to invent the project myself, but I respect this approach and would like to keep it all working.

Three requests:

  • Please preserve the coloring of the logo. I think this should work with the CSS filter that I suggested in my previous review.
  • (optional) As far as I'm concerned, the dark mode background could be darker. But if this offends your sense of beauty, I am willing to let go of this request.
  • Align the indentation with the rest of the code.

index.html Outdated Show resolved Hide resolved
Copy link
Collaborator

@jgonggrijp jgonggrijp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect! Thanks a lot!

@jgonggrijp jgonggrijp merged commit 1205eb5 into jashkenas:master Jul 24, 2024
2 checks passed
@jgonggrijp
Copy link
Collaborator

Released in 1.13.7.

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