This repository has been archived by the owner on Sep 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Added: support for
Glamor
and styled-components
out of the …
…box. Now if you use [Glamor](https://github.com/threepointone/glamor/) to write your style, static rendering will take that into account and will prerender styles for you. Nothing to setup. It’s even injecting glamor ids if you want to rehydrate on startup. See [glamor server documentation](https://github.com/threepointone/glamor/blob/master/docs/ server.md) to setup hydratation (you will need to handle this yourself in your ``scripts/phenomic.browser.js``. Since [styled-components](https://styled-components.com/) [use Glamor under the hood](styled-components/styled-components#124) , this will work for this library as well. Ref #864
- Loading branch information
Showing
4 changed files
with
146 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6d703cb
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.
Saw this and checked it out ;) This is not going to work for Styled Components as it's using a custom StyleSheet. Thus glamor's server methods are not importing the right thing.
https://github.com/styled-components/styled-components/blob/master/src/vendor/glamor/sheet.js
6d703cb
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.
Meh :'(
I guess I will remove the mention of styled-components from the doc and will wait for styled-components/styled-components#124
6d703cb
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.
It's really a shame :( I wanted to use it for implementing rehydration on my project, but noticed that this doesn't work. Also, it seems like
inserted
is not present on the custom StyleSheet, do you know by any chance what this is about? I'm not able to see code related to it in glamor's sheet.Object.keys(styleSheet.inserted)
6d703cb
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.
I have not idea, I just integrated this following glamor docs. I personally don't use this solutions. I use normal CSS (+ css modules) or pure JS solutions (via react-native-web)...
6d703cb
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.
Even if rehydration doesn't work, you can make the SSR styling work (-ish), if you manually import the stylesheet. So basically this will need the user to do:
where
StyleSheet
is in:'node_modules/styled-components/lib/models/StyleSheet'
.However, this is further complicated by the fact that bundlers will use the bundled version of styled-components by default. So the user potentially needs to use aliases to make this work. I guess there's no "one-fits-all" solution for making both standalone glamor and styled-components work. It doesn't even look like there ever will be one solution for both, as long as styled-components has a custom
sheet.js
.6d703cb
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.
I will wait for a public API for styled-components then. Phenomic can handle multiple solutions (currently glamor and aphrodite, without having those as deps) so not a big deal.
6d703cb
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 we vaguely intend to merge our changes to StyleSheet upstream to Glamor but it's not gonna happen immediately, so we'll make a public API for this stuff so if/when we change implementations there's no changes needed at your end.