@inradius/solid-wc-css-mixin 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.cjs +15 -1
- package/dist/index.js +13 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# @inradius/solid-wc-css-mixin
|
|
2
|
-
 
|
|
2
|
+
  
|
|
3
3
|
|
|
4
4
|
A lightweight mixin for [component-register](https://www.npmjs.com/package/component-register) that allows you to inject computed or inlined CSS directly into a Web Component's **Shadow Root** using Constructable Stylesheets.
|
|
5
5
|
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
const componentRegister = require("component-register");
|
|
3
|
+
const withCSS = (styles) => componentRegister.createMixin((options) => {
|
|
4
|
+
const { element } = options;
|
|
5
|
+
const stylesheet = new CSSStyleSheet();
|
|
6
|
+
if ("adoptedStyleSheets" in element.renderRoot) {
|
|
7
|
+
stylesheet.replaceSync(styles);
|
|
8
|
+
element.renderRoot.adoptedStyleSheets = [
|
|
9
|
+
...element.renderRoot.adoptedStyleSheets,
|
|
10
|
+
stylesheet
|
|
11
|
+
];
|
|
12
|
+
}
|
|
13
|
+
return { ...options, element };
|
|
14
|
+
});
|
|
15
|
+
module.exports = withCSS;
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import { createMixin
|
|
2
|
-
const
|
|
3
|
-
const { element
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { createMixin } from "component-register";
|
|
2
|
+
const withCSS = (styles) => createMixin((options) => {
|
|
3
|
+
const { element } = options;
|
|
4
|
+
const stylesheet = new CSSStyleSheet();
|
|
5
|
+
if ("adoptedStyleSheets" in element.renderRoot) {
|
|
6
|
+
stylesheet.replaceSync(styles);
|
|
7
|
+
element.renderRoot.adoptedStyleSheets = [
|
|
8
|
+
...element.renderRoot.adoptedStyleSheets,
|
|
9
|
+
stylesheet
|
|
10
|
+
];
|
|
11
|
+
}
|
|
12
|
+
return { ...options, element };
|
|
8
13
|
});
|
|
9
14
|
export {
|
|
10
|
-
|
|
15
|
+
withCSS as default
|
|
11
16
|
};
|