diff --git a/packages/features/src/student.tsx b/packages/features/src/student.tsx index 46c2b5f..dac8841 100644 --- a/packages/features/src/student.tsx +++ b/packages/features/src/student.tsx @@ -532,9 +532,19 @@ function CoursePage({ slug }: { slug?: string }) { const t = useTranslations(); const { courses, categories, me, locale, nav, catalogLoaded, toast, ds } = useApp(); const { catName } = useCatalog(); - const [tab, setTab] = useState('overview'); + const [tab, setTab] = useState(null); // null: the viewer's default (curriculum once they own it) + // The sticky bar repeats the buy card's button, so it only shows while that button is off screen (P1). + const [ctaEl, setCtaEl] = useState(null); + const [ctaInView, setCtaInView] = useState(true); // start hidden: the bar slides in once the button is known to be off screen, never flashes out on load const c = courses.find((x) => x.slug === slug); useEffect(() => { if (c) document.title = `${ct(c, locale).title} · Sirkul Makeup`; }, [c, locale]); // before the early returns: hooks must run every render + useEffect(() => { + if (!ctaEl || typeof IntersectionObserver === 'undefined') { setCtaInView(false); return; } + // The bottom margin is the bar's own height: a button still underneath the bar doesn't count as visible. + const io = new IntersectionObserver(([e]) => setCtaInView(e.isIntersecting), { rootMargin: '0px 0px -88px 0px' }); + io.observe(ctaEl); + return () => io.disconnect(); + }, [ctaEl]); if (!catalogLoaded) return ; if (!c || !isStudentVisible(c, me)) return nav(`/${locale}/courses`)}>{t('catalog.title')}}>{t('course.notFound')}; const text = ct(c, locale); @@ -549,21 +559,27 @@ function CoursePage({ slug }: { slug?: string }) { const previews = lessons.filter((l) => l.isPreview).length; const cat = categories.find((k) => k.id === c.categoryId); const chapters = [...c.chapters].sort((a, b) => a.sortOrder - b.sortOrder); - const play = mine && r ? `/${locale}/learn/${c.slug}/${r.lesson.id}` : preview ? `/${locale}/learn/${c.slug}/${preview.id}` : null; + // The hero only offers the free preview; once owned, the progress card below carries the one "continue" button (P2). + const play = !mine && preview ? `/${locale}/learn/${c.slug}/${preview.id}` : null; const playLabel = mine && r ? (done ? t('course.watchAgain') : t('course.continue', { n: r.index + 1 })) : t('course.watchPreview'); const share = () => { navigator.clipboard?.writeText(location.href).then(() => toast(t('course.linkCopied')), () => { /* clipboard blocked */ }); }; const teaches = courses.filter((x) => x.instructorName === c.instructorName && isStudentVisible(x, me)).length; // No uploaded cover in the demo → a category photo stands in on the preview card. const photo = c.coverAssetId ? ds.assetUrl(c.coverAssetId) : coursePhoto(c, categories.map((k) => k.id)); - const tabs: [string, string][] = [['overview', t('course.tabOverview')], ['content', t('course.content')], ['instructor', t('course.tabInstructor')]]; + // Owners come back for the curriculum, buyers for the pitch (P4). Desktop shows one tab at a time; + // 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 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]], ['video', t('course.lessons', { n: lessons.length })], ['clock', formatDuration(courseDuration(c))], ...(previews ? [['play', t('course.previewLessons', { n: previews })] as [string, ReactNode]] : []), ...(c.assessments?.length ? [['quiz', t('assess.title')] as [string, ReactNode]] : []), - ['shield', t('course.lifetimeAccess')], ]; + const showBar = !!(mine ? r : c.prices.ETB != null && c.status === 'PUBLISHED'); + const barHidden = showBar && ctaInView; return (
@@ -583,13 +599,12 @@ function CoursePage({ slug }: { slug?: string }) {
{lessons.length}{t('course.lessonsLabel')} {formatDuration(courseDuration(c))} - {previews > 0 && {t('course.previewLessons', { n: previews })}}
{(text.subtitle || text.description) &&

{text.subtitle || text.description}

} {play && }
{initials(c.instructorName)} - {t('course.createdBy')}{c.instructorName} + {t('course.createdBy')}{c.instructorName}{t('course.teaches', { n: teaches })} {t('course.lastUpdated')} {fmtDate(c.updatedAt)}
@@ -600,25 +615,24 @@ function CoursePage({ slug }: { slug?: string }) {
{done ? t('course.completed') : t('course.owned')}{p.pct}%
{t('my.lessonsDone', { done: p.done, total: p.total })} - {r &&
} + {r && !done &&

{t('player.upNext')}{r.index + 1}. {lessonTitle(r.lesson, locale)}{clock(r.lesson.durationSec)}

} + {r &&
} : <> - {c.prices.ETB != null &&
{formatMoney(c.prices.ETB, 'ETB')}{t('course.lifetime')}
} -
- + {c.prices.ETB != null &&
{formatMoney(c.prices.ETB, 'ETB')}{t('checkout.lifetime')}
} +
+
- {preview && } -

{t('checkout.lifetime')}

+
+

{t('course.includes')}

+
    {includes.map(([icon, label], k) =>
  • {label}
  • )}
+ {c.sequentialLessons &&

{t('course.sequential')}

} +
} -
-

{t('course.includes')}

-
    {includes.map(([icon, label], k) =>
  • {label}
  • )}
- {c.sequentialLessons &&

{t('course.sequential')}

} -
- {(mine ? r : c.prices.ETB != null && c.status === 'PUBLISHED') &&
+ {showBar &&
{mine && r ? <> {p.pct}%{t('my.lessonsDone', { done: p.done, total: p.total })} @@ -628,25 +642,22 @@ function CoursePage({ slug }: { slug?: string }) { }
} -
+
{pre && !preDone &&
{t('course.prereq', { title: ct(pre, locale).title })}
} -
{tabs.map(([k, label]) => )}
- {tab === 'overview' &&
- {!!text.outcomes?.length && <> -

{t('course.outcomes')}

-
    {text.outcomes.map((o, k) =>
  • {o}
  • )}
- } - {text.description &&

{text.description}

} - {text.audience &&

{t('course.audience')}: {text.audience}

} +
{tabs.map(([k, label]) => )}
+ {!!text.outcomes?.length &&
+

{t('course.outcomes')}

+
    {text.outcomes.map((o, k) =>
  • {o}
  • )}
} - {tab === 'content' &&
+
+

{t('course.content')}

{t('course.lessons', { n: lessons.length })} · {formatDuration(courseDuration(c))}

{chapters.map((ch, i) => { const ls = [...ch.lessons].sort((a, b) => a.sortOrder - b.sortOrder).filter((l) => l.isPublished); if (!ls.length) return null; const d = ls.filter((l) => isCompleted(me, l.id)).length; return ( -
+
{tr(ch.translations, locale)?.title}{d}/{ls.length} · {formatDuration(ls.reduce((s, l) => s + l.durationSec, 0))} {ls.map((l) => )}
@@ -656,8 +667,12 @@ function CoursePage({ slug }: { slug?: string }) { {t('assess.title')}{c.assessments.filter((a) => me?.assessments?.[a.id]?.passed).length}/{c.assessments.length} {c.assessments.map((a) => )}
} +
+ {(text.description || text.audience) &&
+

{t('course.about')}

+ {text.description &&

{text.description}

} + {text.audience &&

{t('course.audience')}: {text.audience}

}
} - {tab === 'instructor' &&
{initials(c.instructorName)}
{c.instructorName}

{t('course.teaches', { n: teaches })}

}
); diff --git a/packages/features/src/styles.css b/packages/features/src/styles.css index 37b9038..1248b1a 100644 --- a/packages/features/src/styles.css +++ b/packages/features/src/styles.css @@ -905,6 +905,29 @@ fieldset[disabled] .quiz-opt { cursor: default; } .cd-bar .btn { border-radius: 999px; min-height: 48px; padding-inline: 22px; } @media (min-width: 1024px) { .cd-bar { display: none; } } +/* ---------- course page polish 2026-10-26 (P1–P5) ---------- */ +/* P1: the bar repeats the buy card's button, so it steps aside while that button is on screen */ +.cd-bar { transition: transform 220ms var(--ease-out), opacity 220ms var(--ease-out); } +.cd-bar[data-hidden="true"] { transform: translateY(100%); opacity: 0; pointer-events: none; } +/* P2: price once, with its terms underneath */ +.cd-price { flex-direction: column; align-items: flex-start; gap: 2px; } +.cd-price > span:last-child { font-weight: 600; color: var(--ink-3); } +/* P4: owners see the next lesson instead of the sales list */ +.cd-next { margin: 0; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 14px; background: var(--mist); } +.cd-next > span:first-child { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); } +.cd-next > .num { font-size: var(--fs-sm); color: var(--ink-3); } +/* P5: what the instructor tab said, in the creator row */ +.cd-by-n { font-size: 12px; color: var(--ink-3); } +/* P3: desktop keeps tabs (one section at a time); phones drop them and stack every section in one scroll */ +.cd-pane-h { margin-bottom: 4px; } +@media (min-width: 1024px) { .cd-pane[data-active="false"], .cd-pane-h { display: none; } } +@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 */ +} + /* help: big ask, three contact doors, FAQ beside the report form */ .help { display: flex; flex-direction: column; gap: clamp(28px, 4vw, 48px); } .help-hero { display: flex; flex-direction: column; gap: 10px; padding-top: clamp(8px, 3vw, 32px); } diff --git a/packages/i18n/messages/am.json b/packages/i18n/messages/am.json index 566c650..6bf63df 100644 --- a/packages/i18n/messages/am.json +++ b/packages/i18n/messages/am.json @@ -151,6 +151,7 @@ "watchAgain": "እንደገና ይመልከቱ", "tabOverview": "አጠቃላይ እይታ", "tabInstructor": "አሠልጣኝ", + "about": "ስለ ኮርሱ", "summary": "ማጠቃለያ", "duration": "ጠቅላላ ርዝመት", "language": "ቋንቋ", diff --git a/packages/i18n/messages/en.json b/packages/i18n/messages/en.json index fa935c7..b197c12 100644 --- a/packages/i18n/messages/en.json +++ b/packages/i18n/messages/en.json @@ -151,6 +151,7 @@ "watchAgain": "Watch again", "tabOverview": "Overview", "tabInstructor": "Instructor", + "about": "About this course", "summary": "Summary", "duration": "Total duration", "language": "Language", diff --git a/packages/i18n/messages/om.json b/packages/i18n/messages/om.json index d4bfeb8..2eaa4a6 100644 --- a/packages/i18n/messages/om.json +++ b/packages/i18n/messages/om.json @@ -151,6 +151,7 @@ "watchAgain": "Irra deebi'ii ilaali", "tabOverview": "Overview", "tabInstructor": "Instructor", + "about": "Waa'ee koorsii kanaa", "summary": "Summary", "duration": "Total duration", "language": "Language", diff --git a/packages/i18n/messages/ti.json b/packages/i18n/messages/ti.json index 164bb58..99e9e43 100644 --- a/packages/i18n/messages/ti.json +++ b/packages/i18n/messages/ti.json @@ -151,6 +151,7 @@ "watchAgain": "እንደገና ርአ", "tabOverview": "Overview", "tabInstructor": "Instructor", + "about": "ብዛዕባ እዚ ኮርስ", "summary": "Summary", "duration": "Total duration", "language": "Language",