chore: move setInitialMode to own module and import with raw#125
Open
paoloricciuti wants to merge 2 commits intosvecosystem:mainfrom
Open
chore: move setInitialMode to own module and import with raw#125paoloricciuti wants to merge 2 commits intosvecosystem:mainfrom
paoloricciuti wants to merge 2 commits intosvecosystem:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 947727b 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 |
Contributor
built with Refined Cloudflare Pages Action⚡ Cloudflare Pages Deployment
|
Member
|
Thanks man! Will give this a check! |
sacrosanctic
reviewed
Nov 1, 2025
| @@ -0,0 +1 @@ | |||
| function setInitialMode(a){const{defaultMode:b="system",themeColors:c,darkClassNames:d=["dark"],lightClassNames:e=[],defaultTheme:f="",modeStorageKey:g="mode-watcher-mode",themeStorageKey:h="mode-watcher-theme"}=a||{};const k=document.documentElement,l=localStorage.getItem(g)??b,m=localStorage.getItem(h)??f,n=l=="light"||(l=="system"&&matchMedia("(prefers-color-scheme: light)").matches),p=(q,r)=>q.length&&k.classList[r](...q);if(n){p(d,"remove");p(e,"add")}else{p(e,"remove");p(d,"add")}k.style.colorScheme=n?"light":"dark";let s;if(c&&(s=document.querySelector('meta[name="theme-color"]')))s.setAttribute("content",n?c.light:c.dark);if(m){k.setAttribute("data-theme",m);localStorage.setItem(h,m)}localStorage.setItem(g,l)} No newline at end of file | |||
There was a problem hiding this comment.
Isn't this hard to debug. Would it be better to keep the source code and run it through a minifier.
pnpm esbuild src/lib/set-initial-mode.ts --minify --format=esm --outfile=src/lib/set-initial-mode.min.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is the change we talked about @huntabyte ...dunno if you actually like it (and i didn't check it actually works more than running the tests but maybe we should test it out there for completeness).