Video stills skip YouTube's gray placeholder; timeline back to teal dots; people rows fill
- A still that fails or comes back as YouTube's 120 x 90 "no thumbnail" image gives way to the next; with none left the player is a flat teal panel with the play button showing. - Timeline: solid teal dots, a solid teal rail and teal decade tags (still on their branch), one color throughout, until a vine or tree drawing replaces them. The leaf colors are gone. - People tiles fill each row with as many as fit (2 to 10), one fewer only when the last row would be a single tile, instead of evening rows out (8 where 6 fit had come out 4 and 4). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
6506f65b1e
commit
57f8020542
11 changed files with 98 additions and 151 deletions
|
|
@ -88,37 +88,3 @@ export function paletteFill(name: string): { background: string; color: string }
|
|||
for (const char of name.trim().toLowerCase()) hash = (hash * 31 + char.charCodeAt(0)) >>> 0
|
||||
return NAMED_FILLS[hash % NAMED_FILLS.length]
|
||||
}
|
||||
|
||||
/* ── Timeline leaves ─────────────────────────────────────────────
|
||||
Each year on a timeline is a leaf, green for this year and
|
||||
turning autumn as the years go back: gold, then orange, reaching
|
||||
full autumn at 2000; every year before 2000 is fully turned. The
|
||||
green is the palette's, deepened so a leaf stands out on the
|
||||
page; the autumn shades are the one set of colors outside the
|
||||
palette, since the palette has none. A hex, so readableOn can
|
||||
pick text for something filled with it (a decade's tag). */
|
||||
const LEAF_GREEN = '#008f2f' // #00b83d deepened toward #00521b
|
||||
const LEAF_GOLD = '#c98a0b'
|
||||
const LEAF_AUTUMN = '#b8461b'
|
||||
const LEAF_TURNED_BY = 2000
|
||||
|
||||
function mixHex(from: string, to: string, amount: number): string {
|
||||
const channel = (hex: string, i: number) => parseInt(hex.slice(i, i + 2), 16)
|
||||
return (
|
||||
'#' +
|
||||
[1, 3, 5]
|
||||
.map((i) => Math.round(channel(from, i) + (channel(to, i) - channel(from, i)) * amount))
|
||||
.map((value) => value.toString(16).padStart(2, '0'))
|
||||
.join('')
|
||||
)
|
||||
}
|
||||
|
||||
export function leafColor(year: number, thisYear = new Date().getFullYear()): string {
|
||||
if (year < LEAF_TURNED_BY) return LEAF_AUTUMN
|
||||
const span = Math.max(1, thisYear - LEAF_TURNED_BY)
|
||||
const turned = Math.min(1, Math.max(0, (thisYear - year) / span))
|
||||
// Green to gold over the first half of the span, gold to autumn over the second.
|
||||
return turned <= 0.5
|
||||
? mixHex(LEAF_GREEN, LEAF_GOLD, turned * 2)
|
||||
: mixHex(LEAF_GOLD, LEAF_AUTUMN, (turned - 0.5) * 2)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -127,15 +127,18 @@ export function playingSource(source: VideoSource): VideoSource {
|
|||
/** A still for a video link: YouTube's own thumbnail. Other hosts
|
||||
* need an API call to find theirs, so they return null and the
|
||||
* card uses its uploaded image or a plain panel. */
|
||||
export function videoThumbnail(raw?: string | null): string | null {
|
||||
if (!raw) return null
|
||||
export function videoThumbnails(raw?: string | null): string[] {
|
||||
if (!raw) return []
|
||||
try {
|
||||
const id = youtubeId(new URL(raw.trim()))
|
||||
// hq720 is a 16:9 frame; hqdefault (every video has one) is 4:3
|
||||
// with black bars baked in, so it's only the fallback (VideoPlayer
|
||||
// swaps to it if hq720 is missing, and crops it to 16:9).
|
||||
return id ? `https://i.ytimg.com/vi/${encodeURIComponent(id)}/hq720.jpg` : null
|
||||
if (!id) return []
|
||||
// hq720 is a 16:9 frame but some videos lack it; hqdefault is 4:3
|
||||
// with black bars baked in (VideoPlayer crops them). A private or
|
||||
// removed video has neither, and YouTube answers with a gray
|
||||
// placeholder instead of an error, which VideoPlayer also skips.
|
||||
const base = `https://i.ytimg.com/vi/${encodeURIComponent(id)}`
|
||||
return [`${base}/hq720.jpg`, `${base}/hqdefault.jpg`]
|
||||
} catch {
|
||||
return null
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue