Skip to content

Instantly share code, notes, and snippets.

@WebReflection
Created April 27, 2020 14:37
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save WebReflection/7276c39f9a9c25d9c76308b1fa6d64da to your computer and use it in GitHub Desktop.
Save WebReflection/7276c39f9a9c25d9c76308b1fa6d64da to your computer and use it in GitHub Desktop.
A way to inject once per selector global styles, for more portable components.
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