'use client' import Link from 'next/link' import { usePathname } from 'next/navigation' import { ArrowLeft, AlertCircle, BookOpen, RefreshCw, type LucideIcon } from 'lucide-react' import type { ReactNode, Ref, UIEventHandler } from 'react' import { useTranslation } from 'react-i18next' import { LEARNING_HUB } from '@/lib/learning-routes' import { FeaturePage, PageHeader } from '@/components/layout/FeaturePage' import { useUiLayoutLabel } from '@/features/ui-layout/tokens' import { LEARNING_SURFACES } from './surfaces' /** The same page rhythm for the hub and each library; readers keep their full-screen layouts. */ export function LearningShell({ title, subtitle, action, tabs, children, back = true, className = '', scrollRef, onScroll, icon, }: { title: ReactNode subtitle: ReactNode action?: ReactNode tabs?: ReactNode children: ReactNode back?: boolean className?: string scrollRef?: Ref onScroll?: UIEventHandler /** Defaults to the icon of the learning surface this page belongs to. */ icon?: LucideIcon }) { const pathname = usePathname() const learningLabel = useUiLayoutLabel('learning') // usePathname is null outside the App Router (tests, embeds): no icon then. const surfaceIcon = LEARNING_SURFACES.find(surface => pathname?.startsWith(surface.href))?.icon return ( {back && ( {learningLabel} )} {tabs}
{children}
) } export function LearningEmptyState({ title, description, action, icon, }: { title: ReactNode description?: ReactNode action?: ReactNode icon?: ReactNode }) { return (
{icon && (
{icon}
)}

{title}

{description && (

{description}

)} {action &&
{action}
}
) } export function LearningErrorState({ message, onRetry, }: { message: ReactNode onRetry?: () => void }) { const { t } = useTranslation() return (
{message} {onRetry && ( )}
) } export function LearningSkeleton({ count = 3 }: { count?: number }) { const { t } = useTranslation() return (
{Array.from({ length: count }, (_, index) => (
))}
) }