mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-07-27 10:24:48 +10:00
perf(home): eliminate hero CLS from unreserved video box
The hero <section> is `flex items-center` (shrink-to-fit), so the video wrapper's width depended on the video's intrinsic size, which only resolves after the media loads. aspect-ratio couldn't reserve height without a definite width, so the video grew from ~190px to ~563px after first paint and shoved the centered hero text down ~373px (CLS ~0.095). Give the wrapper a definite width (w-full + mx-auto on the CometCard) and set an explicit aspect ratio + width/height on the video so its box is reserved before load. CLS 0.095 -> 0; hero stays visually centered at max-w-4xl.
This commit is contained in:
@@ -17,20 +17,27 @@ export function Hero() {
|
|||||||
<Spotlight />
|
<Spotlight />
|
||||||
|
|
||||||
<m.div
|
<m.div
|
||||||
className="will-change-[transform,opacity]"
|
className="w-full will-change-[transform,opacity]"
|
||||||
initial={{ opacity: 0, y: 100 }}
|
initial={{ opacity: 0, y: 100 }}
|
||||||
animate={{ opacity: 1, y: 0 }}
|
animate={{ opacity: 1, y: 0 }}
|
||||||
transition={{ duration: 1.1, ease: "easeOut" }}
|
transition={{ duration: 1.1, ease: "easeOut" }}
|
||||||
>
|
>
|
||||||
<CometCard glareOpacity={0} className="relative -mb-12 3xl:max-w-7xl max-w-4xl px-8 md:-mb-24 md:px-12 lg:px-0">
|
<CometCard
|
||||||
|
glareOpacity={0}
|
||||||
|
className="relative mx-auto -mb-12 3xl:max-w-7xl max-w-4xl px-8 md:-mb-24 md:px-12 lg:px-0"
|
||||||
|
>
|
||||||
<video
|
<video
|
||||||
loop
|
loop
|
||||||
muted
|
muted
|
||||||
autoPlay
|
autoPlay
|
||||||
playsInline
|
playsInline
|
||||||
|
width={1146}
|
||||||
|
height={720}
|
||||||
src="/videos/timelapse.mp4"
|
src="/videos/timelapse.mp4"
|
||||||
aria-label={t`Timelapse demonstration of building a resume with Reactive Resume`}
|
aria-label={t`Timelapse demonstration of building a resume with Reactive Resume`}
|
||||||
className="pointer-events-none size-full rounded-md border object-cover"
|
// Reserve the intrinsic aspect ratio so the box height is known before the video
|
||||||
|
// metadata loads — otherwise it reflows the centered hero column and causes CLS (~0.10).
|
||||||
|
className="pointer-events-none aspect-[1146/720] w-full rounded-md border object-cover"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
|||||||
Reference in New Issue
Block a user