diff --git a/src/components/ReusableTabRoute.tsx b/src/components/ReusableTabRoute.tsx
index f8ab464..2efe2c3 100644
--- a/src/components/ReusableTabRoute.tsx
+++ b/src/components/ReusableTabRoute.tsx
@@ -1,6 +1,6 @@
import * as TabsPrimitive from "@radix-ui/react-tabs";
import { useAtom } from "jotai";
-import { useEffect, useLayoutEffect } from "react";
+import { useEffect, useLayoutEffect, useRef, useState } from "react";
import { isAtTopAtom, reusableTabRouteScrollAtom } from "~/utils/atoms";
@@ -70,28 +70,35 @@ export function ReusableTabRoute({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
+ //const { sentinelRef, isStuck } = useSticky(52);
+ //bg-gray-100 dark:bg-gray-900
+
return (
-
-
+
- {Object.entries(tabs).map(([key]) => (
-
- {key}
-
+ {/* */}
+
+ {Object.entries(tabs).map(([key]) => (
+
+ {key}
+
+ ))}
+
+
+ {Object.entries(tabs).map(([key, node]) => (
+
+ {activeTab === key && node}
+
))}
-
-
- {Object.entries(tabs).map(([key, node]) => (
-
- {activeTab === key && node}
-
- ))}
-
+
+ >
+
);
}
@@ -121,4 +128,28 @@ export function useReusableTabScrollRestore(route: string) {
window.scrollTo(0, savedY);
}, [activeTab, notifState.scrollPositions]);
- */
\ No newline at end of file
+ */
+
+
+
+export function useSticky(top: number = 0) {
+ const sentinelRef = useRef(null);
+ const [isStuck, setIsStuck] = useState(false);
+
+ useEffect(() => {
+ if (!sentinelRef.current) return;
+
+ const observer = new IntersectionObserver(
+ ([entry]) => setIsStuck(!entry.isIntersecting),
+ {
+ rootMargin: `-${top}px 0px 0px 0px`,
+ threshold: 0,
+ }
+ );
+
+ observer.observe(sentinelRef.current);
+ return () => observer.disconnect();
+ }, [top]);
+
+ return { sentinelRef, isStuck };
+}
\ No newline at end of file