Skip to content

Commit

Permalink
fix: update docs + rename
Browse files Browse the repository at this point in the history
  • Loading branch information
dillionverma committed Dec 24, 2024
1 parent 792726a commit ba7dc82
Show file tree
Hide file tree
Showing 11 changed files with 416 additions and 780 deletions.
1,042 changes: 340 additions & 702 deletions __registry__/index.tsx

Large diffs are not rendered by default.

30 changes: 16 additions & 14 deletions config/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,7 @@ export const docsConfig: DocsConfig = {
items: [],
label: "New",
},
{
title: "Scratch To Reveal",
href: `/docs/components/scratch-to-reveal`,
items: [],
label: "New",
},

],
},
{
Expand Down Expand Up @@ -291,6 +286,12 @@ export const docsConfig: DocsConfig = {
items: [],
label: "",
},
{
title: "Scratch To Reveal",
href: `/docs/components/scratch-to-reveal`,
items: [],
label: "New",
},
{
title: "Scroll Progress",
href: `/docs/components/scroll-progress`,
Expand All @@ -308,12 +309,7 @@ export const docsConfig: DocsConfig = {
items: [],
label: "",
},
{
title: "Warp Animation Container",
href: `/docs/components/warp-animation-container`,
items: [],
label: "New",
},

],
},
{
Expand Down Expand Up @@ -434,7 +430,7 @@ export const docsConfig: DocsConfig = {
title: "Rainbow Button",
href: `/docs/components/rainbow-button`,
items: [],
label: "New",
label: "",
},
{
title: "Shimmer Button",
Expand All @@ -451,7 +447,7 @@ export const docsConfig: DocsConfig = {
title: "Interactive Hover Button",
href: `/docs/components/interactive-hover-button`,
items: [],
label: "New",
label: "",
},
{
title: "Animated Subscribe Button",
Expand All @@ -476,6 +472,12 @@ export const docsConfig: DocsConfig = {
{
title: "Backgrounds",
items: [
{
title: "Warp Animation Container",
href: `/docs/components/warp-animation-container`,
items: [],
label: "New",
},
{
title: "Flickering Grid",
href: `/docs/components/flickering-grid`,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
title: Warp Animation Container
title: Warp Background
date: 2024-12-24
description: A container component that applies a warp animation effect to its children
author: magicui
published: true
---

<ComponentPreview name="warp-animation-container-demo" />
<ComponentPreview name="warp-background-demo" />

## Installation

Expand All @@ -19,7 +19,7 @@ published: true
<TabsContent value="cli">

```bash
npx shadcn@latest add "https://magicui.design/r/warp-animation-container"
npx shadcn@latest add "https://magicui.design/r/warp-background"
```

</TabsContent>
Expand All @@ -30,7 +30,7 @@ npx shadcn@latest add "https://magicui.design/r/warp-animation-container"

<Step>Copy and paste the following code into your project.</Step>

<ComponentSource name="warp-animation-container" />
<ComponentSource name="warp-background" />

<Step>Update the import paths to match your project setup.</Step>

Expand Down
4 changes: 2 additions & 2 deletions public/r/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
]
},
{
"name": "warp-animation-container",
"name": "warp-background",
"type": "registry:ui",
"dependencies": [
"framer-motion"
],
"files": [
{
"path": "magicui/warp-animation-container.tsx",
"path": "magicui/warp-background.tsx",
"type": "registry:ui"
}
]
Expand Down
15 changes: 0 additions & 15 deletions public/r/styles/default/warp-animation-container.json

This file was deleted.

15 changes: 15 additions & 0 deletions public/r/styles/default/warp-background.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "warp-background",
"type": "registry:ui",
"dependencies": [
"framer-motion"
],
"files": [
{
"path": "magicui/warp-background.tsx",
"content": "import { cn } from \"@/lib/utils\";\nimport { motion } from \"framer-motion\";\nimport React, { HTMLAttributes, useCallback, useMemo } from \"react\";\n\ninterface WarpBackgroundProps extends HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n perspective?: number;\n beamsPerSide?: number;\n beamSize?: number;\n beamDelayMax?: number;\n beamDelayMin?: number;\n beamDuration?: number;\n gridColor?: string;\n}\n\nconst Beam = ({\n width,\n x,\n delay,\n duration,\n}: {\n width: string | number;\n x: string | number;\n delay: number;\n duration: number;\n}) => {\n const hue = Math.floor(Math.random() * 360);\n const ar = Math.floor(Math.random() * 10) + 1;\n\n return (\n <motion.div\n style={\n {\n \"--x\": `${x}`,\n \"--width\": `${width}`,\n \"--aspect-ratio\": `${ar}`,\n \"--background\": `linear-gradient(hsl(${hue} 80% 60%), transparent)`,\n } as React.CSSProperties\n }\n className={`absolute left-[var(--x)] top-0 [aspect-ratio:1/var(--aspect-ratio)] [background:var(--background)] [width:var(--width)]`}\n initial={{ y: \"100cqmax\", x: \"-50%\" }}\n animate={{ y: \"-100%\", x: \"-50%\" }}\n transition={{\n duration,\n delay,\n repeat: Infinity,\n ease: \"linear\",\n }}\n />\n );\n};\n\nexport const WarpBackground: React.FC<WarpBackgroundProps> = ({\n children,\n perspective = 100,\n className,\n beamsPerSide = 3,\n beamSize = 5,\n beamDelayMax = 3,\n beamDelayMin = 0,\n beamDuration = 3,\n gridColor = \"hsl(var(--border))\",\n ...props\n}) => {\n const generateBeams = useCallback(() => {\n const beams = [];\n const cellsPerSide = Math.floor(100 / beamSize);\n const step = cellsPerSide / beamsPerSide;\n\n for (let i = 0; i < beamsPerSide; i++) {\n const x = Math.floor(i * step);\n const delay =\n Math.random() * (beamDelayMax - beamDelayMin) + beamDelayMin;\n beams.push({ x, delay });\n }\n return beams;\n }, [beamsPerSide, beamSize, beamDelayMax, beamDelayMin]);\n\n const topBeams = useMemo(() => generateBeams(), [generateBeams]);\n const rightBeams = useMemo(() => generateBeams(), [generateBeams]);\n const bottomBeams = useMemo(() => generateBeams(), [generateBeams]);\n const leftBeams = useMemo(() => generateBeams(), [generateBeams]);\n\n return (\n <div className={cn(\"relative rounded border p-20\", className)} {...props}>\n <div\n style={\n {\n \"--perspective\": `${perspective}px`,\n \"--grid-color\": gridColor,\n \"--beam-size\": `${beamSize}%`,\n } as React.CSSProperties\n }\n className={\n \"pointer-events-none absolute left-0 top-0 size-full overflow-hidden [clip-path:inset(0)] [container-type:size] [perspective:var(--perspective)] [transform-style:preserve-3d]\"\n }\n >\n {/* top side */}\n <div className=\"absolute [transform-style:preserve-3d] [background-size:var(--beam-size)_var(--beam-size)] [background:linear-gradient(var(--grid-color)_0_1px,_transparent_1px_var(--beam-size))_50%_-0.5px_/var(--beam-size)_var(--beam-size),linear-gradient(90deg,_var(--grid-color)_0_1px,_transparent_1px_var(--beam-size))_50%_50%_/var(--beam-size)_var(--beam-size)] [container-type:inline-size] [height:100cqmax] [transform-origin:50%_0%] [transform:rotateX(-90deg)] [width:100cqi]\">\n {topBeams.map((beam, index) => (\n <Beam\n key={`top-${index}`}\n width={`${beamSize}%`}\n x={`${beam.x * beamSize}%`}\n delay={beam.delay}\n duration={beamDuration}\n />\n ))}\n </div>\n {/* bottom side */}\n <div className=\"absolute top-full [transform-style:preserve-3d] [background-size:var(--beam-size)_var(--beam-size)] [background:linear-gradient(var(--grid-color)_0_1px,_transparent_1px_var(--beam-size))_50%_-0.5px_/var(--beam-size)_var(--beam-size),linear-gradient(90deg,_var(--grid-color)_0_1px,_transparent_1px_var(--beam-size))_50%_50%_/var(--beam-size)_var(--beam-size)] [container-type:inline-size] [height:100cqmax] [transform-origin:50%_0%] [transform:rotateX(-90deg)] [width:100cqi]\">\n {bottomBeams.map((beam, index) => (\n <Beam\n key={`bottom-${index}`}\n width={`${beamSize}%`}\n x={`${beam.x * beamSize}%`}\n delay={beam.delay}\n duration={beamDuration}\n />\n ))}\n </div>\n {/* left side */}\n <div className=\"absolute left-0 top-0 [transform-style:preserve-3d] [background-size:var(--beam-size)_var(--beam-size)] [background:linear-gradient(var(--grid-color)_0_1px,_transparent_1px_var(--beam-size))_50%_-0.5px_/var(--beam-size)_var(--beam-size),linear-gradient(90deg,_var(--grid-color)_0_1px,_transparent_1px_var(--beam-size))_50%_50%_/var(--beam-size)_var(--beam-size)] [container-type:inline-size] [height:100cqmax] [transform-origin:0%_0%] [transform:rotate(90deg)_rotateX(-90deg)] [width:100cqh]\">\n {leftBeams.map((beam, index) => (\n <Beam\n key={`left-${index}`}\n width={`${beamSize}%`}\n x={`${beam.x * beamSize}%`}\n delay={beam.delay}\n duration={beamDuration}\n />\n ))}\n </div>\n {/* right side */}\n <div className=\"absolute right-0 top-0 [transform-style:preserve-3d] [background-size:var(--beam-size)_var(--beam-size)] [background:linear-gradient(var(--grid-color)_0_1px,_transparent_1px_var(--beam-size))_50%_-0.5px_/var(--beam-size)_var(--beam-size),linear-gradient(90deg,_var(--grid-color)_0_1px,_transparent_1px_var(--beam-size))_50%_50%_/var(--beam-size)_var(--beam-size)] [container-type:inline-size] [height:100cqmax] [width:100cqh] [transform-origin:100%_0%] [transform:rotate(-90deg)_rotateX(-90deg)]\">\n {rightBeams.map((beam, index) => (\n <Beam\n key={`right-${index}`}\n width={`${beamSize}%`}\n x={`${beam.x * beamSize}%`}\n delay={beam.delay}\n duration={beamDuration}\n />\n ))}\n </div>\n </div>\n <div className=\"relative\">{children}</div>\n </div>\n );\n};\n",
"type": "registry:ui",
"target": ""
}
]
}
26 changes: 0 additions & 26 deletions registry/default/example/warp-animation-container-demo.tsx

This file was deleted.

24 changes: 24 additions & 0 deletions registry/default/example/warp-background-demo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { WarpBackground } from "@/components/magicui/warp-background";
import {
Card,
CardContent,
CardDescription,
CardTitle,
} from "@/components/ui/card";

export default function ExampleComponentDemo() {
return (
<WarpBackground>
<Card className="w-80">
<CardContent className="flex flex-col gap-2 p-4">
<CardTitle>Congratulations on Your Promotion!</CardTitle>
<CardDescription>
Your hard work and dedication have paid off. We&apos;re thrilled to
see you take this next step in your career. Keep up the fantastic
work!
</CardDescription>
</CardContent>
</Card>
</WarpBackground>
);
}
Loading

0 comments on commit ba7dc82

Please sign in to comment.