Files
DeepTutor/web/components/reading/library/FolderGlyph.tsx
Bingxi Zhao (Frank) 28c11e2ae8 feat: update notes, chat interactions and workspace UI on preview
Remove course pages, APIs and the course_study capability. Add anchored note
threads and reviewed learning-block generation, queued and withdrawable chat
messages, quote attachments, side chats, and the calendar/favorites/navigation
updates.

Keep preview's existing backend architecture. Wire the new features through
its Python application and existing chat engine, retain legacy selected-text
requests, persist mid-turn messages in replay, and restore note context when
regenerating. Leave stored user data intact.

Validate frontend contracts, dependency boundaries, types, 1290 node tests,
840 rendered tests, lint, localization and the production build. Exercise
session/notes/API regressions, 53 chat-engine tests and 20 Python/native
integration tests with isolated runtime data.
2026-10-26 22:13:34 +08:00

86 lines
2.5 KiB
TypeScript

"use client";
/**
* A collection's folder tint. The server keeps only the key; the tone is a
* `--folder-*` token in globals.css so a palette change never needs a
* migration and dark themes get their own shade. "" is the neutral folder
* every collection had before colours existed.
*/
export const FOLDER_COLORS = [
{ key: "", label: "Default", tone: "var(--folder-default)" },
{ key: "blue", label: "Blue", tone: "var(--folder-blue)" },
{ key: "teal", label: "Teal", tone: "var(--folder-teal)" },
{ key: "green", label: "Green", tone: "var(--folder-green)" },
{ key: "amber", label: "Amber", tone: "var(--folder-amber)" },
{ key: "orange", label: "Orange", tone: "var(--folder-orange)" },
{ key: "rose", label: "Rose", tone: "var(--folder-rose)" },
{ key: "violet", label: "Violet", tone: "var(--folder-violet)" },
{ key: "slate", label: "Slate", tone: "var(--folder-slate)" },
] as const;
export function folderTone(color: string | undefined): string {
return (
FOLDER_COLORS.find((row) => row.key === (color ?? ""))?.tone ??
FOLDER_COLORS[0].tone
);
}
/**
* A folder drawn with one sheet peeking out per file (up to three), so an
* empty collection reads as empty at a glance.
*/
export function FolderGlyph({
color,
tone: toneOverride,
files,
size = 56,
className,
}: {
color?: string;
/** A raw CSS colour instead of a palette key — favorites store hex. */
tone?: string;
files: number;
size?: number;
className?: string;
}) {
const tone = toneOverride || folderTone(color);
const sheets = Math.min(Math.max(files, 0), 3);
return (
<svg
viewBox="0 0 64 50"
width={size}
height={(size * 50) / 64}
aria-hidden
className={className}
>
<path
d="M4 8a4 4 0 0 1 4-4h13.6a4 4 0 0 1 2.9 1.2L28 9h28a4 4 0 0 1 4 4v29a4 4 0 0 1-4 4H8a4 4 0 0 1-4-4Z"
fill={`color-mix(in srgb, ${tone} 82%, black)`}
/>
{Array.from({ length: sheets }, (_, index) => (
<rect
key={index}
x={10 + index * 3}
y={12 - index * 2.5}
width={44 - index * 6}
height={28}
rx={2}
fill="var(--card)"
stroke={`color-mix(in srgb, ${tone} 35%, var(--border))`}
strokeWidth={0.8}
/>
))}
<path
d="M4 20a4 4 0 0 1 4-4h48a4 4 0 0 1 4 4v22a4 4 0 0 1-4 4H8a4 4 0 0 1-4-4Z"
fill={tone}
/>
<path
d="M8 16.5h48"
stroke="white"
strokeOpacity={0.28}
strokeWidth={1}
/>
</svg>
);
}