Hero Video Dialog
svelte-animations/hero-video-dialogFreeBlock
A video dialog component with animated entrance effects, thumbnail support, and customizable animation styles.
Install it
npx shadcn@latest add https://sv-animations.vercel.app/r/hero-video-dialog.jsonSource
1<script lang="ts">2 import { motion, AnimatePresence } from "motion-sv";3 import { cn } from "$UTILS$";45 type AnimationStyle =6 | "from-bottom"7 | "from-center"8 | "from-top"9 | "from-left"10 | "from-right"11 | "fade"12 | "top-in-bottom-out"13 | "left-in-right-out";1415 interface HeroVideoDialogProps {16 animationStyle?: AnimationStyle;17 videoSrc: string;18 thumbnailSrc: string;19 thumbnailAlt?: string;20 class?: string;21 }2223 let {24 animationStyle = "from-center",25 videoSrc,26 thumbnailSrc,27 thumbnailAlt = "Video thumbnail",28 class: className,29 }: HeroVideoDialogProps = $props();3031 let isVideoOpen = $state(false);3233 const animationVariants = {34 "from-bottom": {35 initial: { y: "100%", opacity: 0 },36 animate: { y: 0, opacity: 1 },37 exit: { y: "100%", opacity: 0 },38 },39 "from-center": {40 initial: { scale: 0.5, opacity: 0 },41 animate: { scale: 1, opacity: 1 },42 exit: { scale: 0.5, opacity: 0 },43 },44 "from-top": {45 initial: { y: "-100%", opacity: 0 },46 animate: { y: 0, opacity: 1 },47 exit: { y: "-100%", opacity: 0 },48 },49 "from-left": {50 initial: { x: "-100%", opacity: 0 },51 animate: { x: 0, opacity: 1 },52 exit: { x: "-100%", opacity: 0 },53 },54 "from-right": {55 initial: { x: "100%", opacity: 0 },56 animate: { x: 0, opacity: 1 },57 exit: { x: "100%", opacity: 0 },58 },59 fade: {60 initial: { opacity: 0 },61 animate: { opacity: 1 },62 exit: { opacity: 0 },63 },64 "top-in-bottom-out": {65 initial: { y: "-100%", opacity: 0 },66 animate: { y: 0, opacity: 1 },67 exit: { y: "100%", opacity: 0 },68 },69 "left-in-right-out": {70 initial: { x: "-100%", opacity: 0 },71 animate: { x: 0, opacity: 1 },72 exit: { x: "100%", opacity: 0 },73 },74 };7576 const selectedAnimation = $derived(animationVariants[animationStyle]);7778 const handleKeyDown = (e: KeyboardEvent) => {79 if (e.key === "Escape" || e.key === "Enter" || e.key === " ") {80 isVideoOpen = false;81 }82 };83</script>8485<div class={cn("relative", className)}>86 <button87 type="button"88 aria-label="Play video"89 class="group relative cursor-pointer border-0 bg-transparent p-0"90 onclick={() => (isVideoOpen = true)}91 >92 <img93 src={thumbnailSrc}94 alt={thumbnailAlt}95 width={1920}96 height={1080}97 class="w-full rounded-md border shadow-lg transition-all duration-200 ease-out group-hover:brightness-[0.8]"98 />99 <div100 class="absolute inset-0 flex scale-[0.9] items-center justify-center rounded-2xl transition-all duration-200 ease-out group-hover:scale-100"101 >102// … truncated
What it pulls in
npm packages
Files it writes
More from Svelte Animations
All 66 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Animated Beamanimated-beam | Svelte Animations | Blocks | Free | 1 dep · 6 files | |
| Animated Circular Progress Baranimated-circular-progress-bar | Svelte Animations | Blocks | Free | no deps · 2 files | |
| Animated Gradient Textanimated-gradient-text | Svelte Animations | Blocks | Free | no deps · 2 files | |
| Animated Grid Patternanimated-grid-pattern | Svelte Animations | Blocks | Free | 1 dep · 2 files | |
| Animated Listanimated-list | Svelte Animations | Blocks | Free | 1 dep · 2 files | |
| Animated Shiny Textanimated-shiny-text | Svelte Animations | Blocks | Free | no deps | |
| Animated Theme Toggleranimated-theme-toggler | Svelte Animations | Blocks | Free | no deps · 2 files | |
| Arc Timelinearc-timeline | Svelte Animations | Blocks | Free | no deps · 3 files |
