Skip to content

Documentation: dark theme & images #103960

Description

@denballakh

Documentation

Starting from version 3.12, the Docs now have a dark theme. However, this feature does not affect the images. As an example, please visit https://docs.python.org/3.12/library/pathlib.html.
The page contains an image of an inheritance tree. In the dark theme, the rectangles remain white, which is not visually appealing: image

To address this issue, I propose making these images compatible with the dark theme:
example of image with dark theme

Although I'm not an expert in HTML/CSS, a quick search suggests that adding style="filter:invert(1)" to <img> element can help achieve this.

Linked PRs

Activity

  1. denballakh commented on Apr 28, 2023

    @denballakh
    ContributorAuthor

    I think this issue is also relevant to https://github.com/python/python-docs-theme

    Also filter: hue-rotate(180deg) invert(1) instead of filter: invert(1) works a bit better.
    Without hue rotation:
    image
    With hue rotation:
    image

  2. hugovk commented on Apr 28, 2023

    @hugovk
    Member

    Thanks for the report.

    Images/pages to review:

    howto/logging.rst - logging_flow.png

    https://docs.python.org/3.12/howto/logging.html#logging-flow
    Image has white background and no transparency, but filter:invert(1) would help

    image

    image

    using/windows.rst - win_installer.png

    https://docs.python.org/3.12/using/windows.html#installation-steps
    The installer image above. We might need to leave this one because it's a screenshot and might not want to modify the logo colours:

    image

    Or, the actual installer dialog now also supports dark mode (at least on macOS, also Windows?), perhaps we could create new screenshots and show the relevant one?

    library/pathlib.rst - pathlib-inheritance.png

    https://docs.python.org/3.12/library/pathlib.html
    The inheritance tree above. Needs fixing, e.g. filter:invert(1)

    library/tkinter.messagebox.rst - tk_msg.png

    https://docs.python.org/3.12/library/tkinter.messagebox.html
    Image has white background and no transparency:

    image

    filter:invert(1) might work, but it's a screenshot so maybe we don't want to show a dark mode version if it doesn't have one in reality (I've not checked).

    image

    library/hashlib.rst - hashlib-blake2-tree.png

    https://docs.python.org/3.12/library/hashlib.html#creating-hash-objects
    White background, no transparency, can be inverted:

    image

    image

  3. hugovk commented on Apr 28, 2023

    @hugovk
    Member

    See also python/peps#2409 and python/peps#2949 for how we dealt with some images for dark mode on the PEPs site.

  4. hugovk commented on Apr 28, 2023

    @hugovk
    Member

    Please see PR python/python-docs-theme#128 to add the class to the theme.

  5. hugovk commented on Apr 28, 2023

    @hugovk
    Member

    And please see PR #103983 to add the class to the three diagrams.

    I didn't invert the installer or tkinter.messagebox screenshots shown in #103960 (comment) because they're screenshots of real dialogs and inverting would be misleading and potentially confusing. It's okay to have some lighter screenshots in dark mode.

  6. barneygale commented on Apr 29, 2023

    @barneygale
    Contributor

    Inverting the hashlib image makes the shaded areas almost invisible!

  7. hugovk commented on Apr 29, 2023

    @hugovk
    Member

    In contrast (no pun intended) to the above, here's how PR #103983 renders it with inverted brightness, but not inverted contrast:

    image

    It's not so visible in the original:

    image

    What does the shading actually signify here?

  8. added a commit that references this issue on May 10, 2023
  9. added a commit that references this issue on May 10, 2023
  10. added a commit that references this issue on May 10, 2023
  11. hauntsaninja commented on May 26, 2023

    @hauntsaninja
    Contributor

    Thanks for fixing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions