-
Notifications
You must be signed in to change notification settings - Fork 319
Description
Description
Currently, CSSResult seems to be designed for LitElements having shadow dom. CSSResult modules tend to be quite closely coupled to the get static styles array as well.
Imagine however the following situation: I have an implementation of a Design System consisting of css modules (meaning equivalents of BEM/SMACCS etc. type of components) that should be reusable in many 'technology contexts' (meaning with and without shadow DOM and in multiple frameworks (React, Angular, Vue, vanilla, whatever).
This example illustrates how one would be able to reuse a 'technology agnostic' implementation of a Design System across different technologies:
- example of a css module: https://stackblitz.com/edit/css-modules-in-all-contexts?file=style%2Fmodules%2Fbutton-css-module.js
- example of applying local styles (in LitElement) with shadowRoot: https://stackblitz.com/edit/css-modules-in-all-contexts?file=my-lit-app.js
- example of applying global styles (in a non Lit context): https://stackblitz.com/edit/css-modules-in-all-contexts?file=index.ts
For me, it would increase the Developer Experience when I can think about those CSS Modules as being technology agnostic strings.
So then instead of {myModule.cssText}, I could do {myModule}.
Seems like a small thing, but for me it would just be a better experience and it would feel like my styles would be less tightly coupled to CSSResult (and thus LitElement and shadow dom).
Also, It will help decrease verbosity in situations like this:
.grid-container {
margin: auto;
max-width: ${unsafeCss(Number(small.cssText.slice(0,-2)) -(Number(containerPadding.cssText.slice(0,-2) * 2)))}px;
}Would it be possible to add a toString() method that returns the cssText?
Live Demo
See links above.