-
Notifications
You must be signed in to change notification settings - Fork 23
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
Preview doesn't respond to light / dark theme changes in the tutorial #247
Comments
We've had some discussions about this earlier with @Nemikolh. The way how learn.svelte does this is:
I don't think there's a way to actually affect With TutorialKit it's not that simple, as end-users control what is running in the preview. @Nemikolh any new ideas how to solve this? |
Another option might be for TutorialKit to There's also a new WC API option @Nemikolh is working on for programmatically injecting scripts into all devservers which TutorialKit would be able to leverage for doing this automatically, but TBD on when that's going to land (hopefully in the next few weeks iirc). |
Hey everyone! 👋 Really interesting conversation! 😃 I think this is definitely something we will try to solve at the WebContainer API level under a flag so that everyone that use the WebContainer API can enjoy that feature. I believe we might be able to solve this using the However, I haven't yet experimented with the idea and would need to double-check to be sure. Also like @EricSimons said, we talked about having an API to easily inject scripts in previews. This is however very TBD at this point. |
I think matching the The In this this demo the "light" theme media query is still matched despite using a dark Note that the documentation of I've crafted a third demo, where the To sum it up:
Tested on Chrome and Firefox. This might be a bug. To my best knowledge you cannot alter the prefers-color-scheme media query with JavaScript either (which is annoying for unit tests), but this would need double checking. I think patching Fun fact: it makes it surprisingly difficult to implement a dark/light toggle in a webcontainer because there is a very strong isolation of CSS selector inheritance so a top-level ".dark" is of no use (or at least I failed to use it last time I've checked). Ironically the CSS styles themselves are less isolated and some inheritance is possible. |
Thanks for the detailed write up @eric-burel! And my apologies for not having sent an update regarding this issue and our current plan. We are not going to do it using Ou current plan is to expose at the WC API level a function, maybe called
It will update all iframes At the TutorialKit level, we will essentially call that function based on the value of the theme and expose it as Let me know what you think! 😃 |
Describe the bug
In my tutorial, I want the preview window to react to changes in dark/light button that are available on the top bar - currently, the code and md change, but not my site
Would love some guidance
Link to a StackBlitz project which shows the error
No response
Steps to reproduce
In a new tutorial, click the light/dark theme and see that it doesn't affect the preview window.
Even when I added media queries, it didn't respond:
Expected behavior
I would like a way to be aware in the preview of the light/dark change of the tutorial
Screenshots
No response
Platform
Additional context
No response
The text was updated successfully, but these errors were encountered: