-
Notifications
You must be signed in to change notification settings - Fork 29k
Add example using glamorous π #1620
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
Conversation
Now. There's a big FOUC. I'm not sure if it's my example or |
That FOUC is super sad. I would be spelled if it were glamorous. But I suppose it could be. Does the Glamor example do that? |
@kentcdodds Now for @rauchg it would be great if all the examples were hosted on now.sh already. |
Ah, no FOUC on that because it's doing server-side rendering with rehydration. You can actually do this same thing with glamorous! It's actually the exact same process (using |
This is excellent! Thank you very much :) |
import glamorous from 'glamorous' | ||
|
||
// Adds server generated styles to glamor cache. |
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.
Is this required on every page? Can we make this more DRY?
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.
You could probably put this in a global component like a layout and get away with it. I haven't given it a try though.
FWIW, I'd call this a "working example" more than a "best practices example". π
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.
Cool. Out of curiosity what are we rehydrating here? What's stored insides ids
?
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.
We're rehydrating the CSS by shoving the computed styles into the DOM in the head
. This is actually being done by glamor
. See here for more: https://github.com/threepointone/glamor/blob/master/docs/server.md
The ids
are the hashes that are part of the generated classes uses in the CSS.
Here's an example I just pulled from a different project:
__NEXT_DATA__ = {"props":{},"pathname":"/","query":{},"buildId":"-","buildStats":null,"assetPrefix":"","err":null,"ids":["14e33nr","151tlpa","63oe3q","35577l","wfyxwh","858wo0","2y5bqi","1nvbmsg","17186zx","cuyszr","ehn2ke","6l3qzw","1jfbwxw","gzrewh","1jh79q9","kv69lr","ubp1jq"]}
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.
@ads1018 You can DRY this up by including in a component (like a layout component) and using that on all the pages. See here: kentcdodds/glamorous-website#14
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.
Ah perfect. This is exactly what I was thinking. Thanks!
I created a quick example using glamorous. It's very similar to
glamor
(it depends on it), but why not. π€·ββοΈ