WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@jzimdars
Copy link
Member

@jzimdars jzimdars commented Dec 8, 2025

The implementation in #1935 is solid but needs some design polish:

image

@jzimdars jzimdars requested a review from andyra December 9, 2025 00:07
Copy link
Member

@jorgemanrubia jorgemanrubia left a comment

Choose a reason for hiding this comment

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

Love this one!

#applyStoredTheme() {
const storedTheme = this.#storedTheme

if (storedTheme === "light") {
Copy link
Member

Choose a reason for hiding this comment

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

could invert to make more concise:

if (storedTheme === "auto") {
  document.documentElement.removeAttribute("data-theme")
} else {
  document.documentElement.setAttribute("data-theme", storedTheme)
} 

But maybe we can even do just"

  document.documentElement.setAttribute("data-theme", this.#storedTheme)

auto won't have any style handling, so that is fine, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

In CSS, we currently check for the presence of data-theme. If we're saving data-theme="auto" in the JS controller, we'll need to update the CSS to html:not([data-theme="light"])

@media (prefers-color-scheme: dark) {
  html:not([data-theme]) & {
    box-shadow: 0 0 0 1px var(--color-ink-lighter);
  }
}

Copy link
Contributor

@andyra andyra left a comment

Choose a reason for hiding this comment

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

I pushed a couple small improvements to reduce the repetition of inline SVGs, but other than that this is looking nice! 👍 We can revisit in a few months when it looks like light-dark() has better support. We'll be able to remove a couple hundred lines of CSS, I'd wager.

Copy link
Member

@jorgemanrubia jorgemanrubia left a comment

Choose a reason for hiding this comment

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

couple of minor comments but looks great 👏

@jzimdars jzimdars merged commit 1e59bc9 into main Dec 11, 2025
11 checks passed
@jzimdars jzimdars deleted the theme-switcher-revised branch December 11, 2025 15:46
@jzimdars
Copy link
Member Author

Closes #1935

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.

5 participants