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

Book theme options to specify theme and disable theme toggle button #522

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

gvarnavi
Copy link

Adds the following two options to the book-theme:

site:
  template: book-theme
  options:
    theme: 'dark'
    hide_theme_toggle: true
  • theme can either be 'light' or 'dark' and forces the initial theme (as opposed to using local storage)
  • hide_theme_toggle is a boolean and disables the top-right theme toggle

Copy link

changeset-bot bot commented Jan 14, 2025

⚠️ No Changeset found

Latest commit: 536dac3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@agoose77
Copy link
Collaborator

agoose77 commented Jan 14, 2025

Hi @gvarnavi,

Thank you for opening this PR!

Theme selectors are an important part of accessibility (though there is nuance to that point). Is there a particular reason that you want to disable this preference for your users of the theme?

@gvarnavi
Copy link
Author

Thanks for the prompt reply @agoose77 !

The real use case is that I started modifying the book-theme to achieve a stripped-down "presentation-like" look, similar to what I've been using with Observable Framework.
I was pleasantly surprised to find out I could get most of the way there with site options such as

  template: book-theme
  options:
    logo: ./figures/logo.svg
    logo_dark: ./figures/logo_dark.svg
    hide_outline: true
    hide_title_block: true
    hide_search: true

But wanted more customization to completely style/disable the header, hence the hide_theme_toggle option.

As for locking in the theme, we use a lot of interactive matplotlib figures for the Elemental Microscopy journal, which are challenging to have support both light/dark themes both when static (we should at the very least add a placeholder_dark attribute to the figure directives), but also when dynamic (due to matplotlib not providing transparent backgrounds, and the Jupyter kernel presumably not able to access the current theme/theme changes).

I appreciate the accessibility point, but that requires a level of sophistication I don't think is currently easy to support for interactive figures (in contrast e.g. to MyST tables, which look great in both).

Thanks again for looking into this!

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