-
-
Notifications
You must be signed in to change notification settings - Fork 902
Unified setDark API. Happens to take care of meta
#5483
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
base: main
Are you sure you want to change the base?
Conversation
|
@evnchn well this was fun to test... TLDR a8fd25b subtly changed the behavior to make my original repro from #5471 not work, so this PR is still probably correct, but in a way I can't verify (without cherry-picking fix back). I presume the Dark Reader extension has some built in semantics to guess if the page is 'dark', and the changes in a8fd25b make the page settle fast enough for it to automatically detect when To further complicate things only a hard browser reload would causes the issue (regardless of a8fd25b). Here's hard / soft refresh before / after a8fd25b: Screen.Recording.2025-12-17.at.12.35.22.PM.mp4So, with that said, LGTM 😁 |
|
Consider to change your calls to |
|
@evnchn to be sure: I'm not doing any custom styling. But that is a good tip. |
@davetapley Sorry but I can't see how the repro can be broken while you are not using custom styling (so no If you really have me guess, then I have to guess that Dark Reader is reacting to the following body snippet: <script>
addStyle = (c) => document.head.append(Object.assign(document.createElement("style"), { textContent: c }));
</script>Which I am so shocked if that is the case, think should not be the case, and if that really is the case then bug report to Dark Reader (https://github.com/darkreader/darkreader) is highly recommended. |
|
@evnchn hmm, I was using ⬇️ to repro (obvs with nicegui/examples/todo_list/main.py Line 61 in b11972f
Not sure how to proceed. |
|
@evnchn Since it's your PR: How should we proceed? Are you and @davetapley still testing, or should I review? Personally I'd love to hear that it actually serves a purpose in solving #5471 before spending time reviewing and possibly discussing about API details. |
|
Let me clean up the conversation history. @davetapley kindly check 🙏 Context: Test page is
@falkoschindler TL-DR: a8fd25b muddied waters by mysterious fixing the Dark Reader invocation except the first one, but the purpose of this PR still stands as it fixes it 100%. I think we can move straight to review and API design. Though you may want to wait for @davetapley and check out the other PRs (many) in the meantime. |
|
Let's re-schedule this PR to 3.7. At the moment I see the following open questions:
|
Motivation
There are 2 problems this PR want to address:
<meta>tags to inform themui.dark_modeis hard-coded to useQuasar.Dark.setwhich gets in the way of using other UI frameworks than Quasar (Let configure UI framework other than Quasar #4859)Real motivation: to experiment, since I have doubts over "demo is good enough instead of API addition" #5471 (comment)
Implementation
Quasar.Dark.setwill never be called directly: It will be wrapped to take true/false/undefined, then set asdarkSetterdarkSettercan be another UI library's dark mode function, if you need that.setDarkcalls thedarkSetterwhile also handles the<meta>tags for you.<meta>tags are also populated in HTML.Progress