Repository navigation
Redesign 3/6: the episode page, built around its stage #80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1233ffe
The episode page, built around its stage
RobbieTheWagner 5b9f652
Hold a landed section under the bar where there's no scroll anchoring
RobbieTheWagner dc14fdc
Hold a landed section in WebKit too, which accepts overflow-anchor
RobbieTheWagner 7603296
Hold a landed section to the pixel
RobbieTheWagner 05c64b7
Address CodeRabbit on the episode page
RobbieTheWagner 13e5615
Fix episode page edges found in review
RobbieTheWagner 9d1ad41
Put the phone script limits after the base script rules
RobbieTheWagner d6c3b2d
Expect the redesigned transcript in the transcript tests
RobbieTheWagner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,214 @@ | ||
| --- | ||
| import { matchNames, sortCast, voiceFor, type CastPerson } from '../lib/cast'; | ||
| import { getEpisodeCues } from '../lib/episode-cues'; | ||
| import { optimizeImage } from '../lib/optimize-episode-image'; | ||
| import type { Episode, Show } from '../lib/rss'; | ||
| import { dasherize } from '../utils/dasherize'; | ||
| import { formatDuration, toPlayable } from '../utils/playable'; | ||
| import { ArrowOutIcon, HeadphonesIcon, VideoIcon } from './icons'; | ||
| import Sponsors from './episode/Sponsors.astro'; | ||
| import LiveScript from './media/LiveScript'; | ||
| import PersonFace from './PersonFace.astro'; | ||
| import StageControls from './media/StageControls'; | ||
|
|
||
| import type { ImageMetadata } from 'astro'; | ||
| import { getImage } from 'astro:assets'; | ||
| import starpodConfig from 'virtual:starpod/config'; | ||
| // The face for someone without a photo, light or dark with the page. | ||
| import avatar from '../assets/avatar.svg?url'; | ||
|
|
||
| export interface Props { | ||
| episode: Episode; | ||
| show: Show; | ||
| /** | ||
| * The episode's hosts and guests, from the guests/sponsors database. Empty | ||
| * (or absent) when the database isn't enabled: no cast is shown. | ||
| */ | ||
| people?: Array<CastPerson>; | ||
| /** The episode's sponsors from the database; the row hides when empty. */ | ||
| sponsors?: Array<{ id: string; img: string | null; name: string; url: string }>; | ||
| /** `feature` on the home page (links on to the episode), `page` on its own page. */ | ||
| variant: 'feature' | 'page'; | ||
| /** | ||
| * Divide the stage between the picture and the live transcript with a | ||
| * draggable divider (desktop, when the episode has a transcript). See | ||
| * `episode/split.ts`. | ||
| */ | ||
| split?: boolean; | ||
| } | ||
|
|
||
| const { episode, people = [], show, sponsors = [], split = false, variant } = Astro.props; | ||
| const playable = toPlayable(episode, show); | ||
| const Heading = variant === 'page' ? 'h1' : 'h2'; | ||
| const art = | ||
| (await optimizeImage(episode.episodeImage ?? show.image, { width: 960, height: 960 })) ?? | ||
| show.image; | ||
| const date = new Date(episode.published); | ||
| const titleId = `stage-title-${episode.id.replace(/[^a-z0-9]/gi, '')}`; | ||
| const scriptId = `stage-script-${episode.id.replace(/[^a-z0-9]/gi, '')}`; | ||
| const presets = [ | ||
| ['watch', 'Watch'], | ||
| ['balanced', 'Balanced'], | ||
| ['read', 'Read'] | ||
| ]; | ||
|
|
||
| // The cast: this episode's own hosts and guests, in credit order. Anyone who | ||
| // speaks as one of the transcript's two main voices wears that voice's face. | ||
| const photos = import.meta.glob<{ default: ImageMetadata }>( | ||
| '/src/img/people/*.{jpeg,jpg,png}' | ||
| ); | ||
| const cues = people.length ? await getEpisodeCues(episode) : null; | ||
| const names = people.map((person) => person.name); | ||
| const speakerOf = matchNames(names, [...new Set(cues?.flatMap((cue) => (cue.n ? [cue.n] : [])))], { | ||
| surnames: true | ||
| }); | ||
| const cast = await Promise.all( | ||
| sortCast(people, starpodConfig.hosts.map((host) => host.name)).map(async (person) => { | ||
| const photo = | ||
| person.img && (await photos[`/src/img/people/${person.img}`]?.())?.default; | ||
| const image = photo | ||
| ? await getImage({ src: photo, width: 112, height: 112, format: 'webp' }) | ||
| : { src: avatar }; | ||
| return { | ||
| guest: !person.isHost, | ||
| name: person.name, | ||
| speaksAs: speakerOf.get(person.name), | ||
| src: image.src, | ||
| voice: voiceFor(person.name, cues, names) | ||
| }; | ||
| }) | ||
| ); | ||
| --- | ||
|
|
||
| <section | ||
| aria-labelledby={titleId} | ||
| class="stage" | ||
| data-has-video={episode.video ? '' : undefined} | ||
| data-split={split ? '' : undefined} | ||
| data-stage | ||
| data-variant={variant} | ||
| > | ||
| <div class="stage-side"> | ||
| <div class="stage-room"> | ||
| <div aria-hidden="true" class="stage-light" style={`--art: url("${art}")`}> | ||
| <canvas | ||
| class="stage-light-canvas" | ||
| data-episode-id={episode.id} | ||
| data-stage-light | ||
| height="18" | ||
| width="32" | ||
| ></canvas> | ||
| </div> | ||
| <div class="stage-frame PropFLIP" data-stage-frame> | ||
| <div aria-hidden="true" class="stage-ambient" style={`--art: url("${art}")`}></div> | ||
| <img | ||
| alt={`${episode.title} - episode art`} | ||
| class="stage-art" | ||
| decoding="async" | ||
| fetchpriority="high" | ||
| height="960" | ||
| src={art} | ||
| style={`view-transition-name: vt-art-${dasherize(episode.title)}`} | ||
| width="960" | ||
| /> | ||
| <div class="stage-slot" data-episode-id={episode.id} data-media-slot></div> | ||
| <StageControls client:load episode={playable} part="overlay" /> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div class="stage-meta"> | ||
| <Heading | ||
| class="stage-title" | ||
| id={titleId} | ||
| style={`view-transition-name: vt-${dasherize(episode.title)}`} | ||
| > | ||
| {episode.title} | ||
| </Heading> | ||
| <p class="stage-facts"> | ||
| <span>{episode.episodeNumber === 'Bonus' ? 'Bonus' : `Episode ${episode.episodeNumber}`}</span> | ||
| <time datetime={date.toISOString()}> | ||
| {date.toLocaleDateString('en-us', { month: 'short', day: 'numeric', year: 'numeric' })} | ||
| </time> | ||
| <span>{formatDuration(episode.duration)}</span> | ||
| <span class="stage-kind"> | ||
| {episode.video ? <VideoIcon size={15} /> : <HeadphonesIcon size={15} />} | ||
| {episode.video ? 'Video' : 'Audio'} | ||
| </span> | ||
| </p> | ||
| { | ||
| cast.length > 0 && ( | ||
| <ul aria-label="Creators and guests" class="cast"> | ||
| {cast.map((person) => ( | ||
| <li | ||
| class="cast-member" | ||
| data-speaks-as={person.speaksAs} | ||
| data-voice={person.voice ?? 'none'} | ||
| > | ||
| <PersonFace src={person.src} /> | ||
| <span class="flex flex-col leading-tight"> | ||
| <span class="cast-name text-ink font-semibold">{person.name}</span> | ||
| <span class="text-muted text-xs font-semibold"> | ||
| {person.guest ? 'Guest' : 'Host'} | ||
| </span> | ||
| </span> | ||
| </li> | ||
| ))} | ||
| </ul> | ||
| ) | ||
| } | ||
| <Sponsors sponsors={sponsors} /> | ||
| <p class="stage-desc">{episode.description}</p> | ||
| <StageControls client:load episode={playable} part="actions" /> | ||
| { | ||
| variant === 'feature' && ( | ||
| <a class="link-on" href={`/${episode.episodeSlug}`}> | ||
| Show notes and transcript | ||
| <ArrowOutIcon size={16} /> | ||
| </a> | ||
| ) | ||
| } | ||
| </div> | ||
| </div> | ||
|
|
||
| { | ||
| split && ( | ||
| <div | ||
| aria-controls={scriptId} | ||
| aria-label="Resize the picture and the transcript" | ||
| aria-orientation="vertical" | ||
| aria-valuemax="100" | ||
| aria-valuemin="0" | ||
| class="ep-split PropFLIP" | ||
| role="separator" | ||
| tabindex="0" | ||
| {...{ 'data-⚓️-name': '--ep-split' }} | ||
| /> | ||
| ) | ||
| } | ||
|
|
||
| <div class="stage-script" id={scriptId}> | ||
| { | ||
| split && ( | ||
| <div | ||
| aria-label="Stage layout" | ||
| class="ep-presets" | ||
| role="group" | ||
| {...{ 'data-⚓️-root': '', 'data-⚓️-scope-name': '--ep-on' }} | ||
| > | ||
| <i | ||
| aria-hidden="true" | ||
| class="ep-presets-on" | ||
| {...{ 'data-⚓️-to': '--ep-on', 'data-⚓️-fill': '' }} | ||
| /> | ||
| {presets.map(([key, label]) => ( | ||
| <button aria-pressed="false" data-preset={key} type="button"> | ||
| {label} | ||
| </button> | ||
| ))} | ||
| </div> | ||
| ) | ||
| } | ||
| <LiveScript client:only="preact" episode={playable} /> | ||
| </div> | ||
|
|
||
| </section> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| --- | ||
| /** | ||
| * A person's portrait: a circle in their voice's ring with the hairline over | ||
| * the photo. See styles/people.css for the markup contract other components | ||
| * (Preact islands included) can copy. | ||
| */ | ||
| export interface Props { | ||
| src: string; | ||
| /** Rendered size in px (the ring and gap included); leave it out to size | ||
| * it from CSS (`--person-size`, 64px by default). */ | ||
| size?: number; | ||
| /** Transcript voice 0 or 1 wears that voice's ring colour. */ | ||
| voice?: number; | ||
| loading?: 'eager' | 'lazy'; | ||
| } | ||
|
|
||
| const { loading = 'lazy', size, src, voice } = Astro.props; | ||
| --- | ||
|
|
||
| <span | ||
| class="person-face" | ||
| data-voice={voice} | ||
| style={size ? `--person-size: ${size}px` : undefined} | ||
| ><img | ||
| alt="" | ||
| decoding="async" | ||
| height={size ?? 64} | ||
| loading={loading} | ||
| src={src} | ||
| width={size ?? 64} | ||
| /></span | ||
| > |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use one playback controller for the episode route.
Mounting
StageControlsstarts the new media engine, but the current layout still mountsPlayer. Both consume the same playback state and load their own media element. For a video episode, the new engine loads the video, butplaceMedia()returns because the layout has no[data-player-media]element. The video never reaches the stage, and the legacy player still loads the MP3. Keep the legacy controls until the layout can hand off playback to the new engine, or make that handoff in this slice. (raw.githubusercontent.com)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No change. The shell slice (#82) removes the legacy
Playerand moves playback to the new engine. The slices merge into an integration branch that only reachesmaincomplete.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Analysis chain
Script executed:
Length of output: 93459
@RobbieTheWagnerThanks for the clarification.#82removes the legacyPlayerand adds[data-player-media], so I won’t request that handoff in this slice.I haven’t verified playback on the completed integration branch, so I’m not marking this finding as addressed. Please run the video playback tests on that branch before merging to
main.You are interacting with an AI system.