Course experience polish: course page, home, cards, catalog, player #4

Merged
Kerod-Fresenbet-Yaltopia merged 6 commits from ui-ux-course-polish into main 2026-10-30 11:31:55 +03:00
2 changed files with 44 additions and 16 deletions
Showing only changes of commit 7c9c9d97d5 - Show all commits

View File

@ -462,8 +462,10 @@ function Home() {
const others = visible.filter((c) => !owns(me, c.id));
return (
<>
<h1 style={{ fontSize: 'var(--fs-2xl)' }}>{t('home.hello', { name: me?.name.split(' ')[0] ?? '' })}</h1>
{cont ? <ContinueCard c={cont} /> : <Empty action={<button className="btn" onClick={() => nav(`/${locale}/courses`)}>{t('landing.browse')}</button>}>{t('home.emptyMine')}</Empty>}
<div className="home-top">
<h1 style={{ fontSize: 'var(--fs-2xl)' }}>{t('home.hello', { name: me?.name.split(' ')[0] ?? '' })}</h1>
{cont ? <ContinueCard c={cont} /> : <Empty action={<button className="btn" onClick={() => nav(`/${locale}/courses`)}>{t('landing.browse')}</button>}>{t('home.emptyMine')}</Empty>}
</div>
{mine.length > 1 && <section className="stack"><div className="section-h"><h2>{t('nav.myCourses')}</h2><button className="link" onClick={() => nav(`/${locale}/my`)}>{t('my.viewProgress')}</button></div><div className="grid-cards">{mine.map((c) => <CourseCard key={c.id} c={c} />)}</div></section>}
<section className="stack">
<div className="section-h"><h2>{t('home.categories')}</h2></div>
@ -474,21 +476,30 @@ function Home() {
);
}
// H1/H2: a short photo header carries the course and its progress; the body leads with the next lesson and how long
// it takes, with the button at the bottom where a thumb reaches it.
function ContinueCard({ c }: { c: Course }) {
const t = useTranslations();
const { me, locale, nav } = useApp();
const { me, locale, nav, ds, categories } = useApp();
const p = courseProgress(c, me);
const r = resumePoint(c, me);
const finished = p.pct === 100;
const photo = c.coverAssetId ? ds.assetUrl(c.coverAssetId) : coursePhoto(c, categories.map((k) => k.id));
return (
<section className="continue" aria-label={t('home.continue')}>
<Cover course={c} locale={locale} />
<div className="stack-sm">
<span className="small" style={{ opacity: .8 }}>{t('home.continue')}</span>
<h2 style={{ fontSize: 'var(--fs-xl)' }}>{ct(c, locale).title}</h2>
{r && <p style={{ opacity: .85 }}>{r.index + 1}. {lessonTitle(r.lesson, locale)}</p>}
<div className="bar"><i style={{ width: `${p.pct}%` }} /></div>
<span className="small num" style={{ opacity: .8 }}>{t('my.lessonsDone', { done: p.done, total: p.total })}</span>
{r && <div><button className="btn btn-accent" onClick={() => nav(`/${locale}/learn/${c.slug}/${r.lesson.id}`)}><Icon name="play" size={16} />{p.pct === 100 ? t('course.watchAgain') : t('course.continue', { n: r.index + 1 })}</button></div>}
<div className="continue-media">
<img src={photo} alt="" />
<span className="continue-kicker">{t('home.continue')}</span>
<h2>{ct(c, locale).title}</h2>
<span className="continue-bar" role="progressbar" aria-valuenow={p.pct} aria-valuemin={0} aria-valuemax={100} aria-label={t('my.lessonsDone', { done: p.done, total: p.total })}><i style={{ width: `${p.pct}%` }} /></span>
</div>
<div className="continue-body">
{r && <p className="continue-next">
<span>{finished ? t('course.completed') : t('player.upNext')}</span>
<strong>{r.index + 1}. {lessonTitle(r.lesson, locale)}</strong>
<span className="num">{formatDuration(r.lesson.durationSec)} · {t('my.lessonsDone', { done: p.done, total: p.total })}</span>
</p>}
{r && <button className="btn btn-accent btn-lg" onClick={() => nav(`/${locale}/learn/${c.slug}/${r.lesson.id}`)}><Icon name="play" size={16} />{finished ? t('course.watchAgain') : t('course.continue', { n: r.index + 1 })}</button>}
</div>
</section>
);

View File

@ -171,9 +171,28 @@ textarea.input { min-height: 110px; resize: vertical; }
.ccard h3 { font-size: var(--fs-lg); }
.ccard:hover h3 { text-decoration: underline; text-underline-offset: 4px; }
.ccard .meta { font-size: var(--fs-sm); color: var(--ink-3); }
.continue { display: grid; gap: 20px; grid-template-columns: 1fr; padding: 20px; border-radius: var(--r-lg); background: var(--ink); color: var(--on-ink); }
.continue .bar { background: rgba(255, 255, 255, .18); }
@media (min-width: 720px) { .continue { grid-template-columns: 260px 1fr; align-items: center; } }
/* home: greeting + continue card (H1–H3). The card is a dark photo surface in both themes. */
.home-top { display: flex; flex-direction: column; gap: 16px; }
.continue { display: grid; grid-template-columns: 1fr; border-radius: 22px; overflow: hidden; background: #111; color: #F5F5F5; }
.continue-media { position: relative; isolation: isolate; aspect-ratio: 16 / 9; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; padding: 16px 18px 22px; }
.continue-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 25%; z-index: -2; }
.continue-media::after { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(10, 10, 10, 0) 30%, rgba(10, 10, 10, .82)); }
.continue-kicker, .continue-next > span:first-child { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: rgba(245, 245, 245, .75); }
.continue-media h2 { font-size: var(--fs-xl); line-height: 1.15; letter-spacing: -.02em; color: #fff; }
.continue-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, .2); }
.continue-bar > i { display: block; height: 100%; background: #fff; }
.continue-body { display: flex; flex-direction: column; gap: 16px; padding: 16px 18px 18px; }
.continue-next { margin: 0; display: flex; flex-direction: column; gap: 2px; }
.continue-next strong { font-size: var(--fs-lg); line-height: 1.3; }
.continue-next > .num { font-size: var(--fs-sm); color: #A3A3A3; }
.continue-body .btn { width: 100%; border-radius: 999px; }
.continue .btn-accent { background: #F5F5F5; color: #0A0A0A; }
@media (min-width: 720px) {
.continue { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
.continue-media { aspect-ratio: auto; min-height: 260px; padding: 20px 24px 26px; }
.continue-body { justify-content: center; padding: 24px 28px; }
.continue-body .btn { align-self: flex-start; width: auto; }
}
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.chip { flex: none; border: 1px solid var(--line); background: var(--paper); padding: 8px 14px; border-radius: var(--r-pill); cursor: pointer; font-weight: 700; color: var(--ink-2); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
@ -467,8 +486,6 @@ h1:lang(en), h2:lang(en), h3:lang(en), h1:lang(om), h2:lang(om), h3:lang(om), .b
.cta-band { position: relative; overflow: hidden; background: #111; color: #fff; }
.cta-band::after { content: ''; position: absolute; right: -60px; bottom: -120px; width: 280px; height: 280px; border-radius: 50%; background: #fff; opacity: .12; pointer-events: none; }
.cta-band > * { position: relative; z-index: 1; }
.continue { background: #111; color: #fff; }
.continue .bar > i { background: #fff; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); }
.pay-mark { width: 48px; height: 28px; flex: none; display: grid; place-items: center; }
.pay-mark img { width: 48px; height: 28px; object-fit: contain; }