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

Degrade gracefully when JavaScript is disabled #1146

Commits on Feb 8, 2023

  1. Degrade gracefully when JavaScript is disabled

    Support for light/dark themes has been implemented using a `data-theme`
    attribute set on the `<html/>` tag. As this attribute is set using
    JavaScript, this meant that it was left unset when visitors had
    JavaScript disabled. This resulted in several important CSS rules not
    being matched and a “broken feeling” due to wrong colors, and logo or
    images shown twice.
    
    To better support browsers with JavaScript disabled:
    
    1. Add the same CSS rules as for the light theme when the `data-theme`
       attribute is not set. This creates a safe fallback in every
       situation.
    2. If `default_mode` is set, write its value to the `data-theme` attribute
       when writing the HTML files. This enables theme users to present
       their preferred mode to visitors with JavaScript disabled.
    3. Use JavaScript to add the search, theme switcher and version switcher
       interface as they require JavaScript to work. This avoid unusable UI
       elements to be shown to visitors with JavaScript disabled.
    4. Use JavaScript to write the logo for the “other theme”, depending on
       the value of `default_mode`, defaulting to “light” if unset.
    5. Use JavaScript to write the announcement block to the HTML if the
       announcement is a remote URL.
    
    While this last change might seem redundant considering the other ones,
    it does make the resulting pages better for search engines and text
    browsers.
    
    Closes: pydata#1145
    Jérémy Bobbio (Lunar) committed Feb 8, 2023
    Configuration menu
    Copy the full SHA
    4ed402f View commit details
    Browse the repository at this point in the history