-
-
Notifications
You must be signed in to change notification settings - Fork 505
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
Set default color theme in template #1473
Conversation
🦋 Changeset detectedLatest commit: 3fea4c6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
size-limit report 📦
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the approach is sound and this also fixes syntax highlighting for users having a preference set to light mode and JavaScript disabled 👍
* main: (96 commits) [ci] format i18n(ko-KR): update `manual-setup.mdx` (withastro#1482) i18n(ko-KR): update `community-content.mdx` (withastro#1483) [ci] format [ci] release (withastro#1481) [ci] format Make Starlight compatible with server output mode (withastro#1454) [i18nIgnore] community content: article description copy edit (withastro#1408) [ci] format i18n(it): Updated plugins.md and community-content.mdx (withastro#1480) i18n(fr): update `resources/community-content` (withastro#1479) [ci] format i18n(it): Modified everything in the /guides folder (withastro#1456) i18n(it): Modified frontmatter.md and overrides.md (withastro#1457) i18n(es): fix syntax highlighting with `diff`-like syntax example (withastro#1477) Add CodingCat.dev stream video to community content page (withastro#1475) i18n(fr): fix frontmatter `label` default value translation (withastro#1476) [ci] format [ci] release (withastro#1474) Set default color theme in template (withastro#1473) ...
Description
Fixes Both dark and light Starlight appears when JS disabled #1470
We are not currently setting
data-theme
by default, only when a small inline script runs:starlight/packages/starlight/components/ThemeProvider.astro
Line 14 in fb89bd1
For most styles this isn’t an issue because we set dark theme variables on
:root
, light theme variables on[data-theme="light"]
. But ourlight:sl-hidden
anddark:sl-hidden
classes expectdata-theme
to be set.To resolve this, this PR sets
data-theme="dark"
in the prerendered HTML, so we are not dependent on JS running in order for those styles to work.There should be no behaviour change for users running JS, only this bug fix for those without.
Alternative solutions
I considered an alternative solution of updating the
dark:sl-hidden
style to work whendata-theme
is not set:But given that it seems like a whole class of potential bugs could be caused by missing
data-theme
(including potentially in user code), it seemed safest to set the default value at source.