import React, { useState } from 'react' import { Link } from 'react-router' import { ArrowRight, ArrowUpRight, BookOpen, LayoutList, ListOrdered, Compass, ChevronRight, ChevronDown, Camera, LayoutGrid } from 'lucide-react' import { useTranslation } from '../../i18n' import { useHelpStore, docTitle } from '../../store/helpStore' import { ctxKey, ctxBulletKey, guideKey, guidesFor, helpMedia, docsRoute, helpContextTrail, childHelpContexts } from '../../help/registry' import type { HelpContext, HelpGuide } from '../../help/types' import { helpIcon } from './helpIcons' import HelpBadge from './HelpBadge' import HelpDocLink from './HelpDocLink' import HelpSizeChip from './HelpSizeChip' import { useScreenRoute } from './useScreenRoute' /** * The overview of a screen: what it is, what is on it, and a card per guide. * With no registered context (a screen that has no help yet) it says so and * leaves the search box as the way forward. */ export default function HelpHome({ context }: { context: HelpContext | null }): React.ReactElement { const { t } = useTranslation() const docIndex = useHelpStore(s => s.docIndex) const closeHelp = useHelpStore(s => s.closeHelp) // Folded until asked for: the guides below matter more, the tabs are one click away. const [subScreensOpen, setSubScreensOpen] = useState(false) const screenRoute = useScreenRoute(context?.route) if (!context) { return (

{t('help.center.noContext')}

{t('help.center.noContextHint')}

) } const guides = guidesFor(context) const bullets = Array.from({ length: context.bullets }, (_, i) => t(ctxBulletKey(context.id, i + 1))) const children = childHelpContexts(context.id) const Icon = helpIcon(context.icon) return (
{/* Which screen, what it is, what help there is */}
{t('help.center.screens')} {helpContextTrail(context).slice(0, -1).map(parent => ( {t(ctxKey(parent.id, 'title'))} ))} {t('help.center.overview')}

{t(ctxKey(context.id, 'title'))}

{t(ctxKey(context.id, 'summary'))}

{t('help.center.searchGuides')} {context.docs.length > 0 && {t('help.center.searchDocs')}} {screenRoute && ( {t('help.center.goToScreen', { screen: t(ctxKey(context.id, 'title')) })} )}
{/* Screens under this one (the tabs of Settings, the journal of Journey) */} {children.length > 0 && (
{subScreensOpen && ( )}
)} {/* The screen itself */} {context.hero && (
{t(ctxKey(context.id, 'title'))}
)} {/* What is on it */} {bullets.length > 0 && (
{t('help.center.onThisScreen')}
)} {/* Guides */} {guides.length > 0 && (
{t('help.center.howTo')}
)} {/* Docs */} {context.docs.length > 0 && (
{t('help.center.docsSection')}
)}
) } /** One sub-screen: opens its overview in place; the one the reader is on says so. */ function SubScreenCard({ screen }: { screen: HelpContext }): React.ReactElement { const { t } = useTranslation() const browse = useHelpStore(s => s.browse) const contextId = useHelpStore(s => s.contextId) const current = screen.id === contextId const Icon = helpIcon(screen.icon) return ( ) } /** The marker for the screen the reader is actually on. */ export function ThisScreenChip(): React.ReactElement { const { t } = useTranslation() return ( {t('help.center.thisScreen')} ) } export function SectionLabel({ children }: { children: React.ReactNode }): React.ReactElement { return

{children}

} export function GuideCard({ guide }: { guide: HelpGuide }): React.ReactElement { const { t } = useTranslation() const openGuide = useHelpStore(s => s.openGuide) const Icon = helpIcon(guide.icon) return ( ) }