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

Version Path
satis-2.1.47 app/javascript/satis/utils.js
satis-2.1.46 app/javascript/satis/utils.js
satis-2.1.45 app/javascript/satis/utils.js
satis-2.1.44 app/javascript/satis/utils.js
satis-2.1.43 app/javascript/satis/utils.js
satis-2.1.42 app/javascript/satis/utils.js
satis-2.1.41 app/javascript/satis/utils.js
satis-2.1.40 app/javascript/satis/utils.js
satis-2.1.39 app/javascript/satis/utils.js
satis-2.1.38 app/javascript/satis/utils.js
satis-2.1.37 app/javascript/satis/utils.js
satis-2.1.36 app/javascript/satis/utils.js
satis-2.1.35 app/javascript/satis/utils.js
satis-2.1.33 app/javascript/satis/utils.js
satis-2.1.31 app/javascript/satis/utils.js
satis-2.1.30 app/javascript/satis/utils.js
satis-2.1.29 app/javascript/satis/utils.js
satis-2.1.28 app/javascript/satis/utils.js
satis-2.1.27 app/javascript/satis/utils.js
satis-2.1.26 app/javascript/satis/utils.js