Skip to content

Add Dark Mode and Theme Toggle Support to Trac - #309

Open
kehach07 wants to merge 6 commits into
django:mainfrom
kehach07:darkmode
Open

Add Dark Mode and Theme Toggle Support to Trac#309
kehach07 wants to merge 6 commits into
django:mainfrom
kehach07:darkmode

Conversation

@kehach07

Copy link
Copy Markdown
Contributor

Summary

This draft PR introduces dark mode support and theme toggle functionality to Django's Trac instance (code.djangoproject.com), aligning its design, color tokens, and toggle behavior with the main djangoproject.com website.

Work done under Google Summer of Code (GSoC) 2026 with the Django Software Foundation.


Key Changes

  • Theme Toggle Component: Implemented a 3-state switcher (Auto $\rightarrow$ Light $\rightarrow$ Dark) matching the upstream toggle behavior on the main Django website.
  • Template Updates: Updated trac-env/templates/site_header.html and site_head.html to inject theme markup, include accessibility hooks, and load dark mode scripts.
  • Stylesheets & Tokens: Created scss/trachacks.scss and darkmode.css with clean CSS custom properties for surfaces, borders, ticket tables, query builders, and admin views.
  • Accessibility Enhancements: Added accessible labels (aria-label, visible focus outlines, and compliant .visually-hidden styling) and fixed contrast ratios across key pages.
  • Dev Workflow & Docs: Updated README.rst and docker-entrypoint.sh for smoother static asset builds and local plugin registration checks.

Testing & Verification

  • Verified theme switching and state persistence across page refreshes.
  • Confirmed support for system preference detection (prefers-color-scheme).
  • Tested keyboard accessibility and screen-reader announcements using Accessibility Insights for Web.
  • Verified views locally across /query, /ticket, and /admin.

Related Links & References

- Improve contrast for query count (.numrows) and inline filter buttons
- Fix text and link contrast for breadcrumbs (#pagepath) and search buttons
- Enhance admin sidebar navigation (#tabs) active states and subheadings
- Correct contrast for missing/forbidden indicators in table rows

@sabderemane sabderemane left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hey @kehach07 ! This is close! It's missing the last changes and we are good to go ⭐

If there are anything else after that, I think it could be fixed in another PR while this one is merged.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hey Keha , there are still some light grey which could worth improvement in term of contrast, but most importantly the elements with the class foldable like filters and columns are barely readable since they include a link inside, see below:
Image

The greyish color could be #9f9d9d for all those elements, this way you could have the same variable color and one color for all of them (they are not all the same grey).

The foldable elements with a link inside could be same as the nav bar colors (#0C3C26 on #C9F0DD).

After that, that would be perfect! ⭐

#top p.meta,
#top .meta,
p.meta {
color: #c5e4d6; /* High contrast light green/mint */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this color seems to be used many times, worth to have a variable with the color name to use it everywhere

span.hint,
form.addnew p.hint,
form.addnew span.hint {
color: #c1cad2;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this color seems to be used many times, worth to have a variable with the color name to use it everywhere

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In a detail of a ticket they are still things which are hardly visible as I have previously mentioned like the code (class code):

Image

or foldable elements here and cnum and timeline classes which correspond to the number of comment and the timeline
Image

Note that if you hover on a foldable element with a link, it's impossible to read (this is on the screenshot with "Change history" below "Attachements") .

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