cloudoperators / juno

Monorepo for the Juno microfrontend framework, microfrontend apps, design system and component library
Apache License 2.0
2 stars 0 forks source link

research(ui): Possibility to use webcomponent templates to share style sheet between shadow roots #79

Open edda opened 2 weeks ago

edda commented 2 weeks ago

Currently in juno we render the styles needed for juno-ui-components and for the microfrontend itself as text into a <style> tag. This leads to duplications if multiple microfrontends are loaded on the same page (each in its own ShadowRoot, each one will include the same style block from juno-ui-components. We had tried to use constructed stylesheets in the past but the spec states:

Where the resolution of rules considers stylesheet order, adoptedStyleSheets are assumed to be ordered after those in Document.styleSheets (see: https://developer.mozilla.org/en-US/docs/Web/API/Document/adoptedStyleSheets)

This made them not usable for us since we want the styles of the components in our component library to be overrideable by users. See also here: https://github.com/cloudoperators/juno/blob/main/libs/juno-ui-components/src/components/ShadowRoot/ShadowRoot.component.js#L19-L23