Skip to content

DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.

fix(web): migrate learning and reading button title hints (#1526)

Bingxi Zhao (Frank)108ca70072fb
diff --git a/web/app/(workspace)/learning/books/components/BookChatPanel.tsx b/web/app/(workspace)/learning/books/components/BookChatPanel.tsx
index deac0257e..908eb2887 100644
--- a/web/app/(workspace)/learning/books/components/BookChatPanel.tsx
+++ b/web/app/(workspace)/learning/books/components/BookChatPanel.tsx
@@ -41,6 +41,7 @@ import type {
import { UnifiedTurnClient } from "@/features/chat/transport/UnifiedTurnClient";
import type { MessageAttachment } from "@/features/chat/ChatStateAdapter";
import type { Page, Book } from "@/lib/book-types";
+import Tooltip from "@/shared/ui/Tooltip";
interface ChatMessage {
role: "user" | "assistant";
@@ -559,15 +560,16 @@ export default function BookChatPanel({
<div className="mb-2 text-[11px] text-red-500">{attachmentError}</div>
)}
<div className="flex items-end gap-2 rounded-2xl border border-[var(--border)] bg-[var(--background)] px-2 py-2 focus-within:border-[var(--primary)]/50 focus-within:ring-2 focus-within:ring-[var(--primary)]/10">
- <button
- type="button"
- onClick={() => fileInputRef.current?.click()}
- className="mb-0.5 inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-xl text-[var(--muted-foreground)] transition-colors hover:bg-[var(--muted)] hover:text-[var(--foreground)]"
- title={t("Attach files")}
- aria-label={t("Attach files")}
- >
- <Paperclip className="h-4 w-4" />
- </button>
+ <Tooltip label={t("Attach files")}>
+ <button
+ type="button"
+ onClick={() => fileInputRef.current?.click()}
+ className="mb-0.5 inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-xl text-[var(--muted-foreground)] transition-colors hover:bg-[var(--muted)] hover:text-[var(--foreground)]"
+ aria-label={t("Attach files")}
+ >
+ <Paperclip className="h-4 w-4" />
+ </button>
+ </Tooltip>
<textarea
value={input}
onChange={(e) => setInput(e.target.value)}
diff --git a/web/app/(workspace)/learning/books/components/BookCreator.tsx b/web/app/(workspace)/learning/books/components/BookCreator.tsx
index 9e62a21c6..23887c27f 100644
--- a/web/app/(workspace)/learning/books/components/BookCreator.tsx
+++ b/web/app/(workspace)/learning/books/components/BookCreator.tsx
@@ -12,6 +12,7 @@ import {
toggleSourceSelection,
} from '@/hooks/useTopicSourceLibrary'
import { SourcesStep } from '@/components/space/learning/TopicWizardSteps'
+import Tooltip from '@/shared/ui/Tooltip'
/**
* Languages a book can be written in, plus the request-driven default.
@@ -274,20 +275,20 @@ export default function BookCreator({
{t('Depth')}
<div className="inline-flex overflow-hidden rounded-md border border-[var(--border)] text-[11px]">
{DEPTH_OPTIONS.map(option => (
- <button
- key={option.value}
- type="button"
- onClick={() => setDepth(option.value)}
- aria-pressed={depth === option.value}
- title={t(option.hint)}
- className={`px-2 py-0.5 font-medium transition-colors ${
- depth === option.value
- ? 'bg-[var(--primary)]/12 text-[var(--foreground)]'
- : 'text-[var(--muted-foreground)] hover:bg-[var(--muted)]/40 hover:text-[var(--foreground)]'
- }`}
- >
- {t(option.label)}
- </button>
+ <Tooltip key={option.value} label={t(option.hint)}>
+ <button
+ type="button"
+ onClick={() => setDepth(option.value)}
+ aria-pressed={depth === option.value}
+ className={`px-2 py-0.5 font-medium transition-colors ${
+ depth === option.value
+ ? 'bg-[var(--primary)]/12 text-[var(--foreground)]'
+ : 'text-[var(--muted-foreground)] hover:bg-[var(--muted)]/40 hover:text-[var(--foreground)]'
+ }`}
+ >
+ {t(option.label)}
+ </button>
+ </Tooltip>
))}
</div>
</div>
diff --git a/web/app/(workspace)/learning/books/components/BookHealthBanner.tsx b/web/app/(workspace)/learning/books/components/BookHealthBanner.tsx
index f5bdf8b23..1f1bea586 100644
--- a/web/app/(workspace)/learning/books/components/BookHealthBanner.tsx
+++ b/web/app/(workspace)/learning/books/components/BookHealthBanner.tsx
@@ -5,6 +5,7 @@ import { AlertTriangle, RefreshCcw, X, ScrollText } from "lucide-react";
import { useTranslation } from "react-i18next";
import { bookApi } from "@/lib/book-api";
import type { GenerationSummary } from "@/lib/book-types";
+import Tooltip from "@/shared/ui/Tooltip";
export interface BookHealthBannerProps {
bookId: string | null;
@@ -328,26 +329,32 @@ export default function BookHealthBanner({
</div>
<div className="flex items-center gap-1">
{hasDrift && (
- <button
- onClick={() => acknowledge()}
- disabled={busy}
- title={t(
+ <Tooltip
+ label={t(
"Available only after every stale page has been recompiled.",
)}
- className="whitespace-nowrap rounded-md border border-current px-2 py-1 text-xs font-medium hover:bg-white/40 disabled:opacity-60"
>
- {busy ? "…" : t("Mark as seen")}
- </button>
+ <button
+ onClick={() => acknowledge()}
+ disabled={busy}
+ className="whitespace-nowrap rounded-md border border-current px-2 py-1 text-xs font-medium hover:bg-white/40 disabled:opacity-60"
+ >
+ {busy ? "…" : t("Mark as seen")}
+ </button>
+ </Tooltip>
)}
{hasDrift && canForce && onRecompile && (
- <button
- onClick={() => acknowledge(true)}
- disabled={busy}
- title={t("Dismiss the warning without recompiling those pages.")}
- className="whitespace-nowrap rounded-md border border-current px-2 py-1 text-xs font-medium hover:bg-white/40 disabled:opacity-60"
+ <Tooltip
+ label={t("Dismiss the warning without recompiling those pages.")}
>
- {t("Mark as seen anyway")}
- </button>
+ <button
+ onClick={() => acknowledge(true)}
+ disabled={busy}
+ className="whitespace-nowrap rounded-md border border-current px-2 py-1 text-xs font-medium hover:bg-white/40 disabled:opacity-60"
+ >
+ {t("Mark as seen anyway")}
+ </button>
+ </Tooltip>
)}
<button
onClick={() => setDismissed(true)}
diff --git a/web/app/(workspace)/learning/books/components/BookLibrary.tsx b/web/app/(workspace)/learning/books/components/BookLibrary.tsx
index 8aef392bb..a7cebc179 100644
--- a/web/app/(workspace)/learning/books/components/BookLibrary.tsx
+++ b/web/app/(workspace)/learning/books/components/BookLibrary.tsx
@@ -28,6 +28,7 @@ import { useTranslation } from 'react-i18next'
import type { Book, BookStatus } from '@/lib/book-types'
import { formatRelativeTime } from '@/lib/relative-time'
+import Tooltip from '@/shared/ui/Tooltip'
const STATUS_STYLES: Record<BookStatus, { label: string; className: string; dot: string }> = {
draft: {
@@ -248,29 +249,33 @@ export default function BookLibrary({
)}
{book.can_delete !== false && (
- <button
- type="button"
- onClick={event => {
- event.stopPropagation()
- if (isPendingDelete) {
- onDeleteBook(book.id, book.content_workspace_id ?? '')
- setPendingDeleteId(null)
- } else {
- setPendingDeleteId(libraryItemKey(book, book.id))
- }
- }}
- title={isPendingDelete ? t('Click again to confirm') : t('Delete book')}
- // Permanently visible on touch, where there is no hover
- // to reveal it — a control that only appears on hover
- // does not exist on a phone.
- className={`absolute right-2 top-2 z-10 rounded-md p-1.5 transition-colors ${
- isPendingDelete
- ? 'bg-rose-500/15 text-rose-600 dark:text-rose-400'
- : 'text-[var(--muted-foreground)]/70 hover:bg-rose-500/10 hover:text-rose-600 sm:opacity-0 sm:group-hover:opacity-100 dark:hover:text-rose-400'
- }`}
- >
- <Trash2 size={13} />
- </button>
+ <div className="absolute right-2 top-2 z-10">
+ <Tooltip label={isPendingDelete ? t('Click again to confirm') : t('Delete book')}>
+ <button
+ type="button"
+ onClick={event => {
+ event.stopPropagation()
+ if (isPendingDelete) {
+ onDeleteBook(book.id, book.content_workspace_id ?? '')
+ setPendingDeleteId(null)
+ } else {
+ setPendingDeleteId(libraryItemKey(book, book.id))
+ }
+ }}
+ aria-label={isPendingDelete ? t('Click again to confirm') : t('Delete book')}
+ // Permanently visible on touch, where there is no hover
+ // to reveal it — a control that only appears on hover
+ // does not exist on a phone.
+ className={`rounded-md p-1.5 transition-colors ${
+ isPendingDelete
+ ? 'bg-rose-500/15 text-rose-600 dark:text-rose-400'
+ : 'text-[var(--muted-foreground)]/70 hover:bg-rose-500/10 hover:text-rose-600 sm:opacity-0 sm:group-hover:opacity-100 sm:focus-visible:opacity-100 dark:hover:text-rose-400'
+ }`}
+ >
+ <Trash2 size={13} />
+ </button>
+ </Tooltip>
+ </div>
)}
{/* Body */}
diff --git a/web/app/(workspace)/learning/books/components/BookSidebar.tsx b/web/app/(workspace)/learning/books/components/BookSidebar.tsx
index f78bdcc0a..646a679f7 100644
--- a/web/app/(workspace)/learning/books/components/BookSidebar.tsx
+++ b/web/app/(workspace)/learning/books/components/BookSidebar.tsx
@@ -15,6 +15,7 @@ import { useTranslation } from "react-i18next";
import { ActivityMark } from "@/components/activity";
import type { ActivityState, MarkTone } from "@/components/activity";
import type { Book, Page } from "@/lib/book-types";
+import Tooltip from "@/shared/ui/Tooltip";
const STATUS_LABEL: Record<string, string> = {
pending: "Queued",
@@ -88,41 +89,46 @@ export default function BookSidebar({
if (collapsed) {
return (
<aside className="flex h-full w-14 flex-col items-center gap-3 border-r border-[var(--border)] bg-[var(--card)]/40 px-2 py-4">
- <button
- onClick={onBackToLibrary}
- title={t("All books")}
- className="inline-flex h-8 w-8 items-center justify-center rounded-md text-[var(--muted-foreground)] transition-colors hover:bg-[var(--muted)]/40 hover:text-[var(--foreground)]"
- >
- <ArrowLeft className="h-4 w-4" />
- </button>
- <button
- onClick={() => setCollapsed(false)}
- title={t("Expand chapters")}
- className="inline-flex h-8 w-8 items-center justify-center rounded-md text-[var(--muted-foreground)] transition-colors hover:bg-[var(--muted)]/40 hover:text-[var(--foreground)]"
- >
- <ChevronRight className="h-4 w-4" />
- </button>
+ <Tooltip label={t("All books")}>
+ <button
+ onClick={onBackToLibrary}
+ aria-label={t("All books")}
+ className="inline-flex h-8 w-8 items-center justify-center rounded-md text-[var(--muted-foreground)] transition-colors hover:bg-[var(--muted)]/40 hover:text-[var(--foreground)]"
+ >
+ <ArrowLeft className="h-4 w-4" />
+ </button>
+ </Tooltip>
+ <Tooltip label={t("Expand chapters")}>
+ <button
+ onClick={() => setCollapsed(false)}
+ aria-label={t("Expand chapters")}
+ className="inline-flex h-8 w-8 items-center justify-center rounded-md text-[var(--muted-foreground)] transition-colors hover:bg-[var(--muted)]/40 hover:text-[var(--foreground)]"
+ >
+ <ChevronRight className="h-4 w-4" />
+ </button>
+ </Tooltip>
<div className="mt-1 h-px w-8 bg-[var(--border)]" />
<div className="flex flex-1 flex-col items-center gap-1 overflow-y-auto">
{pages.map((page, index) => {
const active = page.id === selectedPageId;
return (
- <button
- key={page.id}
- onClick={() => onSelectPage?.(page.id)}
- title={page.title || t("Untitled")}
- className={`inline-flex h-8 w-8 items-center justify-center rounded-md text-[11px] font-semibold ${
- active
- ? "bg-[var(--primary)]/15 text-[var(--foreground)]"
- : "text-[var(--muted-foreground)] hover:bg-[var(--muted)]/40 hover:text-[var(--foreground)]"
- }`}
- >
- {page.content_type === "overview" ? (
- <Compass className="h-3.5 w-3.5" />
- ) : (
- index + 1
- )}
- </button>
+ <Tooltip key={page.id} label={page.title || t("Untitled")}>
+ <button
+ onClick={() => onSelectPage?.(page.id)}
+ aria-label={page.title || t("Untitled")}
+ className={`inline-flex h-8 w-8 items-center justify-center rounded-md text-[11px] font-semibold ${
+ active
+ ? "bg-[var(--primary)]/15 text-[var(--foreground)]"
+ : "text-[var(--muted-foreground)] hover:bg-[var(--muted)]/40 hover:text-[var(--foreground)]"
+ }`}
+ >
+ {page.content_type === "overview" ? (
+ <Compass className="h-3.5 w-3.5" />
+ ) : (
+ index + 1
+ )}
+ </button>
+ </Tooltip>
);
})}
</div>
@@ -139,13 +145,15 @@ export default function BookSidebar({
>
<ArrowLeft className="h-3.5 w-3.5" /> {t("All books")}
</button>
- <button
- onClick={() => setCollapsed(true)}
- title={t("Collapse chapters")}
- className="inline-flex h-7 w-7 items-center justify-center rounded-md text-[var(--muted-foreground)] transition-colors hover:bg-[var(--muted)]/40 hover:text-[var(--foreground)]"
- >
- <ChevronLeft className="h-3.5 w-3.5" />
- </button>
+ <Tooltip label={t("Collapse chapters")}>
+ <button
+ onClick={() => setCollapsed(true)}
+ aria-label={t("Collapse chapters")}
+ className="inline-flex h-7 w-7 items-center justify-center rounded-md text-[var(--muted-foreground)] transition-colors hover:bg-[var(--muted)]/40 hover:text-[var(--foreground)]"
+ >
+ <ChevronLeft className="h-3.5 w-3.5" />
+ </button>
+ </Tooltip>
</div>
{book && (
diff --git a/web/app/(workspace)/learning/books/components/LearningCapturePanel.tsx b/web/app/(workspace)/learning/books/components/LearningCapturePanel.tsx
index 30e71e424..64ebd14a8 100644
--- a/web/app/(workspace)/learning/books/components/LearningCapturePanel.tsx
+++ b/web/app/(workspace)/learning/books/components/LearningCapturePanel.tsx
@@ -5,6 +5,7 @@ import { useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
import type { LearningCapture } from "@/lib/book-types";
+import Tooltip from "@/shared/ui/Tooltip";
interface LearningCapturePanelProps {
captures: LearningCapture[];
@@ -92,19 +93,22 @@ export default function LearningCapturePanel({
</span>
</button>
{open && (
- <button
- type="button"
- onClick={() => setShowAll((current) => !current)}
- className="inline-flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-[11px] text-[var(--muted-foreground)] hover:bg-[var(--muted)] hover:text-[var(--foreground)]"
- title={
+ <Tooltip
+ label={
showAll
? t("Show only reviewable captures")
: t("Show all captures")
}
>
- <ListFilter className="h-3.5 w-3.5" />
- {showAll ? t("Review") : t("All")}
- </button>
+ <button
+ type="button"
+ onClick={() => setShowAll((current) => !current)}
+ className="inline-flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-[11px] text-[var(--muted-foreground)] hover:bg-[var(--muted)] hover:text-[var(--foreground)]"
+ >
+ <ListFilter className="h-3.5 w-3.5" />
+ {showAll ? t("Review") : t("All")}
+ </button>
+ </Tooltip>
)}
</div>
diff --git a/web/app/(workspace)/learning/books/components/PageOutlineNav.tsx b/web/app/(workspace)/learning/books/components/PageOutlineNav.tsx
index 6f1b33b1e..c1ab410fd 100644
--- a/web/app/(workspace)/learning/books/components/PageOutlineNav.tsx
+++ b/web/app/(workspace)/learning/books/components/PageOutlineNav.tsx
@@ -22,6 +22,7 @@ import {
import { useTranslation } from "react-i18next";
import type { Block, BlockType, BlockStatus } from "@/lib/book-types";
+import Tooltip from "@/shared/ui/Tooltip";
const TYPE_ICON: Record<BlockType, LucideIcon> = {
text: AlignLeft,
@@ -224,15 +225,16 @@ export default function PageOutlineNav({
<Layers className="h-3 w-3" />
<span>{headerText}</span>
</div>
- <button
- type="button"
- onClick={() => setOutlineCollapsed(true)}
- title={collapseTip}
- aria-label={collapseTip}
- className="rounded p-1 text-[var(--muted-foreground)] transition-colors hover:bg-[var(--background)] hover:text-[var(--foreground)]"
- >
- <ChevronRight className="h-3.5 w-3.5" />
- </button>
+ <Tooltip label={collapseTip}>
+ <button
+ type="button"
+ onClick={() => setOutlineCollapsed(true)}
+ aria-label={collapseTip}
+ className="rounded p-1 text-[var(--muted-foreground)] transition-colors hover:bg-[var(--background)] hover:text-[var(--foreground)]"
+ >
+ <ChevronRight className="h-3.5 w-3.5" />
+ </button>
+ </Tooltip>
</div>
<ol className="flex-1 overflow-y-auto px-1.5 py-1.5">
@@ -298,27 +300,32 @@ export default function PageOutlineNav({
</nav>
{/* ── Collapsed handle: chevron-only button overlays the same card */}
- <button
- type="button"
- onClick={() => setOutlineCollapsed(false)}
- title={expandTip}
- aria-label={expandTip}
- aria-hidden={!collapsed}
- tabIndex={collapsed ? 0 : -1}
+ <div
className={[
- "group absolute inset-0 flex items-center justify-center text-[var(--muted-foreground)] transition-colors hover:text-[var(--foreground)]",
+ "absolute inset-0 [&>span]:h-full [&>span]:w-full",
collapsed ? "pointer-events-auto" : "pointer-events-none",
].join(" ")}
- style={{
- opacity: collapsed ? 1 : 0,
- transform: collapsed ? "translateX(0)" : "translateX(-6px)",
- transition: collapsed
- ? `opacity 220ms ease-out 120ms, transform 320ms ${EASE} 80ms`
- : `opacity 140ms ease-out, transform 220ms ${EASE}`,
- }}
>
- <ChevronRight className="h-3.5 w-3.5 rotate-180 transition-transform duration-200 group-hover:-translate-x-0.5" />
- </button>
+ <Tooltip label={expandTip} suppressed={!collapsed}>
+ <button
+ type="button"
+ onClick={() => setOutlineCollapsed(false)}
+ aria-label={expandTip}
+ aria-hidden={!collapsed}
+ tabIndex={collapsed ? 0 : -1}
+ className="group flex h-full w-full items-center justify-center text-[var(--muted-foreground)] transition-colors hover:text-[var(--foreground)]"
+ style={{
+ opacity: collapsed ? 1 : 0,
+ transform: collapsed ? "translateX(0)" : "translateX(-6px)",
+ transition: collapsed
+ ? `opacity 220ms ease-out 120ms, transform 320ms ${EASE} 80ms`
+ : `opacity 140ms ease-out, transform 220ms ${EASE}`,
+ }}
+ >
+ <ChevronRight className="h-3.5 w-3.5 rotate-180 transition-transform duration-200 group-hover:-translate-x-0.5" />
+ </button>
+ </Tooltip>
+ </div>
</div>
</div>
);
diff --git a/web/app/(workspace)/learning/books/components/PageReader.tsx b/web/app/(workspace)/learning/books/components/PageReader.tsx
index fd53bbce7..a20a58497 100644
--- a/web/app/(workspace)/learning/books/components/PageReader.tsx
+++ b/web/app/(workspace)/learning/books/components/PageReader.tsx
@@ -27,6 +27,7 @@ import {
type SequentialReadDirection,
} from "@/lib/book-reader-navigation";
import { browserStorage } from "@/shared/storage";
+import Tooltip from "@/shared/ui/Tooltip";
import BlockRenderer from "./blocks/BlockRenderer";
import type { QuizAttemptArgs } from "./blocks/QuizBlock";
import PageOutlineNav from "./PageOutlineNav";
@@ -490,25 +491,27 @@ export default function PageReader({
</span>
)}
{onToggleBookmark && (
- <button
- type="button"
- onClick={onToggleBookmark}
- title={
- bookmarked ? t("Remove bookmark") : t("Bookmark this chapter")
- }
- aria-pressed={bookmarked}
- className={`inline-flex h-6 w-6 items-center justify-center rounded-md transition-colors ${
- bookmarked
- ? "text-[var(--primary)]"
- : "text-[var(--muted-foreground)] hover:bg-[var(--background)] hover:text-[var(--foreground)]"
- }`}
+ <Tooltip
+ label={bookmarked ? t("Remove bookmark") : t("Bookmark this chapter")}
>
- {bookmarked ? (
- <BookmarkCheck className="h-3.5 w-3.5" />
- ) : (
- <Bookmark className="h-3.5 w-3.5" />
- )}
- </button>
+ <button
+ type="button"
+ onClick={onToggleBookmark}
+ aria-label={bookmarked ? t("Remove bookmark") : t("Bookmark this chapter")}
+ aria-pressed={bookmarked}
+ className={`inline-flex h-6 w-6 items-center justify-center rounded-md transition-colors ${
+ bookmarked
+ ? "text-[var(--primary)]"
+ : "text-[var(--muted-foreground)] hover:bg-[var(--background)] hover:text-[var(--foreground)]"
+ }`}
+ >
+ {bookmarked ? (
+ <BookmarkCheck className="h-3.5 w-3.5" />
+ ) : (
+ <Bookmark className="h-3.5 w-3.5" />
+ )}
+ </button>
+ </Tooltip>
)}
{!headerCollapsed && onRecompile && (
<button
@@ -524,22 +527,23 @@ export default function PageReader({
{loading ? t("Regenerating…") : t("Force regenerate")}
</button>
)}
- <button
- type="button"
- onClick={() => {
- setHeaderCollapsed((v) => !v);
- setUserToggled(true);
- }}
- title={headerCollapsed ? expandTip : collapseTip}
- aria-label={headerCollapsed ? expandTip : collapseTip}
- className="inline-flex h-6 w-6 items-center justify-center rounded-md text-[var(--muted-foreground)] hover:bg-[var(--background)] hover:text-[var(--foreground)]"
- >
- {headerCollapsed ? (
- <ChevronDown className="h-3.5 w-3.5" />
- ) : (
- <ChevronUp className="h-3.5 w-3.5" />
- )}
- </button>
+ <Tooltip label={headerCollapsed ? expandTip : collapseTip}>
+ <button
+ type="button"
+ onClick={() => {
+ setHeaderCollapsed((v) => !v);
+ setUserToggled(true);
+ }}
+ aria-label={headerCollapsed ? expandTip : collapseTip}
+ className="inline-flex h-6 w-6 items-center justify-center rounded-md text-[var(--muted-foreground)] hover:bg-[var(--background)] hover:text-[var(--foreground)]"
+ >
+ {headerCollapsed ? (
+ <ChevronDown className="h-3.5 w-3.5" />
+ ) : (
+ <ChevronUp className="h-3.5 w-3.5" />
+ )}
+ </button>
+ </Tooltip>
</div>
</div>
</header>
@@ -800,22 +804,25 @@ function NavButton({
if (!page) return <span className="min-w-0 flex-1" />;
const isNext = direction === "next";
return (
- <button
- type="button"
- onClick={() => onNavigate(page.id)}
- className={`group inline-flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-2 py-1 text-xs text-[var(--muted-foreground)] transition-colors hover:bg-[var(--muted)]/40 hover:text-[var(--foreground)] ${
- isNext ? "justify-end text-right" : "justify-start text-left"
- }`}
- title={page.title}
- >
- {!isNext && <ChevronLeft className="h-3.5 w-3.5 shrink-0" />}
- <span className="min-w-0">
- <span className="block text-[10px] uppercase tracking-wider opacity-70">
- {label}
- </span>
- <span className="block truncate">{page.title}</span>
- </span>
- {isNext && <ChevronRight className="h-3.5 w-3.5 shrink-0" />}
- </button>
+ <div className="min-w-0 flex-1 [&>span]:w-full">
+ <Tooltip label={page.title}>
+ <button
+ type="button"
+ onClick={() => onNavigate(page.id)}
+ className={`group inline-flex w-full min-w-0 items-center gap-1.5 rounded-md px-2 py-1 text-xs text-[var(--muted-foreground)] transition-colors hover:bg-[var(--muted)]/40 hover:text-[var(--foreground)] ${
+ isNext ? "justify-end text-right" : "justify-start text-left"
+ }`}
+ >
+ {!isNext && <ChevronLeft className="h-3.5 w-3.5 shrink-0" />}
+ <span className="min-w-0">
+ <span className="block text-[10px] uppercase tracking-wider opacity-70">
+ {label}
+ </span>
+ <span className="block truncate">{page.title}</span>
+ </span>
+ {isNext && <ChevronRight className="h-3.5 w-3.5 shrink-0" />}
+ </button>
+ </Tooltip>
+ </div>
);
}
diff --git a/web/app/(workspace)/learning/books/components/blocks/BlockRenderer.tsx b/web/app/(workspace)/learning/books/components/blocks/BlockRenderer.tsx
index bc4cbc3cc..2fc629f8a 100644
--- a/web/app/(workspace)/learning/books/components/blocks/BlockRenderer.tsx
+++ b/web/app/(workspace)/learning/books/components/blocks/BlockRenderer.tsx
@@ -14,6 +14,7 @@ import {
import { useTranslation } from "react-i18next";
import type { Block, BlockType, QuizAttempt } from "@/lib/book-types";
import MarkdownRenderer from "@/components/common/MarkdownRenderer";
+import Tooltip from "@/shared/ui/Tooltip";
import BlockBodyEditor from "./BlockBodyEditor";
import TextBlock from "./TextBlock";
@@ -268,34 +269,41 @@ export default function BlockRenderer({
</div>
)}
{hasActions && (
- <div className="pointer-events-none absolute -top-3 right-2 z-10 flex translate-y-1 items-center gap-1 rounded-md border border-[var(--border)] bg-[var(--card)] px-1 py-0.5 text-[var(--muted-foreground)] opacity-0 shadow-sm transition group-hover:translate-y-0 group-hover:opacity-100">
+ <div className="pointer-events-none absolute -top-3 right-2 z-10 flex translate-y-1 items-center gap-1 rounded-md border border-[var(--border)] bg-[var(--card)] px-1 py-0.5 text-[var(--muted-foreground)] opacity-0 shadow-sm transition group-hover:translate-y-0 group-hover:opacity-100 group-focus-within:translate-y-0 group-focus-within:opacity-100">
{onMove && (
<>
- <button
- onClick={() => onMove(block, "up")}
- className="pointer-events-auto rounded p-1 hover:bg-[var(--background)] hover:text-[var(--foreground)]"
- title={t("Move up")}
- >
- <ArrowUp className="h-3.5 w-3.5" />
- </button>
- <button
- onClick={() => onMove(block, "down")}
- className="pointer-events-auto rounded p-1 hover:bg-[var(--background)] hover:text-[var(--foreground)]"
- title={t("Move down")}
- >
- <ArrowDown className="h-3.5 w-3.5" />
- </button>
+ <Tooltip label={t("Move up")}>
+ <button
+ onClick={() => onMove(block, "up")}
+ aria-label={t("Move up")}
+ className="pointer-events-auto rounded p-1 hover:bg-[var(--background)] hover:text-[var(--foreground)]"
+ >
+ <ArrowUp className="h-3.5 w-3.5" />
+ </button>
+ </Tooltip>
+ <Tooltip label={t("Move down")}>
+ <button
+ onClick={() => onMove(block, "down")}
+ aria-label={t("Move down")}
+ className="pointer-events-auto rounded p-1 hover:bg-[var(--background)] hover:text-[var(--foreground)]"
+ >
+ <ArrowDown className="h-3.5 w-3.5" />
+ </button>
+ </Tooltip>
</>
)}
{onChangeType && (
<div className="relative pointer-events-auto">
- <button
- onClick={() => setShowTypeMenu((v) => !v)}
- className="rounded p-1 hover:bg-[var(--background)] hover:text-[var(--foreground)]"
- title={t("Change type")}
- >
- <Replace className="h-3.5 w-3.5" />
- </button>
+ <Tooltip label={t("Change type")} suppressed={showTypeMenu}>
+ <button
+ onClick={() => setShowTypeMenu((v) => !v)}
+ aria-label={t("Change type")}
+ aria-expanded={showTypeMenu}
+ className="rounded p-1 hover:bg-[var(--background)] hover:text-[var(--foreground)]"
+ >
+ <Replace className="h-3.5 w-3.5" />
+ </button>
+ </Tooltip>
{showTypeMenu && (
<div className="absolute right-0 top-full mt-1 max-h-60 w-44 overflow-y-auto rounded-md border border-[var(--border)] bg-[var(--card)] p-1 shadow-lg">
{CHANGEABLE_TYPES.filter((type) => type !== block.type).map(
@@ -317,47 +325,59 @@ export default function BlockRenderer({
</div>
)}
{canEditBody && !editingBody && (
- <button
- onClick={() => setEditingBody(true)}
- className="pointer-events-auto rounded p-1 hover:bg-[var(--background)] hover:text-[var(--foreground)]"
- title={t("Edit text")}
- >
- <Pencil className="h-3.5 w-3.5" />
- </button>
+ <Tooltip label={t("Edit text")}>
+ <button
+ onClick={() => setEditingBody(true)}
+ aria-label={t("Edit text")}
+ className="pointer-events-auto rounded p-1 hover:bg-[var(--background)] hover:text-[var(--foreground)]"
+ >
+ <Pencil className="h-3.5 w-3.5" />
+ </button>
+ </Tooltip>
)}
{onRegenerate && (
- <button
- onClick={() => onRegenerate(block)}
- className="pointer-events-auto rounded p-1 hover:bg-[var(--background)] hover:text-[var(--foreground)]"
- title={t("Regenerate")}
- >
- <RefreshCw className="h-3.5 w-3.5" />
- </button>
+ <Tooltip label={t("Regenerate")}>
+ <button
+ onClick={() => onRegenerate(block)}
+ aria-label={t("Regenerate")}
+ className="pointer-events-auto rounded p-1 hover:bg-[var(--background)] hover:text-[var(--foreground)]"
+ >
+ <RefreshCw className="h-3.5 w-3.5" />
+ </button>
+ </Tooltip>
)}
{onDelete && (
- <button
- onClick={() => {
- if (confirmDelete) {
- setConfirmDelete(false);
- onDelete(block);
- } else {
- setConfirmDelete(true);
- }
- }}
- onBlur={() => setConfirmDelete(false)}
- className={`pointer-events-auto rounded p-1 ${
- confirmDelete
- ? "bg-rose-500/15 text-rose-600 dark:text-rose-300"
- : "hover:bg-rose-100 hover:text-rose-700 dark:hover:bg-rose-500/10 dark:hover:text-rose-200"
- }`}
- title={
+ <Tooltip
+ label={
confirmDelete
? t("Click again to delete this block")
: t("Delete")
}
>
- <Trash2 className="h-3.5 w-3.5" />
- </button>
+ <button
+ onClick={() => {
+ if (confirmDelete) {
+ setConfirmDelete(false);
+ onDelete(block);
+ } else {
+ setConfirmDelete(true);
+ }
+ }}
+ onBlur={() => setConfirmDelete(false)}
+ aria-label={
+ confirmDelete
+ ? t("Click again to delete this block")
+ : t("Delete")
+ }
+ className={`pointer-events-auto rounded p-1 ${
+ confirmDelete
+ ? "bg-rose-500/15 text-rose-600 dark:text-rose-300"
+ : "hover:bg-rose-100 hover:text-rose-700 dark:hover:bg-rose-500/10 dark:hover:text-rose-200"
+ }`}
+ >
+ <Trash2 className="h-3.5 w-3.5" />
+ </button>
+ </Tooltip>
)}
</div>
)}
diff --git a/web/app/(workspace)/learning/books/components/blocks/DeepDiveBlock.tsx b/web/app/(workspace)/learning/books/components/blocks/DeepDiveBlock.tsx
index 319d76b52..f27cdec8e 100644
--- a/web/app/(workspace)/learning/books/components/blocks/DeepDiveBlock.tsx
+++ b/web/app/(workspace)/learning/books/components/blocks/DeepDiveBlock.tsx
@@ -4,6 +4,7 @@ import { useState } from "react";
import { ArrowUpRight, ChevronRight, Sparkles, Loader2 } from "lucide-react";
import { useTranslation } from "react-i18next";
import type { Block } from "@/lib/book-types";
+import Tooltip from "@/shared/ui/Tooltip";
interface Suggestion {
topic?: string;
@@ -62,55 +63,60 @@ export default function DeepDiveBlock({
return (
<li key={topic || i}>
- <button
- onClick={async () => {
- if (!topic) return;
- // Already expanded → this is the way back to that chapter.
- if (existingPageId) {
- onOpenPage?.(existingPageId);
- return;
+ <div className="[&>span]:w-full">
+ <Tooltip
+ label={
+ existingPageId
+ ? t("Open the chapter this created")
+ : t("Generate a chapter on this")
}
- if (!onDeepDive) return;
- setBusy(topic);
- try {
- await onDeepDive(topic, block.id);
- } finally {
- setBusy(null);
- }
- }}
- // Only the topic being generated locks, plus the others while a
- // generation is in flight. Choosing one no longer retires the rest.
- disabled={isPending || (anyPending && !existingPageId)}
- title={
- existingPageId
- ? t("Open the chapter this created")
- : t("Generate a chapter on this")
- }
- className="group flex w-full items-start justify-between gap-3 rounded-xl border border-[var(--border)] bg-[var(--card)] px-3 py-2 text-left transition hover:border-[var(--primary)]/40 disabled:opacity-60"
- >
- <div className="flex-1">
- <div className="flex items-center gap-1.5 text-sm font-medium text-[var(--foreground)]">
- {topic}
- {existingPageId && (
- <span className="rounded-full bg-[var(--primary)]/10 px-1.5 py-0.5 text-[9px] font-semibold uppercase tracking-wider text-[var(--primary)]">
- {t("Created")}
- </span>
- )}
- </div>
- {s.rationale && (
- <div className="mt-0.5 text-xs leading-relaxed text-[var(--muted-foreground)]">
- {s.rationale}
+ >
+ <button
+ onClick={async () => {
+ if (!topic) return;
+ // Already expanded → this is the way back to that chapter.
+ if (existingPageId) {
+ onOpenPage?.(existingPageId);
+ return;
+ }
+ if (!onDeepDive) return;
+ setBusy(topic);
+ try {
+ await onDeepDive(topic, block.id);
+ } finally {
+ setBusy(null);
+ }
+ }}
+ // Only the topic being generated locks, plus the others while a
+ // generation is in flight. Choosing one no longer retires the rest.
+ disabled={isPending || (anyPending && !existingPageId)}
+ className="group flex w-full items-start justify-between gap-3 rounded-xl border border-[var(--border)] bg-[var(--card)] px-3 py-2 text-left transition hover:border-[var(--primary)]/40 disabled:opacity-60"
+ >
+ <div className="flex-1">
+ <div className="flex items-center gap-1.5 text-sm font-medium text-[var(--foreground)]">
+ {topic}
+ {existingPageId && (
+ <span className="rounded-full bg-[var(--primary)]/10 px-1.5 py-0.5 text-[9px] font-semibold uppercase tracking-wider text-[var(--primary)]">
+ {t("Created")}
+ </span>
+ )}
+ </div>
+ {s.rationale && (
+ <div className="mt-0.5 text-xs leading-relaxed text-[var(--muted-foreground)]">
+ {s.rationale}
+ </div>
+ )}
</div>
- )}
- </div>
- {isPending ? (
- <Loader2 className="h-4 w-4 shrink-0 animate-spin text-[var(--primary)]" />
- ) : existingPageId ? (
- <ArrowUpRight className="h-4 w-4 shrink-0 text-[var(--primary)]" />
- ) : (
- <ChevronRight className="h-4 w-4 shrink-0 text-[var(--muted-foreground)] transition group-hover:translate-x-0.5 group-hover:text-[var(--primary)]" />
- )}
- </button>
+ {isPending ? (
+ <Loader2 className="h-4 w-4 shrink-0 animate-spin text-[var(--primary)]" />
+ ) : existingPageId ? (
+ <ArrowUpRight className="h-4 w-4 shrink-0 text-[var(--primary)]" />
+ ) : (
+ <ChevronRight className="h-4 w-4 shrink-0 text-[var(--muted-foreground)] transition group-hover:translate-x-0.5 group-hover:text-[var(--primary)]" />
+ )}
+ </button>
+ </Tooltip>
+ </div>
</li>
);
})}
diff --git a/web/app/(workspace)/learning/books/components/blocks/UserNoteBlock.tsx b/web/app/(workspace)/learning/books/components/blocks/UserNoteBlock.tsx
index 8238e9d34..968ee3635 100644
--- a/web/app/(workspace)/learning/books/components/blocks/UserNoteBlock.tsx
+++ b/web/app/(workspace)/learning/books/components/blocks/UserNoteBlock.tsx
@@ -6,6 +6,7 @@ import { useTranslation } from "react-i18next";
import MarkdownRenderer from "@/components/common/MarkdownRenderer";
import type { Block } from "@/lib/book-types";
+import Tooltip from "@/shared/ui/Tooltip";
export interface UserNoteBlockProps {
block: Block;
@@ -74,14 +75,16 @@ export default function UserNoteBlock({
{t("Your note")}
</div>
{editable && !editing && (
- <button
- type="button"
- onClick={() => setEditing(true)}
- title={t("Edit note")}
- className="inline-flex h-6 w-6 items-center justify-center rounded-md text-[var(--muted-foreground)] opacity-0 transition-opacity hover:bg-[var(--background)] hover:text-[var(--foreground)] group-hover/note:opacity-100"
- >
- <Pencil className="h-3 w-3" />
- </button>
+ <Tooltip label={t("Edit note")}>
+ <button
+ type="button"
+ onClick={() => setEditing(true)}
+ aria-label={t("Edit note")}
+ className="inline-flex h-6 w-6 items-center justify-center rounded-md text-[var(--muted-foreground)] opacity-0 transition-opacity hover:bg-[var(--background)] hover:text-[var(--foreground)] group-hover/note:opacity-100 focus-visible:opacity-100"
+ >
+ <Pencil className="h-3 w-3" />
+ </button>
+ </Tooltip>
)}
</div>
diff --git a/web/components/learning/practice/PracticeInsights.tsx b/web/components/learning/practice/PracticeInsights.tsx
index 632054ee4..8e5c180d9 100644
--- a/web/components/learning/practice/PracticeInsights.tsx
+++ b/web/components/learning/practice/PracticeInsights.tsx
@@ -5,6 +5,7 @@ import { useRouter, useSearchParams } from "next/navigation";
import { useTranslation } from "react-i18next";
import { BarChart3, ChartNoAxesCombined, RefreshCw } from "lucide-react";
import { practiceRoute } from "@/lib/learning-routes";
+import Tooltip from "@/shared/ui/Tooltip";
import {
getPracticeAnalytics,
type PracticeAnalytics,
@@ -116,17 +117,17 @@ export function PracticeInsights({ courseId, revision, workspaceId }: { courseId
aria-label={t("Chart style")}
>
{(["line", "bars"] as const).map(value => (
- <button
- key={value}
- type="button"
- aria-pressed={style === value}
- title={t(value === "line" ? "Line chart" : "Bar chart")}
- aria-label={t(value === "line" ? "Line chart" : "Bar chart")}
- onClick={() => setView("stats_chart", value)}
- className={`rounded-md p-2 ${style === value ? "bg-muted text-foreground" : "text-muted-foreground hover:text-foreground"}`}
- >
- {value === "line" ? <ChartNoAxesCombined size={15} /> : <BarChart3 size={15} />}
- </button>
+ <Tooltip key={value} label={t(value === "line" ? "Line chart" : "Bar chart")}>
+ <button
+ type="button"
+ aria-pressed={style === value}
+ aria-label={t(value === "line" ? "Line chart" : "Bar chart")}
+ onClick={() => setView("stats_chart", value)}
+ className={`rounded-md p-2 ${style === value ? "bg-muted text-foreground" : "text-muted-foreground hover:text-foreground"}`}
+ >
+ {value === "line" ? <ChartNoAxesCombined size={15} /> : <BarChart3 size={15} />}
+ </button>
+ </Tooltip>
))}
</div>
</div>
diff --git a/web/components/quiz/QuizConfigPanel.tsx b/web/components/quiz/QuizConfigPanel.tsx
index 676d9ac14..23be496a1 100644
--- a/web/components/quiz/QuizConfigPanel.tsx
+++ b/web/components/quiz/QuizConfigPanel.tsx
@@ -27,6 +27,7 @@ import {
Field,
INPUT_CLS,
} from "@/components/chat/home/composer-field";
+import Tooltip from "@/shared/ui/Tooltip";
interface QuizConfigPanelProps {
value: DeepQuestionFormConfig;
@@ -483,8 +484,8 @@ function TypeMultiSelect({ value, onChange }: TypeMultiSelectProps) {
return `${value.length} ${t("types")}`;
}, [value, t]);
- // Full list of selected types — surfaced as a native title tooltip on
- // the trigger so the user can see exactly which types are picked when
+ // Full list of selected types — surfaced through the shared tooltip so
+ // the user can see exactly which types are picked when
// the summary collapses to "N types" (or even just truncates a single
// long label).
const triggerTooltip = useMemo(() => {
@@ -555,21 +556,25 @@ function TypeMultiSelect({ value, onChange }: TypeMultiSelectProps) {
return (
<>
- <button
- ref={triggerRef}
- type="button"
- title={triggerTooltip}
- onClick={toggleMenu}
- className={`${INPUT_CLS} flex w-full items-center justify-between gap-1`}
- >
- <span className="min-w-0 truncate text-left">{summary}</span>
- <ChevronDown
- size={12}
- className={`shrink-0 text-[var(--muted-foreground)]/60 transition-transform ${
- open ? "rotate-180" : ""
- }`}
- />
- </button>
+ <span className="block w-full [&>span]:w-full">
+ <Tooltip label={triggerTooltip} suppressed={open}>
+ <button
+ ref={triggerRef}
+ type="button"
+ onClick={toggleMenu}
+ aria-expanded={open}
+ className={`${INPUT_CLS} flex w-full items-center justify-between gap-1`}
+ >
+ <span className="min-w-0 truncate text-left">{summary}</span>
+ <ChevronDown
+ size={12}
+ className={`shrink-0 text-[var(--muted-foreground)]/60 transition-transform ${
+ open ? "rotate-180" : ""
+ }`}
+ />
+ </button>
+ </Tooltip>
+ </span>
{menu}
</>
);
@@ -590,7 +595,6 @@ function DropdownRow({
<button
type="button"
onClick={onClick}
- title={label}
className="flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-[12px] text-[var(--foreground)] transition-colors hover:bg-[var(--muted)]"
>
<span
diff --git a/web/components/quiz/QuizViewer.tsx b/web/components/quiz/QuizViewer.tsx
index 2f033f524..e7db6a88a 100644
--- a/web/components/quiz/QuizViewer.tsx
+++ b/web/components/quiz/QuizViewer.tsx
@@ -54,6 +54,7 @@ import {
} from "@/lib/notebook-api";
import { recordQuizResults } from "@/lib/session-api";
import { apiUrl } from "@/lib/api";
+import Tooltip from "@/shared/ui/Tooltip";
import { randomUuid } from "@/lib/random-uuid";
@@ -780,16 +781,17 @@ export default function QuizViewer({
className="overflow-hidden rounded-xl border border-[var(--border)] bg-[var(--card)]"
>
<div className="flex items-center gap-2 border-b border-[var(--border)] px-3 py-2">
- <button
- type="button"
- onClick={() => setIdx((value) => Math.max(0, value - 1))}
- disabled={idx === 0}
- title={t("Previous")}
- aria-label={t("Previous")}
- className="inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-[var(--border)] bg-[var(--muted)]/60 text-[var(--foreground)] shadow-sm transition-colors hover:border-[var(--primary)] hover:bg-[var(--primary)]/10 hover:text-[var(--primary)] disabled:cursor-not-allowed disabled:border-[var(--border)] disabled:bg-transparent disabled:text-[var(--muted-foreground)] disabled:opacity-40 disabled:hover:bg-transparent"
- >
- <ChevronLeft size={18} strokeWidth={2.5} />
- </button>
+ <Tooltip label={t("Previous")}>
+ <button
+ type="button"
+ onClick={() => setIdx((value) => Math.max(0, value - 1))}
+ disabled={idx === 0}
+ aria-label={t("Previous")}
+ className="inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-[var(--border)] bg-[var(--muted)]/60 text-[var(--foreground)] shadow-sm transition-colors hover:border-[var(--primary)] hover:bg-[var(--primary)]/10 hover:text-[var(--primary)] disabled:cursor-not-allowed disabled:border-[var(--border)] disabled:bg-transparent disabled:text-[var(--muted-foreground)] disabled:opacity-40 disabled:hover:bg-transparent"
+ >
+ <ChevronLeft size={18} strokeWidth={2.5} />
+ </button>
+ </Tooltip>
<span className="text-[11px] font-semibold text-[var(--muted-foreground)]">
{completedCount}/{total}
</span>
@@ -866,16 +868,17 @@ export default function QuizViewer({
);
})}
</div>
- <button
- type="button"
- onClick={() => setIdx((value) => Math.min(total - 1, value + 1))}
- disabled={idx === total - 1}
- title={t("Next")}
- aria-label={t("Next")}
- className="inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-[var(--border)] bg-[var(--muted)]/60 text-[var(--foreground)] shadow-sm transition-colors hover:border-[var(--primary)] hover:bg-[var(--primary)]/10 hover:text-[var(--primary)] disabled:cursor-not-allowed disabled:border-[var(--border)] disabled:bg-transparent disabled:text-[var(--muted-foreground)] disabled:opacity-40 disabled:hover:bg-transparent"
- >
- <ChevronRight size={18} strokeWidth={2.5} />
- </button>
+ <Tooltip label={t("Next")}>
+ <button
+ type="button"
+ onClick={() => setIdx((value) => Math.min(total - 1, value + 1))}
+ disabled={idx === total - 1}
+ aria-label={t("Next")}
+ className="inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-[var(--border)] bg-[var(--muted)]/60 text-[var(--foreground)] shadow-sm transition-colors hover:border-[var(--primary)] hover:bg-[var(--primary)]/10 hover:text-[var(--primary)] disabled:cursor-not-allowed disabled:border-[var(--border)] disabled:bg-transparent disabled:text-[var(--muted-foreground)] disabled:opacity-40 disabled:hover:bg-transparent"
+ >
+ <ChevronRight size={18} strokeWidth={2.5} />
+ </button>
+ </Tooltip>
</div>
<div className="h-0.5 bg-[var(--muted)]">
<div
@@ -910,47 +913,52 @@ export default function QuizViewer({
{ans.submitted && (
<div className="relative flex items-center gap-1">
- <button
- onClick={handleToggleBookmark}
- disabled={!currentEntryId}
- title={currentBookmarked ? t("Remove Bookmark") : t("Bookmark")}
- className={`rounded-lg p-1.5 transition-all disabled:opacity-30 ${
- currentBookmarked
- ? "scale-110 text-amber-500 dark:text-amber-400"
- : "text-[var(--muted-foreground)] hover:text-amber-500 dark:hover:text-amber-400"
- }`}
- >
- <Bookmark
- size={18}
- strokeWidth={currentBookmarked ? 2.5 : 1.8}
- fill={currentBookmarked ? "currentColor" : "none"}
- />
- </button>
+ <Tooltip label={currentBookmarked ? t("Remove Bookmark") : t("Bookmark")}>
+ <button
+ type="button"
+ onClick={handleToggleBookmark}
+ disabled={!currentEntryId}
+ aria-label={currentBookmarked ? t("Remove Bookmark") : t("Bookmark")}
+ className={`rounded-lg p-1.5 transition-all disabled:opacity-30 ${
+ currentBookmarked
+ ? "scale-110 text-amber-500 dark:text-amber-400"
+ : "text-[var(--muted-foreground)] hover:text-amber-500 dark:hover:text-amber-400"
+ }`}
+ >
+ <Bookmark
+ size={18}
+ strokeWidth={currentBookmarked ? 2.5 : 1.8}
+ fill={currentBookmarked ? "currentColor" : "none"}
+ />
+ </button>
+ </Tooltip>
<CategoryMenu
categories={categories}
disabled={!currentEntryId}
onPick={handleAddToCategory}
onCreate={handleCreateAndAdd}
/>
- <button
- onClick={handleOpenFollowup}
- title={t("Follow-up Chat")}
- className="ml-1 inline-flex items-center gap-1 rounded-lg border border-[var(--primary)]/60 bg-[var(--primary)]/10 px-2 py-1 text-[12px] font-medium text-[var(--primary)] transition-colors hover:bg-[var(--primary)]/15"
- >
- <MessageSquarePlus size={13} />
- {t("Follow-up")}
- {(() => {
- const tcount =
- followupThreads[questionKey]?.messages.filter(
- (m) => m.role !== "system",
- ).length ?? 0;
- return tcount > 0 ? (
- <span className="rounded-full bg-[var(--primary)]/25 px-1.5 py-0 text-[10px]">
- {tcount}
- </span>
- ) : null;
- })()}
- </button>
+ <Tooltip label={t("Follow-up Chat")}>
+ <button
+ type="button"
+ onClick={handleOpenFollowup}
+ className="ml-1 inline-flex items-center gap-1 rounded-lg border border-[var(--primary)]/60 bg-[var(--primary)]/10 px-2 py-1 text-[12px] font-medium text-[var(--primary)] transition-colors hover:bg-[var(--primary)]/15"
+ >
+ <MessageSquarePlus size={13} />
+ {t("Follow-up")}
+ {(() => {
+ const tcount =
+ followupThreads[questionKey]?.messages.filter(
+ (m) => m.role !== "system",
+ ).length ?? 0;
+ return tcount > 0 ? (
+ <span className="rounded-full bg-[var(--primary)]/25 px-1.5 py-0 text-[10px]">
+ {tcount}
+ </span>
+ ) : null;
+ })()}
+ </button>
+ </Tooltip>
</div>
)}
</div>
@@ -1154,14 +1162,18 @@ export default function QuizViewer({
{image.filename}
</div>
{!ans.submitted && (
- <button
- type="button"
- onClick={() => handleRemoveImage(image.id)}
- title={t("Remove image")}
- className="absolute right-1 top-1 inline-flex h-5 w-5 items-center justify-center rounded-full bg-black/55 text-white opacity-0 transition-opacity group-hover:opacity-100"
- >
- <X size={11} />
- </button>
+ <span className="absolute right-1 top-1 opacity-0 transition-opacity group-hover:opacity-100">
+ <Tooltip label={t("Remove image")}>
+ <button
+ type="button"
+ onClick={() => handleRemoveImage(image.id)}
+ aria-label={t("Remove image")}
+ className="inline-flex h-5 w-5 items-center justify-center rounded-full bg-black/55 text-white"
+ >
+ <X size={11} />
+ </button>
+ </Tooltip>
+ </span>
)}
</div>
);
@@ -1298,18 +1310,19 @@ export default function QuizViewer({
<Loader2 size={10} className="animate-spin" />
)}
</button>
- <button
- type="button"
- onClick={toggleCollapsed}
- aria-label={collapsed ? t("Expand") : t("Collapse")}
- title={collapsed ? t("Expand") : t("Collapse")}
- className="ml-auto inline-flex h-5 w-5 items-center justify-center rounded-md text-[var(--muted-foreground)] transition-colors hover:bg-[var(--muted)] hover:text-[var(--foreground)]"
- >
- <ChevronDown
- size={13}
- className={`transition-transform ${collapsed ? "-rotate-90" : ""}`}
- />
- </button>
+ <Tooltip label={collapsed ? t("Expand") : t("Collapse")}>
+ <button
+ type="button"
+ onClick={toggleCollapsed}
+ aria-label={collapsed ? t("Expand") : t("Collapse")}
+ className="ml-auto inline-flex h-5 w-5 items-center justify-center rounded-md text-[var(--muted-foreground)] transition-colors hover:bg-[var(--muted)] hover:text-[var(--foreground)]"
+ >
+ <ChevronDown
+ size={13}
+ className={`transition-transform ${collapsed ? "-rotate-90" : ""}`}
+ />
+ </button>
+ </Tooltip>
</div>
) : (
<button
diff --git a/web/components/reading/AnnotationLayer.tsx b/web/components/reading/AnnotationLayer.tsx
index 5eecc3348..3e7e2de99 100644
--- a/web/components/reading/AnnotationLayer.tsx
+++ b/web/components/reading/AnnotationLayer.tsx
@@ -1,6 +1,8 @@
"use client";
import type { AnnotationItem, NormalisedRect } from "@/lib/reading-api";
+import { useTranslation } from "react-i18next";
+import Tooltip from "@/shared/ui/Tooltip";
/** Ink for each palette colour, tuned to stay readable over black-on-white text. */
const COLOR_INK: Record<string, string> = {
@@ -41,6 +43,7 @@ export function AnnotationLayer({
flashRects,
onAnnotationClick,
}: AnnotationLayerProps) {
+ const { t } = useTranslation();
return (
<div className="pointer-events-none absolute inset-0">
{annotations.map((annotation) =>
@@ -49,14 +52,21 @@ export function AnnotationLayer({
const isFocused =
annotation.annotation_id === highlightedAnnotationId;
const isUnderline = annotation.kind === "underline";
+ const label =
+ annotation.note ||
+ annotation.quote ||
+ t(
+ annotation.kind === "citation"
+ ? "Citation"
+ : isUnderline
+ ? "Underline"
+ : "Highlight",
+ );
return (
- <button
+ <span
key={`${annotation.annotation_id}-${index}`}
- type="button"
- title={annotation.note || annotation.quote || undefined}
- onClick={() => onAnnotationClick?.(annotation)}
className={[
- "pointer-events-auto absolute cursor-pointer transition-[box-shadow,filter] duration-150",
+ "pointer-events-auto absolute cursor-pointer transition-[box-shadow,filter] duration-150 [&>span]:h-full [&>span]:w-full [&>span>button]:h-full [&>span>button]:w-full",
isUnderline ? "" : "mix-blend-multiply",
isFocused ? "ring-2 ring-[var(--ring)] ring-offset-1" : "",
]
@@ -76,13 +86,22 @@ export function AnnotationLayer({
borderRadius: isUnderline ? 0 : 2,
}}
>
- {annotation.author === "assistant" && index === 0 && (
- <span
- aria-hidden
- className="absolute -top-1 -right-1 h-1.5 w-1.5 rounded-full bg-[var(--primary)] shadow-sm"
- />
- )}
- </button>
+ <Tooltip label={label}>
+ <button
+ type="button"
+ aria-label={label}
+ onClick={() => onAnnotationClick?.(annotation)}
+ className="block cursor-pointer"
+ >
+ {annotation.author === "assistant" && index === 0 && (
+ <span
+ aria-hidden
+ className="absolute -top-1 -right-1 h-1.5 w-1.5 rounded-full bg-[var(--primary)] shadow-sm"
+ />
+ )}
+ </button>
+ </Tooltip>
+ </span>
);
}),
)}
diff --git a/web/components/reading/AnnotationList.tsx b/web/components/reading/AnnotationList.tsx
index 7bb4f1eba..b7ee1e994 100644
--- a/web/components/reading/AnnotationList.tsx
+++ b/web/components/reading/AnnotationList.tsx
@@ -10,6 +10,7 @@ import {
Trash2,
} from "lucide-react";
import { useTranslation } from "react-i18next";
+import Tooltip from "@/shared/ui/Tooltip";
import {
ANNOTATION_SWATCH,
type AnnotationColor,
@@ -177,18 +178,21 @@ export function AnnotationList({
</span>
)}
</div>
- <button
- type="button"
- title={t("Delete annotation")}
- aria-label={t("Delete annotation")}
- onClick={(event) => {
- event.stopPropagation();
- onDelete(annotation);
- }}
- className="absolute right-1.5 top-1.5 inline-flex h-6 w-6 items-center justify-center rounded-md text-[var(--muted-foreground)] opacity-0 transition hover:bg-[color-mix(in_srgb,var(--destructive)_10%,transparent)] hover:text-[var(--destructive)] focus-visible:opacity-100 group-hover/anno:opacity-100"
- >
- <Trash2 size={12} />
- </button>
+ <span className="absolute right-1.5 top-1.5 opacity-0 transition focus-within:opacity-100 group-hover/anno:opacity-100">
+ <Tooltip label={t("Delete annotation")}>
+ <button
+ type="button"
+ aria-label={t("Delete annotation")}
+ onClick={(event) => {
+ event.stopPropagation();
+ onDelete(annotation);
+ }}
+ className="inline-flex h-6 w-6 items-center justify-center rounded-md text-[var(--muted-foreground)] hover:bg-[color-mix(in_srgb,var(--destructive)_10%,transparent)] hover:text-[var(--destructive)]"
+ >
+ <Trash2 size={12} />
+ </button>
+ </Tooltip>
+ </span>
</div>
</li>
))}
diff --git a/web/components/reading/ReaderDisplayControls.tsx b/web/components/reading/ReaderDisplayControls.tsx
index ce6e62d60..14ce4d254 100644
--- a/web/components/reading/ReaderDisplayControls.tsx
+++ b/web/components/reading/ReaderDisplayControls.tsx
@@ -11,6 +11,7 @@ import {
type LucideIcon,
} from "lucide-react";
import { useTranslation } from "react-i18next";
+import Tooltip from "@/shared/ui/Tooltip";
import {
DEFAULT_READER_DISPLAY_PREFERENCES,
@@ -36,19 +37,20 @@ export function PreferenceButton({
onClick: () => void;
}) {
return (
- <button
- type="button"
- title={label}
- aria-label={label}
- aria-pressed={active}
- disabled={disabled}
- onClick={onClick}
- className={`inline-flex h-7 w-7 items-center justify-center rounded-lg text-inherit transition hover:bg-[color-mix(in_srgb,currentColor_10%,transparent)] disabled:opacity-35 disabled:hover:bg-transparent ${
- active ? "opacity-100" : "opacity-70 hover:opacity-100"
- }`}
- >
- <Icon size={15} />
- </button>
+ <Tooltip label={label}>
+ <button
+ type="button"
+ aria-label={label}
+ aria-pressed={active}
+ disabled={disabled}
+ onClick={onClick}
+ className={`inline-flex h-7 w-7 items-center justify-center rounded-lg text-inherit transition hover:bg-[color-mix(in_srgb,currentColor_10%,transparent)] disabled:opacity-35 disabled:hover:bg-transparent ${
+ active ? "opacity-100" : "opacity-70 hover:opacity-100"
+ }`}
+ >
+ <Icon size={15} />
+ </button>
+ </Tooltip>
);
}
diff --git a/web/components/reading/ReaderPane.tsx b/web/components/reading/ReaderPane.tsx
index e6e27711a..1b41fb0ec 100644
--- a/web/components/reading/ReaderPane.tsx
+++ b/web/components/reading/ReaderPane.tsx
@@ -1,6 +1,7 @@
"use client";
import { browserStorage } from "@/shared/storage";
+import Tooltip from "@/shared/ui/Tooltip";
import { useCallback, useEffect, useMemo, useRef, useState, type RefObject } from "react";
import {
@@ -1265,26 +1266,27 @@ function HeaderButton({
className?: string;
}) {
return (
- <button
- ref={buttonRef}
- type="button"
- title={label}
- aria-label={label}
- aria-pressed={menu ? undefined : active}
- aria-haspopup={menu ? "menu" : undefined}
- aria-expanded={menu ? active : undefined}
- disabled={spinning || disabled}
- onClick={onClick}
- className={`h-7 w-7 shrink-0 items-center justify-center rounded-lg transition disabled:cursor-default ${
- className || "inline-flex"
- } ${
- active
- ? "bg-[color-mix(in_srgb,var(--primary)_12%,transparent)] text-[var(--primary)]"
- : "text-[var(--muted-foreground)] hover:bg-[var(--muted)] hover:text-[var(--foreground)] disabled:opacity-35 disabled:hover:bg-transparent"
- }`}
- >
- <Icon size={14} className={spinning ? "animate-spin" : undefined} />
- </button>
+ <Tooltip label={label} suppressed={Boolean(menu && active)}>
+ <button
+ ref={buttonRef}
+ type="button"
+ aria-label={label}
+ aria-pressed={menu ? undefined : active}
+ aria-haspopup={menu ? "menu" : undefined}
+ aria-expanded={menu ? active : undefined}
+ disabled={spinning || disabled}
+ onClick={onClick}
+ className={`h-7 w-7 shrink-0 items-center justify-center rounded-lg transition disabled:cursor-default ${
+ className || "inline-flex"
+ } ${
+ active
+ ? "bg-[color-mix(in_srgb,var(--primary)_12%,transparent)] text-[var(--primary)]"
+ : "text-[var(--muted-foreground)] hover:bg-[var(--muted)] hover:text-[var(--foreground)] disabled:opacity-35 disabled:hover:bg-transparent"
+ }`}
+ >
+ <Icon size={14} className={spinning ? "animate-spin" : undefined} />
+ </button>
+ </Tooltip>
);
}
@@ -1310,7 +1312,6 @@ function MenuToolButton({
<button
type="button"
role={active === undefined ? "menuitem" : "menuitemcheckbox"}
- title={hint || label}
aria-label={hint ? `${label}. ${hint}` : label}
aria-checked={active}
disabled={spinning || disabled}
diff --git a/web/components/reading/ReadingExtensionBar.tsx b/web/components/reading/ReadingExtensionBar.tsx
index 9f8a5092b..249f83a74 100644
--- a/web/components/reading/ReadingExtensionBar.tsx
+++ b/web/components/reading/ReadingExtensionBar.tsx
@@ -19,6 +19,7 @@ import {
type ReadingExtensionResult,
} from "@/lib/reading-api";
import { useReadingActions } from "./reading-actions-context";
+import Tooltip from "@/shared/ui/Tooltip";
type VocabularyTerm = {
term: string;
@@ -227,12 +228,11 @@ function ExtensionToolbar({
const Icon =
(ageMode !== "default" ? PRIMARY_ACTION_ICONS[primaryRank] : null) ?? Sparkles;
const iconSize = primaryRank >= 0 && ageMode === "early" ? 18 : 14;
- return (
+ const button = (
<button
key={key}
type="button"
disabled={disabled}
- title={needsSelection ? t("Select text in the document first.") : undefined}
aria-label={
shortLabel && builtInLabel
? `${t(shortLabel)} — ${t(builtInLabel)}`
@@ -257,6 +257,21 @@ function ExtensionToolbar({
</span>
</button>
);
+ if (!needsSelection) return button;
+ return (
+ <span
+ key={key}
+ className={
+ ageMode === "default"
+ ? "inline-flex min-w-[88px] flex-1 [&>span]:w-full [&>span>button]:w-full"
+ : "inline-flex w-max flex-none max-sm:min-w-0 max-sm:w-0 max-sm:flex-1 [&>span]:w-full [&>span>button]:w-full"
+ }
+ >
+ <Tooltip label={t("Select text in the document first.")}>
+ {button}
+ </Tooltip>
+ </span>
+ );
})}
</div>
{speaking ? (
@@ -266,15 +281,18 @@ function ExtensionToolbar({
>
<Volume2 size={14} />
<span>{t("Reading aloud")}</span>
- <button
- type="button"
- aria-label={t("Stop reading aloud")}
- title={t("Stop reading aloud")}
- onClick={stopSpeaking}
- className="ml-auto inline-flex h-7 w-7 items-center justify-center rounded-md text-[var(--foreground)] transition hover:bg-[var(--muted)]"
- >
- <Square size={12} fill="currentColor" />
- </button>
+ <span className="ml-auto">
+ <Tooltip label={t("Stop reading aloud")}>
+ <button
+ type="button"
+ aria-label={t("Stop reading aloud")}
+ onClick={stopSpeaking}
+ className="inline-flex h-7 w-7 items-center justify-center rounded-md text-[var(--foreground)] transition hover:bg-[var(--muted)]"
+ >
+ <Square size={12} fill="currentColor" />
+ </button>
+ </Tooltip>
+ </span>
</div>
) : null}
{result && result.type !== "browser_speech" ? (
diff --git a/web/components/reading/library/FolderDialog.tsx b/web/components/reading/library/FolderDialog.tsx
index 71836ddd9..b024f6277 100644
--- a/web/components/reading/library/FolderDialog.tsx
+++ b/web/components/reading/library/FolderDialog.tsx
@@ -12,6 +12,7 @@ import {
} from "@/lib/reading-workspace-api";
import { FOLDER_COLORS, FolderGlyph, folderTone } from "./FolderGlyph";
+import Tooltip from "@/shared/ui/Tooltip";
/**
* Creating a collection and renaming or recolouring one are the same small
@@ -135,21 +136,21 @@ export function FolderDialog({
{FOLDER_COLORS.map((row) => {
const selected = row.key === color;
return (
- <button
- key={row.key || "default"}
- type="button"
- onClick={() => setColor(row.key)}
- aria-label={t(row.label)}
- aria-pressed={selected}
- title={t(row.label)}
- className="size-6 rounded-full transition hover:scale-110"
- style={{
- background: row.tone,
- boxShadow: selected
- ? `0 0 0 2px var(--card), 0 0 0 3.5px ${folderTone(row.key)}`
- : undefined,
- }}
- />
+ <Tooltip key={row.key || "default"} label={t(row.label)}>
+ <button
+ type="button"
+ onClick={() => setColor(row.key)}
+ aria-label={t(row.label)}
+ aria-pressed={selected}
+ className="size-6 rounded-full transition hover:scale-110"
+ style={{
+ background: row.tone,
+ boxShadow: selected
+ ? `0 0 0 2px var(--card), 0 0 0 3.5px ${folderTone(row.key)}`
+ : undefined,
+ }}
+ />
+ </Tooltip>
);
})}
</div>
diff --git a/web/components/reading/library/ReadingFolder.tsx b/web/components/reading/library/ReadingFolder.tsx
index 490fd509f..7ba731903 100644
--- a/web/components/reading/library/ReadingFolder.tsx
+++ b/web/components/reading/library/ReadingFolder.tsx
@@ -17,6 +17,7 @@ import Link from "next/link";
import { useRouter } from "next/navigation";
import { useCallback, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
+import Tooltip from "@/shared/ui/Tooltip";
import { LearningSkeleton } from "@/components/learning/LearningShell";
import { useChatWorkspaces } from "@/hooks/useChatWorkspaces";
@@ -410,45 +411,49 @@ function FileRow({
return (
<li className="group flex items-center">
- <button
- type="button"
- onClick={onOpen}
- title={t("Open in reader")}
- className="flex min-w-0 flex-1 items-center gap-3 px-1 py-2.5 text-left transition hover:bg-[var(--secondary)]"
- >
- <span className="flex size-8 shrink-0 items-center justify-center rounded-md bg-[var(--muted)] text-[var(--muted-foreground)]">
- {opening || pending ? (
- <Loader2 size={14} className="animate-spin" />
- ) : (
- <MaterialGlyph material={material} size={14} />
- )}
- </span>
- <span className="min-w-0 flex-1">
- <span className="block truncate text-[13px] font-medium">
- {material.title || material.filename}
- </span>
- {detail && (
- <span
- className={`block truncate text-[11px] ${
- failed
- ? "text-[var(--destructive)]"
- : "text-[var(--muted-foreground)]"
- }`}
- >
- {detail}
+ <span className="min-w-0 flex-1 [&>span]:w-full [&>span>button]:w-full">
+ <Tooltip label={t("Open in reader")}>
+ <button
+ type="button"
+ onClick={onOpen}
+ className="flex min-w-0 flex-1 items-center gap-3 px-1 py-2.5 text-left transition hover:bg-[var(--secondary)]"
+ >
+ <span className="flex size-8 shrink-0 items-center justify-center rounded-md bg-[var(--muted)] text-[var(--muted-foreground)]">
+ {opening || pending ? (
+ <Loader2 size={14} className="animate-spin" />
+ ) : (
+ <MaterialGlyph material={material} size={14} />
+ )}
</span>
- )}
- </span>
- </button>
- <button
- type="button"
- onClick={onRemove}
- aria-label={t("Remove from collection")}
- title={t("Remove from collection")}
- className="mx-1 flex size-7 shrink-0 items-center justify-center rounded-md text-[var(--muted-foreground)] opacity-100 transition hover:bg-[var(--muted)] hover:text-[var(--foreground)] sm:opacity-0 sm:focus:opacity-100 sm:group-hover:opacity-100"
- >
- <X size={13} />
- </button>
+ <span className="min-w-0 flex-1">
+ <span className="block truncate text-[13px] font-medium">
+ {material.title || material.filename}
+ </span>
+ {detail && (
+ <span
+ className={`block truncate text-[11px] ${
+ failed
+ ? "text-[var(--destructive)]"
+ : "text-[var(--muted-foreground)]"
+ }`}
+ >
+ {detail}
+ </span>
+ )}
+ </span>
+ </button>
+ </Tooltip>
+ </span>
+ <Tooltip label={t("Remove from collection")}>
+ <button
+ type="button"
+ onClick={onRemove}
+ aria-label={t("Remove from collection")}
+ className="mx-1 flex size-7 shrink-0 items-center justify-center rounded-md text-[var(--muted-foreground)] opacity-100 transition hover:bg-[var(--muted)] hover:text-[var(--foreground)] sm:opacity-0 sm:focus:opacity-100 sm:group-hover:opacity-100"
+ >
+ <X size={13} />
+ </button>
+ </Tooltip>
</li>
);
}
diff --git a/web/components/reading/workspace/SourceNavigator.tsx b/web/components/reading/workspace/SourceNavigator.tsx
index a54d2abdc..474a7ae2d 100644
--- a/web/components/reading/workspace/SourceNavigator.tsx
+++ b/web/components/reading/workspace/SourceNavigator.tsx
@@ -468,24 +468,29 @@ export function SourceNavigator({
/>
) : (
visibleHeadings.map((heading) => (
- <button
+ <span
key={heading.id}
- type="button"
- onClick={() => onNavigateHeading(heading)}
- style={{
- paddingLeft: `${
- 10 + (Math.min(heading.level, 4) - 1) * 10
- }px`,
- }}
- className={`mb-0.5 block w-full truncate rounded-lg py-1.5 pr-2 text-left text-[12px] leading-[1.4] transition ${
- activeHeadingId === heading.id
- ? "bg-[var(--muted)] font-medium text-[var(--primary)]"
- : "text-[var(--muted-foreground)] hover:bg-[var(--muted)] hover:text-[var(--foreground)]"
- }`}
- title={heading.title}
+ className="block w-full [&>span]:w-full [&>span>button]:w-full"
>
- {heading.title}
- </button>
+ <Tooltip label={heading.title}>
+ <button
+ type="button"
+ onClick={() => onNavigateHeading(heading)}
+ style={{
+ paddingLeft: `${
+ 10 + (Math.min(heading.level, 4) - 1) * 10
+ }px`,
+ }}
+ className={`mb-0.5 block w-full truncate rounded-lg py-1.5 pr-2 text-left text-[12px] leading-[1.4] transition ${
+ activeHeadingId === heading.id
+ ? "bg-[var(--muted)] font-medium text-[var(--primary)]"
+ : "text-[var(--muted-foreground)] hover:bg-[var(--muted)] hover:text-[var(--foreground)]"
+ }`}
+ >
+ {heading.title}
+ </button>
+ </Tooltip>
+ </span>
))
)}
</div>
@@ -597,33 +602,34 @@ export function WorkspaceOutlineBranch({
: "text-[var(--foreground)] hover:bg-[var(--muted)]"
}`}
>
- <button
- type="button"
- onClick={() => onNavigate(node.row.locator)}
- // The spelled-out locator is the tooltip rather than the label:
- // see the number column below.
- title={t("p. {{page}}", { page: node.row.locator })}
- className="flex min-w-0 flex-1 items-baseline gap-2 px-2 py-1.5 text-left"
- >
- {/* A table of contents is read by its titles, so the title
- carries the weight and the locator is the quiet column
- beside it — the other way round, 74 blue page numbers
- out-shouted the headings they were pointing at.
+ <span className="inline-flex min-w-0 flex-1 [&>span]:w-full [&>span>button]:w-full">
+ <Tooltip label={t("p. {{page}}", { page: node.row.locator })}>
+ <button
+ type="button"
+ onClick={() => onNavigate(node.row.locator)}
+ className="flex min-w-0 flex-1 items-baseline gap-2 px-2 py-1.5 text-left"
+ >
+ {/* A table of contents is read by its titles, so the title
+ carries the weight and the locator is the quiet column
+ beside it — the other way round, 74 blue page numbers
+ out-shouted the headings they were pointing at.
- It is also just the number. "p. 12" fits the 32px this
- column had, but every translation of it does not: in
- Chinese ("第 12 页") 65 of this document's 74 rows wrapped
- onto a second line, so the list had two different row
- heights and a ragged left edge for the titles. Right-
- aligned tabular digits are what a printed contents page
- does anyway, and no translation can outgrow them. */}
- <span className="w-7 shrink-0 text-right text-[11px] tabular-nums text-[var(--muted-foreground)]">
- {node.row.locator}
- </span>
- <span className="line-clamp-3 min-w-0 text-[12px] leading-[1.5]">
- {node.row.title}
- </span>
- </button>
+ It is also just the number. "p. 12" fits the 32px this
+ column had, but every translation of it does not: in
+ Chinese ("第 12 页") 65 of this document's 74 rows wrapped
+ onto a second line, so the list had two different row
+ heights and a ragged left edge for the titles. Right-
+ aligned tabular digits are what a printed contents page
+ does anyway, and no translation can outgrow them. */}
+ <span className="w-7 shrink-0 text-right text-[11px] tabular-nums text-[var(--muted-foreground)]">
+ {node.row.locator}
+ </span>
+ <span className="line-clamp-3 min-w-0 text-[12px] leading-[1.5]">
+ {node.row.title}
+ </span>
+ </button>
+ </Tooltip>
+ </span>
{node.children.length > 0 && (
<button
type="button"
diff --git a/web/components/space/learning/MasteryStudy.tsx b/web/components/space/learning/MasteryStudy.tsx
index 8c3b594c7..421bc3cb0 100644
--- a/web/components/space/learning/MasteryStudy.tsx
+++ b/web/components/space/learning/MasteryStudy.tsx
@@ -4,6 +4,7 @@ import { scopedUrl } from "@/lib/workspace-scope";
import { MASTERY_HOME, masterySessionsRoute, masteryTopicRoute } from "@/lib/learning-routes";
import { browserStorage } from "@/shared/storage";
+import Tooltip from "@/shared/ui/Tooltip";
import dynamic from "next/dynamic";
import Link from "next/link";
@@ -597,16 +598,17 @@ export function MasteryStudy({
/>
<div className="flex shrink-0 items-center gap-1.5 pl-2">
- <button
- type="button"
- onClick={() => setShowSaveModal(true)}
- disabled={!notebookSavePayload}
- className="flex h-8 w-8 items-center justify-center rounded-lg text-[var(--muted-foreground)] transition-colors hover:bg-[var(--muted)]/60 hover:text-[var(--foreground)] disabled:cursor-not-allowed disabled:opacity-40"
- title={t("Save to Notebook")}
- aria-label={t("Save to Notebook")}
- >
- <BookmarkPlus className="h-4 w-4" />
- </button>
+ <Tooltip label={t("Save to Notebook")}>
+ <button
+ type="button"
+ onClick={() => setShowSaveModal(true)}
+ disabled={!notebookSavePayload}
+ className="flex h-8 w-8 items-center justify-center rounded-lg text-[var(--muted-foreground)] transition-colors hover:bg-[var(--muted)]/60 hover:text-[var(--foreground)] disabled:cursor-not-allowed disabled:opacity-40"
+ aria-label={t("Save to Notebook")}
+ >
+ <BookmarkPlus className="h-4 w-4" />
+ </button>
+ </Tooltip>
<button
type="button"
onClick={() => setViewerOpen((open) => !open)}
diff --git a/web/components/space/learning/ModeSwitch.tsx b/web/components/space/learning/ModeSwitch.tsx
index ed61ff290..89439e3e4 100644
--- a/web/components/space/learning/ModeSwitch.tsx
+++ b/web/components/space/learning/ModeSwitch.tsx
@@ -1,6 +1,7 @@
"use client";
import { useTranslation } from "react-i18next";
+import Tooltip from "@/shared/ui/Tooltip";
import {
MASTERY_MODES,
@@ -47,34 +48,36 @@ export function ModeSwitch({
{MASTERY_MODES.map((candidate) => {
const active = candidate === mode;
return (
- <button
+ <Tooltip
key={candidate}
- type="button"
- onClick={() => !active && onSelect(candidate)}
- disabled={disabled || active}
- aria-pressed={active}
- // Why it is not clickable right now, rather than a dead control.
- title={
+ label={
disabled
? t("Wait for the tutor to finish before changing mode")
- : undefined
+ : t(MASTERY_MODE_LABELS[candidate])
}
- className={`flex h-7 items-center gap-1.5 rounded-md px-2 text-[12px] font-medium transition ${
- active
- ? "bg-[var(--background)] text-[var(--foreground)] shadow-sm"
- : "text-[var(--muted-foreground)] hover:text-[var(--foreground)] disabled:hover:text-[var(--muted-foreground)]"
- } disabled:cursor-default`}
>
- <span
- aria-hidden="true"
- className={`h-[7px] w-[7px] rounded-full border transition-colors ${
+ <button
+ type="button"
+ onClick={() => !active && onSelect(candidate)}
+ disabled={disabled || active}
+ aria-pressed={active}
+ className={`flex h-7 items-center gap-1.5 rounded-md px-2 text-[12px] font-medium transition ${
active
- ? "border-[var(--primary)] bg-[var(--primary)]"
- : "border-[var(--muted-foreground)]/45"
- }`}
- />
- {t(MASTERY_MODE_LABELS[candidate])}
- </button>
+ ? "bg-[var(--background)] text-[var(--foreground)] shadow-sm"
+ : "text-[var(--muted-foreground)] hover:text-[var(--foreground)] disabled:hover:text-[var(--muted-foreground)]"
+ } disabled:cursor-default`}
+ >
+ <span
+ aria-hidden="true"
+ className={`h-[7px] w-[7px] rounded-full border transition-colors ${
+ active
+ ? "border-[var(--primary)] bg-[var(--primary)]"
+ : "border-[var(--muted-foreground)]/45"
+ }`}
+ />
+ {t(MASTERY_MODE_LABELS[candidate])}
+ </button>
+ </Tooltip>
);
})}
</div>
diff --git a/web/components/space/learning/PathTitle.tsx b/web/components/space/learning/PathTitle.tsx
index f84092836..7ffdac28c 100644
--- a/web/components/space/learning/PathTitle.tsx
+++ b/web/components/space/learning/PathTitle.tsx
@@ -3,6 +3,7 @@
import { Check, Pencil, X } from "lucide-react";
import { useTranslation } from "react-i18next";
import { useEffect, useRef, useState } from "react";
+import Tooltip from "@/shared/ui/Tooltip";
import type { Translate } from "./format";
@@ -89,14 +90,16 @@ export function PathTitle({
<h1 className={`truncate ${TITLE_TYPE}`}>{displayName}</h1>
{/* Always present, like the reset/delete controls beside it. A
hover-revealed affordance does not exist on a touch screen. */}
- <button
- onClick={() => setEditing(true)}
- title={t("Rename")}
- aria-label={t("Rename")}
- className="shrink-0 cursor-pointer rounded-lg p-1.5 text-[var(--muted-foreground)]/60 transition-colors hover:bg-[var(--accent)] hover:text-[var(--foreground)]"
- >
- <Pencil className="h-4 w-4" />
- </button>
+ <Tooltip label={t("Rename")}>
+ <button
+ type="button"
+ onClick={() => setEditing(true)}
+ aria-label={t("Rename")}
+ className="shrink-0 cursor-pointer rounded-lg p-1.5 text-[var(--muted-foreground)]/60 transition-colors hover:bg-[var(--accent)] hover:text-[var(--foreground)]"
+ >
+ <Pencil className="h-4 w-4" />
+ </button>
+ </Tooltip>
</div>
);
}
@@ -122,28 +125,32 @@ export function PathTitle({
className={`min-w-0 flex-1 rounded-xl border border-[var(--border)] bg-[var(--background)] px-3 py-1 outline-none focus:border-[var(--primary)] disabled:opacity-60 ${TITLE_TYPE}`}
/>
{/* mousedown, not click: blur fires first and would commit-then-cancel. */}
- <button
- onMouseDown={(event) => {
- event.preventDefault();
- void commit();
- }}
- title={t("Save")}
- aria-label={t("Save")}
- className="shrink-0 cursor-pointer rounded-lg p-1.5 text-[var(--muted-foreground)] hover:bg-[var(--accent)] hover:text-[var(--foreground)]"
- >
- <Check className="h-4 w-4" />
- </button>
- <button
- onMouseDown={(event) => {
- event.preventDefault();
- cancel();
- }}
- title={t("Cancel")}
- aria-label={t("Cancel")}
- className="shrink-0 cursor-pointer rounded-lg p-1.5 text-[var(--muted-foreground)] hover:bg-[var(--accent)] hover:text-[var(--foreground)]"
- >
- <X className="h-4 w-4" />
- </button>
+ <Tooltip label={t("Save")}>
+ <button
+ type="button"
+ onMouseDown={(event) => {
+ event.preventDefault();
+ void commit();
+ }}
+ aria-label={t("Save")}
+ className="shrink-0 cursor-pointer rounded-lg p-1.5 text-[var(--muted-foreground)] hover:bg-[var(--accent)] hover:text-[var(--foreground)]"
+ >
+ <Check className="h-4 w-4" />
+ </button>
+ </Tooltip>
+ <Tooltip label={t("Cancel")}>
+ <button
+ type="button"
+ onMouseDown={(event) => {
+ event.preventDefault();
+ cancel();
+ }}
+ aria-label={t("Cancel")}
+ className="shrink-0 cursor-pointer rounded-lg p-1.5 text-[var(--muted-foreground)] hover:bg-[var(--accent)] hover:text-[var(--foreground)]"
+ >
+ <X className="h-4 w-4" />
+ </button>
+ </Tooltip>
</div>
);
}
diff --git a/web/components/space/learning/ReviewTrail.tsx b/web/components/space/learning/ReviewTrail.tsx
index 9478a38f9..24584621e 100644
--- a/web/components/space/learning/ReviewTrail.tsx
+++ b/web/components/space/learning/ReviewTrail.tsx
@@ -109,7 +109,6 @@ export function ReviewTrail({
type="button"
onClick={() => onSelect(review.knowledge_point_id)}
className="min-w-0 flex-1 text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)]/40"
- title={review.reason}
>
<span className="block truncate text-xs font-medium text-[var(--foreground)]">
{review.knowledge_point_name}
diff --git a/web/components/space/learning/StudyOutline.tsx b/web/components/space/learning/StudyOutline.tsx
index 197cae60b..2d5547364 100644
--- a/web/components/space/learning/StudyOutline.tsx
+++ b/web/components/space/learning/StudyOutline.tsx
@@ -14,6 +14,7 @@
import { ChevronsLeft, ChevronsRight } from "lucide-react";
import { useTranslation } from "react-i18next";
+import Tooltip from "@/shared/ui/Tooltip";
import type { MapKnowledgePoint, MasteryTopic } from "@/lib/learning-api";
@@ -80,7 +81,6 @@ export function StudyOutline({
<button
type="button"
onClick={onToggleCollapsed}
- title={t("Show outline")}
aria-label={t("Show outline")}
className={`flex h-full w-full flex-col items-center gap-2.5 pt-4 text-[var(--muted-foreground)] transition-colors hover:bg-[var(--muted)]/50 hover:text-[var(--foreground)] ${
justMasteredId ? "mastery-just-mastered-strip" : ""
@@ -107,15 +107,16 @@ export function StudyOutline({
<span className="text-[10.5px] tabular-nums text-[var(--muted-foreground)]/55">
{mastered}/{total}
</span>
- <button
- type="button"
- onClick={onToggleCollapsed}
- title={t("Hide outline")}
- aria-label={t("Hide outline")}
- className="flex h-5 w-5 items-center justify-center rounded text-[var(--muted-foreground)]/50 transition-colors hover:bg-[var(--muted)]/60 hover:text-[var(--foreground)]"
- >
- <ChevronsLeft className="h-3.5 w-3.5" />
- </button>
+ <Tooltip label={t("Hide outline")}>
+ <button
+ type="button"
+ onClick={onToggleCollapsed}
+ aria-label={t("Hide outline")}
+ className="flex h-5 w-5 items-center justify-center rounded text-[var(--muted-foreground)]/50 transition-colors hover:bg-[var(--muted)]/60 hover:text-[var(--foreground)]"
+ >
+ <ChevronsLeft className="h-3.5 w-3.5" />
+ </button>
+ </Tooltip>
</div>
</div>
diff --git a/web/tests/annotation-layer-tooltip.spec.tsx b/web/tests/annotation-layer-tooltip.spec.tsx
new file mode 100644
index 000000000..59937fee8
--- /dev/null
+++ b/web/tests/annotation-layer-tooltip.spec.tsx
@@ -0,0 +1,49 @@
+import { fireEvent, render, screen, waitFor } from "@testing-library/react";
+import { expect, it, vi } from "vitest";
+
+import { AnnotationLayer } from "@/components/reading/AnnotationLayer";
+import type { AnnotationItem } from "@/lib/reading-api";
+
+vi.mock("react-i18next", () => ({
+ useTranslation: () => ({ t: (value: string) => value }),
+}));
+
+it("keeps a highlight's hit area while exposing its note through the shared tooltip", async () => {
+ const annotation: AnnotationItem = {
+ annotation_id: "a1",
+ locator: 1,
+ kind: "highlight",
+ color: "yellow",
+ quote: "A selected passage",
+ note: "Review this step",
+ rects: [[0.1, 0.2, 0.4, 0.3]],
+ source_anchor: "",
+ author: "user",
+ created_at: 1,
+ updated_at: 1,
+ };
+ const onAnnotationClick = vi.fn();
+ render(
+ <AnnotationLayer
+ annotations={[annotation]}
+ onAnnotationClick={onAnnotationClick}
+ />,
+ );
+
+ const button = screen.getByRole("button", { name: "Review this step" });
+ const marker = button.parentElement!.parentElement!;
+ expect(button).not.toHaveAttribute("title");
+ expect(parseFloat(marker.style.left)).toBeCloseTo(10);
+ expect(parseFloat(marker.style.top)).toBeCloseTo(20);
+ expect(parseFloat(marker.style.width)).toBeCloseTo(30);
+ expect(parseFloat(marker.style.height)).toBeCloseTo(10);
+ fireEvent.click(button);
+ expect(onAnnotationClick).toHaveBeenCalledWith(annotation);
+
+ fireEvent.focus(button);
+ await waitFor(() =>
+ expect(document.body.querySelector('[role="tooltip"].fixed')).toHaveTextContent(
+ "Review this step",
+ ),
+ );
+});