From b6a84f2fbcc353b65763a49055b47c2086937403 Mon Sep 17 00:00:00 2001 From: Alex Mickelson Date: Wed, 7 Jan 2026 09:10:42 -0700 Subject: [PATCH] more tooltips --- .../[courseName]/calendar/day/ItemInDay.tsx | 65 +++++++++++++++---- 1 file changed, 54 insertions(+), 11 deletions(-) diff --git a/src/app/course/[courseName]/calendar/day/ItemInDay.tsx b/src/app/course/[courseName]/calendar/day/ItemInDay.tsx index b6f1cbc..e7987e8 100644 --- a/src/app/course/[courseName]/calendar/day/ItemInDay.tsx +++ b/src/app/course/[courseName]/calendar/day/ItemInDay.tsx @@ -1,13 +1,48 @@ import { IModuleItem } from "@/features/local/modules/IModuleItem"; import { getModuleItemUrl } from "@/services/urlUtils"; import Link from "next/link"; -import { ReactNode, useRef, useState } from "react"; +import { ReactNode } from "react"; import { useCourseContext } from "../../context/courseContext"; +import { useTooltip } from "@/components/useTooltip"; +import MarkdownDisplay from "@/components/MarkdownDisplay"; import { DraggableItem } from "../../context/drag/draggingContext"; import ClientOnly from "@/components/ClientOnly"; import { useDragStyleContext } from "../../context/drag/dragStyleContext"; import { Tooltip } from "../../../../../components/Tooltip"; +function getPreviewContent( + type: "assignment" | "page" | "quiz", + item: IModuleItem +): ReactNode { + if (type === "assignment" && "description" in item) { + const assignment = item as { + description: string; + githubClassroomAssignmentShareLink?: string; + }; + return ( + + ); + } else if (type === "page" && "text" in item) { + return ; + } else if (type === "quiz" && "questions" in item) { + const quiz = item as { questions: { text: string }[] }; + return quiz.questions.map((q, i: number) => ( +
+ +
+ )); + } + return null; +} + export function ItemInDay({ type, moduleName, @@ -23,8 +58,8 @@ export function ItemInDay({ }) { const { courseName } = useCourseContext(); const { setIsDragging } = useDragStyleContext(); - const linkRef = useRef(null); - const [tooltipVisible, setTooltipVisible] = useState(false); + const { visible, targetRef, showTooltip, hideTooltip } = useTooltip(500); + return (
setTooltipVisible(true)} - onMouseLeave={() => setTooltipVisible(false)} - ref={linkRef} + onMouseEnter={showTooltip} + onMouseLeave={hideTooltip} + ref={targetRef} > {item.name} - + {status === "published" ? ( + getPreviewContent(type, item) && ( + {getPreviewContent(type, item)}
+ } + targetRef={targetRef} + visible={visible} + /> + ) + ) : ( + + )} );