-
-
Save arekbartnik/d7713ba699fa58529549b3ea49069f5d to your computer and use it in GitHub Desktop.
A way to inject once per selector global styles, for more portable components.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {define as hookedDefinition} from 'hooked-elements'; // or wicked- | |
import css from 'ustyler'; | |
export const define = (selector, definition) => { | |
// let the library throw on duplicated selectors | |
const result = hookedDefinition(selector, definition); | |
// add styles for this selector | |
if (definition.style) css(definition.style); | |
// return the wicked/hooked magic 🌈 | |
return result; | |
}; | |
// export any other utility you like (i.e. useState and others) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment