UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.
✨ feat: Add meteors component
Dillion Verma45144d22f9ab
diff --git a/app/(marketing)/page.tsx b/app/(marketing)/page.tsxindex d141ef0f..8dd13435 100644--- a/app/(marketing)/page.tsx+++ b/app/(marketing)/page.tsx@@ -16,7 +16,7 @@ export default async function Home() {<div className="container flex max-w-[64rem] flex-col items-center gap-4 text-center"><FadeIn className="z-10 flex flex-col items-center justify-center w-full h-full"><Link- href="/components/magic-card"+ href="/components/meteors"className={cn("flex justify-center items-center flex-row","rounded-2xl px-4 py-1.5 text-sm font-medium shadow-[inset_0_-8px_10px_#8fdfff1f]",@@ -46,7 +46,7 @@ export default async function Home() {`inline`)}>- Introducing Magic Card+ Introducing Meteors</span><ChevronRight className="ml-1 h-4 w-4 text-gray-500" /></Link>diff --git a/content/components/meteors.mdx b/content/components/meteors.mdxnew file mode 100644index 00000000..9e7c8d1d--- /dev/null+++ b/content/components/meteors.mdx@@ -0,0 +1,71 @@+---+title: Meteors+date: 2023-07-13+summary: A meteor shower effect.+author: dillionverma+published: true+video: https://cdn.magicuikit.com/meteors.mp4+---++<ComponentPreview name="meteors-demo" />++<Steps>++<Step>++## Prerequisites++```bash+npm install -D tailwindcss clsx+```++```js+// tailwind.config.js+module.exports = {+ theme: {+ extend: {+ animation: {+ meteor: "meteor 5s linear infinite",+ },+ keyframes: {+ meteor: {+ "0%": { transform: "rotate(215deg) translateX(0)", opacity: 1 },+ "70%": { opacity: 1 },+ "100%": {+ transform: "rotate(215deg) translateX(-500px)",+ opacity: 0,+ },+ },+ },+ },+ },+};+```++</Step>++<Step>++## Installation++Copy and page the following code into your project.++```text+components/magicui/meteors.tsx+```++<ComponentSource name="meteors" >++</ComponentSource>++</Step>++</Steps>++## Props++### Meteors++| Prop | Type | Description | Default |+| ------ | ------ | ----------------- | ------- |+| number | number | Number of meteors | 20 |diff --git a/registry/components/example/meteors-demo.tsx b/registry/components/example/meteors-demo.tsxnew file mode 100644index 00000000..994a49ee--- /dev/null+++ b/registry/components/example/meteors-demo.tsx@@ -0,0 +1,13 @@+import Meteors from "@/registry/components/magicui/meteors";++export default function MeteorDemo() {+ return (+ <div className="border rounded-lg h-full w-full relative flex justify-center items-center bg-background overflow-hidden">+ <Meteors />+ <p className="text-5xl font-medium tracking-tighter whitespace-nowrap text-white z-10">+ Meteors+ </p>+ <div className="pointer-events-none h-full absolute inset-0 bg-[radial-gradient(circle_at_50%_120%,rgba(120,119,198,0.3),rgba(255,255,255,0))]" />+ </div>+ );+}diff --git a/registry/components/magicui/meteors.tsx b/registry/components/magicui/meteors.tsxnew file mode 100644index 00000000..30477a3d--- /dev/null+++ b/registry/components/magicui/meteors.tsx@@ -0,0 +1,50 @@+import clsx from "clsx";+import { useEffect, useState } from "react";++interface MeteorsProps {+ number?: number;+}+export const Meteors = ({ number = 20 }: MeteorsProps) => {+ const [meteorStyles, setMeteorStyles] = useState<Array<React.CSSProperties>>(+ []+ );++ useEffect(() => {+ const styles = [...new Array(number)].map(() => ({+ top: -5,+ left: Math.floor(Math.random() * 800 - 400) + "px",+ animationDelay: Math.random() * 0.6 + 0.2 + "s",+ animationDuration: Math.floor(Math.random() * 8 + 2) + "s",+ }));+ setMeteorStyles(styles);+ }, [number]);++ return (+ <>+ {[...meteorStyles].map((style, idx) => (+ // Meteor Head+ <span+ key={idx}+ className={clsx(+ "absolute top-1/2 left-1/2 h-0.5 w-0.5 rotate-[215deg] animate-meteor rounded-[9999px] bg-slate-500 shadow-[0_0_0_1px_#ffffff10]"+ )}+ style={style}+ >+ {/* Meteor Tail */}+ <div+ style={{+ position: "absolute",+ top: "50%",+ transform: "translateY(-50%)",+ width: "50px",+ height: "1px",+ background: "linear-gradient(90deg, #64748b, transparent)",+ }}+ />+ </span>+ ))}+ </>+ );+};++export default Meteors;diff --git a/registry/index.tsx b/registry/index.tsxindex fb4fbe3b..f143c356 100644--- a/registry/index.tsx+++ b/registry/index.tsx@@ -17,6 +17,11 @@ const ui: Registry = {type: "components:ui",files: ["registry/components/magicui/radial-gradient.tsx"],},+ meteors: {+ name: "meteors",+ type: "components:ui",+ files: ["registry/components/magicui/meteors.tsx"],+ },};const example: Registry = {@@ -44,6 +49,14 @@ const example: Registry = {() => import("@/registry/components/example/radial-gradient-demo")),},+ "meteors-demo": {+ name: "meteors-demo",+ type: "components:example",+ files: ["registry/components/example/meteors-demo.tsx"],+ component: React.lazy(+ () => import("@/registry/components/example/meteors-demo")+ ),+ },};export const registry: Registry = {diff --git a/tailwind.config.js b/tailwind.config.jsindex 22f21ed2..247ecde0 100644--- a/tailwind.config.js+++ b/tailwind.config.js@@ -62,6 +62,7 @@ module.exports = {"accordion-down": "accordion-down 0.2s ease-out","accordion-up": "accordion-up 0.2s ease-out",gradient: "gradient 8s linear infinite",+ meteor: "meteor 5s linear infinite",},keyframes: {"accordion-down": {@@ -77,6 +78,14 @@ module.exports = {backgroundPosition: "var(--bg-size) 0",},},+ meteor: {+ "0%": { transform: "rotate(215deg) translateX(0)", opacity: 1 },+ "70%": { opacity: 1 },+ "100%": {+ transform: "rotate(215deg) translateX(-500px)",+ opacity: 0,+ },+ },},},},