Skip to content

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

Merged
merged 6 commits into from
Apr 6, 2017

Conversation

paulmolluzzo
Copy link
Contributor

I created a quick example using glamorous. It's very similar to glamor (it depends on it), but why not. πŸ€·β€β™‚οΈ

@paulmolluzzo
Copy link
Contributor Author

Now.

There's a big FOUC. I'm not sure if it's my example or glamorous. 😟

@kentcdodds
Copy link

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?

@paulmolluzzo
Copy link
Contributor Author

paulmolluzzo commented Apr 5, 2017

@kentcdodds Now for with-glamor: https://with-glamor-jvryhwqqfq.now.sh


@rauchg it would be great if all the examples were hosted on now.sh already.

@kentcdodds
Copy link

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 glamor APIs). Can you see if that will solve the FOUC issues?

@paulmolluzzo
Copy link
Contributor Author

Fixed the FOUC.

@kentcdodds
Copy link

This is excellent! Thank you very much :)

@rauchg rauchg merged commit 12a7610 into vercel:master Apr 6, 2017
import glamorous from 'glamorous'

// Adds server generated styles to glamor cache.
Copy link
Contributor

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?

Copy link
Contributor Author

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". πŸ˜‰

Copy link
Contributor

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?

Copy link
Contributor Author

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"]}

Copy link
Contributor Author

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

Copy link
Contributor

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!

@paulmolluzzo paulmolluzzo deleted the add-glamorous-example branch May 26, 2017 18:15
@lock lock bot locked as resolved and limited conversation to collaborators May 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants