import React from 'react' import { Link } from 'react-router' import { CheckCircle2, Lightbulb, ArrowUpRight, ChevronRight, Maximize2, ListOrdered, Camera, Link2 } from 'lucide-react' import { useTranslation } from '../../i18n' import { useHelpStore, docTitle } from '../../store/helpStore' import { guideKey, guideStepKey, guideTipKey, helpMedia, docsRoute, getHelpGuide, getHelpContext, ctxKey, helpContextTrail } from '../../help/registry' import type { HelpGuide } from '../../help/types' import { helpIcon } from './helpIcons' import HelpBadge from './HelpBadge' import HelpDocLink from './HelpDocLink' import { useAuthStore } from '../../store/authStore' import HelpSizeChip from './HelpSizeChip' import { useScreenRoute } from './useScreenRoute' // A step plays its loop where the guide has one and the system allows motion; the still is the fallback. const prefersReducedMotion = (): boolean => typeof window !== 'undefined' && (window.matchMedia?.('(prefers-reduced-motion: reduce)')?.matches ?? false) const stepMedia = (guide: HelpGuide, n: number): string => guide.media.clips?.includes(n) && !prefersReducedMotion() ? helpMedia.clip(guide.id, n) : helpMedia.step(guide.id, n) /** * One guide, top to bottom: a header card that says where you are and how big * the task is, the steps as a numbered rail with a picture each, what the * reader ends up with, the things worth knowing, and where to go next. */ export default function HelpGuideView({ guide }: { guide: HelpGuide }): React.ReactElement { const { t } = useTranslation() const openLightbox = useHelpStore(s => s.openLightbox) const closeHelp = useHelpStore(s => s.closeHelp) const docIndex = useHelpStore(s => s.docIndex) // No Help & Docs page on a managed install (App.tsx), so no link into it. const docs = useAuthStore(s => s.managed) ? undefined : guide.docs const openGuide = useHelpStore(s => s.openGuide) const title = t(guideKey(guide.id, 'title')) const screen = getHelpContext(guide.context) const steps = Array.from({ length: guide.steps }, (_, i) => i + 1) const tips = Array.from({ length: guide.tips }, (_, i) => t(guideTipKey(guide.id, i + 1))) const related = (guide.related ?? []).map(getHelpGuide).filter((g): g is HelpGuide => g !== null) const Icon = helpIcon(guide.icon) const ScreenIcon = screen ? helpIcon(screen.icon) : Icon const screenRoute = useScreenRoute(screen?.route) return (
{t(guideKey(guide.id, 'goal'))}
{text}
{t(guideKey(guide.id, 'result'))}