feat(course): course page polish P6–P10
- P6: "last updated" moves from the hero to the end of About - P7: quizzes sit inside their chapter; only chapterless quizzes keep a final group, and quiz rows share the lesson row's look - P8: share becomes a glass button in the hero corner; the owned chip joins the stat pills - P9: prerequisite shown in the buy card before purchase instead of a banner below it - P10: lesson rows always number in the title; the circle shows state (play, check, lock, now playing) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
805c6b9f6e
commit
20946236a0
|
|
@ -570,6 +570,8 @@ function CoursePage({ slug }: { slug?: string }) {
|
|||
// phones drop the tabs and stack every section in one scroll (P3).
|
||||
const active = tab ?? (mine ? 'content' : 'overview');
|
||||
const tabs: [string, string][] = [['overview', t('course.tabOverview')], ['content', t('course.content')]];
|
||||
const quizzes = c.assessments ?? [];
|
||||
const finalQuizzes = quizzes.filter((a) => !a.chapterId || !chapters.some((ch) => ch.id === a.chapterId && ch.lessons.some((l) => l.isPublished)));
|
||||
const nextChapter = mine && r ? chapters.find((ch) => ch.lessons.some((l) => l.id === r.lesson.id))?.id : undefined;
|
||||
const includes: [string, ReactNode][] = [
|
||||
['globe', LOCALE_NAMES[c.instructionLocale]],
|
||||
|
|
@ -592,20 +594,20 @@ function CoursePage({ slug }: { slug?: string }) {
|
|||
</nav>
|
||||
<span className="row" style={{ gap: 6 }}>
|
||||
{c.status === 'ARCHIVED' && <StatusPill status="ARCHIVED" />}
|
||||
{mine && <span className="cd-chip"><Icon name="check" size={12} />{done ? t('course.completed') : t('course.owned')}</span>}
|
||||
<button className="cd-share" onClick={share} aria-label={t('course.share')}><Icon name="share" size={16} /></button>
|
||||
</span>
|
||||
</div>
|
||||
<h1>{text.title}</h1>
|
||||
<div className="cd-stats">
|
||||
<span className="cd-pill"><Icon name="video" size={14} /><strong className="num">{lessons.length}</strong>{t('course.lessonsLabel')}</span>
|
||||
<span className="cd-pill"><Icon name="clock" size={14} /><strong className="num">{formatDuration(courseDuration(c))}</strong></span>
|
||||
{mine && <span className="cd-pill cd-pill-own"><Icon name="check" size={14} /><strong>{done ? t('course.completed') : t('course.owned')}</strong></span>}
|
||||
</div>
|
||||
{(text.subtitle || text.description) && <p className="cd-lead">{text.subtitle || text.description}</p>}
|
||||
{play && <button className="cd-hero-play" onClick={() => nav(play)}><span className="play-dot"><Icon name="play" size={12} /></span>{playLabel}</button>}
|
||||
<div className="cd-by">
|
||||
<span className="avatar" aria-hidden>{initials(c.instructorName)}</span>
|
||||
<span className="cd-by-txt"><em>{t('course.createdBy')}</em><strong>{c.instructorName}</strong><span className="cd-by-n">{t('course.teaches', { n: teaches })}</span></span>
|
||||
<span className="cd-updated"><Icon name="calendar" size={14} />{t('course.lastUpdated')} <span className="num">{fmtDate(c.updatedAt)}</span></span>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
|
@ -615,13 +617,14 @@ function CoursePage({ slug }: { slug?: string }) {
|
|||
<div className="row-between"><strong>{done ? t('course.completed') : t('course.owned')}</strong><span className="small num">{p.pct}%</span></div>
|
||||
<div className="bar"><i style={{ width: `${p.pct}%` }} /></div>
|
||||
<span className="small muted num">{t('my.lessonsDone', { done: p.done, total: p.total })}</span>
|
||||
{pre && !preDone && <p className="cd-prereq"><Icon name="lock" size={14} /><span>{t('course.prereq', { title: ct(pre, locale).title })} <button className="link" onClick={() => nav(`/${locale}/course/${pre.slug}`)}>{t('course.prereqLink', { title: ct(pre, locale).title })}</button></span></p>}
|
||||
{r && !done && <p className="cd-next"><span>{t('player.upNext')}</span><strong>{r.index + 1}. {lessonTitle(r.lesson, locale)}</strong><span className="num">{clock(r.lesson.durationSec)}</span></p>}
|
||||
{r && <div className="cd-cta" ref={setCtaEl}><button className={`btn btn-lg ${done ? 'btn-ghost' : 'btn-accent'}`} onClick={() => nav(`/${locale}/learn/${c.slug}/${r.lesson.id}`)}>{playLabel}</button><button className="cd-round" onClick={share} aria-label={t('course.share')}><Icon name="share" size={18} /></button></div>}
|
||||
{r && <div className="cd-cta" ref={setCtaEl}><button className={`btn btn-lg ${done ? 'btn-ghost' : 'btn-accent'}`} onClick={() => nav(`/${locale}/learn/${c.slug}/${r.lesson.id}`)}>{playLabel}</button></div>}
|
||||
</> : <>
|
||||
{c.prices.ETB != null && <div className="cd-price"><span className="num">{formatMoney(c.prices.ETB, 'ETB')}</span><span>{t('checkout.lifetime')}</span></div>}
|
||||
{pre && !preDone && <p className="cd-prereq"><Icon name="lock" size={14} /><span>{t('course.prereq', { title: ct(pre, locale).title })} <button className="link" onClick={() => nav(`/${locale}/course/${pre.slug}`)}>{t('course.prereqLink', { title: ct(pre, locale).title })}</button></span></p>}
|
||||
<div className="cd-cta" ref={setCtaEl}>
|
||||
<button className="btn btn-accent btn-lg" disabled={c.status !== 'PUBLISHED' || c.prices.ETB == null} onClick={() => nav(`/${locale}/checkout/${c.slug}`)}>{t('course.buyShort')}</button>
|
||||
<button className="cd-round" onClick={share} aria-label={t('course.share')}><Icon name="share" size={18} /></button>
|
||||
</div>
|
||||
<div className="cd-includes">
|
||||
<h2>{t('course.includes')}</h2>
|
||||
|
|
@ -643,7 +646,6 @@ function CoursePage({ slug }: { slug?: string }) {
|
|||
</div>}
|
||||
|
||||
<section className={`cd-body${mine ? ' is-owner' : ''}`}>
|
||||
{pre && !preDone && <div className="banner">{t('course.prereq', { title: ct(pre, locale).title })} <button className="link" onClick={() => nav(`/${locale}/course/${pre.slug}`)}>{t('course.prereqLink', { title: ct(pre, locale).title })}</button></div>}
|
||||
<div className="cd-tabs" role="tablist">{tabs.map(([k, label]) => <button key={k} role="tab" aria-selected={active === k} onClick={() => setTab(k)}>{label}</button>)}</div>
|
||||
{!!text.outcomes?.length && <div className="cd-pane" data-tab="overview" data-active={active === 'overview'}>
|
||||
<h2><KitIcon name="brush" size={22} />{t('course.outcomes')}</h2>
|
||||
|
|
@ -660,18 +662,20 @@ function CoursePage({ slug }: { slug?: string }) {
|
|||
<details key={ch.id} className="ch" open={nextChapter ? ch.id === nextChapter : i === 0}>
|
||||
<summary><span className="grow"><strong>{tr(ch.translations, locale)?.title}</strong><span className="small muted num">{d}/{ls.length} · {formatDuration(ls.reduce((s, l) => s + l.durationSec, 0))}</span></span><Icon name="down" size={18} /></summary>
|
||||
{ls.map((l) => <LessonRow key={l.id} c={c} l={l} />)}
|
||||
{quizzes.filter((a) => a.chapterId === ch.id).map((a) => <AssessmentRow key={a.id} c={c} a={a} inline />)}
|
||||
</details>
|
||||
);
|
||||
})}
|
||||
{!!c.assessments?.length && <details className="ch" open>
|
||||
<summary><span className="grow"><strong>{t('assess.title')}</strong><span className="small muted num">{c.assessments.filter((a) => me?.assessments?.[a.id]?.passed).length}/{c.assessments.length}</span></span><Icon name="down" size={18} /></summary>
|
||||
{c.assessments.map((a) => <AssessmentRow key={a.id} c={c} a={a} />)}
|
||||
{!!finalQuizzes.length && <details className="ch" open>
|
||||
<summary><span className="grow"><strong>{t('assess.title')}</strong><span className="small muted num">{finalQuizzes.filter((a) => me?.assessments?.[a.id]?.passed).length}/{finalQuizzes.length}</span></span><Icon name="down" size={18} /></summary>
|
||||
{finalQuizzes.map((a) => <AssessmentRow key={a.id} c={c} a={a} />)}
|
||||
</details>}
|
||||
</div>
|
||||
{(text.description || text.audience) && <div className="cd-pane" data-tab="overview" data-active={active === 'overview'}>
|
||||
<h2>{t('course.about')}</h2>
|
||||
{text.description && <p style={{ whiteSpace: 'pre-line' }}>{text.description}</p>}
|
||||
{text.audience && <p className="small"><strong>{t('course.audience')}: </strong>{text.audience}</p>}
|
||||
<p className="cd-updated"><Icon name="calendar" size={14} />{t('course.lastUpdated')} <span className="num">{fmtDate(c.updatedAt)}</span></p>
|
||||
</div>}
|
||||
</section>
|
||||
</div>
|
||||
|
|
@ -687,9 +691,9 @@ function LessonRow({ c, l, current }: { c: Course; l: Lesson; current?: boolean
|
|||
const seen = !done && l.durationSec ? Math.min(100, ((me?.progress?.[l.id]?.maxPositionSec ?? 0) / l.durationSec) * 100) : 0;
|
||||
return (
|
||||
<button className={`lesson-row${current ? ' is-current' : ''}${done ? ' is-done' : ''}${access.ok ? '' : ' is-locked'}`} aria-current={current ? 'step' : undefined} onClick={() => nav(`/${locale}/learn/${c.slug}/${l.id}`)}>
|
||||
<span className="lr-ic" aria-hidden>{current && !done ? <span className="eq"><i /><i /><i /></span> : done ? <Icon name="check" size={14} /> : access.ok ? <span className="num">{n}</span> : <Icon name="lock" size={14} />}</span>
|
||||
<span className="lr-ic" aria-hidden>{current && !done ? <span className="eq"><i /><i /><i /></span> : done ? <Icon name="check" size={14} /> : access.ok ? <Icon name="play" size={12} /> : <Icon name="lock" size={14} />}</span>
|
||||
<span className="lr-txt">
|
||||
<span className="lr-title">{current || done || !access.ok ? `${n}. ` : ''}{lessonTitle(l, locale)}</span>
|
||||
<span className="lr-title">{n}. {lessonTitle(l, locale)}</span>
|
||||
<span className="lr-meta num">{clock(l.durationSec)}{l.isPreview && !owns(me, c.id) && <span className="lr-tag">{t('course.preview')}</span>}{!access.ok && access.reason === 'COMING_SOON' && <span className="lr-tag">{t('course.comingSoon')}</span>}</span>
|
||||
{seen > 0 && <span className="lr-seen" aria-hidden><i style={{ width: `${seen}%` }} /></span>}
|
||||
</span>
|
||||
|
|
@ -700,18 +704,21 @@ function LessonRow({ c, l, current }: { c: Course; l: Lesson; current?: boolean
|
|||
|
||||
// ---------------------------------------------------------------- assessments
|
||||
|
||||
function AssessmentRow({ c, a }: { c: Course; a: Assessment }) {
|
||||
function AssessmentRow({ c, a, inline }: { c: Course; a: Assessment; inline?: boolean }) {
|
||||
const t = useTranslations();
|
||||
const { me, locale, nav } = useApp();
|
||||
const r = me?.assessments?.[a.id];
|
||||
const mine = owns(me, c.id);
|
||||
const ch = a.chapterId ? c.chapters.find((x) => x.id === a.chapterId) : undefined;
|
||||
const where = ch ? t('assess.chapter', { chapter: tr(ch.translations, locale)?.title ?? '' }) : t('assess.final');
|
||||
const where = inline ? '' : ch ? t('assess.chapter', { chapter: tr(ch.translations, locale)?.title ?? '' }) : t('assess.final');
|
||||
return (
|
||||
<button className="lesson-row" onClick={() => nav(`/${locale}/assess/${c.slug}/${a.id}`)}>
|
||||
<span className={`ic ${r?.passed ? 'done' : ''}`}>{r?.passed ? <Icon name="check" size={14} /> : owns(me, c.id) ? <Icon name="quiz" size={14} /> : <Icon name="lock" size={14} />}</span>
|
||||
<span className="grow"><span style={{ display: 'block', fontWeight: 700 }}>{tr(a.translations, locale)?.title}</span>
|
||||
<span className="small muted num">{where} · {t('assess.questions', { n: a.questions.length })}</span>
|
||||
{r && <span className={`small num ${r.passed ? 'quiz-ok' : 'quiz-todo'}`}>{r.passed ? t('assess.passed') : t('assess.notPassed')} · {t('assess.best', { pct: r.bestPct })}</span>}</span>
|
||||
<button className={`lesson-row is-quiz${r?.passed ? ' is-done' : ''}${mine ? '' : ' is-locked'}`} onClick={() => nav(`/${locale}/assess/${c.slug}/${a.id}`)}>
|
||||
<span className="lr-ic" aria-hidden>{r?.passed ? <Icon name="check" size={14} /> : mine ? <Icon name="quiz" size={14} /> : <Icon name="lock" size={14} />}</span>
|
||||
<span className="lr-txt">
|
||||
<span className="lr-title">{tr(a.translations, locale)?.title}</span>
|
||||
<span className="lr-meta num">{where && <>{where} · </>}{t('assess.questions', { n: a.questions.length })}
|
||||
{r && <span className={`lr-tag ${r.passed ? 'quiz-ok' : 'quiz-todo'}`}>{r.passed ? t('assess.passed') : t('assess.notPassed')} · {t('assess.best', { pct: r.bestPct })}</span>}</span>
|
||||
</span>
|
||||
<Icon name="chevron" size={16} />
|
||||
</button>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -798,8 +798,6 @@ fieldset[disabled] .quiz-opt { cursor: default; }
|
|||
.cd-price > span:last-child { font-weight: 700; font-size: var(--fs-sm); color: var(--ink-2); }
|
||||
.cd-cta { display: flex; gap: 10px; }
|
||||
.cd-cta .btn { flex: 1; border-radius: 999px; min-height: 54px; }
|
||||
.cd-round { flex: none; width: 54px; height: 54px; border-radius: 50%; border: 1px solid var(--line); background: var(--paper); color: var(--ink); display: grid; place-items: center; cursor: pointer; transition: background 160ms; }
|
||||
.cd-round:hover { background: var(--mist); }
|
||||
.cd-buy .btn-ghost.btn-block { border-radius: 999px; }
|
||||
.cd-note { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-3); padding: 0 4px; }
|
||||
.cd-includes { padding: 6px 4px 4px; display: flex; flex-direction: column; gap: 10px; }
|
||||
|
|
@ -924,9 +922,25 @@ fieldset[disabled] .quiz-opt { cursor: default; }
|
|||
@media (max-width: 1023px) {
|
||||
.cd-tabs { display: none; }
|
||||
.cd-body { gap: 0; }
|
||||
.cd-body > .banner { order: -2; }
|
||||
.cd-body.is-owner > .cd-content { order: -1; } /* P4: owners land on the curriculum */
|
||||
}
|
||||
/* P8: share is a quiet glass button in the hero corner, matching the preview pill */
|
||||
.cd-top { flex-wrap: nowrap; align-items: flex-start; }
|
||||
.cd-top > .crumbs { flex: 1; min-width: 0; }
|
||||
.cd-top > .row { margin-left: auto; flex-wrap: nowrap; }
|
||||
.cd-share { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .25); background: rgba(10, 10, 10, .45); backdrop-filter: blur(8px); color: #fff; cursor: pointer; transition: background-color 160ms ease, transform 160ms var(--ease-out); }
|
||||
.cd-share:active { transform: scale(.96); }
|
||||
.cd-head .cd-pill-own { background: rgba(245, 245, 245, .92); border-color: transparent; color: #0A0A0A; }
|
||||
.cd-head .cd-pill-own svg, .cd-head .cd-pill-own strong { color: #0A0A0A; }
|
||||
@media (hover: hover) and (pointer: fine) { .cd-share:hover { background: rgba(30, 30, 30, .7); } }
|
||||
/* P9: the prerequisite, said where the buying decision happens */
|
||||
.cd-prereq { margin: 0; display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: var(--mist); font-size: var(--fs-sm); color: var(--ink-2); }
|
||||
.cd-prereq > svg { flex: none; margin-top: 3px; color: var(--ink-3); }
|
||||
.cd-prereq .link { font-weight: 700; }
|
||||
/* P6: "last updated" closes the About section */
|
||||
.cd-pane .cd-updated { margin: 0; }
|
||||
/* P7: quiz rows inside chapters reuse the lesson row; their result is a tag, not a block line */
|
||||
.lesson-row .lr-tag.quiz-ok, .lesson-row .lr-tag.quiz-todo { display: inline-block; font-weight: 600; }
|
||||
|
||||
/* help: big ask, three contact doors, FAQ beside the report form */
|
||||
.help { display: flex; flex-direction: column; gap: clamp(28px, 4vw, 48px); }
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user