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

Cannot use SUID to build web components #231

Open
vorth opened this issue Jun 28, 2023 · 4 comments
Open

Cannot use SUID to build web components #231

vorth opened this issue Jun 28, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@vorth
Copy link

vorth commented Jun 28, 2023

I'm porting a web component implementation from React (material-ui) to Solid JS. With MUI, I found a workaround to make JSS attach the style elements to the web component's shadow DOM rather than the document head. No such workaround seems possible for SUID:

const head = document.head || document.getElementsByTagName("head")[0];

This means that only a single web component per page would function, at best... and it appears that styling is broken even in that case within the web component.

@juanrgm
Copy link
Member

juanrgm commented Jun 28, 2023

Any proposal?

@credred
Copy link

credred commented Aug 14, 2023

Same problem. can StyledEngineProvider provide an option to modify the location of the added style?

@juanrgm
Copy link
Member

juanrgm commented Aug 16, 2023

Could you put a link to the emotion/mui docs where it "fixes" this problem?

@juanrgm juanrgm added the enhancement New feature or request label Aug 16, 2023
@vorth
Copy link
Author

vorth commented Aug 16, 2023

Here is the snippet I had in my React code, wrapping the main component element with a StylesProvider. This may not be very helpful, as I was still using MUI 4 and JSS, not Emotion.

import { StylesProvider, jssPreset } from '@material-ui/styles';
...
  // We need JSS to inject styles on our shadow root, not on the document head.
  // I found this solution here:
  //   https://stackoverflow.com/questions/51832583/react-components-material-ui-theme-not-scoped-locally-to-shadow-dom
  const jss = create({
      ...jssPreset(),
      insertionPoint: container
  });
  const reactElement = React.createElement( StylesProvider, { jss: jss }, [ viewerElement ] );

Here is a clickable link for that URL

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

No branches or pull requests

3 participants