UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.
✨ feat: Add hero video and fix components
Dillion Verma0a6abdba4f6d
diff --git a/components/landing/testimonials.tsx b/components/landing/testimonials.tsxindex bb182d1c..accb2e46 100644--- a/components/landing/testimonials.tsx+++ b/components/landing/testimonials.tsx@@ -23,6 +23,7 @@ const tweetUrls = ["https://twitter.com/sxndrao/status/1668634137547399168","https://twitter.com/jordienr/status/1681389309037772820","https://twitter.com/beneverman/status/1681477151042797568",+ "",].map((t) => t.split("/").slice(-1)[0]);async function getTweets() {diff --git a/content/components/hero-video.mdx b/content/components/hero-video.mdxnew file mode 100644index 00000000..ad82c4e8--- /dev/null+++ b/content/components/hero-video.mdx@@ -0,0 +1,47 @@+---+title: Hero Video+date: 2023-08-16+summary: A react component that renders a video in a modal with a play button.+author: dillionverma+published: true+video: https://cdn.magicuikit.com/hero-video.mp4+---++<ComponentPreview name="hero-video-demo" />++<Steps>++<Step>++## Installation++Copy and paste the following code into your project.++```typescript+// lib/utils.ts+import clsx, { ClassValue } from "clsx";+import { twMerge } from "tailwind-merge";++export function cn(...inputs: ClassValue[]) {+ return twMerge(clsx(inputs));+}+```++```text+components/magicui/hero-video.tsx+```++<ComponentSource name="hero-video" />++</Step>++</Steps>++## Examples++## Props++### Hero Video++| Prop | Type | Description | Default |+| ---- | ---- | ----------- | ------- |diff --git a/package.json b/package.jsonindex 40491c53..d79cc261 100644--- a/package.json+++ b/package.json@@ -17,6 +17,7 @@},"dependencies": {"@auth/prisma-adapter": "^1.0.0",+ "@headlessui/react": "^1.7.17","@hookform/resolvers": "^3.1.1","@next-auth/prisma-adapter": "^1.0.7","@prisma/client": "^4.16.1",diff --git a/registry/components/example/hero-video-demo.tsx b/registry/components/example/hero-video-demo.tsxnew file mode 100644index 00000000..2a9e8f9c--- /dev/null+++ b/registry/components/example/hero-video-demo.tsx@@ -0,0 +1,21 @@+import HeroVideo from "@/registry/components/magicui/hero-video";+import {+ MagicCard,+ MagicContainer,+} from "@/registry/components/magicui/magic-card";++export default function HeroVideoDemo() {+ return (+ <div className="relative flex h-[600px] w-full flex-col items-center justify-center gap-4 overflow-hidden rounded-lg border bg-background p-10">+ <span className="pointer-events-none whitespace-pre-wrap bg-gradient-to-b from-black to-gray-300/80 bg-clip-text text-center text-8xl font-semibold leading-none text-transparent dark:from-white dark:to-slate-900/10">+ Hero Video+ </span>+ <div className="pointer-events-none absolute inset-0 h-full bg-[radial-gradient(circle_at_50%_120%,rgba(120,119,198,0.3),rgba(255,255,255,0))]" />+ <MagicContainer>+ <MagicCard className="[mask:linear-gradient(0deg,transparent_0%,#fff_100%)]">+ <HeroVideo image="https://media.discordapp.net/attachments/993733319386730541/1144082029076557947/newpreviewimage.png?width=2226&height=1228" />+ </MagicCard>+ </MagicContainer>+ </div>+ );+}diff --git a/registry/components/magicui/hero-video.tsx b/registry/components/magicui/hero-video.tsxnew file mode 100644index 00000000..534043fb--- /dev/null+++ b/registry/components/magicui/hero-video.tsx@@ -0,0 +1,110 @@+import { cn } from "@/lib/utils";+import ShimmerButton from "@/registry/components/magicui/shimmer-button";+import { Dialog, Transition } from "@headlessui/react";+import { X } from "lucide-react";+import { Fragment, useState } from "react";++interface HeroVideoProps {+ children?: React.ReactNode;+ image?: string;+ className?: string;+}++const HeroVideo = ({ children, image, className }: HeroVideoProps) => {+ let [isOpen, setIsOpen] = useState(false);++ function closeModal() {+ setIsOpen(false);+ }++ function openModal() {+ setIsOpen(true);+ }++ return (+ <div+ className={cn(+ "absolute inset-[1px] flex overflow-hidden rounded-2xl",+ className,+ )}+ >+ <img+ className="pointer-events-none h-full w-full object-cover"+ src={image}+ />+ <div className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 transform">+ <ShimmerButton onClick={openModal}>+ <svg+ xmlns="http://www.w3.org/2000/svg"+ viewBox="0 0 24 24"+ fill="currentColor"+ className="h-6 w-6 dark:text-white"+ >+ <path+ fillRule="evenodd"+ d="M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z"+ clipRule="evenodd"+ />+ </svg>++ {/* <span className="dark:text-white">play</span> */}+ </ShimmerButton>+ </div>+ <Transition appear show={isOpen} as={Fragment}>+ <Dialog as="div" className="relative z-50" onClose={closeModal}>+ {/* Backdrop */}+ <Transition.Child+ as={Fragment}+ enter="ease-out duration-500"+ enterFrom="opacity-0"+ enterTo="opacity-100"+ leave="ease-in duration-200"+ leaveFrom="opacity-100"+ leaveTo="opacity-0"+ >+ <div className="fixed inset-0 bg-black bg-opacity-50 backdrop-blur-sm" />+ </Transition.Child>++ {/* Video Modal */}+ <div className="fixed inset-0 overflow-y-auto">+ <div className="flex min-h-full items-center justify-center p-4 text-center">+ <Transition.Child+ as={Fragment}+ enter="ease-out duration-500"+ enterFrom="opacity-0 scale-95"+ enterTo="opacity-100 scale-100"+ leave="ease-in duration-200"+ leaveFrom="opacity-100 scale-100"+ leaveTo="opacity-0 scale-95"+ >+ <Dialog.Panel className="flex w-full max-w-4xl transform flex-col gap-2 overflow-hidden rounded-2xl p-6 text-left align-middle shadow-xl transition-all">+ <div className="flex flex-row items-center justify-between">+ <Dialog.Title+ as="h3"+ className="text-lg font-medium leading-6 text-gray-100"+ >+ Magic UI Demo+ </Dialog.Title>++ <button onClick={closeModal}>+ <X className="h-6 w-6" />+ </button>+ </div>+ <video+ autoPlay+ className="rounded-xl border"+ poster={image}+ playsInline+ src="https://cdn.magicuikit.com/globe.mp4"+ />+ </Dialog.Panel>+ </Transition.Child>+ </div>+ </div>+ </Dialog>+ </Transition>+ </div>+ );+};++export default HeroVideo;diff --git a/registry/components/magicui/magic-card.tsx b/registry/components/magicui/magic-card.tsxindex dcb3b00a..0ab8a9c1 100644--- a/registry/components/magicui/magic-card.tsx+++ b/registry/components/magicui/magic-card.tsx@@ -111,7 +111,7 @@ const MagicContainer = ({ children, className }: MagicContainerProps) => {};return (- <div className={className} ref={containerRef}>+ <div className={cn("h-full w-full", className)} ref={containerRef}>{children}</div>);@@ -190,6 +190,7 @@ const MagicCard = ({size = 600,spotlight = true,spotlightColor = "rgba(120,119,198,0.1)",+ borderColor = "rgba(120,119,198,0.7)",isolated = true,...props}: MagicCardProps) => {@@ -201,11 +202,18 @@ const MagicCard = ({{"--mask-size": `${size}px`,"--spotlight-color": `${spotlightColor}`,+ "--border-color": `${borderColor}`,} as CSSProperties}>{/* Border */}- <div className="pointer-events-none absolute inset-0 h-full w-full rounded-2xl bg-gray-300 bg-[radial-gradient(var(--mask-size)_circle_at_var(--mouse-x)_var(--mouse-y),#ffaa40_0,#9c40ff_50%,transparent_100%)] transition-opacity duration-500 dark:bg-gray-700 " />+ <div+ className={cn(+ "pointer-events-none absolute inset-0 h-full w-full rounded-2xl bg-gray-300 transition-opacity duration-500 dark:bg-gray-700",+ // "bg-[radial-gradient(var(--mask-size)_circle_at_var(--mouse-x)_var(--mouse-y),#ffaa40_0,#9c40ff_50%,transparent_100%)]",+ "bg-[radial-gradient(var(--mask-size)_circle_at_var(--mouse-x)_var(--mouse-y),var(--border-color),transparent_100%)]",+ )}+ />{/* Background */}<div className={"absolute inset-[1px] rounded-2xl bg-background"} />diff --git a/registry/components/magicui/shimmer-button.tsx b/registry/components/magicui/shimmer-button.tsxindex 61565cb8..1a371e5c 100644--- a/registry/components/magicui/shimmer-button.tsx+++ b/registry/components/magicui/shimmer-button.tsx@@ -1,7 +1,8 @@import { cn } from "@/lib/utils";-import { CSSProperties } from "react";+import React, { CSSProperties } from "react";-interface ShimmerButtonProps {+interface ShimmerButtonProps+ extends React.ButtonHTMLAttributes<HTMLButtonElement> {shimmerColor?: string;shimmerSize?: string;borderRadius?: string;@@ -12,53 +13,59 @@ interface ShimmerButtonProps {[key: string]: any; // ...props}-const ShimmerButton = ({- shimmerColor = "#ffffff",- shimmerSize = "0.1em",- shimmerDuration = "1.5s",- borderRadius = "100px",- background = "radial-gradient(ellipse 80% 50% at 50% 120%,rgba(62, 61, 117),rgba(18, 18, 38))",- className,- children,- ...props-}: ShimmerButtonProps) => {- return (- <button- style={- {- "--spread": "90deg",- "--shimmer-color": shimmerColor,- "--radius": borderRadius,- "--speed": shimmerDuration,- "--cut": shimmerSize,- "--bg": background,- } as CSSProperties- }- className={cn(- "group relative cursor-pointer overflow-hidden whitespace-nowrap px-6 py-4 [background:var(--bg)] [border-radius:var(--radius)] ",- "transition-all duration-300 hover:scale-105 hover:shadow-[0_0_40px_8px_rgba(62,61,117,0.7)]",- className,- )}- {...props}- >- {/* spark container */}- <div className="absolute inset-0 overflow-visible [container-type:size]">- {/* spark */}- <div className="absolute inset-0 h-[100cqh] animate-slide [aspect-ratio:1] [border-radius:0] [mask:none] ">- {/* spark before */}- <div className="absolute inset-[-100%] w-auto rotate-0 animate-spin [background:conic-gradient(from_calc(270deg-(var(--spread)*0.5)),transparent_0,hsl(0_0%_100%/1)_var(--spread),transparent_var(--spread))] [translate:0_0]" />+const ShimmerButton = React.forwardRef<HTMLButtonElement, ShimmerButtonProps>(+ (+ {+ shimmerColor = "#ffffff",+ shimmerSize = "0.1em",+ shimmerDuration = "1.5s",+ borderRadius = "100px",+ background = "radial-gradient(ellipse 80% 50% at 50% 120%,rgba(62, 61, 117),rgba(18, 18, 38))",+ className,+ children,+ ...props+ },+ ref,+ ) => {+ return (+ <button+ style={+ {+ "--spread": "90deg",+ "--shimmer-color": shimmerColor,+ "--radius": borderRadius,+ "--speed": shimmerDuration,+ "--cut": shimmerSize,+ "--bg": background,+ } as CSSProperties+ }+ className={cn(+ "group relative cursor-pointer overflow-hidden whitespace-nowrap px-6 py-4 [background:var(--bg)] [border-radius:var(--radius)] ",+ "transition-all duration-300 ease-in-out hover:scale-105 hover:shadow-[0_0_20px_10px_rgba(62,61,117,0.5)]",+ className,+ )}+ ref={ref}+ {...props}+ >+ {/* spark container */}+ <div className="absolute inset-0 overflow-visible [container-type:size]">+ {/* spark */}+ <div className="absolute inset-0 h-[100cqh] animate-slide [aspect-ratio:1] [border-radius:0] [mask:none] ">+ {/* spark before */}+ <div className="absolute inset-[-100%] w-auto rotate-0 animate-spin [background:conic-gradient(from_calc(270deg-(var(--spread)*0.5)),transparent_0,hsl(0_0%_100%/1)_var(--spread),transparent_var(--spread))] [translate:0_0]" />+ </div></div>- </div>- {/* backdrop */}- <div className="absolute [background:var(--bg)] [border-radius:var(--radius)] [inset:var(--cut)]" />- {/* content */}+ {/* backdrop */}+ <div className="absolute [background:var(--bg)] [border-radius:var(--radius)] [inset:var(--cut)]" />+ {/* content */}- <div className="pointer-events-none relative z-10 flex text-white dark:text-black">- {children}- </div>- </button>- );-};+ <div className="pointer-events-none relative z-10 flex text-white dark:text-black">+ {children}+ </div>+ </button>+ );+ },+);export default ShimmerButton;diff --git a/registry/components/magicui/tweet-card.tsx b/registry/components/magicui/tweet-card.tsxindex 134fee69..6e329e9b 100644--- a/registry/components/magicui/tweet-card.tsx+++ b/registry/components/magicui/tweet-card.tsx@@ -2,7 +2,6 @@import { Skeleton } from "@/components/ui/skeleton";import { cn } from "@/lib/utils";-import { Twitter } from "lucide-react";import {enrichTweet,useTweet,@@ -12,6 +11,42 @@ import {} from "react-tweet";import type { Tweet } from "react-tweet/api";+interface TwitterIconProps {+ className?: string;+ [key: string]: any;+}+const Twitter = ({ className, ...props }: TwitterIconProps) => (+ <svg+ stroke="currentColor"+ fill="currentColor"+ stroke-width="0"+ viewBox="0 0 24 24"+ height="1em"+ width="1em"+ xmlns="http://www.w3.org/2000/svg"+ className={className}+ {...props}+ >+ <g>+ <path fill="none" d="M0 0h24v24H0z"></path>+ <path d="M22.162 5.656a8.384 8.384 0 0 1-2.402.658A4.196 4.196 0 0 0 21.6 4c-.82.488-1.719.83-2.656 1.015a4.182 4.182 0 0 0-7.126 3.814 11.874 11.874 0 0 1-8.62-4.37 4.168 4.168 0 0 0-.566 2.103c0 1.45.738 2.731 1.86 3.481a4.168 4.168 0 0 1-1.894-.523v.052a4.185 4.185 0 0 0 3.355 4.101 4.21 4.21 0 0 1-1.89.072A4.185 4.185 0 0 0 7.97 16.65a8.394 8.394 0 0 1-6.191 1.732 11.83 11.83 0 0 0 6.41 1.88c7.693 0 11.9-6.373 11.9-11.9 0-.18-.005-.362-.013-.54a8.496 8.496 0 0 0 2.087-2.165z"></path>+ </g>+ </svg>+);++const Verified = ({ className, ...props }: TwitterIconProps) => (+ <svg+ aria-label="Verified Account"+ viewBox="0 0 24 24"+ className={className}+ {...props}+ >+ <g fill="currentColor">+ <path d="M22.5 12.5c0-1.58-.875-2.95-2.148-3.6.154-.435.238-.905.238-1.4 0-2.21-1.71-3.998-3.818-3.998-.47 0-.92.084-1.336.25C14.818 2.415 13.51 1.5 12 1.5s-2.816.917-3.437 2.25c-.415-.165-.866-.25-1.336-.25-2.11 0-3.818 1.79-3.818 4 0 .494.083.964.237 1.4-1.272.65-2.147 2.018-2.147 3.6 0 1.495.782 2.798 1.942 3.486-.02.17-.032.34-.032.514 0 2.21 1.708 4 3.818 4 .47 0 .92-.086 1.335-.25.62 1.334 1.926 2.25 3.437 2.25 1.512 0 2.818-.916 3.437-2.25.415.163.865.248 1.336.248 2.11 0 3.818-1.79 3.818-4 0-.174-.012-.344-.033-.513 1.158-.687 1.943-1.99 1.943-3.484zm-6.616-3.334l-4.334 6.5c-.145.217-.382.334-.625.334-.143 0-.288-.04-.416-.126l-.115-.094-2.415-2.415c-.293-.293-.293-.768 0-1.06s.768-.294 1.06 0l1.77 1.767 3.825-5.74c.23-.345.696-.436 1.04-.207.346.23.44.696.21 1.04z" />+ </g>+ </svg>+);+export const truncate = (str: string | null, length: number) => {if (!str || str.length <= length) return str;return `${str.slice(0, length - 3)}...`;@@ -53,17 +88,10 @@ export const TweetHeader = ({ tweet }: { tweet: EnrichedTweet }) => (className="flex items-center whitespace-nowrap font-semibold">{truncate(tweet.user.name, 20)}- {tweet.user.verified || tweet.user.is_blue_verified ? (- <svg- aria-label="Verified Account"- className="ml-1 inline h-4 w-4 text-blue-500"- viewBox="0 0 24 24"- >- <g fill="currentColor">- <path d="M22.5 12.5c0-1.58-.875-2.95-2.148-3.6.154-.435.238-.905.238-1.4 0-2.21-1.71-3.998-3.818-3.998-.47 0-.92.084-1.336.25C14.818 2.415 13.51 1.5 12 1.5s-2.816.917-3.437 2.25c-.415-.165-.866-.25-1.336-.25-2.11 0-3.818 1.79-3.818 4 0 .494.083.964.237 1.4-1.272.65-2.147 2.018-2.147 3.6 0 1.495.782 2.798 1.942 3.486-.02.17-.032.34-.032.514 0 2.21 1.708 4 3.818 4 .47 0 .92-.086 1.335-.25.62 1.334 1.926 2.25 3.437 2.25 1.512 0 2.818-.916 3.437-2.25.415.163.865.248 1.336.248 2.11 0 3.818-1.79 3.818-4 0-.174-.012-.344-.033-.513 1.158-.687 1.943-1.99 1.943-3.484zm-6.616-3.334l-4.334 6.5c-.145.217-.382.334-.625.334-.143 0-.288-.04-.416-.126l-.115-.094-2.415-2.415c-.293-.293-.293-.768 0-1.06s.768-.294 1.06 0l1.77 1.767 3.825-5.74c.23-.345.696-.436 1.04-.207.346.23.44.696.21 1.04z" />- </g>- </svg>- ) : null}+ {tweet.user.verified ||+ (tweet.user.is_blue_verified && (+ <Verified className="ml-1 inline h-4 w-4 text-blue-500" />+ ))}</a><div className="flex items-center space-x-1"><a@@ -139,6 +167,29 @@ export const MyTweet = ({><TweetHeader tweet={tweet} /><TweetBody tweet={tweet} />+ <div className="flex flex-1 items-center justify-center">+ {tweet.video && (+ <video+ poster={tweet.video.poster}+ src={tweet.video.variants[0].src}+ autoPlay+ loop+ muted+ className="rounded-xl border shadow-sm"+ />+ )}+ {tweet.photos && (+ <div className="flex flex-row gap-2">+ {tweet.photos.map((photo) => (+ <img+ key={photo.url}+ src={photo.url}+ className="rounded-xl border shadow-sm"+ />+ ))}+ </div>+ )}+ </div></div>);};diff --git a/registry/index.tsx b/registry/index.tsxindex 95d1739b..8fb8472a 100644--- a/registry/index.tsx+++ b/registry/index.tsx@@ -32,7 +32,6 @@ const ui: Registry = {type: "components:ui",files: ["registry/components/magicui/dot-pattern.tsx"],},-marquee: {name: "marquee",type: "components:ui",@@ -43,16 +42,21 @@ const ui: Registry = {type: "components:ui",files: ["registry/components/magicui/globe.tsx"],},- "tweet-card": {- name: "tweet-card",- type: "components:ui",- files: ["registry/components/magicui/tweet-card.tsx"],- },"shimmer-button": {name: "shimmer-button",type: "components:ui",files: ["registry/components/magicui/shimmer-button.tsx"],},+ "hero-video": {+ name: "hero-video",+ type: "components:ui",+ files: ["registry/components/magicui/hero-video.tsx"],+ },+ "tweet-card": {+ name: "tweet-card",+ type: "components:ui",+ files: ["registry/components/magicui/tweet-card.tsx"],+ },};const example: Registry = {@@ -169,6 +173,14 @@ const example: Registry = {() => import("@/registry/components/example/shimmer-button-demo"),),},+ "hero-video-demo": {+ name: "hero-video-demo",+ type: "components:example",+ files: ["registry/components/example/hero-video-demo.tsx"],+ component: React.lazy(+ () => import("@/registry/components/example/hero-video-demo"),+ ),+ },};export const registry: Registry = {diff --git a/yarn.lock b/yarn.lockindex 6c3f3956..f4210d35 100644--- a/yarn.lock+++ b/yarn.lock@@ -506,6 +506,13 @@protobufjs "^7.0.0"yargs "^17.7.2"+"@headlessui/react@^1.7.17":+ version "1.7.17"+ resolved "https://registry.yarnpkg.com/@headlessui/react/-/react-1.7.17.tgz#a0ec23af21b527c030967245fd99776aa7352bc6"+ integrity sha512-4am+tzvkqDSSgiwrsEpGWqgGo9dz8qU5M3znCkC4PgkpY4HcCZzEDEvozltGGGHIKl9jbXbZPSH5TWn4sWJdow==+ dependencies:+ client-only "^0.0.1"+"@hookform/resolvers@^3.1.1":version "3.1.1"resolved "https://registry.yarnpkg.com/@hookform/resolvers/-/resolvers-3.1.1.tgz#b374d33e356428fff9c6ef3c933441fe15e40784"@@ -2545,7 +2552,7 @@ cli-spinners@^2.5.0:resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-2.9.0.tgz#5881d0ad96381e117bbe07ad91f2008fe6ffd8db"integrity sha512-4/aL9X3Wh0yiMQlE+eeRhWP6vclO3QRtw1JHKIT0FFUs5FjpFmESqtMvYZ0+lbzBw900b95mS0hohy+qn2VK/g==[email protected], client-only@^0.0.1:version "0.0.1"resolved "https://registry.yarnpkg.com/client-only/-/client-only-0.0.1.tgz#38bba5d403c41ab150bff64a95c85013cf73bca1"integrity sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==