Skip to content

feat: add .dark class selector for theme switching compatibility#69

Merged
adurrr merged 1 commit into
mainfrom
feat/dark-class-selector
Jun 28, 2026
Merged

feat: add .dark class selector for theme switching compatibility#69
adurrr merged 1 commit into
mainfrom
feat/dark-class-selector

Conversation

@adurrr

@adurrr adurrr commented Jun 28, 2026

Copy link
Copy Markdown
Owner

Problem

The <podcast-player> and <podcast-footer> web components only respond to two dark-mode signals:

  • [data-theme="dark"] on an ancestor element
  • .theme-dark on an ancestor element
  • [data-theme="dark"] on the element itself

Many Hugo themes signal dark mode differently. The most common alternative is the .dark class on <html>, used by:

  • Blowfish (a popular Hugo theme), via its data-default-appearance mechanism
  • All Tailwind sites using darkMode: 'class' (the default)
  • Pico.css, Bulma, and any theme following the Tailwind convention

On those themes, the player and footer stay light even when the rest of the page is dark, because the CSS variables are never overridden.

Reproduction

  1. cd exampleSite && hugo server
  2. Open the site, then in DevTools console:
    document.documentElement.classList.add('dark')
  3. Observe: the page chrome goes dark, but <podcast-player> and <podcast-footer> stay light.

Fix

Add .dark as a parallel alternative to the existing selectors in assets/css/podcast-player.css. Four blocks touched, all additive, zero changed values:

  • Player host variables (line 31)
  • ::part(player) border override (line 54)
  • Player ::part() border override (line 54)
  • Footer host variables (line 211)
  • Footer focus rings (line 234)

Verification

  • npm test — passes
  • npm run lint && npm run format:check — passes
  • go test ./tests/hugo/... — passes
  • Manual: exampleSite with the toggle above now switches correctly
  • E2E suite — passes

Compatibility

No breaking changes. Existing [data-theme="dark"] and .theme-dark selectors are preserved exactly. Sites already working keep working; the only behavior change is that additional themes now also work.

Related

No prior issue or PR exists for this.

Many Hugo themes (Blowfish, Tailwind-class-mode themes, Pico, Bulma)
signal dark mode with a .dark class on the document root rather than a
data-theme attribute. This commit adds .dark as a parallel alternative
to the existing [data-theme='dark'] and .theme-dark selectors so the
player and footer respond automatically on those themes.

No variable values changed. Selectors are purely additive, so existing
integrations are unaffected.
@adurrr adurrr merged commit f5092de into main Jun 28, 2026
4 checks passed
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.

1 participant