Skip to content

Packs / web-development-public

hero-section

Full-viewport hero with a looping background video (manual loop with 0.5 s fade so the seam never shows), poster fallback, scrim for contrast, glass nav, display headline and CTA pair. Pauses off-screen, honours reduced motion and Save-Data, has a pause control.

Install

logicpacks pack use web-development-public/hero-section
get_pack web-development-public/hero-section

The second line is the MCP tool call for the LogicPacks connector (Claude Code, Codex, Claude.ai and others). The first run of a pack someone else wrote asks for your yes.

Keys it needs (names only)

None.

Playbooks included

  • Spec: spec/SPEC.md (goal, steps, edge cases, don’ts)
  • Routes: static-local
  • Checks: 2 in outcome/checks.yaml
  • Code: _shots/shot-1280-rm.png_shots/shot-1280.png_shots/shot-390-rm.png_shots/shot-390.pnghero.jsindex.htmlmedia/hero-loop.mp4media/hero-loop.webmmedia/hero-poster.jpgstyle.css
  • Tools: python3, playwright-python, chromium, ffmpeg (optional, to encode your own loop)

Usage, last 8 weeks

New: no recorded use yet.

Purpose (from spec/SPEC.md)

Goal

The first screen of a landing page: one clear promise, one primary action, and motion that adds mood without hurting load time, readability or accessibility. Passes on a 390 px phone and on desktop, with and without reduced motion.

Steps

  1. Copy code/ (index.html hero block, style.css, hero.js, media/).
  2. Replace the demo loop: encode your clip to both WebM (VP9) and MP4 (H.264), 6-12 s, no audio, <= 2-4 MB, 1280-1920 px wide: ffmpeg -i in.mp4 -an -vf scale=1600:-2 -c:v libvpx-vp9 -b:v 0 -crf 38 hero-loop.webm and ffmpeg -i in.mp4 -an -vf scale=1600:-2 -c:v libx264 -crf 26 -preset slow -movflags +faststart hero-loop.mp4. Export a poster from the first frame (-frames:v 1 hero-poster.jpg) and preload it.
  3. List WebM first, MP4 second (Chromium without proprietary codecs needs WebM; Safari takes MP4).
  4. Keep the manual loop in hero.js: no loop attribute; on ended hide, wait 100 ms, rewind, play; the rAF tick keeps opacity 0 for the first and last 0.5 s so the cut is invisible.
  5. Keep the scrim gradient; check headline contrast against the brightest frame.
  6. Headline 6-10 words, max-width: 14ch, fluid clamp() size; sub line <= 25 words; CTA pair = primary + ghost.
  7. Run the outcome checks; then check LCP (poster or headline should be the LCP element).

Edge cases

  • Autoplay blocked (iOS Low Power, data saver): the poster stays; nothing breaks.
  • prefers-reduced-motion: reduce or Save-Data: never start the video; entrance animation off.
  • Off-screen or background tab: pause (IntersectionObserver + visibilitychange) to save battery.
  • 100svh for mobile browser chrome; avoid 100vh jumps.
  • Long localized headlines: overflow-wrap: break-word and the headline-fits-viewport check.

Don'ts

  • Never hotlink NovaMotion or other host media in production; download and re-encode into the project.
  • No autoplay with sound; no crossorigin games; no video without a pause control when it plays > 5 s.
  • Do not put text inside the video; real text stays HTML for SEO and accessibility.
  • Do not lazy-load the poster or the hero headline font.