From 6fbd272acfc230fab710a9f7010abafb41fa337b Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Tue, 26 Mar 2024 08:07:49 -0500 Subject: [PATCH] Add tooltips for review item chips (#10685) * tooltips for review item chips * use flexbox instead of margins --- .../player/PreviewThumbnailPlayer.tsx | 73 +++++++++++++------ 1 file changed, 50 insertions(+), 23 deletions(-) diff --git a/web/src/components/player/PreviewThumbnailPlayer.tsx b/web/src/components/player/PreviewThumbnailPlayer.tsx index 52b3e7b53..12e4bd706 100644 --- a/web/src/components/player/PreviewThumbnailPlayer.tsx +++ b/web/src/components/player/PreviewThumbnailPlayer.tsx @@ -19,6 +19,7 @@ import { useFormattedTimestamp } from "@/hooks/use-date-utils"; import useImageLoaded from "@/hooks/use-image-loaded"; import { Skeleton } from "../ui/skeleton"; import { useSwipeable } from "react-swipeable"; +import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/tooltip"; type PreviewPlayerProps = { review: ReviewSegment; @@ -121,7 +122,11 @@ export default function PreviewThumbnailPlayer({ const [hoverTimeout, setHoverTimeout] = useState(); const [playback, setPlayback] = useState(false); - const playingBack = useMemo(() => playback, [playback]); + const [tooltipHovering, setTooltipHovering] = useState(false); + const playingBack = useMemo( + () => playback && !tooltipHovering, + [playback, tooltipHovering], + ); const [isHovered, setIsHovered] = useState(false); useEffect(() => { @@ -129,7 +134,7 @@ export default function PreviewThumbnailPlayer({ return; } - if (isHovered) { + if (isHovered && !tooltipHovering) { setHoverTimeout( setTimeout(() => { setPlayback(true); @@ -149,7 +154,7 @@ export default function PreviewThumbnailPlayer({ } // we know that these deps are correct // eslint-disable-next-line react-hooks/exhaustive-deps - }, [isHovered, scrollLock]); + }, [isHovered, scrollLock, tooltipHovering]); // date @@ -196,28 +201,50 @@ export default function PreviewThumbnailPlayer({ }} /> +
+ +
setTooltipHovering(true)} + onMouseLeave={() => setTooltipHovering(false)} + > + +
+ {(review.severity == "alert" || + review.severity == "detection") && ( + <> + + {review.data.objects.map((object) => { + return getIconForLabel(object, "size-3 text-white"); + })} + {review.data.audio.map((audio) => { + return getIconForLabel(audio, "size-3 text-white"); + })} + {review.data.sub_labels?.map((sub) => { + return getIconForSubLabel(sub, "size-3 text-white"); + })} + + + )} +
+
+
+ + {[ + ...(review.data.objects || []), + ...(review.data.audio || []), + ...(review.data.sub_labels || []), + ] + .filter((item) => item !== undefined) + .join(", ")} + +
+
{!playingBack && ( <> -
-
- {(review.severity == "alert" || - review.severity == "detection") && ( - - {review.data.objects.map((object) => { - return getIconForLabel(object, "size-3 text-white"); - })} - {review.data.audio.map((audio) => { - return getIconForLabel(audio, "size-3 text-white"); - })} - {review.data.sub_labels?.map((sub) => { - return getIconForSubLabel(sub, "size-3 text-white"); - })} - - )} -
-
+