import { useEffect, useState } from 'react' import { HELP } from './helpContent' /** * 버튼·영역 옆에 붙는 물음표. 누르면 그 기능의 설명서 모달이 열린다. * * 설명 문구는 helpContent.ts 한 곳에만 둔다 - 화면 곳곳에 흩어 두면 화면을 고쳤을 때 * 어떤 설명이 낡았는지 찾을 수 없게 된다. * * 캡처 이미지는 public/help 아래 실제 화면이다. 파일이 아직 없거나 깨져도 설명은 * 그대로 읽히도록 이미지 로드 실패는 조용히 감춘다. */ interface Props { /** helpContent.ts의 키. 없는 키면 아무것도 그리지 않는다(잘못된 키로 화면이 깨지지 않게). */ topic: string } export default function HelpButton({ topic }: Props) { const [open, setOpen] = useState(false) const help = HELP[topic] useEffect(() => { if (!open) { return } const onKey = (e: KeyboardEvent) => { if (e.key === 'Escape') { setOpen(false) } } window.addEventListener('keydown', onKey) return () => window.removeEventListener('keydown', onKey) }, [open]) if (!help) { return null } return ( <> {open && (
setOpen(false)} className="fixed inset-0 z-50 flex items-start justify-center overflow-y-auto bg-black/40 p-6" >
e.stopPropagation()} className="w-full max-w-4xl rounded-lg bg-white shadow-xl" >

{help.title}

{help.summary}

{help.images?.map((image) => (
{image.alt} { ;(e.currentTarget.parentElement as HTMLElement).style.display = 'none' }} // 작은 캡처(경고창 등)가 모달 폭에 맞춰 늘어나면 흐려진다. // 원본보다 크게 키우지 않고 가운데 정렬만 한다. className="mx-auto max-h-[26rem] w-auto max-w-full rounded-md border border-gray-200" />
{image.caption}
))} {help.steps && (

사용 방법

    {help.steps.map((step, i) => (
  1. {i + 1} {step}
  2. ))}
)} {help.cautions && (

알아둘 점

    {help.cautions.map((caution) => (
  • {caution}
  • ))}
)}
)} ) }