diff --git a/apps/dashboard/src/app/(app)/[organizationSlug]/[projectId]/realtime/page.tsx b/apps/dashboard/src/app/(app)/[organizationSlug]/[projectId]/realtime/page.tsx index 3f3c3c2c..0f8b9ab1 100644 --- a/apps/dashboard/src/app/(app)/[organizationSlug]/[projectId]/realtime/page.tsx +++ b/apps/dashboard/src/app/(app)/[organizationSlug]/[projectId]/realtime/page.tsx @@ -1,5 +1,9 @@ import { Suspense } from 'react'; -import { Fullscreen, FullscreenToggle } from '@/components/fullscreen-toggle'; +import { + Fullscreen, + FullscreenClose, + FullscreenOpen, +} from '@/components/fullscreen-toggle'; import { LazyChart } from '@/components/report/chart/LazyChart'; import PageLayout from '../page-layout'; @@ -20,10 +24,11 @@ export default function Page({ return ( <> } + title={} {...{ projectId, organizationSlug }} /> + diff --git a/apps/dashboard/src/components/fullscreen-toggle.tsx b/apps/dashboard/src/components/fullscreen-toggle.tsx index af08344e..b15d6b97 100644 --- a/apps/dashboard/src/components/fullscreen-toggle.tsx +++ b/apps/dashboard/src/components/fullscreen-toggle.tsx @@ -1,8 +1,11 @@ 'use client'; +import { useEffect, useRef, useState } from 'react'; import { cn } from '@/utils/cn'; -import { FullscreenIcon } from 'lucide-react'; +import { bind } from 'bind-event-listener'; +import { ChevronLeftIcon, FullscreenIcon } from 'lucide-react'; import { parseAsBoolean, useQueryState } from 'nuqs'; +import { useDebounce } from 'usehooks-ts'; import { Tooltiper } from './ui/tooltip'; @@ -25,7 +28,7 @@ export const Fullscreen = (props: Props) => { return (
{props.children} @@ -33,7 +36,7 @@ export const Fullscreen = (props: Props) => { ); }; -export const FullscreenToggle = () => { +export const FullscreenOpen = () => { const [, setIsFullscreen] = useFullscreen(); return ( @@ -49,3 +52,54 @@ export const FullscreenToggle = () => { ); }; + +export const FullscreenClose = () => { + const [fullscreen, setIsFullscreen] = useFullscreen(); + const isFullscreenDebounced = useDebounce(fullscreen, 1000); + const [visible, setVisible] = useState(false); + const ref = useRef(null); + useEffect(() => { + let timer: any; + const unsub = bind(window, { + type: 'mousemove', + listener(ev) { + if (fullscreen) { + setVisible(true); + clearTimeout(timer); + timer = setTimeout(() => { + if (!ref.current?.contains(ev.target as Node)) { + setVisible(false); + } + }, 500); + } + }, + }); + return () => { + unsub(); + clearTimeout(timer); + }; + }, [fullscreen]); + + if (!fullscreen) { + return null; + } + + return ( +
+ + + +
+ ); +};