SPB Git

Repository Public

WatchBody.tsx 5.4 KB 73 lines tsx

1import Link from "next/link";2import { WatchClient } from "@/components/player/WatchClient";3import type { PlayerCapsule } from "@/components/player/types";4import { DeckSection } from "@/components/slides/DeckSection";5import { Callout, PreviewChip } from "@/components/ui/Bits";6import { Icon } from "@/components/ui/Icon";7import { getCapsuleData } from "@/lib/content";8import { pad2, partOf } from "@/lib/labels";9import { mediaPath, sessionPath, type CourseView, type SessionView } from "@/modules/content-schema";1011/** The watch page. `base` prefixes page and media addresses when it is rendered inside the studio's private preview. */12export async function WatchBody({ course, session, base = "" }: { course: CourseView; session: SessionView; base?: string }) {13  const part = partOf(course, session);14  const index = course.sessions.findIndex((s) => s.id === session.id), prev = course.sessions[index - 1], next = course.sessions[index + 1];1516  const capsules: PlayerCapsule[] = await Promise.all(session.capsules.map(async (c) => {17    const { chapters, transcript } = await getCapsuleData(c);18    return {19      id: c.id, title: c.title, durationSeconds: c.durationSeconds, synthetic: c.synthetic, optional: c.optional,20      hls: c.media.hls ? base + mediaPath(c.media.hls) : null, mp4: c.media.mp4 ? base + mediaPath(c.media.mp4) : null, poster: c.media.poster ? base + mediaPath(c.media.poster) : null,21      captions: c.media.captions.map((t) => ({ lang: t.lang, label: t.label, src: base + mediaPath(t.path) })),22      chapters, transcript: transcript?.segments ?? null,23    };24  }));2526  return (27    <div data-session={session.id}>28      <div className="site-chrome shell pt-6">29        <nav aria-label="Fil d’Ariane" className="text-sm text-muted">30          <ol className="flex flex-wrap items-center gap-2">31            <li><Link href="/programme" className="hover:underline">Programme</Link></li><li aria-hidden="true">/</li>32            <li><Link href={base + sessionPath(session.slug)} className="hover:underline">Séance {pad2(session.number)}</Link></li><li aria-hidden="true">/</li>33            <li aria-current="page">Regarder</li>34          </ol>35        </nav>36        <div className="mt-3 flex flex-wrap items-center gap-3">37          <h1 className="text-[clamp(1.4rem,2vw+1rem,2rem)]">{session.title}</h1>38          {session.previewOnly && <PreviewChip />}39        </div>40        <p className="mt-1 text-sm text-muted">Partie {part.id} — {part.short} · {course.author.name}, {course.author.role.toLowerCase()}, {course.author.institution}</p>41      </div>4243      {capsules.length === 0 ? (44        <div className="shell-narrow py-10">45          <Callout tone="amber" title={session.access === "open" ? "Les vidéos de cette séance ne sont pas encore enregistrées." : "Cette séance n’est pas encore publiée."}>46            <p>Il n’y a donc rien à regarder pour l’instant. {session.sections.slides ? "Les diapositives de la séance, elles, se consultent sur sa page." : "Le plan de la séance, lui, est déjà public."}</p>47          </Callout>48          <p className="mt-6"><Link href={base + sessionPath(session.slug)} className="btn btn-primary"><Icon name="back" size={18} />Retour à la séance</Link></p>49        </div>50      ) : (51        <WatchClient session={{ id: session.id, slug: session.slug, number: session.number, title: session.title }} capsules={capsules} />52      )}5354      {capsules.length > 0 && <div className="site-chrome shell mt-10"><DeckSection session={session} base={base} /></div>}5556      <div className="site-chrome shell mt-10">57        <div className="flex flex-wrap gap-2">58          <Link href={base + sessionPath(session.slug)} className="btn btn-ghost btn-sm"><Icon name="layers" size={16} />Page de la séance</Link>59          {session.sections.quiz && <Link href={`${base}${sessionPath(session.slug)}#quiz`} className="btn btn-ghost btn-sm">Quiz</Link>}60          {session.sections.lab && <Link href={`${base}${sessionPath(session.slug)}#laboratoire`} className="btn btn-ghost btn-sm">Laboratoire</Link>}61          {session.sections.figures && <Link href={`${base}${sessionPath(session.slug)}#figures`} className="btn btn-ghost btn-sm">Figures</Link>}62          {session.sections.glossary && <Link href={`${base}${sessionPath(session.slug)}#glossaire`} className="btn btn-ghost btn-sm">Glossaire</Link>}63        </div>64        {session.dependsOn.length > 0 && <p className="mt-4 text-sm text-muted">Préalables : {session.dependsOn.map((d, i) => { const s = course.sessions.find((x) => x.id === d)!; return <span key={d}>{i > 0 && " ; "}<Link href={base + sessionPath(s.slug)} className="link">séance {s.number} — {s.short}</Link></span>; })}</p>}65        <nav aria-label="Séances voisines" className="mt-8 grid gap-3 border-t border-line pt-6 sm:grid-cols-2">66          {prev ? <Link href={base + sessionPath(prev.slug)} className="card card-hover p-4"><span className="flex items-center gap-2 text-sm text-muted"><Icon name="back" size={16} />Séance précédente</span><span className="mt-1 block font-medium">{pad2(prev.number)} — {prev.short}</span></Link> : <span />}67          {next && <Link href={base + sessionPath(next.slug)} className="card card-hover p-4 sm:text-right"><span className="flex items-center gap-2 text-sm text-muted sm:justify-end">Séance suivante<Icon name="arrow" size={16} /></span><span className="mt-1 block font-medium">{pad2(next.number)} — {next.short}</span></Link>}68        </nav>69      </div>70    </div>71  );72}73
Files main
Menu

Theme