-
Notifications
You must be signed in to change notification settings - Fork 671
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
examples/next: fix unstyled flash #277
Conversation
Signed-off-by: Jordan Overbye <jordanoverbye@gmail.com>
Signed-off-by: Jordan Overbye <jordanoverbye@gmail.com>
Signed-off-by: Jordan Overbye <jordanoverbye@gmail.com>
Signed-off-by: Jordan Overbye <jordanoverbye@gmail.com>
Signed-off-by: Jordan Overbye <jordanoverbye@gmail.com>
Signed-off-by: Jordan Overbye <jordanoverbye@gmail.com>
examples/next/pages/_document.js
Outdated
<Html> | ||
<Head /> | ||
<body> | ||
<script |
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.
Thanks for looking into this! I wonder if it might make more sense from an API standpoint to make this a component, since this and gatsby-ssr.js
both use a script element
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.
Yeah that's a good idea! I was thinking that after I submitted this PR. The reason I didn't do that is because in gatsby-ssr.js
it's using a js function and not JSX. But I will update
@jxnblk @jordanoverbye When I run your code ... I get a module not found error for After installing it, everything works fine! |
@johnletey good pickup! I'll fix that. |
Signed-off-by: Jordan Overbye <jordanoverbye@gmail.com>
Signed-off-by: Jordan Overbye <jordanoverbye@gmail.com>
Signed-off-by: Jordan Overbye <jordanoverbye@gmail.com>
Signed-off-by: Jordan Overbye <jordanoverbye@gmail.com>
Hey @jxnblk , do you mind taking another look at this please? Also, I'm not 100% on the name |
Signed-off-by: Jordan Overbye <jordanoverbye@gmail.com>
packages/theme-ui/src/color-modes.js
Outdated
@@ -68,4 +68,17 @@ const bodyColor = theme => ({ | |||
|
|||
export const ColorMode = () => <Global styles={bodyColor} /> | |||
|
|||
export const ApplyColorModeFromLocalStorage = () => ( |
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.
As far as names go, what about
export const ApplyColorModeFromLocalStorage = () => ( | |
export const InitializeColorMode = () => ( |
This is looking great! Not sure about what would make most sense for the component name, but other than that this seems great! We can add docs for Next.js usage after this is merged in |
Co-Authored-By: Brent Jackson <jxnblk@gmail.com>
Signed-off-by: Jordan Overbye <jordanoverbye@gmail.com>
Thanks @jxnblk , I've just updated those changes |
@jordanoverbye @jxnblk When I use the newest update
|
Hey @johnletey So because this example lives outside the I think the problem you are seeing is because haven't done this step and we have added a new API which doesn't exist in the current version of
Let me know if that fixes it for you. |
No @jordanoverbye ... I'm literally just copying-n-pasting your code into a different Next.js project that I'm working on and I need Theme UI for, and the newest changes to |
Hey @johnletey Oh right that makes sense - but the error you are seeing is caused by the same thing though. In your NextJS project you have What you can do for now is just copy the source code of
|
Wonderful ... thank you so much @jordanoverbye Now I don't have an unstyled flash! |
@jordanoverbye Thanks for working on this, this looks great! |
Hello 👋
This PR attempts to fix #270
So I don't think it's possible to create a
theme-ui-next
plugin as we have to do things that plugins aren't able to do (like wrapping the App in a ThemeProvider). So instead I have done something else:noflash
function ingatsby-plugin-theme-ui
into its own function thattheme-ui
exports calledapplyColorModeFromLocalStorage
.applyColorModeFromLocalStorage
which prevents the unstyled flash.