"use client" /** * One description of a library question, for every host that shows one. * * The tree view's right pane and the hub's peek rail both answer "what is this * question?", and they used to answer it in different files. Only the frame * differs — the tree pane has a sticky header with its own actions, the rail has * `FloatingSheetPanelToolbar` and `FloatingSheetPanelHeader` — so the frame stays * with each host and the fields live here. * * Hosts supply the scrolling; this returns the stack of sections only. */ import * as React from "react" import { LIST_HUB_INSPECTOR_CHIP_SHELL } from "@/components/list-hub-status-badge" import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" import { Separator } from "@/components/ui/separator" import { Tip } from "@/components/ui/tip" import { cn } from "@/lib/utils" import type { LibraryItem, LibraryLevel } from "@/lib/mock/library" import type { LibraryFolder } from "@/lib/mock/library-folders" import { formatDateUS } from "@/lib/date-filter" import { deriveBloomLevel, deriveLastEditedLine, deriveQuestionItemCode, deriveTags, QUESTION_TYPE_ABBREV, } from "@/lib/mock/library-inspector" import { initialsFromDisplayName } from "@/lib/initials-from-name" export const DIFFICULTY_LABEL: Record = { easy: "Low", medium: "Normal", hard: "High", } export function DetailSection({ title, children, className, }: { title: string children: React.ReactNode className?: string }) { return (

{title}

{children}
) } export function InspectorSectionTitle({ children, id, }: { children: React.ReactNode id?: string }) { return (

{children}

) } const FIELD_ROW_CLASS = "grid grid-cols-[minmax(5.5rem,auto)_minmax(0,1fr)] gap-x-3 gap-y-0.5" export interface LibraryQuestionDetailBodyProps { question: LibraryItem /** Used to name the question's parent folder. */ folders: LibraryFolder[] className?: string } export function LibraryQuestionDetailBody({ question, folders, className, }: LibraryQuestionDetailBodyProps) { const parentFolder = folders.find(f => f.id === question.folderId) const folderLeafName = parentFolder?.name ?? "None" const itemCode = deriveQuestionItemCode(question) const bloom = deriveBloomLevel(question) const tags = deriveTags(question) const createdBy = question.createdBy ?? question.author const creatorInitials = initialsFromDisplayName(createdBy) const createdAtLabel = formatDateUS(question.createdAt ?? question.updatedAt) const lastEditedLine = deriveLastEditedLine(question) const versionLabel = question.version ?? "v1" return (
Bloom's
{bloom}
Difficulty
{DIFFICULTY_LABEL[question.difficulty]}
Type
{QUESTION_TYPE_ABBREV[question.type]}
Folder
{folderLeafName}
Code
{itemCode}
{tags.length > 0 ? (
Tags
{tags.map(raw => { const label = raw.replace(/^#/, "").trim() return ( #{label} ) })}
) : null}
Creator & history
{creatorInitials}

Created by

{createdBy}

{createdAtLabel}

Last edited

{lastEditedLine}

Version {versionLabel}