Sha256: 541a0deb9e669b284d95fde4d76ea163be564d2b9699ee6476c883143553f554
Contents?: true
Size: 1.02 KB
Versions: 40
Compression:
Stored size: 1.02 KB
Contents
const debounce = (func, wait = 500) => { let timeout return function (...args) { clearTimeout(timeout) timeout = setTimeout(() => { func.apply(this, args) }, wait) } } const getInitialTheme = () => { if (typeof window !== "undefined" && window.localStorage) { const storedPrefs = window.localStorage.getItem("color-theme") if (typeof storedPrefs === "string") { return storedPrefs } const userMedia = window.matchMedia("(prefers-color-scheme: dark)") if (userMedia.matches) { return "dark" } } // If you want to use dark theme as the default, return 'dark' instead return "light" } const popperSameWidth = { name: "sameWidth", enabled: true, phase: "beforeWrite", requires: ["computeStyles"], fn: ({ state }) => { state.styles.popper.width = `${state.rects.reference.width}px` }, effect: ({ state }) => { state.elements.popper.style.width = `${state.elements.reference.offsetWidth}px` }, } export { debounce, getInitialTheme, popperSameWidth }
Version data entries
40 entries across 40 versions & 1 rubygems