add header

This commit is contained in:
smanylov
2025-11-26 14:01:35 +07:00
parent 7a8c2cee56
commit ebca795c1b
16 changed files with 618 additions and 41 deletions
+24
View File
@@ -0,0 +1,24 @@
'use client';
import { useEffect, RefObject } from 'react';
export function useClickOutside(
ref: RefObject<HTMLDivElement | null>,
callback: () => void
) {
useEffect(() => {
const handleClick = (event: MouseEvent) => {
if (!ref) {
return;
}
if (ref.current && !ref.current.contains(event.target as Node)) {
callback();
}
};
document.addEventListener('mousedown', handleClick);
return () => {
document.removeEventListener('mousedown', handleClick);
};
}, [ref, callback]);
}