diff --git a/packages/features/src/student.tsx b/packages/features/src/student.tsx index 46c2b5f..0c06fca 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,29 @@ 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 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]], ['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 (
@@ -576,21 +594,20 @@ function CoursePage({ slug }: { slug?: string }) { {c.status === 'ARCHIVED' && } - {mine && {done ? t('course.completed') : t('course.owned')}} +

{text.title}

{lessons.length}{t('course.lessonsLabel')} {formatDuration(courseDuration(c))} - {previews > 0 && {t('course.previewLessons', { n: previews })}} + {mine && {done ? t('course.completed') : t('course.owned')}}
{(text.subtitle || text.description) &&

{text.subtitle || text.description}

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

{t('course.prereq', { title: ct(pre, locale).title })}

} + {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')}
} + {pre && !preDone &&

{t('course.prereq', { title: ct(pre, locale).title })}

} +
+ +
+
+

{t('course.includes')}

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

{t('course.sequential')}

}
- {preview && } -

{t('checkout.lifetime')}

} -
-

{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,36 +645,38 @@ 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) => )} + {quizzes.filter((a) => a.chapterId === ch.id).map((a) => )}
); })} - {!!c.assessments?.length &&
- {t('assess.title')}{c.assessments.filter((a) => me?.assessments?.[a.id]?.passed).length}/{c.assessments.length} - {c.assessments.map((a) => )} + {!!finalQuizzes.length &&
+ {t('assess.title')}{finalQuizzes.filter((a) => me?.assessments?.[a.id]?.passed).length}/{finalQuizzes.length} + {finalQuizzes.map((a) => )}
} +
+ {(text.description || text.audience) &&
+

{t('course.about')}

+ {text.description &&

{text.description}

} + {text.audience &&

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

} +

{t('course.lastUpdated')} {fmtDate(c.updatedAt)}

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

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

}
); @@ -672,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 ( ); diff --git a/packages/features/src/styles.css b/packages/features/src/styles.css index 37b9038..f693336 100644 --- a/packages/features/src/styles.css +++ b/packages/features/src/styles.css @@ -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; } @@ -905,6 +903,45 @@ 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.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); } .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",