DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
wrapped PRIMARY_NAV items with Tooltip for expanded and collapsed states, refactored Tooltip prop
Phillip Lagoc646a241b0219
diff --git a/web/app/globals.css b/web/app/globals.cssindex fb7106244..d11906d36 100644--- a/web/app/globals.css+++ b/web/app/globals.css@@ -567,3 +567,38 @@padding-right: min(560px, 92vw);}}++/* Tooltip Component Styles */+.tooltip-wrapper {+ @apply relative inline-flex;+}++.tooltip-content {+ @apply absolute z-50 rounded-lg bg-[var(--popover)] px-3 py-1.5 text-xs shadow-md text-[var(--popover-foreground)];+ animation: tooltip-fade-in 150ms ease-out;+}++.tooltip-label {+ @apply font-medium;+}++.tooltip-desc {+ @apply mt-0.5 text-[11px] text-[var(--muted-foreground)];+}++[data-side="right"] {+ @apply left-full top-1/2 -translate-y-1/2 ml-2;+}++[data-side="bottom"] {+ @apply bottom-[-40px] left-1/2 -translate-x-1/2;+}++@keyframes tooltip-fade-in {+ from {+ opacity: 0;+ }+ to {+ opacity: 1;+ }+}diff --git a/web/components/sidebar/SidebarShell.tsx b/web/components/sidebar/SidebarShell.tsxindex 98b71516f..5c3fd4fe6 100644--- a/web/components/sidebar/SidebarShell.tsx+++ b/web/components/sidebar/SidebarShell.tsx@@ -269,6 +269,9 @@ export function SidebarShell({{PRIMARY_NAV.map((item) => {const active = pathname.startsWith(item.href);+ const tooltipProps = item.tooltipKey+ ? { description: t(item.tooltipKey) }+ : {};const hasSessionsBelow =item.href === "/chat" &&showSessions &&@@ -277,35 +280,42 @@ export function SidebarShell({onDeleteSession;const hasBots = item.href === "/agents";return (- <div key={item.href}>- <Link- href={item.href}- className={`flex items-center gap-2.5 rounded-lg px-3 py-2 text-[13.5px] transition-colors ${- active- ? "bg-[var(--background)]/70 font-medium text-[var(--foreground)]"- : "text-[var(--muted-foreground)] hover:bg-[var(--background)]/50 hover:text-[var(--foreground)]"- }`}- >- <item.icon size={16} strokeWidth={active ? 1.9 : 1.5} />- <span>{t(item.label)}</span>- </Link>- {hasSessionsBelow && (- <div- className={`${sessionViewportClassName} overflow-y-auto`}+ <Tooltip+ key={item.href}+ label={t(item.label)}+ side="bottom"+ {...tooltipProps}+ >+ <div key={item.href}>+ <Link+ href={item.href}+ className={`flex items-center gap-2.5 rounded-lg px-3 py-2 text-[13.5px] transition-colors ${+ active+ ? "bg-[var(--background)]/70 font-medium text-[var(--foreground)]"+ : "text-[var(--muted-foreground)] hover:bg-[var(--background)]/50 hover:text-[var(--foreground)]"+ }`}>- <SessionList- sessions={sessions}- activeSessionId={activeSessionId}- loading={loadingSessions}- onSelect={onSelectSession}- onRename={onRenameSession}- onDelete={onDeleteSession}- compact- />- </div>- )}- {hasBots && <TutorBotRecent />}- </div>+ <item.icon size={16} strokeWidth={active ? 1.9 : 1.5} />+ <span>{t(item.label)}</span>+ </Link>+ {hasSessionsBelow && (+ <div+ className={`${sessionViewportClassName} overflow-y-auto`}+ >+ <SessionList+ sessions={sessions}+ activeSessionId={activeSessionId}+ loading={loadingSessions}+ onSelect={onSelectSession}+ onRename={onRenameSession}+ onDelete={onDeleteSession}+ compact+ />+ </div>+ )}+ {hasBots && <TutorBotRecent />}+ </div>+ </Tooltip>);})}</div>diff --git a/web/components/ui/Tooltip.tsx b/web/components/ui/Tooltip.tsxindex 9e44e73a1..4313de2be 100644--- a/web/components/ui/Tooltip.tsx+++ b/web/components/ui/Tooltip.tsx@@ -1,6 +1,6 @@"use client";-import { ReactNode } from "react";+import { ReactNode, useState, useCallback, useRef, useId } from "react";interface TooltipProps {label: string;@@ -15,29 +15,41 @@ export function Tooltip({children,side = "right",}: TooltipProps) {- const sideStyles = {- right: "left-full top-1/2 -translate-y-1/2 ml-2",- bottom: "top-full left-1/2 -translate-x-1/2 mt-2",- };+ const [visible, setVisible] = useState(false);+ const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);+ const tooltipId = useId();++ const showTooltip = useCallback(() => {+ if (timeoutRef.current) clearTimeout(timeoutRef.current);+ timeoutRef.current = setTimeout(() => setVisible(true), 300);+ }, []);++ const hideTooltip = useCallback(() => {+ if (timeoutRef.current) clearTimeout(timeoutRef.current);+ setVisible(false);+ }, []);return (- <div className="group relative inline-flex">+ <div+ className="tooltip-wrapper"+ onMouseEnter={showTooltip}+ onMouseLeave={hideTooltip}+ onFocus={showTooltip}+ onBlur={hideTooltip}+ aria-describedby={visible ? tooltipId : undefined}+ >{children}- <div- className={`- absolute z-50 whitespace-nowrap rounded-lg bg-[var(--popover)] px-3 py-1.5 text-xs text-[var(--popover-foreground)] shadow-md- opacity-0 group-hover:opacity-100 transition-opacity duration-200- pointer-events-none- ${sideStyles[side]}- `}- >- <div className="font-medium">{label}</div>- {description && (- <div className="mt-0.5 text-[var(--muted-foreground)] text-[11px]">- {description}- </div>- )}- </div>+ {visible && (+ <div+ id={tooltipId}+ className="tooltip-content"+ data-side={side}+ role="tooltip"+ >+ <div className="tooltip-label">{label}</div>+ {description && <div className="tooltip-desc">{description}</div>}+ </div>+ )}</div>);}diff --git a/web/locales/zh/app.json b/web/locales/zh/app.jsonindex 916d32812..203b52b52 100644--- a/web/locales/zh/app.json+++ b/web/locales/zh/app.json@@ -1598,10 +1598,10 @@"Context": "上下文","Ask a question about this page. The current chapter content is sent to the assistant automatically.": "可以询问本页内容。当前章节内容会自动发送给助手。","Ask about this page...": "询问本页内容…",- "Chat tooltip": "This is the Chat tooltip.",- "TutorBot tooltip": "This is the TutorBot tooltip.",- "Co-Writer tooltip": "This is the Co-Writer tooltip.",- "Book tooltip": "This is the Book tooltip.",- "Knowledge tooltip": "This is the Knowledge tooltip.",- "Space tooltip": "This is the Space tooltip."+ "Chat tooltip": "This is the Chat tooltip (zh).",+ "TutorBot tooltip": "This is the TutorBot tooltip (zh).",+ "Co-Writer tooltip": "This is the Co-Writer tooltip (zh).",+ "Book tooltip": "This is the Book tooltip (zh).",+ "Knowledge tooltip": "This is the Knowledge tooltip (zh).",+ "Space tooltip": "This is the Space tooltip (zh)."}