Skip to content
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

Styling with styled-jsx and React renderer #1547

Open
ussuritiger opened this issue Dec 19, 2018 · 9 comments
Open

Styling with styled-jsx and React renderer #1547

ussuritiger opened this issue Dec 19, 2018 · 9 comments

Comments

@ussuritiger
Copy link

I am trying to use React renderer with style-jsx but cannot make styling work. Babel and Webpack is properly configured so the build is going well. Markup with styled-jsx unique classes is rendered correctly inside SkateJS custom element however styling itself is missing. Any ideas on why styled-jsx does not work inside custom elements build with SkateJS? Thanks.

@treshugart
Copy link
Member

It's almost certainly because styled-jsx is inserting styles into the head and Skate creates a shadow root. Related issue: vercel/styled-jsx#28.

If you're not doing anything super crazy with your styles, you can try using something like https://github.com/treshugart/shadow-css.

@ussuritiger
Copy link
Author

Thanks @treshugart for quick reply. In my case React components need to be shared between React project and web components. React project uses styled-jsx so it would be nice to make SkateJS web components able to use that shared React components with styled-jsx using React renderer.

Another thing I was trying to do is to use flush from styled-jsx/server like explained here: https://github.com/zeit/styled-jsx#server-side-rendering. So the idea is to get all styles with flush and put them inside SkateJS component in the same way I can put just <style>...</style> element inside SkateJS web component. However this does not work for me either. Any ideas about this approach?

@treshugart
Copy link
Member

Is there a way for you to share a working example, gist or some code? Happy to take it from there to try and get something working.

I'll see if I can ping Zeit to see if they've found an easier solution for this.

@treshugart
Copy link
Member

Pinged: vercel/styled-jsx#28 (comment).

@ussuritiger
Copy link
Author

ussuritiger commented Dec 22, 2018

I've created a very simple demo: https://github.com/ussuritiger/skatejs-react-styled-jsx

The only difference with real case is that shared components are installed with yarn/npm from GitHub (in this demo shared React component is in ./src/shared-components folder).

Thanks for your time and enthusiasm. Hopefully you have some ideas how to make this combination work.

@ussuritiger
Copy link
Author

Hey @treshugart, did you have a chance to look at the example I’ve provided?

@treshugart
Copy link
Member

Hey @ussuritiger. Sorry for the late reply. That link is 404'ing.

@ussuritiger
Copy link
Author

Sorry, please have a look, it is back @treshugart

@OKNoah
Copy link

OKNoah commented Dec 31, 2019

@ussuritiger 404 again...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants