Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

839 B
Raw Blame
"use client";

import { useEffect } from "react";

import { boardViewportWidthCookieName } from "@homarr/boards/layout-selection";

export const ViewportHint = () => {
  useEffect(() => {
    let timeout: ReturnType<typeof setTimeout> | undefined;
    const persist = () => {
      const viewportWidth = document.documentElement.clientWidth || window.innerWidth;
      document.cookie = `${boardViewportWidthCookieName}=${Math.round(viewportWidth)}; Path=/; Max-Age=31536000; SameSite=Lax`;
    };
    const handleResize = () => {
      clearTimeout(timeout);
      timeout = setTimeout(persist, 150);
    };

    persist();
    window.addEventListener("resize", handleResize, { passive: true });
    return () => {
      clearTimeout(timeout);
      window.removeEventListener("resize", handleResize);
    };
  }, []);

  return null;
};