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

fix: respond to media query change events when theme is auto #1731

Merged
merged 4 commits into from
Apr 10, 2024

Conversation

techfg
Copy link
Contributor

@techfg techfg commented Apr 10, 2024

Description

  • Closes auto theme does not respond to change in system/browser preferences #1684
  • What does this PR change? Give us a brief description.
    Will respond to media change query events and update the theme to system/browser preference when current theme is set to auto
  • Did you change something visual? A before/after screenshot can be helpful.
    Technically it's a visual change but nothing visual about the package changed :)

I didn't see any existing tests in/around the components, specifically ThemeSelect. If I overlooked and/or you'd like me to add some, just let me know.

Copy link

changeset-bot bot commented Apr 10, 2024

🦋 Changeset detected

Latest commit: 19d163f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@astrojs/starlight Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Apr 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
starlight ✅ Ready (Inspect) Visit Preview Apr 10, 2024 3:24pm

@github-actions github-actions bot added the 🌟 core Changes to Starlight’s main package label Apr 10, 2024
@astrobot-houston
Copy link
Collaborator

Hello! Thank you for opening your first PR to Starlight! ✨

Here’s what will happen next:

  1. Our GitHub bots will run to check your changes.
    If they spot any issues you will see some error messages on this PR.
    Don’t hesitate to ask any questions if you’re not sure what these mean!

  2. In a few minutes, you’ll be able to see a preview of your changes on Vercel 🤩

  3. One or more of our maintainers will take a look and may ask you to make changes.
    We try to be responsive, but don’t worry if this takes a few days.

Copy link
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

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

Thank you for this PR @techfg! I made a couple of small tweaks — mainly to use the existing #loadTheme() method instead of writing additional logic for extracting the theme from the select menu.

There is a small “bug” in this version of things because we actually have two instances of <ThemeSelect> in most pages — one in the nav bar, one in the mobile menu. That means we have two media query event listeners that, due to some internal wiring, each update both instances. I’ll tackle that separately though as it will need a small refactor to pull some of this logic up out of the custom element class.

Appreciate you helping out 🙌

@delucis delucis added the 🌟 patch Change that triggers a patch release label Apr 10, 2024
@techfg
Copy link
Contributor Author

techfg commented Apr 10, 2024

@delucis - Thanks for reviewing so quickly and getting merged! Your changes make sense, much simpler, and yeah, noticed the multiple ThemeSelect but figured that was a separate issue as you mention :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌟 core Changes to Starlight’s main package 🌟 patch Change that triggers a patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

auto theme does not respond to change in system/browser preferences
3 participants