feat(cards): course card polish C1–C4
- C1: one quiet "lessons · length" line; "new course" / student count becomes a tag on the photo - C2: round arrow removed; the whole card is the target and the footer is just the price - C3: owned cards show the next lesson and its length above the progress bar - C4: home Featured becomes a swipe rail of tall cards, the next one peeking past the edge Card styles were spread over five overriding passes; they now live in one block.
This commit is contained in:
parent
7c9c9d97d5
commit
529f35cdf6
|
|
@ -35,22 +35,29 @@ const ct = (c: Course, l: Locale) => tr(c.translations, l) ?? { title: c.slug, d
|
|||
const lessonTitle = (l: Lesson, loc: Locale) => tr(l.translations, loc)?.title ?? '';
|
||||
const lessonNumber = (c: Course, id: string) => publishedLessons(c).findIndex((l) => l.id === id) + 1;
|
||||
|
||||
function CourseCard({ c }: { c: Course }) {
|
||||
// C1: one quiet "lessons · length" line, with "new course" / student count as a tag on the photo.
|
||||
// C2: the whole card is the target, so the footer is just the price. C3: owned cards say what's next.
|
||||
// `tall` keeps the photo-on-top layout on phones too (the home Featured rail, C4).
|
||||
function CourseCard({ c, tall }: { c: Course; tall?: boolean }) {
|
||||
const { locale, nav, me, signedIn } = useApp();
|
||||
const t = useTranslations();
|
||||
const { catName } = useCatalog();
|
||||
const p = courseProgress(c, me);
|
||||
const mine = signedIn && owns(me, c.id);
|
||||
const r = mine ? resumePoint(c, me) : null;
|
||||
const tag = c.enrolledCount ? t('course.enrolled', { n: c.enrolledCount }) : t('course.newCourse');
|
||||
return (
|
||||
<button className="ccard" onClick={() => nav(`/${locale}/course/${c.slug}`)}>
|
||||
<Cover course={c} locale={locale} badge={<span className="pill">{catName(c.categoryId)}</span>} />
|
||||
<button className={`ccard${tall ? ' ccard-tall' : ''}`} onClick={() => nav(`/${locale}/course/${c.slug}`)}>
|
||||
<Cover course={c} locale={locale} badge={<><span className="pill">{catName(c.categoryId)}</span>{!mine && <span className="ccard-tag">{tag}</span>}</>} />
|
||||
<div className="ccard-body">
|
||||
<h3>{ct(c, locale).title}</h3>
|
||||
<span className="meta"><span><Icon name="video" size={14} />{t('course.lessons', { n: p.total })}</span><span><Icon name="clock" size={14} />{formatDuration(courseDuration(c))}</span><span><Icon name="users" size={14} />{c.enrolledCount ? t('course.enrolled', { n: c.enrolledCount }) : t('course.newCourse')}</span></span>
|
||||
<span className="meta num">{t('course.lessons', { n: p.total })} · {formatDuration(courseDuration(c))}</span>
|
||||
<span className="ccard-by">{t('course.by', { name: c.instructorName })}</span>
|
||||
<div className="ccard-foot">
|
||||
{mine ? <><div className="bar grow" aria-label={`${p.pct}%`}><i style={{ width: `${p.pct}%` }} /></div><span className="small num">{p.pct}%</span></>
|
||||
: <>{c.prices.ETB != null ? <strong className="num">{formatMoney(c.prices.ETB, 'ETB')}</strong> : <span />}<span className="ccard-go" aria-hidden><Icon name="chevron" size={18} /></span></>}
|
||||
{mine ? <>
|
||||
{r && <span className="ccard-next">{p.pct === 100 ? <b>{t('course.completed')}</b> : <><b>{t('player.upNext')}</b> {r.index + 1}. {lessonTitle(r.lesson, locale)} · <span className="num">{formatDuration(r.lesson.durationSec)}</span></>}</span>}
|
||||
<span className="ccard-prog"><span className="bar grow" aria-label={`${p.pct}%`}><i style={{ width: `${p.pct}%` }} /></span><span className="small num">{p.pct}%</span></span>
|
||||
</> : c.prices.ETB != null && <strong className="num">{formatMoney(c.prices.ETB, 'ETB')}</strong>}
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
|
|
@ -471,7 +478,7 @@ function Home() {
|
|||
<div className="section-h"><h2>{t('home.categories')}</h2></div>
|
||||
<div className="chips">{categories.filter((c) => c.isActive).map((c) => <button key={c.id} className="chip" onClick={() => nav(`/${locale}/courses/${c.slug}`)}>{tr(c.translations, locale)?.name}</button>)}</div>
|
||||
</section>
|
||||
{others.length > 0 && <section className="stack"><div className="section-h"><h2>{others.some((c) => c.isFeatured) ? t('home.featured') : t('home.new')}</h2><button className="link" onClick={() => nav(`/${locale}/courses`)}>{t('catalog.title')}</button></div><div className="grid-cards">{[...others.filter((c) => c.isFeatured), ...others.filter((c) => !c.isFeatured)].slice(0, 4).map((c) => <CourseCard key={c.id} c={c} />)}</div></section>}
|
||||
{others.length > 0 && <section className="stack"><div className="section-h"><h2>{others.some((c) => c.isFeatured) ? t('home.featured') : t('home.new')}</h2><button className="link" onClick={() => nav(`/${locale}/courses`)}>{t('catalog.title')}</button></div><div className="rail">{[...others.filter((c) => c.isFeatured), ...others.filter((c) => !c.isFeatured)].slice(0, 4).map((c) => <CourseCard key={c.id} c={c} tall />)}</div></section>}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,10 +167,6 @@ textarea.input { min-height: 110px; resize: vertical; }
|
|||
.tone-sand { background: var(--tone-sand); } .tone-sage { background: var(--tone-sage); } .tone-ink { background: var(--tone-ink); }
|
||||
.grid-cards { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
|
||||
.grid-cards > * { max-width: 440px; }
|
||||
.ccard { display: flex; flex-direction: column; gap: 10px; text-align: left; background: none; border: 0; padding: 0; cursor: pointer; min-width: 0; }
|
||||
.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); }
|
||||
/* 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; }
|
||||
|
|
@ -280,11 +276,6 @@ table.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
|
|||
/* compact course rows on phones (§11.2: catalog cards are compact; the Continue card stays wide) */
|
||||
@media (max-width: 599px) {
|
||||
.grid-cards { grid-template-columns: 1fr; gap: 14px; }
|
||||
.ccard { display: grid; grid-template-columns: 104px 1fr; gap: 2px 14px; align-items: start; }
|
||||
.ccard .cover { grid-row: 1 / span 4; aspect-ratio: 1; padding: 8px; }
|
||||
.ccard .cover .ttl { font-size: 13px; -webkit-line-clamp: 4; }
|
||||
.ccard .cover .pill { display: none; }
|
||||
.ccard h3 { font-size: var(--fs-base); }
|
||||
}
|
||||
/* audit fixes: no sideways scroll at 360–400px */
|
||||
@media (max-width: 600px) { .stats { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .stat { min-width: 0; } .stat .lbl { flex-wrap: wrap; letter-spacing: .03em; } .stat .lbl span { overflow-wrap: anywhere; } }
|
||||
|
|
@ -292,7 +283,6 @@ table.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
|
|||
.cover .ttl { margin-top: auto; }
|
||||
.hero-card .cover { aspect-ratio: 16 / 10; }
|
||||
.hero-card .cover .ttl { font-size: clamp(24px, 3.2vw, 36px); }
|
||||
.ccard .cover { aspect-ratio: 16 / 9; }
|
||||
/* touch targets: 40px minimum everywhere, 44px on touch screens */
|
||||
.btn-sm { min-height: 40px; }
|
||||
@media (pointer: coarse) { .btn-sm, .controls button, .controls select { min-height: 44px; min-width: 44px; } .lesson-row { min-height: 56px; } }
|
||||
|
|
@ -382,22 +372,6 @@ h1:lang(en), h2:lang(en), h3:lang(en), h1:lang(om), h2:lang(om), h3:lang(om), .b
|
|||
.cta-band { display: flex; flex-wrap: wrap; gap: 20px; justify-content: space-between; align-items: center; padding: 36px; border-radius: 24px; background: var(--ink); color: var(--on-ink); }
|
||||
.cta-band h2 { font-size: var(--fs-xl); } .cta-band p { opacity: .8; }
|
||||
|
||||
/* course cards */
|
||||
.ccard { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 10px; gap: 0; transition: box-shadow .2s, transform .2s; }
|
||||
.ccard:hover { box-shadow: var(--shadow-soft); transform: translateY(-2px); border-color: transparent; }
|
||||
.ccard:hover h3 { text-decoration: none; }
|
||||
.ccard-body { display: flex; flex-direction: column; gap: 8px; padding: 14px 8px 6px; min-width: 0; }
|
||||
.ccard .meta { display: flex; gap: 14px; flex-wrap: wrap; }
|
||||
.ccard .meta > span { display: inline-flex; align-items: center; gap: 5px; }
|
||||
.ccard-by { font-size: var(--fs-sm); color: var(--ink-2); }
|
||||
.ccard-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; margin-top: 4px; border-top: 1px solid var(--line); }
|
||||
.ccard-cta { font-size: var(--fs-sm); font-weight: 700; padding: 6px 12px; border-radius: var(--r-pill); border: 1px solid var(--line); }
|
||||
.ccard:hover .ccard-cta { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
|
||||
@media (max-width: 599px) {
|
||||
.ccard { padding: 8px; grid-template-columns: 96px 1fr; gap: 0 12px; }
|
||||
.ccard .cover { grid-row: auto; }
|
||||
.ccard-body { padding: 2px 0; gap: 4px; } .ccard-by { display: none; } .ccard-foot { padding-top: 8px; } .ccard-cta { display: none; }
|
||||
}
|
||||
|
||||
/* course page */
|
||||
.c-page { display: flex; flex-direction: column; gap: 20px; }
|
||||
|
|
@ -563,8 +537,6 @@ fieldset[disabled] .quiz-opt { cursor: default; }
|
|||
.thumb .cover .ttl { font-size: 15px; line-height: 1.3; -webkit-line-clamp: 2; }
|
||||
/* phone course rows: square thumbnail that shows the title instead of an empty swatch */
|
||||
@media (max-width: 599px) {
|
||||
.ccard .cover { aspect-ratio: 1; padding: 8px; }
|
||||
.ccard .cover .ttl { font-size: 13px; line-height: 1.3; -webkit-line-clamp: 3; max-width: 100%; }
|
||||
.my-row .btn { flex: 1 1 100%; }
|
||||
}
|
||||
.prog-head .grow { flex: 1 1 160px; }
|
||||
|
|
@ -1080,18 +1052,42 @@ fieldset[disabled] .quiz-opt { cursor: default; }
|
|||
@media (min-width: 900px) { .tour-card.at-bottom { bottom: 32px; } }
|
||||
@media (prefers-reduced-motion: reduce) { .tour-ring, .tour-card, .tour-dim { transition: none; animation: none; } }
|
||||
|
||||
/* ---------- course cards 2026-10-20: edge-to-edge photo, enrolled count, arrow that inverts on hover ---------- */
|
||||
.ccard { padding: 0; overflow: hidden; border-radius: 22px; }
|
||||
.ccard .cover { border-radius: 0; overflow: hidden; }
|
||||
/* ---------- course card (C1–C4, 2026-10-27): the one place card styles live ----------
|
||||
Photo on top with the category and a "new course" / students tag on it; one quiet info line; the footer is the
|
||||
price, or progress plus the next lesson once owned. Phones show a compact row unless the card is .ccard-tall. */
|
||||
.ccard { display: flex; flex-direction: column; min-width: 0; padding: 0; text-align: start; cursor: pointer; color: inherit; background: var(--paper); border: 1px solid var(--line); border-radius: 22px; overflow: hidden; }
|
||||
.ccard .cover { aspect-ratio: 16 / 9; border-radius: 0; overflow: hidden; }
|
||||
.ccard .cover img { transition: transform 700ms var(--ease-out); }
|
||||
.ccard:hover .cover img { transform: scale(1.05); }
|
||||
.ccard-body { padding: 16px 16px 14px; }
|
||||
.ccard h3 { letter-spacing: -.02em; line-height: 1.25; }
|
||||
.ccard .meta { gap: 6px 12px; }
|
||||
.ccard-go { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line); color: var(--ink); transition: background 200ms, color 200ms, border-color 200ms, transform 240ms var(--ease-out); }
|
||||
.ccard:hover .ccard-go, .ccard:focus-visible .ccard-go { background: var(--ink); color: var(--paper); border-color: var(--ink); transform: translateX(2px); }
|
||||
@media (max-width: 600px) { .ccard { padding: 8px; border-radius: 18px; } .ccard .cover { border-radius: 12px; } .ccard-body { padding: 2px 0; } .ccard-go { width: 32px; height: 32px; } }
|
||||
@media (hover: none) { .ccard:hover .cover img { transform: none; } }
|
||||
.ccard-tag { position: absolute; z-index: 1; left: 10px; bottom: 10px; padding: 3px 10px; border-radius: 999px; background: rgba(10, 10, 10, .62); backdrop-filter: blur(8px); color: #F5F5F5; font-size: 12px; font-weight: 600; white-space: nowrap; }
|
||||
.ccard-body { display: flex; flex-direction: column; gap: 6px; padding: 16px 16px 14px; min-width: 0; flex: 1; }
|
||||
.ccard h3 { font-size: var(--fs-lg); line-height: 1.25; letter-spacing: -.02em; }
|
||||
.ccard .meta { font-size: var(--fs-sm); color: var(--ink-3); }
|
||||
.ccard-by { font-size: var(--fs-sm); color: var(--ink-2); }
|
||||
.ccard-foot { display: flex; flex-direction: column; gap: 8px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
|
||||
.ccard-foot > strong { font-size: var(--fs-lg); }
|
||||
.ccard-next { font-size: var(--fs-sm); color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.ccard-next b { color: var(--ink); font-weight: 700; }
|
||||
.ccard-prog { display: flex; align-items: center; gap: 10px; }
|
||||
@media (hover: hover) and (pointer: fine) {
|
||||
.ccard:hover { box-shadow: var(--shadow-soft); transform: translateY(-2px); border-color: transparent; }
|
||||
.ccard:hover .cover img { transform: scale(1.05); }
|
||||
}
|
||||
/* phones: compact row (square thumbnail beside the text), except tall cards in a rail */
|
||||
@media (max-width: 599px) {
|
||||
.ccard:not(.ccard-tall) { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 0 12px; align-items: start; padding: 8px; border-radius: 18px; }
|
||||
.ccard:not(.ccard-tall) .cover { aspect-ratio: 1; border-radius: 12px; padding: 8px; }
|
||||
.ccard:not(.ccard-tall) .cover .pill { display: none; }
|
||||
.ccard:not(.ccard-tall) .ccard-tag { left: 6px; right: 6px; bottom: 6px; padding: 2px 6px; font-size: 11px; text-align: center; overflow: hidden; text-overflow: ellipsis; }
|
||||
.ccard:not(.ccard-tall) .ccard-body { padding: 2px 0; gap: 4px; }
|
||||
.ccard:not(.ccard-tall) h3 { font-size: var(--fs-base); }
|
||||
.ccard:not(.ccard-tall) .ccard-by { display: none; }
|
||||
.ccard:not(.ccard-tall) .ccard-foot { padding-top: 8px; gap: 6px; }
|
||||
}
|
||||
/* C4: home Featured is a swipe rail of tall cards; the next card peeks past the edge */
|
||||
.rail { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: 16px; overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; scrollbar-width: none; padding-bottom: 4px; }
|
||||
.rail::-webkit-scrollbar { display: none; }
|
||||
.rail > * { scroll-snap-align: start; }
|
||||
@media (max-width: 599px) { .rail { grid-auto-columns: 78%; gap: 12px; margin-inline: -16px; padding-inline: 16px; scroll-padding-inline: 16px; } }
|
||||
|
||||
/* ---------- how it works: abstract art instead of portraits ---------- */
|
||||
.step { background: var(--paper); border: 1px solid var(--line); color: var(--ink); justify-content: flex-end; min-height: 300px; }
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user