Redesign study Notes, Reflection questions and Community pages; v2.12.0
Publish Container / build (push) Successful in 15m20s
Publish Container / build (push) Successful in 15m20s
- Notes: two-pane reader with searchable lesson list and snippets, track chips, friendlier empty states - Reflection questions: numbered question cards, answered progress bar, unsaved-changes status, sticky save bar, share-to-discussion only when discussion is open - Community: compact header, lesson browser sidebar with post counts (select on mobile), guidelines card, card-style posts Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0ab94bfcd4
commit
eff119e7f0
4 files changed
+803
-175
No files matched your search
+298
-172
@@ -418,15 +418,23 @@ function CommunityBoard({
|
||||
}
|
||||
}
|
||||
|
||||
const postCountFor = (sectionId: string) => posts.filter(p => p.sectionId === sectionId).length
|
||||
const lessonsForFilter = releasedSections.filter(item => postCountFor(item.id) > 0 || item.id === activeSection)
|
||||
const activeSectionTitle = releasedSections.find(item => item.id === activeSection)?.title
|
||||
|
||||
return (
|
||||
<div className="community-layout">
|
||||
<div className="community-feed">
|
||||
{/* Section filter tabs */}
|
||||
{/* Mobile lesson filter */}
|
||||
{releasedSections.length > 1 && canParticipate && (
|
||||
<div className="community-filter-bar">
|
||||
<button type="button" className={`community-filter-chip${activeSection === '' ? ' community-filter-chip--active' : ''}`} onClick={() => setActiveSection('')}>All</button>
|
||||
{releasedSections.map(s => (
|
||||
<button key={s.id} type="button" className={`community-filter-chip${activeSection === s.id ? ' community-filter-chip--active' : ''}`} onClick={() => setActiveSection(s.id)}>{s.title}</button>
|
||||
))}
|
||||
<div className="community-filter-select">
|
||||
<label htmlFor="community-lesson-select">Lesson</label>
|
||||
<select id="community-lesson-select" value={activeSection} onChange={e => setActiveSection(e.target.value)}>
|
||||
<option value="">All discussion ({posts.length})</option>
|
||||
{releasedSections.map(item => (
|
||||
<option key={item.id} value={item.id}>{item.title}{postCountFor(item.id) > 0 ? ` (${postCountFor(item.id)})` : ''}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -580,6 +588,40 @@ function CommunityBoard({
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{canParticipate && (
|
||||
<aside className="community-aside" aria-label="Browse by lesson">
|
||||
<section className="community-aside-card">
|
||||
<h2>Browse by lesson</h2>
|
||||
<ul className="community-lesson-list">
|
||||
<li>
|
||||
<button type="button" className={`community-lesson-item${activeSection === '' ? ' community-lesson-item--active' : ''}`} onClick={() => setActiveSection('')}>
|
||||
<span>All discussion</span><small>{posts.length}</small>
|
||||
</button>
|
||||
</li>
|
||||
{lessonsForFilter.map(item => (
|
||||
<li key={item.id}>
|
||||
<button type="button" className={`community-lesson-item${activeSection === item.id ? ' community-lesson-item--active' : ''}`} onClick={() => setActiveSection(item.id)}>
|
||||
<span>{item.title}</span><small>{postCountFor(item.id)}</small>
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
{activeSection && activeSectionTitle && postCountFor(activeSection) === 0 && (
|
||||
<p className="community-aside-note">No posts on “{activeSectionTitle}” yet — yours can be the first.</p>
|
||||
)}
|
||||
</section>
|
||||
<section className="community-aside-card">
|
||||
<h2>Community guidelines</h2>
|
||||
<ul className="community-guidelines">
|
||||
<li>Be gracious — assume the best of others.</li>
|
||||
<li>Stay on topic and close to the text.</li>
|
||||
<li>Ask honest questions; share what you're learning.</li>
|
||||
</ul>
|
||||
</section>
|
||||
</aside>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2659,6 +2701,7 @@ export function ColossiansStudyNotesPage({ content }: Props) {
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [message, setMessage] = useState('')
|
||||
const [activeNoteTab, setActiveNoteTab] = useState('')
|
||||
const [noteQuery, setNoteQuery] = useState('')
|
||||
|
||||
usePageMeta(
|
||||
study ? `My Notes | ${study.title}` : 'My Study Notes',
|
||||
@@ -2737,108 +2780,149 @@ export function ColossiansStudyNotesPage({ content }: Props) {
|
||||
? getStudies(content).filter(s => (auth.enrolledStudySlugs ?? []).includes(s.slug.toLowerCase()))
|
||||
: []
|
||||
|
||||
return (
|
||||
<main className="study-section-page" aria-label="My study notes">
|
||||
<section className="section-study-classroom">
|
||||
<div className="section-inner">
|
||||
<Breadcrumbs items={[{ label: 'Home', href: '/' }, { label: 'Studies', href: '/study' }, { label: study.title, href: `/study/${study.slug}` }, { label: 'My Notes' }]} />
|
||||
<Link to={`/study/${study.slug}`} className="study-detail-back">Back to {study.title}</Link>
|
||||
<p className="study-lesson-label">Student Workspace</p>
|
||||
<h1>My Lesson Notes</h1>
|
||||
{!loading && auth.authenticated && <p className="study-detail-summary">Signed in as {auth.username}</p>}
|
||||
{enrolledStudies.length > 1 && (
|
||||
<div className="study-track-switcher">
|
||||
<p className="study-lesson-label">Switch Track</p>
|
||||
<div className="study-track-switcher-tabs">
|
||||
{enrolledStudies.map(s => (
|
||||
<Link
|
||||
key={s.slug}
|
||||
to={`/study/${s.slug}/notes`}
|
||||
className={`study-track-tab${s.slug === study.slug ? ' study-track-tab--active' : ''}`}
|
||||
>
|
||||
{s.title}
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{!loading && auth.authenticated && (
|
||||
<div className="study-signup-actions" style={{ marginBottom: '1rem' }}>
|
||||
<Link to="/study/account" className="btn-secondary">My Account</Link>
|
||||
<Link to={`/study/${study.slug}`} className="btn-secondary">Back to Lessons</Link>
|
||||
</div>
|
||||
)}
|
||||
const stripHtml = (html: string) => DOMPurify.sanitize(html, { ALLOWED_TAGS: [] }).replace(/\s+/g, ' ').trim()
|
||||
const noteText = (raw: string) => Object.values(parseNoteMap(raw)).map(value => stripHtml(value ?? '')).filter(Boolean).join(' · ')
|
||||
const sorted = [...entries].sort((a, b) => {
|
||||
const aNum = a.section ? getLessonNumber(study.sections, a.section.id) : 0
|
||||
const bNum = b.section ? getLessonNumber(study.sections, b.section.id) : 0
|
||||
return aNum - bNum
|
||||
})
|
||||
const queryText = noteQuery.trim().toLowerCase()
|
||||
const visible = queryText
|
||||
? sorted.filter(item => `${item.section?.title ?? ''} ${item.section?.reference ?? ''} ${noteText(item.note)}`.toLowerCase().includes(queryText))
|
||||
: sorted
|
||||
const active = visible.find(item => item.sectionId === activeNoteTab) ?? visible[0]
|
||||
|
||||
{loading && <p className="study-detail-copy">Loading your notes...</p>}
|
||||
{!loading && !auth.authenticated && (
|
||||
<article className="study-class-block">
|
||||
<h2>Sign In Required</h2>
|
||||
<p className="study-detail-copy">Open any lesson and sign in from the Student Notes panel to see your saved notes here.</p>
|
||||
<Link to="/study/signup" className="btn-primary">Create Account or Sign In</Link>
|
||||
</article>
|
||||
)}
|
||||
{!loading && auth.authenticated && !enrolled && (
|
||||
<article className="study-class-block">
|
||||
<h2>Enrollment Required</h2>
|
||||
<p className="study-detail-copy">You need to enroll in this study before accessing your notes.</p>
|
||||
<Link to={`/study/${study.slug}`} className="btn-primary">Go to Study Enrollment</Link>
|
||||
</article>
|
||||
)}
|
||||
{!loading && auth.authenticated && enrolled && entries.length === 0 && (
|
||||
<article className="study-class-block">
|
||||
<h2>No Notes Yet</h2>
|
||||
<p className="study-detail-copy">You have not saved notes yet. Open a lesson and use the Student Notes area to start.</p>
|
||||
{study.sections[0] && <Link to={`/study/${study.slug}/${study.sections[0].id}`} className="btn-primary">Open First Lesson</Link>}
|
||||
</article>
|
||||
)}
|
||||
{!loading && auth.authenticated && enrolled && entries.length > 0 && (() => {
|
||||
const sorted = [...entries].sort((a, b) => {
|
||||
const aNum = a.section ? getLessonNumber(study.sections, a.section.id) : 0
|
||||
const bNum = b.section ? getLessonNumber(study.sections, b.section.id) : 0
|
||||
return aNum - bNum
|
||||
})
|
||||
const active = sorted.find(item => item.sectionId === activeNoteTab) ?? sorted[0]
|
||||
return (
|
||||
<div className="study-notebook">
|
||||
<div className="study-notebook-tabs" role="tablist" aria-label="Lesson notes">
|
||||
{sorted.map(({ sectionId, section }) => (
|
||||
<button
|
||||
key={sectionId}
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={active.sectionId === sectionId}
|
||||
className={`study-notebook-tab${active.sectionId === sectionId ? ' study-notebook-tab--active' : ''}`}
|
||||
onClick={() => setActiveNoteTab(sectionId)}
|
||||
>
|
||||
{section ? `Lesson ${getLessonNumber(study.sections, section.id)}` : 'Saved Note'}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<article className="study-notebook-page">
|
||||
<p className="study-module-lesson">{active.section ? `Lesson ${getLessonNumber(study.sections, active.section.id)}` : 'Saved Note'}</p>
|
||||
<h3>{active.section?.title ?? active.sectionId}</h3>
|
||||
<p className="study-detail-reference">{active.section ? active.section.reference : 'Lesson reference unavailable'}</p>
|
||||
{(() => {
|
||||
const anchorMap = parseNoteMap(active.note)
|
||||
const hasContent = Object.values(anchorMap).some(v => v?.trim())
|
||||
if (!hasContent) return <p className="study-detail-copy">No notes saved for this lesson yet.</p>
|
||||
return Object.entries(anchorMap).map(([key, html]) => (
|
||||
html?.trim() ? (
|
||||
<div key={key} style={{ marginBottom: '1.25rem' }}>
|
||||
<p className="study-module-focus" style={{ marginBottom: '0.5rem' }}>{ANCHOR_LABELS[key] ?? key}</p>
|
||||
<div className="study-note-rich-content" dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(html) }} />
|
||||
</div>
|
||||
) : null
|
||||
))
|
||||
})()}
|
||||
{active.section && <Link to={`/study/${study.slug}/${active.section.id}`} className="btn-secondary">Open Lesson</Link>}
|
||||
</article>
|
||||
</div>
|
||||
)
|
||||
})()}
|
||||
{message && <p className="study-note-status">{message}</p>}
|
||||
</div>
|
||||
</section>
|
||||
return (
|
||||
<main className="notes-page" aria-label="My study notes">
|
||||
<div className="notes-shell">
|
||||
<Breadcrumbs items={[{ label: 'Home', href: '/' }, { label: 'Studies', href: '/study' }, { label: study.title, href: `/study/${study.slug}` }, { label: 'My Notes' }]} />
|
||||
|
||||
<header className="notes-header">
|
||||
<div>
|
||||
<p className="eyebrow">Student Workspace</p>
|
||||
<h1>My Notes</h1>
|
||||
<p className="notes-subtitle">
|
||||
{study.title}
|
||||
{!loading && auth.authenticated && enrolled && <> · {entries.length} {entries.length === 1 ? 'lesson' : 'lessons'} with notes</>}
|
||||
</p>
|
||||
</div>
|
||||
<div className="notes-header-actions">
|
||||
<Link to={`/study/${study.slug}`} className="btn-secondary">Back to Lessons</Link>
|
||||
<Link to="/study/account" className="btn-secondary">My Account</Link>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{enrolledStudies.length > 1 && (
|
||||
<div className="notes-tracks" role="tablist" aria-label="Study tracks">
|
||||
{enrolledStudies.map(s2 => (
|
||||
<Link
|
||||
key={s2.slug}
|
||||
to={`/study/${s2.slug}/notes`}
|
||||
className={`notes-track${s2.slug === study.slug ? ' notes-track--active' : ''}`}
|
||||
aria-current={s2.slug === study.slug ? 'page' : undefined}
|
||||
>
|
||||
{s2.title}
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{loading && <p className="notes-empty-text">Loading your notes…</p>}
|
||||
|
||||
{!loading && !auth.authenticated && (
|
||||
<div className="notes-empty">
|
||||
<h2>Sign in to see your notes</h2>
|
||||
<p>Open any lesson and sign in from the Student Notes panel, and your saved notes will show up here.</p>
|
||||
<Link to="/study/signup" className="btn-primary">Create Account or Sign In</Link>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!loading && auth.authenticated && !enrolled && (
|
||||
<div className="notes-empty">
|
||||
<h2>Enroll to use notes</h2>
|
||||
<p>You need to enroll in this study before you can write and read lesson notes.</p>
|
||||
<Link to={`/study/${study.slug}`} className="btn-primary">Go to Study Enrollment</Link>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!loading && auth.authenticated && enrolled && entries.length === 0 && (
|
||||
<div className="notes-empty">
|
||||
<div className="notes-empty-icon" aria-hidden="true">📝</div>
|
||||
<h2>No notes yet</h2>
|
||||
<p>Open a lesson and use the Student Notes panel to jot down what stands out. Everything you save collects here, private to you.</p>
|
||||
{study.sections.find(isSectionReleased) && <Link to={`/study/${study.slug}/${study.sections.find(isSectionReleased)!.id}`} className="btn-primary">Open the First Lesson</Link>}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!loading && auth.authenticated && enrolled && entries.length > 0 && (
|
||||
<div className="notes-layout">
|
||||
<aside className="notes-list-pane" aria-label="Lessons with notes">
|
||||
<input
|
||||
type="search"
|
||||
className="notes-search"
|
||||
placeholder="Search your notes…"
|
||||
aria-label="Search your notes"
|
||||
value={noteQuery}
|
||||
onChange={e => setNoteQuery(e.target.value)}
|
||||
/>
|
||||
{visible.length === 0 ? (
|
||||
<p className="notes-empty-text">No notes match “{noteQuery.trim()}”.</p>
|
||||
) : (
|
||||
<ul className="notes-list" role="tablist" aria-label="Lesson notes">
|
||||
{visible.map(({ sectionId, section, note }) => {
|
||||
const lessonNumber = section ? getLessonNumber(study.sections, section.id) : 0
|
||||
const isActive = active?.sectionId === sectionId
|
||||
return (
|
||||
<li key={sectionId}>
|
||||
<button
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={isActive}
|
||||
className={`notes-item${isActive ? ' notes-item--active' : ''}`}
|
||||
onClick={() => setActiveNoteTab(sectionId)}
|
||||
>
|
||||
<span className="notes-item-number" aria-hidden="true">{lessonNumber || '•'}</span>
|
||||
<span className="notes-item-body">
|
||||
<strong>{section?.title ?? 'Saved note'}</strong>
|
||||
<small>{section?.reference ?? ''}</small>
|
||||
<span className="notes-item-snippet">{noteText(note).slice(0, 110)}</span>
|
||||
</span>
|
||||
</button>
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
)}
|
||||
</aside>
|
||||
|
||||
{active && (
|
||||
<article className="notes-reader" aria-label="Note">
|
||||
<p className="notes-reader-label">{active.section ? `Lesson ${getLessonNumber(study.sections, active.section.id)}` : 'Saved note'}{active.section?.reference ? ` · ${active.section.reference}` : ''}</p>
|
||||
<h2>{active.section?.title ?? active.sectionId}</h2>
|
||||
{(() => {
|
||||
const anchorMap = parseNoteMap(active.note)
|
||||
const blocks = Object.entries(anchorMap).filter(([, html]) => html?.trim())
|
||||
if (blocks.length === 0) return <p className="notes-empty-text">No notes saved for this lesson yet.</p>
|
||||
return blocks.map(([key, html]) => (
|
||||
<section className="notes-block" key={key}>
|
||||
<h3>{ANCHOR_LABELS[key] ?? key}</h3>
|
||||
<div className="study-note-rich-content" dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(html) }} />
|
||||
</section>
|
||||
))
|
||||
})()}
|
||||
{active.section && (
|
||||
<div className="notes-reader-actions">
|
||||
<Link to={`/study/${study.slug}/${active.section.id}`} className="btn-primary">Open Lesson →</Link>
|
||||
</div>
|
||||
)}
|
||||
</article>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{message && <p className="study-note-status" role="alert">{message}</p>}
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
@@ -3942,6 +4026,7 @@ export function StudyQuizPage({ content }: Props) {
|
||||
const [error, setError] = useState('')
|
||||
const [shareToDiscussion, setShareToDiscussion] = useState<Record<number, boolean>>({})
|
||||
const [sharedIndexes, setSharedIndexes] = useState<Set<number>>(new Set())
|
||||
const [dirty, setDirty] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false
|
||||
@@ -3984,6 +4069,13 @@ export function StudyQuizPage({ content }: Props) {
|
||||
}
|
||||
}, [studySlug, sectionId])
|
||||
|
||||
useEffect(() => {
|
||||
if (!dirty) return
|
||||
function onBeforeUnload(e: BeforeUnloadEvent) { e.preventDefault() }
|
||||
window.addEventListener('beforeunload', onBeforeUnload)
|
||||
return () => window.removeEventListener('beforeunload', onBeforeUnload)
|
||||
}, [dirty])
|
||||
|
||||
async function saveQuiz() {
|
||||
if (!studySlug || !sectionId || !study || !section) return
|
||||
setSaving(true)
|
||||
@@ -4024,6 +4116,7 @@ export function StudyQuizPage({ content }: Props) {
|
||||
})
|
||||
}
|
||||
|
||||
setDirty(false)
|
||||
setMessage(newlyShared.length > 0 ? `Answers saved and ${newlyShared.length} shared to the discussion.` : 'Answers saved.')
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Unable to save answers.')
|
||||
@@ -4083,70 +4176,102 @@ export function StudyQuizPage({ content }: Props) {
|
||||
)
|
||||
}
|
||||
|
||||
const answeredCount = sectionQuestions.filter((_, index) => (answers[index] ?? '').trim().length >= 2).length
|
||||
const canShare = isDiscussionOpen(study)
|
||||
|
||||
return (
|
||||
<main className="study-index-page" aria-label="Discussion questions">
|
||||
<section className="section-study-course-hero">
|
||||
<div className="section-inner study-course-hero-inner">
|
||||
<main className="quiz-page" aria-label="Reflection questions">
|
||||
<div className="quiz-shell">
|
||||
<Breadcrumbs items={[{ label: 'Home', href: '/' }, { label: 'Studies', href: '/study' }, { label: study.title, href: `/study/${study.slug}` }, { label: section.title, href: `/study/${study.slug}/${section.id}` }, { label: 'Reflection' }]} />
|
||||
|
||||
<header className="quiz-header">
|
||||
<p className="eyebrow">Reflection Questions</p>
|
||||
<h1>{section.title}</h1>
|
||||
<p className="study-course-hero-copy">Write out your answers below — they're saved privately. You can also choose to share individual answers to the lesson discussion.</p>
|
||||
<div className="study-course-hero-actions">
|
||||
<Link to={`/study/${study.slug}/${section.id}`} className="btn-secondary">Back to Lesson</Link>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{section.reference && <p className="quiz-reference">{section.reference}</p>}
|
||||
<p className="quiz-intro">Take your time. Your answers are saved privately to your account{canShare ? ', and you can choose to share any of them with the lesson discussion' : ''}.</p>
|
||||
{canSubmit && !loading && !error && (
|
||||
<div className="quiz-progress" role="group" aria-label="Answer progress">
|
||||
<div className="quiz-progress-label">
|
||||
<span>{answeredCount} of {sectionQuestions.length} answered</span>
|
||||
<Link to={`/study/${study.slug}/${section.id}`}>← Back to lesson</Link>
|
||||
</div>
|
||||
<div className="study-progress-track" role="progressbar" aria-valuemin={0} aria-valuemax={sectionQuestions.length} aria-valuenow={answeredCount}>
|
||||
<div className="study-progress-fill" style={{ width: `${Math.round((answeredCount / sectionQuestions.length) * 100)}%` }} />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</header>
|
||||
|
||||
<section className="section-study-module" style={{ paddingTop: '2rem' }}>
|
||||
<div className="section-inner">
|
||||
{loading ? (
|
||||
<p>Loading reflection questions...</p>
|
||||
) : error ? (
|
||||
<p className="study-note-status">{error}</p>
|
||||
) : !canSubmit ? (
|
||||
<article className="study-class-block">
|
||||
<h2>No Reflection Questions</h2>
|
||||
<p className="study-detail-copy">This lesson does not have reflection questions configured yet.</p>
|
||||
</article>
|
||||
) : (
|
||||
<form onSubmit={e => { e.preventDefault(); saveQuiz() }}>
|
||||
{sectionQuestions.map((question, index) => (
|
||||
<div key={index} className="quiz-question-block">
|
||||
<p className="quiz-question-label">{`${index + 1}. ${question}`}</p>
|
||||
{loading ? (
|
||||
<p className="notes-empty-text">Loading reflection questions…</p>
|
||||
) : error ? (
|
||||
<p className="study-note-status" role="alert">{error}</p>
|
||||
) : !canSubmit ? (
|
||||
<div className="notes-empty">
|
||||
<h2>No reflection questions</h2>
|
||||
<p>This lesson doesn't have reflection questions yet.</p>
|
||||
<Link to={`/study/${study.slug}/${section.id}`} className="btn-primary">Back to Lesson</Link>
|
||||
</div>
|
||||
) : (
|
||||
<form className="quiz-form" onSubmit={e => { e.preventDefault(); void saveQuiz() }}>
|
||||
{sectionQuestions.map((question, index) => {
|
||||
const answer = answers[index] ?? ''
|
||||
const hasAnswer = answer.trim().length >= 2
|
||||
return (
|
||||
<section key={index} className={`quiz-card${hasAnswer ? ' quiz-card--answered' : ''}`}>
|
||||
<div className="quiz-card-head">
|
||||
<span className="quiz-card-number" aria-hidden="true">{index + 1}</span>
|
||||
<label className="quiz-card-question" htmlFor={`quiz-answer-${index}`}>{question}</label>
|
||||
</div>
|
||||
<textarea
|
||||
id={`quiz-answer-${index}`}
|
||||
rows={4}
|
||||
className="quiz-question-textarea"
|
||||
value={answers[index] ?? ''}
|
||||
onChange={e => setAnswers(prev => {
|
||||
const next = [...prev]
|
||||
next[index] = e.target.value
|
||||
return next
|
||||
})}
|
||||
className="quiz-card-textarea"
|
||||
value={answer}
|
||||
onChange={e => {
|
||||
const value = e.target.value
|
||||
setDirty(true)
|
||||
setAnswers(prev => {
|
||||
const next = [...prev]
|
||||
next[index] = value
|
||||
return next
|
||||
})
|
||||
}}
|
||||
onInput={e => { const el = e.currentTarget; el.style.height = 'auto'; el.style.height = `${Math.max(el.scrollHeight, 110)}px` }}
|
||||
placeholder="Write your answer here…"
|
||||
/>
|
||||
{(answers[index] ?? '').trim().length >= 2 && (
|
||||
<label className="quiz-share-toggle">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={shareToDiscussion[index] ?? false}
|
||||
disabled={sharedIndexes.has(index)}
|
||||
onChange={e => setShareToDiscussion(prev => ({ ...prev, [index]: e.target.checked }))}
|
||||
/>
|
||||
{sharedIndexes.has(index)
|
||||
? <span className="quiz-share-label quiz-share-label--done">✓ Shared to discussion</span>
|
||||
: <span className="quiz-share-label">Share this answer to the lesson discussion</span>}
|
||||
</label>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
<div style={{ display: 'flex', gap: '0.75rem', flexWrap: 'wrap', marginTop: '0.5rem' }}>
|
||||
<button type="submit" className="btn-primary" disabled={saving}>{saving ? 'Saving…' : 'Save Answers'}</button>
|
||||
<div className="quiz-card-foot">
|
||||
{canShare && hasAnswer ? (
|
||||
<label className="quiz-share-toggle">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={shareToDiscussion[index] ?? false}
|
||||
disabled={sharedIndexes.has(index)}
|
||||
onChange={e => setShareToDiscussion(prev => ({ ...prev, [index]: e.target.checked }))}
|
||||
/>
|
||||
{sharedIndexes.has(index)
|
||||
? <span className="quiz-share-label quiz-share-label--done">✓ Shared to the discussion</span>
|
||||
: <span className="quiz-share-label">Share this answer with the lesson discussion</span>}
|
||||
</label>
|
||||
) : <span />}
|
||||
<span className="quiz-card-count">{answer.length.toLocaleString()} characters</span>
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
})}
|
||||
|
||||
<div className="quiz-savebar">
|
||||
<p className="quiz-savebar-status" role="status" aria-live="polite">
|
||||
{saving ? 'Saving…' : message ? message : dirty ? 'You have unsaved changes.' : 'All answers saved.'}
|
||||
</p>
|
||||
<div className="quiz-savebar-actions">
|
||||
<button type="button" className="btn-secondary" onClick={() => navigate(`/study/${study.slug}/${section.id}`)}>Back to Lesson</button>
|
||||
<button type="submit" className="btn-primary" disabled={saving || !dirty && answeredCount === 0}>{saving ? 'Saving…' : 'Save Answers'}</button>
|
||||
</div>
|
||||
{message && <p className="study-note-status" style={{ marginTop: '1rem' }}>{message}</p>}
|
||||
</form>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</form>
|
||||
)}
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
@@ -4311,21 +4436,22 @@ export function StudyCommunityPage({ content }: Props) {
|
||||
const isEnrolled = isEnrolledInStudy(auth, study.slug)
|
||||
|
||||
return (
|
||||
<main className="study-index-page" aria-label="Study community">
|
||||
<section className="section-study-course-hero" style={{ paddingBottom: '2rem' }}>
|
||||
<div className="section-inner study-course-hero-inner">
|
||||
<p className="eyebrow">{study.title}</p>
|
||||
<h1>Study Community</h1>
|
||||
<p className="study-course-hero-copy">Talk with other enrolled students. Keep it gracious and on topic.</p>
|
||||
<div className="study-course-hero-actions">
|
||||
<main className="community-page" aria-label="Study community">
|
||||
<div className="community-shell">
|
||||
<Breadcrumbs items={[{ label: 'Home', href: '/' }, { label: 'Studies', href: '/study' }, { label: study.title, href: `/study/${study.slug}` }, { label: 'Community' }]} />
|
||||
<header className="community-header">
|
||||
<div>
|
||||
<p className="eyebrow">{study.title}</p>
|
||||
<h1>Study Community</h1>
|
||||
<p className="community-subtitle">Talk with the other students in this study. Keep it gracious and on topic.</p>
|
||||
</div>
|
||||
<div className="community-header-actions">
|
||||
<Link to={`/study/${study.slug}`} className="btn-secondary">Back to Study</Link>
|
||||
<Link to={`/contact?source=community&study=${encodeURIComponent(study.title)}`} className="btn-primary">Ask Nate</Link>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section className="section-inner" style={{ paddingTop: '2rem', paddingBottom: '4rem', maxWidth: '860px' }}>
|
||||
</header>
|
||||
<CommunityBoard study={study} auth={auth} isEnrolled={isEnrolled} sectionFilter={defaultSectionId} />
|
||||
</section>
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user