FordTang's picture
Keep a gradient behind the hero video and poster
539ad1c verified
Raw History Blame
2.02 kB
import { useRef } from "react"
import { useLoop } from "@/hooks/motion"
import { MarkLockup } from "@/components/lockup"
/** Footage from minimax.io, one subject per modality: the M3.1 flower, the H3 jellyfish, the
* H3-Image coral, the Speech manta for music. Each fades to white at its foot. */
const media = (kind: "hero" | "tile", cat: string) => {
const c = ["language", "video", "image", "music"].includes(cat) ? cat : "language"
return { src: `media/${kind}-${c}.mp4`, poster: `media/${kind}-${c}.jpg` }
}
/** The moving background at the top of a page, as on minimax.io: full width, taller than the
* first screen, fading into the white page. Purely decorative. */
export function HeroVideo({ cat }: { cat: string }) {
const ref = useRef<HTMLVideoElement>(null)
useLoop(ref)
const m = media("hero", cat)
return (
<div aria-hidden className="brand-backdrop pointer-events-none absolute inset-x-0 top-0 -z-10 h-[clamp(820px,104vw,1500px)] overflow-hidden">
<video ref={ref} key={cat} src={m.src} poster={m.poster} muted loop playsInline preload="auto"
className="size-full object-cover object-top" />
{/* the footage ends a shade off white; this closes the seam */}
<div className="absolute inset-x-0 bottom-0 h-[22%] bg-gradient-to-b from-white/0 to-white" />
</div>
)
}
/** A model card's picture, as on minimax.io: its modality's footage with the model mark on it. */
export function Tile({ name, cat }: { name: string; cat: string }) {
const ref = useRef<HTMLVideoElement>(null)
useLoop(ref)
const m = media("tile", cat)
return (
<div className="relative isolate aspect-[5/4] overflow-hidden rounded-[14px]">
<video ref={ref} src={m.src} poster={m.poster} muted loop playsInline preload="metadata" aria-hidden
className="absolute inset-0 -z-10 size-full scale-[1.02] object-cover" />
<div className="grid size-full place-items-center px-3 text-white">
<MarkLockup name={name} />
</div>
</div>
)
}