-
Notifications
You must be signed in to change notification settings - Fork 243
styled-components improvement #297
Comments
It's a start. |
Thanks for looking into this @datoml :) I'll have a review of this soon. :) |
The glamor Calling |
Has someone got a full working implementation that they are willing to create a PR for? |
I am currently using styled-components for my project with the hope that there will be a fix in die near future for this. |
@datoml I encourage you to try! Check out this cool egghead course: |
Thanks for the link. I'll have a look :): |
@ctrlplusb I implemented the SSR changed that @datoml recommended above, you can check it out here. It seems to work, but it double injects the styles, once on the server and once on the client. |
I'm wondering if you read what i linked. That's all known and discussed and there's no solution for it yet, even though it's very simple in principle |
I did. |
FYI I have been using |
I tried styletron but I like the api from styled-components more.
|
I'm hard to convince as well. On the one hand i'm not sure about the performance implications of styletrons many CSS selectors in really large DOMs (think Githubs Diff view), on the other hand i love to be able to write CSS instead of objects, including inline syntax highlighting etc, so i'm with @datoml on that one :) |
Totally see your guys points, I guess I prefer the object style as it opens up the Javascript as the API to modifying/merging styles: const centeredButtonStyle = Object.assign(
{},
{ color: 'red' },
theme.layout.centered
); I have been really enjoying creating and composing objects for more generic styles. |
Thats true. |
Check this out: https://github.com/RafalFilipek/styled-props :) |
I will have a look on it :). Or am I missing something? :D |
@codepunkt Thanks for suggesting styletron, i was totally unaware of it's existence....:P |
@ctrlplusb @codepunkt Server Rendering API for |
@lucianlature it was merged into |
Got too excited for a moment, sorry. |
Out of curiosity, did you guys look at https://github.com/rofrischmann/fela And with https://github.com/jakecoxon/babel-plugin-css-to-js you can have a very similar API to styled-components! |
@bkniffler The alternatives are endless. CSS in JSS fatigue! 🤣 |
In order to get styled-components working server-side with current v2-beta, which api seems still a bit under discussion (styled-components/styled-components#214), you can use this approach. https://gist.github.com/mschipperheyn/c17280278218074a53147f54259af66a The reference keyword is: styledComponentCSS I based this on react-universally@next |
Does anybody have styled components working with react universally nowadays? I am using version 2.1.1 of styled components, but have not had any joy. I looked at the gist provided by 'mschipperheyn', but it looks like things have changed in styled-components land! I am trying to use ServerStyleSheet, creating an instance and then using collectStyles on my app component. But I am missing something, getStyleElement returns an empty array. I know that app is async so perhaps at the point of collection it is empty? |
Okay, I was on the right track. I managed to implement Styled Components by passing my ServerStyleSheet instance as a prop on ServerHTML, then using .getStyleElement() to add the css to headerElements within ServerHTML.js. I am really pleased I got this working and also pleased I found React Universally. |
@designspin is there a gist you could share if it all works? Btw, here is the main issue on styled-components where you could also maybe post that update for others following the issue - styled-components/styled-components#762 |
Here is a GIST of what appears to be working for me right now: https://gist.github.com/designspin/c11095334ae1f105d1f93123232d37fd |
@designspin If you will link me a repo where you're having issues, I'll take a look. |
No issue, the above GIST is in fact a solution. It is working for me, thanks. |
@mschipperheyn @strues @designspin Does anyone have the setup for using the starter kit with SC v2? The feature branch still seems to have v1 of SC. |
Hello,
I made some tests with server side rendering and the styled components feature branch.
Seems like the server side rendering doesn't work for the styles.
Regarding to this discussions styled-components/styled-components#124 I implemented this:
Then I added them into
Looks now a lot nicer to me.
Can someone confirm that this is a good solution? :)
Thanks
The text was updated successfully, but these errors were encountered: