// Observe / Interpret / Apply as an accordion (one open at a time), plus a "More" // area for background notes and tags so the page stays quiet. import { useEffect, useState } from 'react'; const SECTIONS = [ { field: 'observation', label: 'Observe', hint: 'What does the text say?', placeholder: "What does the text actually say?\n• Who is speaking, and to whom?\n• What key words or phrases repeat?\n• What's the tone, structure, or literary style?" }, { field: 'interpretation', label: 'Interpret', hint: 'What does it mean?', placeholder: "What did this mean to its original audience?\n• What's the historical/cultural context?\n• How does it fit the surrounding argument?\n• What does it reveal about God's character?" }, { field: 'application', label: 'Apply', hint: 'What do I do with it?', placeholder: 'How should this shape your life today?\n• What attitude or action does this call for?\n• Is there a promise to trust or a warning to heed?\n• Who could you share this with?' }, ]; const areaCls = 'w-full resize-y rounded-xl border border-[var(--r-line)] bg-[var(--r-bg)] px-3.5 py-3 font-serif text-[15px] leading-7 text-[var(--r-text)] placeholder:font-sans placeholder:text-[13px] placeholder:leading-5 placeholder:text-[var(--r-sub)] focus:outline-none focus:ring-2 focus:ring-[var(--r-line)]'; const words = (s) => (s ?? '').trim().split(/\s+/).filter(Boolean).length; export default function NotesPane({ chunk, updateChunk, allTags }) { const [open, setOpen] = useState(() => { try { return localStorage.getItem('studyNotesOpen') || 'observation'; } catch { return 'observation'; } }); const [more, setMore] = useState(false); const [tagInput, setTagInput] = useState(''); useEffect(() => { setTagInput(''); }, [chunk.id]); useEffect(() => { try { localStorage.setItem('studyNotesOpen', open || ''); } catch { /* storage unavailable */ } }, [open]); const tags = chunk.tags ?? []; const addTag = (tag) => { const t = tag.trim(); if (!t || tags.some((x) => x.toLowerCase() === t.toLowerCase())) { setTagInput(''); return; } updateChunk(chunk.id, { tags: [...tags, t] }); setTagInput(''); }; const suggestions = allTags.filter((t) => !tags.some((x) => x.toLowerCase() === t.toLowerCase())); return (
{SECTIONS.map(({ field, label, hint, placeholder }) => { const isOpen = open === field; const n = words(chunk[field]); return (
{isOpen && (