-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathstyle.js
More file actions
32 lines (28 loc) · 798 Bytes
/
style.js
File metadata and controls
32 lines (28 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import StyleSheetRegistry from "styled-jsx/dist/stylesheet-registry";
import { onCleanup, createEffect } from "solid-js";
const styleSheetRegistry = new StyleSheetRegistry();
export default function JSXStyle(props) {
createEffect(prev => {
if (prev) {
styleSheetRegistry.remove(prev);
}
const next = { ...props };
styleSheetRegistry.add(next);
return next;
});
onCleanup(() => styleSheetRegistry.remove({ ...props }));
}
JSXStyle.dynamic = info => {
return info
.map(tagInfo => {
const baseId = tagInfo[0];
const props = tagInfo[1];
return styleSheetRegistry.computeId(baseId, props);
})
.join(" ");
};
export function flush() {
const cssRules = styleSheetRegistry.cssRules();
styleSheetRegistry.flush();
return cssRules;
}