Skip to content

UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.

fix: lint

Dillion Verma46a5b44f9364
diff --git a/app/(docs)/docs/[[...slug]]/page.tsx b/app/(docs)/docs/[[...slug]]/page.tsx
index 78ecf4a8..4d339375 100644
--- a/app/(docs)/docs/[[...slug]]/page.tsx
+++ b/app/(docs)/docs/[[...slug]]/page.tsx
@@ -1,18 +1,20 @@
+import { siteConfig } from "@/config/site";
+import { getTableOfContents } from "@/lib/toc";
+import { absoluteUrl, cn } from "@/lib/utils";
+import { badgeVariants } from "@/components/ui/badge";
+import { ScrollArea } from "@/components/ui/scroll-area";
import { Mdx } from "@/components/mdx-components";
import { DocPager } from "@/components/pager";
import SidebarCTA from "@/components/sidebar-cta";
import { DashboardTableOfContents } from "@/components/toc";
-import { badgeVariants } from "@/components/ui/badge";
-import { ScrollArea } from "@/components/ui/scroll-area";
-import { siteConfig } from "@/config/site";
-import { getTableOfContents } from "@/lib/toc";
-import { absoluteUrl, cn } from "@/lib/utils";
+
import "@/styles/mdx.css";
-import { ChevronRightIcon, ExternalLinkIcon } from "@radix-ui/react-icons";
-import { allDocs } from "contentlayer/generated";
+
import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
+import { ChevronRightIcon, ExternalLinkIcon } from "@radix-ui/react-icons";
+import { allDocs } from "contentlayer/generated";
interface DocPageProps {
params: {
@@ -92,10 +94,8 @@ export default async function DocPage({ params }: DocPageProps) {
>
<div className="mx-auto w-full min-w-0">
<div className="mb-4 flex items-center space-x-1 text-sm text-muted-foreground">
- <div className="overflow-hidden text-ellipsis whitespace-nowrap">
- Docs
- </div>
- <ChevronRightIcon className="h-4 w-4" />
+ <div className="truncate">Docs</div>
+ <ChevronRightIcon className="size-4" />
<div className="font-medium text-foreground">{doc.title}</div>
</div>
<div className="space-y-2">
@@ -118,7 +118,7 @@ export default async function DocPage({ params }: DocPageProps) {
className={cn(badgeVariants({ variant: "secondary" }), "gap-1")}
>
Docs
- <ExternalLinkIcon className="h-3 w-3" />
+ <ExternalLinkIcon className="size-3" />
</Link>
)}
{doc.links?.api && (
@@ -129,7 +129,7 @@ export default async function DocPage({ params }: DocPageProps) {
className={cn(badgeVariants({ variant: "secondary" }), "gap-1")}
>
API Reference
- <ExternalLinkIcon className="h-3 w-3" />
+ <ExternalLinkIcon className="size-3" />
</Link>
)}
</div>
diff --git a/app/(docs)/docs/layout.tsx b/app/(docs)/docs/layout.tsx
index cd9bd240..6dfe7215 100644
--- a/app/(docs)/docs/layout.tsx
+++ b/app/(docs)/docs/layout.tsx
@@ -1,6 +1,6 @@
-import { DocsSidebarNav } from "@/components/sidebar-nav";
-import { ScrollArea } from "@/components/ui/scroll-area";
import { docsConfig } from "@/config/docs";
+import { ScrollArea } from "@/components/ui/scroll-area";
+import { DocsSidebarNav } from "@/components/sidebar-nav";
interface DocsLayoutProps {
children: React.ReactNode;
diff --git a/app/(docs)/docs/not-found.tsx b/app/(docs)/docs/not-found.tsx
index 61a66312..b0ad4c83 100644
--- a/app/(docs)/docs/not-found.tsx
+++ b/app/(docs)/docs/not-found.tsx
@@ -1,10 +1,11 @@
"use client";
-import { Icons } from "@/components/icons";
-import { Button, buttonVariants } from "@/components/ui/button";
import Link from "next/link";
import { useRouter } from "next/navigation";
+import { Button, buttonVariants } from "@/components/ui/button";
+import { Icons } from "@/components/icons";
+
export default function NotFound() {
const router = useRouter();
return (
@@ -12,7 +13,7 @@ export default function NotFound() {
<div className="container mx-auto flex min-h-[calc(100vh-8rem)] items-center px-6 py-12">
<div className="mx-auto flex max-w-sm flex-col items-center text-center">
<p className="rounded-full bg-blue-50 p-3 text-sm font-medium dark:bg-gray-800">
- <Icons.warning className="h-6 w-6" />
+ <Icons.warning className="size-6" />
</p>
<h1 className="mt-3 text-2xl font-semibold text-gray-800 dark:text-white md:text-3xl">
Page not found
@@ -26,7 +27,7 @@ export default function NotFound() {
onClick={() => router.back()}
className={buttonVariants({ variant: "secondary" })}
>
- <Icons.chevronLeft className="h-4 w-4 transition-transform group-hover:-translate-x-1" />
+ <Icons.chevronLeft className="size-4 transition-transform group-hover:-translate-x-1" />
<span>Go back</span>
</Button>
diff --git a/app/(marketing)/[...slug]/page.tsx b/app/(marketing)/[...slug]/page.tsx
index 03f929d6..7254c0f7 100644
--- a/app/(marketing)/[...slug]/page.tsx
+++ b/app/(marketing)/[...slug]/page.tsx
@@ -1,11 +1,14 @@
-import { Mdx } from "@/components/mdx-components";
-import { siteConfig } from "@/config/site";
import { env } from "@/env.mjs";
+
+import { siteConfig } from "@/config/site";
import { absoluteUrl } from "@/lib/utils";
+import { Mdx } from "@/components/mdx-components";
+
import "@/styles/mdx.css";
-import { allPages } from "contentlayer/generated";
+
import { Metadata } from "next";
import { notFound } from "next/navigation";
+import { allPages } from "contentlayer/generated";
interface PageProps {
params: {
diff --git a/app/api/og/route.tsx b/app/api/og/route.tsx
index 493d40b7..3bd7adea 100644
--- a/app/api/og/route.tsx
+++ b/app/api/og/route.tsx
@@ -1,6 +1,7 @@
-import { capitalize } from "@/lib/utils";
import { ImageResponse } from "next/og";
+import { capitalize } from "@/lib/utils";
+
export const runtime = "edge";
const inter600 = fetch(
diff --git a/app/layout.tsx b/app/layout.tsx
index 3df0ba52..a086d219 100644
--- a/app/layout.tsx
+++ b/app/layout.tsx
@@ -1,12 +1,14 @@
+import { fontSans } from "@/lib/fonts";
+import { absoluteUrl, cn, constructMetadata } from "@/lib/utils";
+import { Toaster } from "@/components/ui/sonner";
+import { TooltipProvider } from "@/components/ui/tooltip";
import { Analytics } from "@/components/analytics";
import { PHProvider } from "@/components/posthog-provider";
import { ThemeProvider } from "@/components/theme-provider";
-import { Toaster } from "@/components/ui/sonner";
-import { TooltipProvider } from "@/components/ui/tooltip";
-import { fontSans } from "@/lib/fonts";
-import { absoluteUrl, cn, constructMetadata } from "@/lib/utils";
+
import "@/styles/globals.css";
import "@/styles/mdx.css";
+
import type { Viewport } from "next";
import { Metadata } from "next";
diff --git a/app/not-found.tsx b/app/not-found.tsx
index 61a66312..b0ad4c83 100644
--- a/app/not-found.tsx
+++ b/app/not-found.tsx
@@ -1,10 +1,11 @@
"use client";
-import { Icons } from "@/components/icons";
-import { Button, buttonVariants } from "@/components/ui/button";
import Link from "next/link";
import { useRouter } from "next/navigation";
+import { Button, buttonVariants } from "@/components/ui/button";
+import { Icons } from "@/components/icons";
+
export default function NotFound() {
const router = useRouter();
return (
@@ -12,7 +13,7 @@ export default function NotFound() {
<div className="container mx-auto flex min-h-[calc(100vh-8rem)] items-center px-6 py-12">
<div className="mx-auto flex max-w-sm flex-col items-center text-center">
<p className="rounded-full bg-blue-50 p-3 text-sm font-medium dark:bg-gray-800">
- <Icons.warning className="h-6 w-6" />
+ <Icons.warning className="size-6" />
</p>
<h1 className="mt-3 text-2xl font-semibold text-gray-800 dark:text-white md:text-3xl">
Page not found
@@ -26,7 +27,7 @@ export default function NotFound() {
onClick={() => router.back()}
className={buttonVariants({ variant: "secondary" })}
>
- <Icons.chevronLeft className="h-4 w-4 transition-transform group-hover:-translate-x-1" />
+ <Icons.chevronLeft className="size-4 transition-transform group-hover:-translate-x-1" />
<span>Go back</span>
</Button>
diff --git a/app/sitemap.ts b/app/sitemap.ts
index 8c0bfdbd..817a037a 100644
--- a/app/sitemap.ts
+++ b/app/sitemap.ts
@@ -1,6 +1,6 @@
-import { allDocs, allPages } from "@/.contentlayer/generated";
import { MetadataRoute } from "next";
import { headers } from "next/headers";
+import { allDocs, allPages } from "@/.contentlayer/generated";
export default function sitemap(): MetadataRoute.Sitemap {
const headersList = headers();
diff --git a/components/blur-image.tsx b/components/blur-image.tsx
index 0bcde801..d6271a9e 100644
--- a/components/blur-image.tsx
+++ b/components/blur-image.tsx
@@ -1,7 +1,7 @@
"use client";
-import Image, { ImageProps } from "next/image";
import { useEffect, useState } from "react";
+import Image, { ImageProps } from "next/image";
export default function BlurImage(props: ImageProps) {
const [loading, setLoading] = useState(true);
diff --git a/components/code-block-wrapper.tsx b/components/code-block-wrapper.tsx
index bc3145b9..54437c90 100644
--- a/components/code-block-wrapper.tsx
+++ b/components/code-block-wrapper.tsx
@@ -1,13 +1,14 @@
"use client";
+import * as React from "react";
+
+import { cn } from "@/lib/utils";
import { Button } from "@/components/ui/button";
import {
Collapsible,
CollapsibleContent,
CollapsibleTrigger,
} from "@/components/ui/collapsible";
-import { cn } from "@/lib/utils";
-import * as React from "react";
interface CodeBlockProps extends React.HTMLAttributes<HTMLDivElement> {
expandButtonTitle?: string;
diff --git a/components/command-menu.tsx b/components/command-menu.tsx
index 238693c9..bcf88647 100644
--- a/components/command-menu.tsx
+++ b/components/command-menu.tsx
@@ -1,5 +1,13 @@
"use client";
+import * as React from "react";
+import { useRouter } from "next/navigation";
+import { DialogProps } from "@radix-ui/react-alert-dialog";
+import { Circle, File, Laptop, Moon, SunMedium } from "lucide-react";
+import { useTheme } from "next-themes";
+
+import { docsConfig } from "@/config/docs";
+import { cn } from "@/lib/utils";
import { Button } from "@/components/ui/button";
import {
CommandDialog,
@@ -10,13 +18,6 @@ import {
CommandList,
CommandSeparator,
} from "@/components/ui/command";
-import { docsConfig } from "@/config/docs";
-import { cn } from "@/lib/utils";
-import { DialogProps } from "@radix-ui/react-alert-dialog";
-import { Circle, File, Laptop, Moon, SunMedium } from "lucide-react";
-import { useTheme } from "next-themes";
-import { useRouter } from "next/navigation";
-import * as React from "react";
export function CommandMenu({ ...props }: DialogProps) {
const router = useRouter();
@@ -71,7 +72,7 @@ export function CommandMenu({ ...props }: DialogProps) {
runCommand(() => router.push(navItem.href as string));
}}
>
- <File className="mr-2 h-4 w-4" />
+ <File className="mr-2 size-4" />
{navItem.title}
</CommandItem>
))}
@@ -86,8 +87,8 @@ export function CommandMenu({ ...props }: DialogProps) {
runCommand(() => router.push(navItem.href as string));
}}
>
- <div className="mr-2 flex h-4 w-4 items-center justify-center">
- <Circle className="h-3 w-3" />
+ <div className="mr-2 flex size-4 items-center justify-center">
+ <Circle className="size-3" />
</div>
{navItem.title}
</CommandItem>
@@ -97,15 +98,15 @@ export function CommandMenu({ ...props }: DialogProps) {
<CommandSeparator />
<CommandGroup heading="Theme">
<CommandItem onSelect={() => runCommand(() => setTheme("light"))}>
- <SunMedium className="mr-2 h-4 w-4" />
+ <SunMedium className="mr-2 size-4" />
Light
</CommandItem>
<CommandItem onSelect={() => runCommand(() => setTheme("dark"))}>
- <Moon className="mr-2 h-4 w-4" />
+ <Moon className="mr-2 size-4" />
Dark
</CommandItem>
<CommandItem onSelect={() => runCommand(() => setTheme("system"))}>
- <Laptop className="mr-2 h-4 w-4" />
+ <Laptop className="mr-2 size-4" />
System
</CommandItem>
</CommandGroup>
diff --git a/components/commit-list.tsx b/components/commit-list.tsx
index d315dacb..3016fef3 100644
--- a/components/commit-list.tsx
+++ b/components/commit-list.tsx
@@ -1,10 +1,11 @@
"use client";
-import { Badge } from "@/components/ui/badge";
-import { formatDistanceToNow } from "date-fns";
import { useEffect, useState } from "react";
+import { formatDistanceToNow } from "date-fns";
import { toast } from "sonner";
+import { Badge } from "@/components/ui/badge";
+
export default function CommitList({
repo,
owner,
diff --git a/components/component-installation.tsx b/components/component-installation.tsx
index e26a11b6..503068e1 100644
--- a/components/component-installation.tsx
+++ b/components/component-installation.tsx
@@ -23,7 +23,7 @@ export function ComponentInstallation({
role="img"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
- className="h-10 w-10"
+ className="size-10"
fill="currentColor"
>
<title>React.js</title>
@@ -38,7 +38,7 @@ export function ComponentInstallation({
>
<svg
xmlns="http://www.w3.org/2000/svg"
- className="ml-2 h-10 w-10"
+ className="ml-2 size-10"
viewBox="0 0 18 8"
>
<title>Vue.js</title>
@@ -60,7 +60,7 @@ export function ComponentInstallation({
>
<svg
xmlns="http://www.w3.org/2000/svg"
- className="h-10 w-10"
+ className="size-10"
viewBox="0 0 18 14"
>
<title>Svelte</title>
diff --git a/components/component-preview.tsx b/components/component-preview.tsx
index ab1aa7aa..3852d2d3 100644
--- a/components/component-preview.tsx
+++ b/components/component-preview.tsx
@@ -1,11 +1,14 @@
"use client";
+
+import * as React from "react";
+import { RotateCcw } from "lucide-react";
+
+import { cn } from "@/lib/utils";
+import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import ComponentWrapper from "@/components/component-wrapper";
import { Icons } from "@/components/icons";
-import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
-import { cn } from "@/lib/utils";
import { registry } from "@/registry/index";
-import { RotateCcw } from "lucide-react";
-import * as React from "react";
+
import { Button } from "./ui/button";
interface ComponentPreviewProps extends React.HTMLAttributes<HTMLDivElement> {
@@ -80,7 +83,7 @@ export function ComponentPreview({
<React.Suspense
fallback={
<div className="flex items-center text-sm text-muted-foreground">
- <Icons.spinner className="mr-2 h-4 w-4 animate-spin" />
+ <Icons.spinner className="mr-2 size-4 animate-spin" />
Loading...
</div>
}
diff --git a/components/component-source.tsx b/components/component-source.tsx
index 97e24e0b..e2a62219 100644
--- a/components/component-source.tsx
+++ b/components/component-source.tsx
@@ -1,9 +1,10 @@
"use client";
-import { CodeBlockWrapper } from "@/components/code-block-wrapper";
-import { cn } from "@/lib/utils";
import * as React from "react";
+import { cn } from "@/lib/utils";
+import { CodeBlockWrapper } from "@/components/code-block-wrapper";
+
interface ComponentSourceProps extends React.HTMLAttributes<HTMLDivElement> {
src: string;
}
diff --git a/components/component-wrapper.tsx b/components/component-wrapper.tsx
index 8933bd9f..25cb9a17 100644
--- a/components/component-wrapper.tsx
+++ b/components/component-wrapper.tsx
@@ -14,7 +14,7 @@ const ComponentWrapper = ({ className, children }: ComponentWrapperProps) => {
>
<div
className={cn(
- `absolute inset-0 h-full w-full`,
+ `absolute inset-0 size-full`,
`bg-[radial-gradient(#00000055_1px,transparent_1px)] dark:bg-[radial-gradient(#ffffff22_1px,transparent_1px)]`,
"lab-bg [background-size:16px_16px]",
)}
diff --git a/components/copy-button.tsx b/components/copy-button.tsx
index e6a4c506..8ee54038 100644
--- a/components/copy-button.tsx
+++ b/components/copy-button.tsx
@@ -1,10 +1,10 @@
"use client";
-import { DropdownMenuTriggerProps } from "@radix-ui/react-dropdown-menu";
import * as React from "react";
-// import { NpmCommands } from "types/unist";
+import { DropdownMenuTriggerProps } from "@radix-ui/react-dropdown-menu";
-import { Icons } from "@/components/icons";
+import { Event, trackEvent } from "@/lib/events";
+import { cn } from "@/lib/utils";
import { Button } from "@/components/ui/button";
import {
DropdownMenu,
@@ -12,8 +12,9 @@ import {
DropdownMenuItem,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
-import { Event, trackEvent } from "@/lib/events";
-import { cn } from "@/lib/utils";
+// import { NpmCommands } from "types/unist";
+
+import { Icons } from "@/components/icons";
interface CopyButtonProps extends React.HTMLAttributes<HTMLButtonElement> {
value: string;
@@ -48,7 +49,7 @@ export function CopyButton({
size="icon"
variant="ghost"
className={cn(
- "relative z-10 h-6 w-6 text-zinc-50 hover:bg-background/70 hover:text-zinc-50",
+ "relative z-10 size-6 text-zinc-50 hover:bg-background/70 hover:text-zinc-50",
className,
)}
onClick={() => {
@@ -70,9 +71,9 @@ export function CopyButton({
>
<span className="sr-only">Copy</span>
{hasCopied ? (
- <Icons.check className="h-3 w-3" />
+ <Icons.check className="size-3" />
) : (
- <Icons.copy className="h-3 w-3" />
+ <Icons.copy className="size-3" />
)}
</Button>
);
@@ -110,25 +111,25 @@ export function CopyWithClassNames({
size="icon"
variant="ghost"
className={cn(
- "relative z-10 h-6 w-6 text-zinc-50 hover:bg-zinc-700 hover:text-zinc-50",
+ "relative z-10 size-6 text-zinc-50 hover:bg-zinc-700 hover:text-zinc-50",
className,
)}
>
{hasCopied ? (
- <Icons.check className="h-3 w-3" />
+ <Icons.check className="size-3" />
) : (
- <Icons.copy className="h-3 w-3" />
+ <Icons.copy className="size-3" />
)}
<span className="sr-only">Copy</span>
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem onClick={() => copyToClipboard(value)}>
- <Icons.react className="mr-2 h-4 w-4" />
+ <Icons.react className="mr-2 size-4" />
<span>Component</span>
</DropdownMenuItem>
<DropdownMenuItem onClick={() => copyToClipboard(classNames)}>
- <Icons.tailwind className="mr-2 h-4 w-4" />
+ <Icons.tailwind className="mr-2 size-4" />
<span>Classname</span>
</DropdownMenuItem>
</DropdownMenuContent>
diff --git a/components/deal-banner.tsx b/components/deal-banner.tsx
index 30fefcfa..28df3e1d 100644
--- a/components/deal-banner.tsx
+++ b/components/deal-banner.tsx
@@ -1,5 +1,5 @@
-import { ExternalLink } from "lucide-react";
import Link from "next/link";
+import { ExternalLink } from "lucide-react";
export function DealBanner() {
return (
@@ -16,7 +16,7 @@ export function DealBanner() {
</span>{" "}
✨ */}
🔥🔥🔥 FIRE SALE - Get $100 off TODAY ONLY
- <ExternalLink className="h-4 w-4" />
+ <ExternalLink className="size-4" />
{/* with code{" "}
<span className="rounded-md bg-orange-400 p-1 font-bold text-black dark:text-white">
BLOCKPARTY
diff --git a/components/landing/cta-section.tsx b/components/landing/cta-section.tsx
index db99e076..74632d23 100644
--- a/components/landing/cta-section.tsx
+++ b/components/landing/cta-section.tsx
@@ -1,7 +1,8 @@
-import { buttonVariants } from "@/components/ui/button";
-import { cn } from "@/lib/utils";
import { ChevronRight, HeartHandshake } from "lucide-react";
+import { cn } from "@/lib/utils";
+import { buttonVariants } from "@/components/ui/button";
+
export default function CTASection() {
return (
<section id="cta">
diff --git a/components/landing/hero-client.tsx b/components/landing/hero-client.tsx
index fbcc994b..39fbe19e 100644
--- a/components/landing/hero-client.tsx
+++ b/components/landing/hero-client.tsx
@@ -1,10 +1,14 @@
"use client";
+import Link from "next/link";
import { Doc } from "@/.contentlayer/generated";
-import TechStack from "@/components/tech-stack";
+import { motion } from "framer-motion";
+import { ChevronRight } from "lucide-react";
+
+import { cn } from "@/lib/utils";
import { buttonVariants } from "@/components/ui/button";
import { Separator } from "@/components/ui/separator";
-import { cn } from "@/lib/utils";
+import TechStack from "@/components/tech-stack";
import AnimatedBeamMultipleInputDemo from "@/registry/components/example/animated-beam-multiple-inputs";
import AnimatedListDemo from "@/registry/components/example/animated-list-demo";
import BentoDemo from "@/registry/components/example/bento-demo";
@@ -15,9 +19,6 @@ import AnimatedGradientText from "@/registry/components/magicui/animated-gradien
import { VelocityScroll } from "@/registry/components/magicui/scroll-based-velocity";
import TypingAnimation from "@/registry/components/magicui/typing-animation";
import WordRotate from "@/registry/components/magicui/word-rotate";
-import { motion } from "framer-motion";
-import { ChevronRight } from "lucide-react";
-import Link from "next/link";
export default function HeroClient({ post }: { post: Doc }) {
return (
@@ -30,8 +31,8 @@ export default function HeroClient({ post }: { post: Doc }) {
<AnimatedGradientText>
<div
className={cn(
- `absolute inset-0 block h-full w-full animate-gradient bg-gradient-to-r from-[#ffaa40]/50 via-[#9c40ff]/50 to-[#ffaa40]/50 bg-[length:var(--bg-size)_100%] [border-radius:inherit] [mask:linear-gradient(#fff_0_0)_content-box,linear-gradient(#fff_0_0)]`,
- `p-[1px] ![mask-composite:subtract]`,
+ `absolute inset-0 block size-full animate-gradient bg-gradient-to-r from-[#ffaa40]/50 via-[#9c40ff]/50 to-[#ffaa40]/50 bg-[length:var(--bg-size)_100%] [border-radius:inherit] [mask:linear-gradient(#fff_0_0)_content-box,linear-gradient(#fff_0_0)]`,
+ `p-px ![mask-composite:subtract]`,
)}
/>
🎉 <Separator className="mx-2 h-4" orientation="vertical" />
@@ -43,7 +44,7 @@ export default function HeroClient({ post }: { post: Doc }) {
>
Introducing {post.title}
</span>
- <ChevronRight className="ml-1 h-4 w-4 text-gray-500" />
+ <ChevronRight className="ml-1 size-4 text-gray-500" />
</AnimatedGradientText>
</Link>
<div className="relative flex flex-col gap-4 md:items-center lg:flex-row">
@@ -90,7 +91,7 @@ export default function HeroClient({ post }: { post: Doc }) {
)}
>
Browse Components
- <ChevronRight className="ml-1 size-4 flex-shrink-0 transition-all duration-300 ease-out group-hover:translate-x-1" />
+ <ChevronRight className="ml-1 size-4 shrink-0 transition-all duration-300 ease-out group-hover:translate-x-1" />
</Link>
<Link
href="/docs"
@@ -104,14 +105,14 @@ export default function HeroClient({ post }: { post: Doc }) {
)}
>
Get Started
- <ChevronRight className="ml-1 size-4 flex-shrink-0 transition-all duration-300 ease-out group-hover:translate-x-1" />
+ <ChevronRight className="ml-1 size-4 shrink-0 transition-all duration-300 ease-out group-hover:translate-x-1" />
</Link>
</div>
</div>
</div>
</div>
- <div className="relative mx-auto flex w-full max-w-[16rem] items-center justify-center">
+ <div className="relative mx-auto flex w-full max-w-64 items-center justify-center">
<TechStack
className="mx-auto flex w-full items-center justify-between"
technologies={[
@@ -175,13 +176,13 @@ export default function HeroClient({ post }: { post: Doc }) {
<AnimatedBeamMultipleInputDemo />
<AnimatedListDemo />
<RetroGridDemo />
- <div className="relative flex h-full w-full max-w-[32rem] items-center justify-center overflow-hidden rounded-lg border bg-background md:shadow-xl">
+ <div className="relative flex size-full max-w-lg items-center justify-center overflow-hidden rounded-lg border bg-background md:shadow-xl">
<TypingAnimation
className="text-4xl font-bold text-black dark:text-white"
text="Typing Animation"
/>
</div>
- <div className="relative flex h-full w-full max-w-[32rem] items-center justify-center overflow-hidden rounded-lg border bg-background p-4 md:shadow-xl">
+ <div className="relative flex size-full max-w-lg items-center justify-center overflow-hidden rounded-lg border bg-background p-4 md:shadow-xl">
<WordRotate
className="text-4xl font-bold text-black dark:text-white"
words={[
@@ -200,7 +201,7 @@ export default function HeroClient({ post }: { post: Doc }) {
]}
/>
</div>
- <div className="relative flex h-full w-full max-w-[32rem] items-center justify-center overflow-hidden rounded-lg border bg-background py-4 md:shadow-xl">
+ <div className="relative flex size-full max-w-lg items-center justify-center overflow-hidden rounded-lg border bg-background py-4 md:shadow-xl">
<VelocityScroll
text="Velocity Scroll"
default_velocity={5}
diff --git a/components/landing/hero.tsx b/components/landing/hero.tsx
index b37b4006..4624e092 100644
--- a/components/landing/hero.tsx
+++ b/components/landing/hero.tsx
@@ -1,7 +1,8 @@
import { allDocs } from "@/.contentlayer/generated";
-import HeroClient from "@/components/landing/hero-client";
import { compareDesc } from "date-fns";
+import HeroClient from "@/components/landing/hero-client";
+
export default async function Hero() {
const post = allDocs
.filter(
diff --git a/components/landing/testimonials.tsx b/components/landing/testimonials.tsx
index a5d25537..8dbc0cc5 100644
--- a/components/landing/testimonials.tsx
+++ b/components/landing/testimonials.tsx
@@ -43,11 +43,7 @@ export default async function Testimonials() {
<div className="relative flex flex-col">
<Marquee className="max-w-screen [--duration:120s]" pauseOnHover>
{firstRow.map((id, idx) => (
- <TweetCard
- id={id}
- className="max-h-32 w-72 min-w-[18rem]"
- key={idx}
- />
+ <TweetCard id={id} className="max-h-32 w-72 min-w-72" key={idx} />
))}
</Marquee>
<Marquee
@@ -56,11 +52,7 @@ export default async function Testimonials() {
pauseOnHover
>
{secondRow.map((id, idx) => (
- <TweetCard
- id={id}
- className="max-h-32 w-72 min-w-[18rem]"
- key={idx}
- />
+ <TweetCard id={id} className="max-h-32 w-72 min-w-72" key={idx} />
))}
</Marquee>
<div className="pointer-events-none absolute inset-y-0 left-0 h-full w-1/3 bg-gradient-to-r from-background"></div>
diff --git a/components/main-nav.tsx b/components/main-nav.tsx
index eca6e616..6649b738 100644
--- a/components/main-nav.tsx
+++ b/components/main-nav.tsx
@@ -1,13 +1,14 @@
"use client";
-import { Icons } from "@/components/icons";
-import { Badge } from "@/components/ui/badge";
+import Link from "next/link";
+import { usePathname } from "next/navigation";
+import { ExternalLinkIcon } from "@radix-ui/react-icons";
+
import { docsConfig } from "@/config/docs";
import { siteConfig } from "@/config/site";
import { cn } from "@/lib/utils";
-import { ExternalLinkIcon } from "@radix-ui/react-icons";
-import Link from "next/link";
-import { usePathname } from "next/navigation";
+import { Badge } from "@/components/ui/badge";
+import { Icons } from "@/components/icons";
export function MainNav() {
const pathname = usePathname();
@@ -15,7 +16,7 @@ export function MainNav() {
return (
<div className="mr-4 hidden md:flex">
<Link href="/" className="relative mr-6 flex items-center space-x-2">
- <Icons.logo className="h-6 w-6" />
+ <Icons.logo className="size-6" />
<span className="hidden font-bold md:inline-block">
{siteConfig.name}
</span>
diff --git a/components/mdx-components.tsx b/components/mdx-components.tsx
index d2a235bb..e8d6abdc 100644
--- a/components/mdx-components.tsx
+++ b/components/mdx-components.tsx
@@ -1,19 +1,21 @@
-import TechStack from "@/components/tech-stack";
+import Image from "next/image";
+import Link from "next/link";
+import { useMDXComponent } from "next-contentlayer/hooks";
+
+import { Event } from "@/lib/events";
+import { cn } from "@/lib/utils";
import {
Accordion,
AccordionContent,
AccordionItem,
AccordionTrigger,
} from "@/components/ui/accordion";
-import { Event } from "@/lib/events";
-import { cn } from "@/lib/utils";
+import TechStack from "@/components/tech-stack";
import TweetCard from "@/registry/components/magicui/tweet-card";
-import { useMDXComponent } from "next-contentlayer/hooks";
-import Image from "next/image";
-import Link from "next/link";
+
+import { ComponentInstallation } from "./component-installation";
import { ComponentPreview } from "./component-preview";
import { ComponentSource } from "./component-source";
-import { ComponentInstallation } from "./component-installation";
import { CopyButton } from "./copy-button";
const CustomLink = (props: any) => {
@@ -241,4 +243,4 @@ export function Mdx({ code }: MDXProps) {
<Component components={components} />
</article>
);
-}
\ No newline at end of file
+}
diff --git a/components/mobile-nav.tsx b/components/mobile-nav.tsx
index d5cea19d..c5ee7a2a 100644
--- a/components/mobile-nav.tsx
+++ b/components/mobile-nav.tsx
@@ -1,16 +1,17 @@
"use client";
-import { Icons } from "@/components/icons";
-import { Button } from "@/components/ui/button";
-import { ScrollArea } from "@/components/ui/scroll-area";
-import { Sheet, SheetContent, SheetTrigger } from "@/components/ui/sheet";
+import * as React from "react";
+import Link, { LinkProps } from "next/link";
+import { useRouter } from "next/navigation";
+import { SidebarOpen } from "lucide-react";
+
import { docsConfig } from "@/config/docs";
import { siteConfig } from "@/config/site";
import { cn } from "@/lib/utils";
-import { SidebarOpen } from "lucide-react";
-import Link, { LinkProps } from "next/link";
-import { useRouter } from "next/navigation";
-import * as React from "react";
+import { Button } from "@/components/ui/button";
+import { ScrollArea } from "@/components/ui/scroll-area";
+import { Sheet, SheetContent, SheetTrigger } from "@/components/ui/sheet";
+import { Icons } from "@/components/icons";
export function MobileNav() {
const [open, setOpen] = React.useState(false);
@@ -22,7 +23,7 @@ export function MobileNav() {
variant="ghost"
className="mr-2 px-0 text-base hover:bg-transparent focus-visible:bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0 md:hidden"
>
- <SidebarOpen className="h-6 w-6" />
+ <SidebarOpen className="size-6" />
<span className="sr-only">Toggle Menu</span>
</Button>
</SheetTrigger>
@@ -32,7 +33,7 @@ export function MobileNav() {
className="flex items-center"
onOpenChange={setOpen}
>
- <Icons.logo className="mr-2 h-4 w-4" />
+ <Icons.logo className="mr-2 size-4" />
<span className="font-bold">{siteConfig.name}</span>
</MobileLink>
<ScrollArea className="my-4 h-[calc(100vh-8rem)] pb-10 pl-6">
diff --git a/components/mode-toggle.tsx b/components/mode-toggle.tsx
index c66f10fa..e3e49e4a 100644
--- a/components/mode-toggle.tsx
+++ b/components/mode-toggle.tsx
@@ -1,9 +1,10 @@
"use client";
-import { Button } from "@/components/ui/button";
import { MoonIcon, SunIcon } from "@radix-ui/react-icons";
import { useTheme } from "next-themes";
+import { Button } from "@/components/ui/button";
+
export function ModeToggle() {
const { theme, setTheme } = useTheme();
@@ -16,8 +17,8 @@ export function ModeToggle() {
aria-label={"Toggle theme"}
onClick={() => setTheme(theme === "dark" ? "light" : "dark")}
>
- <SunIcon className="h-[1.2rem] w-[1.2rem] text-neutral-800 dark:hidden dark:text-neutral-200" />
- <MoonIcon className="hidden h-[1.2rem] w-[1.2rem] text-neutral-800 dark:block dark:text-neutral-200" />
+ <SunIcon className="size-[1.2rem] text-neutral-800 dark:hidden dark:text-neutral-200" />
+ <MoonIcon className="hidden size-[1.2rem] text-neutral-800 dark:block dark:text-neutral-200" />
</Button>
);
}
diff --git a/components/pager.tsx b/components/pager.tsx
index 95cc29c7..6ef6468b 100644
--- a/components/pager.tsx
+++ b/components/pager.tsx
@@ -1,10 +1,11 @@
+import Link from "next/link";
import { Doc } from "@/.contentlayer/generated";
-import { buttonVariants } from "@/components/ui/button";
-import { docsConfig } from "@/config/docs";
-import { cn } from "@/lib/utils";
import { NavItem, NavItemWithChildren } from "@/types";
import { ChevronLeftIcon, ChevronRightIcon } from "@radix-ui/react-icons";
-import Link from "next/link";
+
+import { docsConfig } from "@/config/docs";
+import { cn } from "@/lib/utils";
+import { buttonVariants } from "@/components/ui/button";
interface DocsPagerProps {
doc: Doc;
@@ -24,7 +25,7 @@ export function DocPager({ doc }: DocsPagerProps) {
href={pager.prev.href}
className={buttonVariants({ variant: "outline" })}
>
- <ChevronLeftIcon className="mr-2 h-4 w-4" />
+ <ChevronLeftIcon className="mr-2 size-4" />
{pager.prev.title}
</Link>
)}
@@ -34,7 +35,7 @@ export function DocPager({ doc }: DocsPagerProps) {
className={cn(buttonVariants({ variant: "outline" }), "ml-auto")}
>
{pager.next.title}
- <ChevronRightIcon className="ml-2 h-4 w-4" />
+ <ChevronRightIcon className="ml-2 size-4" />
</Link>
)}
</div>
diff --git a/components/posthog-provider.tsx b/components/posthog-provider.tsx
index 6fe7ee57..79ef106f 100644
--- a/components/posthog-provider.tsx
+++ b/components/posthog-provider.tsx
@@ -1,9 +1,9 @@
"use client";
+import { useEffect } from "react";
import { usePathname, useSearchParams } from "next/navigation";
import posthog from "posthog-js";
import { PostHogProvider } from "posthog-js/react";
-import { useEffect } from "react";
if (typeof window !== "undefined") {
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_API_KEY!, {
diff --git a/components/sidebar-cta.tsx b/components/sidebar-cta.tsx
index 70d49e04..5999d450 100644
--- a/components/sidebar-cta.tsx
+++ b/components/sidebar-cta.tsx
@@ -2,9 +2,11 @@
import AnimatedShinyText from "@/registry/components/magicui/animated-shiny-text";
import WordPullUp from "@/registry/components/magicui/word-pull-up";
+
import "@/styles/mdx.css";
-import { ChevronRight } from "lucide-react";
+
import Link from "next/link";
+import { ChevronRight } from "lucide-react";
import posthog from "posthog-js";
export default function SidebarCTA() {
diff --git a/components/sidebar-nav.tsx b/components/sidebar-nav.tsx
index ee057c2f..efeb523f 100644
--- a/components/sidebar-nav.tsx
+++ b/components/sidebar-nav.tsx
@@ -1,8 +1,8 @@
"use client";
-import { SidebarNavItem } from "@/types";
import Link from "next/link";
import { usePathname } from "next/navigation";
+import { SidebarNavItem } from "@/types";
import { cn } from "@/lib/utils";
diff --git a/components/site-banner.tsx b/components/site-banner.tsx
index 43f71933..05dfa92c 100644
--- a/components/site-banner.tsx
+++ b/components/site-banner.tsx
@@ -1,7 +1,7 @@
"use client";
-import { ChevronRight } from "lucide-react";
import Link from "next/link";
+import { ChevronRight } from "lucide-react";
import posthog from "posthog-js";
export function SiteBanner() {
diff --git a/components/site-header.tsx b/components/site-header.tsx
index 17e93881..67232539 100644
--- a/components/site-header.tsx
+++ b/components/site-header.tsx
@@ -1,14 +1,15 @@
+import Link from "next/link";
+import { StarIcon } from "@heroicons/react/24/solid";
+
+import { siteConfig } from "@/config/site";
+import { cn } from "@/lib/utils";
+import { buttonVariants } from "@/components/ui/button";
import { CommandMenu } from "@/components/command-menu";
import { Icons } from "@/components/icons";
import { MainNav } from "@/components/main-nav";
import { MobileNav } from "@/components/mobile-nav";
import { ModeToggle } from "@/components/mode-toggle";
-import { buttonVariants } from "@/components/ui/button";
-import { siteConfig } from "@/config/site";
-import { cn } from "@/lib/utils";
import NumberTicker from "@/registry/components/magicui/number-ticker";
-import { StarIcon } from "@heroicons/react/24/solid";
-import Link from "next/link";
export async function SiteHeader() {
let stars = 300; // Default value
@@ -56,13 +57,13 @@ export async function SiteHeader() {
target="_blank"
href={siteConfig.links.github}
>
- <span className="absolute right-0 -mt-12 h-32 w-8 translate-x-12 rotate-12 transform bg-white opacity-10 transition-all duration-1000 ease-out group-hover:-translate-x-40" />
+ <span className="absolute right-0 -mt-12 h-32 w-8 translate-x-12 rotate-12 bg-white opacity-10 transition-all duration-1000 ease-out group-hover:-translate-x-40" />
<div className="flex items-center">
- <Icons.gitHub className="h-4 w-4" />
+ <Icons.gitHub className="size-4" />
<span className="ml-1">Star on GitHub</span>{" "}
</div>
<div className="ml-2 flex items-center gap-1 text-sm md:flex">
- <StarIcon className="h-4 w-4 text-gray-500 transition-all duration-300 group-hover:text-yellow-300" />
+ <StarIcon className="size-4 text-gray-500 transition-all duration-300 group-hover:text-yellow-300" />
<NumberTicker
value={stars}
className="font-display font-medium text-white dark:text-black"
@@ -87,7 +88,7 @@ export async function SiteHeader() {
"w-9 px-0",
)}
>
- <Icons.discord className="h-4 w-4" />
+ <Icons.discord className="size-4" />
<span className="sr-only">Discord</span>
</div>
</Link>
@@ -104,7 +105,7 @@ export async function SiteHeader() {
"w-9 px-0",
)}
>
- <Icons.gitHub className="h-4 w-4" />
+ <Icons.gitHub className="size-4" />
<span className="sr-only">GitHub</span>
</div>
</Link>
@@ -121,7 +122,7 @@ export async function SiteHeader() {
"w-9 px-0",
)}
>
- <Icons.twitter className="h-4 w-4 fill-current" />
+ <Icons.twitter className="size-4 fill-current" />
<span className="sr-only">Twitter</span>
</div>
</Link>
@@ -138,7 +139,7 @@ export async function SiteHeader() {
"w-9 px-0",
)}
>
- <Icons.instagram className="h-4 w-4 fill-current" />
+ <Icons.instagram className="size-4 fill-current" />
<span className="sr-only">Instagram</span>
</div>
</Link>
diff --git a/components/tech-stack.tsx b/components/tech-stack.tsx
index 8f23d54f..815c8361 100644
--- a/components/tech-stack.tsx
+++ b/components/tech-stack.tsx
@@ -1,9 +1,9 @@
+import { cn } from "@/lib/utils";
import {
Tooltip,
TooltipContent,
TooltipTrigger,
} from "@/components/ui/tooltip";
-import { cn } from "@/lib/utils";
type TechComponentType = {
name: string;
diff --git a/components/toc.tsx b/components/toc.tsx
index d3f2ebd2..cd19f140 100644
--- a/components/toc.tsx
+++ b/components/toc.tsx
@@ -1,30 +1,31 @@
"use client";
+import { useEffect, useMemo, useState } from "react";
+
import type { TableOfContents } from "@/lib/toc";
import { useMounted } from "@/lib/use-mounted";
import { cn } from "@/lib/utils";
-import { useEffect, useMemo, useState } from "react";
interface TocProps {
toc: TableOfContents;
}
export function DashboardTableOfContents({ toc }: TocProps) {
-const refinedToc = useMemo(() => {
- if (!toc.items || toc.items.length === 0) {
- return toc;
- }
+ const refinedToc = useMemo(() => {
+ if (!toc.items || toc.items.length === 0) {
+ return toc;
+ }
- const [linksInSteps, ...rest] = toc.items;
+ const [linksInSteps, ...rest] = toc.items;
- if (linksInSteps.items && linksInSteps.items.length > 0) {
- return {
- items: [...linksInSteps.items, ...rest]
- };
- }
+ if (linksInSteps.items && linksInSteps.items.length > 0) {
+ return {
+ items: [...linksInSteps.items, ...rest],
+ };
+ }
- return toc;
-}, [toc]);
+ return toc;
+ }, [toc]);
const itemIds: string[] = useMemo(
() =>
diff --git a/components/ui/accordion.tsx b/components/ui/accordion.tsx
index ce9c962a..73987f2f 100644
--- a/components/ui/accordion.tsx
+++ b/components/ui/accordion.tsx
@@ -1,8 +1,8 @@
"use client";
+import * as React from "react";
import * as AccordionPrimitive from "@radix-ui/react-accordion";
import { ChevronDownIcon } from "@radix-ui/react-icons";
-import * as React from "react";
import { cn } from "@/lib/utils";
@@ -34,7 +34,7 @@ const AccordionTrigger = React.forwardRef<
{...props}
>
{children}
- <ChevronDownIcon className="h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200" />
+ <ChevronDownIcon className="size-4 shrink-0 text-muted-foreground transition-transform duration-200" />
</AccordionPrimitive.Trigger>
</AccordionPrimitive.Header>
));
diff --git a/components/ui/avatar.tsx b/components/ui/avatar.tsx
index 09cd14df..55fbc99e 100644
--- a/components/ui/avatar.tsx
+++ b/components/ui/avatar.tsx
@@ -12,7 +12,7 @@ const Avatar = React.forwardRef<
<AvatarPrimitive.Root
ref={ref}
className={cn(
- "relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
+ "relative flex size-10 shrink-0 overflow-hidden rounded-full",
className,
)}
{...props}
@@ -26,7 +26,7 @@ const AvatarImage = React.forwardRef<
>(({ className, ...props }, ref) => (
<AvatarPrimitive.Image
ref={ref}
- className={cn("aspect-square h-full w-full", className)}
+ className={cn("aspect-square size-full", className)}
{...props}
/>
));
@@ -39,7 +39,7 @@ const AvatarFallback = React.forwardRef<
<AvatarPrimitive.Fallback
ref={ref}
className={cn(
- "flex h-full w-full items-center justify-center rounded-full bg-muted",
+ "flex size-full items-center justify-center rounded-full bg-muted",
className,
)}
{...props}
diff --git a/components/ui/badge.tsx b/components/ui/badge.tsx
index d7ac14df..f7959805 100644
--- a/components/ui/badge.tsx
+++ b/components/ui/badge.tsx
@@ -1,5 +1,5 @@
-import { cva, type VariantProps } from "class-variance-authority";
import * as React from "react";
+import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils";
diff --git a/components/ui/button.tsx b/components/ui/button.tsx
index af2d5408..c5aa81e2 100644
--- a/components/ui/button.tsx
+++ b/components/ui/button.tsx
@@ -24,7 +24,7 @@ const buttonVariants = cva(
default: "h-9 px-4 py-2",
sm: "h-8 rounded-md px-3 text-xs",
lg: "h-10 rounded-md px-8",
- icon: "h-9 w-9",
+ icon: "size-9",
},
},
defaultVariants: {
diff --git a/components/ui/calendar.tsx b/components/ui/calendar.tsx
index 6c08e3ab..3b3d1538 100644
--- a/components/ui/calendar.tsx
+++ b/components/ui/calendar.tsx
@@ -1,13 +1,13 @@
-"use client"
+"use client";
-import * as React from "react"
-import { ChevronLeftIcon, ChevronRightIcon } from "@radix-ui/react-icons"
-import { DayPicker } from "react-day-picker"
+import * as React from "react";
+import { ChevronLeftIcon, ChevronRightIcon } from "@radix-ui/react-icons";
+import { DayPicker } from "react-day-picker";
-import { cn } from "@/lib/utils"
-import { buttonVariants } from "@/components/ui/button"
+import { cn } from "@/lib/utils";
+import { buttonVariants } from "@/components/ui/button";
-export type CalendarProps = React.ComponentProps<typeof DayPicker>
+export type CalendarProps = React.ComponentProps<typeof DayPicker>;
function Calendar({
className,
@@ -27,7 +27,7 @@ function Calendar({
nav: "space-x-1 flex items-center",
nav_button: cn(
buttonVariants({ variant: "outline" }),
- "h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"
+ "size-7 bg-transparent p-0 opacity-50 hover:opacity-100",
),
nav_button_previous: "absolute left-1",
nav_button_next: "absolute right-1",
@@ -40,11 +40,11 @@ function Calendar({
"relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent",
props.mode === "range"
? "[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md"
- : "[&:has([aria-selected])]:rounded-md"
+ : "[&:has([aria-selected])]:rounded-md",
),
day: cn(
buttonVariants({ variant: "ghost" }),
- "h-8 w-8 p-0 font-normal aria-selected:opacity-100"
+ "size-8 p-0 font-normal aria-selected:opacity-100",
),
day_range_start: "day-range-start",
day_range_end: "day-range-end",
@@ -59,13 +59,13 @@ function Calendar({
...classNames,
}}
components={{
- IconLeft: ({ ...props }) => <ChevronLeftIcon className="h-4 w-4" />,
- IconRight: ({ ...props }) => <ChevronRightIcon className="h-4 w-4" />,
+ IconLeft: ({ ...props }) => <ChevronLeftIcon className="size-4" />,
+ IconRight: ({ ...props }) => <ChevronRightIcon className="size-4" />,
}}
{...props}
/>
- )
+ );
}
-Calendar.displayName = "Calendar"
+Calendar.displayName = "Calendar";
-export { Calendar }
+export { Calendar };
diff --git a/components/ui/command.tsx b/components/ui/command.tsx
index 6f4a5eb1..b993343c 100644
--- a/components/ui/command.tsx
+++ b/components/ui/command.tsx
@@ -1,12 +1,12 @@
-"use client"
+"use client";
-import * as React from "react"
-import { DialogProps } from "@radix-ui/react-dialog"
-import { MagnifyingGlassIcon } from "@radix-ui/react-icons"
-import { Command as CommandPrimitive } from "cmdk"
+import * as React from "react";
+import { DialogProps } from "@radix-ui/react-dialog";
+import { MagnifyingGlassIcon } from "@radix-ui/react-icons";
+import { Command as CommandPrimitive } from "cmdk";
-import { cn } from "@/lib/utils"
-import { Dialog, DialogContent } from "@/components/ui/dialog"
+import { cn } from "@/lib/utils";
+import { Dialog, DialogContent } from "@/components/ui/dialog";
const Command = React.forwardRef<
React.ElementRef<typeof CommandPrimitive>,
@@ -15,13 +15,13 @@ const Command = React.forwardRef<
<CommandPrimitive
ref={ref}
className={cn(
- "flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
- className
+ "flex size-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
+ className,
)}
{...props}
/>
-))
-Command.displayName = CommandPrimitive.displayName
+));
+Command.displayName = CommandPrimitive.displayName;
interface CommandDialogProps extends DialogProps {}
@@ -29,32 +29,32 @@ const CommandDialog = ({ children, ...props }: CommandDialogProps) => {
return (
<Dialog {...props}>
<DialogContent className="overflow-hidden p-0">
- <Command className="[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
+ <Command className="[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:size-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:size-5">
{children}
</Command>
</DialogContent>
</Dialog>
- )
-}
+ );
+};
const CommandInput = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.Input>,
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>
>(({ className, ...props }, ref) => (
<div className="flex items-center border-b px-3" cmdk-input-wrapper="">
- <MagnifyingGlassIcon className="mr-2 h-4 w-4 shrink-0 opacity-50" />
+ <MagnifyingGlassIcon className="mr-2 size-4 shrink-0 opacity-50" />
<CommandPrimitive.Input
ref={ref}
className={cn(
"flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
- className
+ className,
)}
{...props}
/>
</div>
-))
+));
-CommandInput.displayName = CommandPrimitive.Input.displayName
+CommandInput.displayName = CommandPrimitive.Input.displayName;
const CommandList = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.List>,
@@ -65,9 +65,9 @@ const CommandList = React.forwardRef<
className={cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className)}
{...props}
/>
-))
+));
-CommandList.displayName = CommandPrimitive.List.displayName
+CommandList.displayName = CommandPrimitive.List.displayName;
const CommandEmpty = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.Empty>,
@@ -78,9 +78,9 @@ const CommandEmpty = React.forwardRef<
className="py-6 text-center text-sm"
{...props}
/>
-))
+));
-CommandEmpty.displayName = CommandPrimitive.Empty.displayName
+CommandEmpty.displayName = CommandPrimitive.Empty.displayName;
const CommandGroup = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.Group>,
@@ -90,13 +90,13 @@ const CommandGroup = React.forwardRef<
ref={ref}
className={cn(
"overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
- className
+ className,
)}
{...props}
/>
-))
+));
-CommandGroup.displayName = CommandPrimitive.Group.displayName
+CommandGroup.displayName = CommandPrimitive.Group.displayName;
const CommandSeparator = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.Separator>,
@@ -107,8 +107,8 @@ const CommandSeparator = React.forwardRef<
className={cn("-mx-1 h-px bg-border", className)}
{...props}
/>
-))
-CommandSeparator.displayName = CommandPrimitive.Separator.displayName
+));
+CommandSeparator.displayName = CommandPrimitive.Separator.displayName;
const CommandItem = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.Item>,
@@ -118,13 +118,13 @@ const CommandItem = React.forwardRef<
ref={ref}
className={cn(
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
- className
+ className,
)}
{...props}
/>
-))
+));
-CommandItem.displayName = CommandPrimitive.Item.displayName
+CommandItem.displayName = CommandPrimitive.Item.displayName;
const CommandShortcut = ({
className,
@@ -134,13 +134,13 @@ const CommandShortcut = ({
<span
className={cn(
"ml-auto text-xs tracking-widest text-muted-foreground",
- className
+ className,
)}
{...props}
/>
- )
-}
-CommandShortcut.displayName = "CommandShortcut"
+ );
+};
+CommandShortcut.displayName = "CommandShortcut";
export {
Command,
@@ -152,4 +152,4 @@ export {
CommandItem,
CommandShortcut,
CommandSeparator,
-}
+};
diff --git a/components/ui/dialog.tsx b/components/ui/dialog.tsx
index 044802b3..c925c242 100644
--- a/components/ui/dialog.tsx
+++ b/components/ui/dialog.tsx
@@ -1,6 +1,6 @@
+import * as React from "react";
import * as DialogPrimitive from "@radix-ui/react-dialog";
import { Cross2Icon } from "@radix-ui/react-icons";
-import * as React from "react";
import { cn } from "@/lib/utils";
@@ -41,7 +41,7 @@ const DialogContent = React.forwardRef<
>
{children}
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
- <Cross2Icon className="h-4 w-4" />
+ <Cross2Icon className="size-4" />
<span className="sr-only">Close</span>
</DialogPrimitive.Close>
</DialogPrimitive.Content>
diff --git a/components/ui/dropdown-menu.tsx b/components/ui/dropdown-menu.tsx
index 9dc361e0..bf4b9fa7 100644
--- a/components/ui/dropdown-menu.tsx
+++ b/components/ui/dropdown-menu.tsx
@@ -38,7 +38,7 @@ const DropdownMenuSubTrigger = React.forwardRef<
{...props}
>
{children}
- <ChevronRightIcon className="ml-auto h-4 w-4" />
+ <ChevronRightIcon className="ml-auto size-4" />
</DropdownMenuPrimitive.SubTrigger>
));
DropdownMenuSubTrigger.displayName =
@@ -51,7 +51,7 @@ const DropdownMenuSubContent = React.forwardRef<
<DropdownMenuPrimitive.SubContent
ref={ref}
className={cn(
- "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
+ "z-50 min-w-32 overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
className,
)}
{...props}
@@ -69,7 +69,7 @@ const DropdownMenuContent = React.forwardRef<
ref={ref}
sideOffset={sideOffset}
className={cn(
- "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md",
+ "z-50 min-w-32 overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md",
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
className,
)}
@@ -110,9 +110,9 @@ const DropdownMenuCheckboxItem = React.forwardRef<
checked={checked}
{...props}
>
- <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
+ <span className="absolute left-2 flex size-3.5 items-center justify-center">
<DropdownMenuPrimitive.ItemIndicator>
- <CheckIcon className="h-4 w-4" />
+ <CheckIcon className="size-4" />
</DropdownMenuPrimitive.ItemIndicator>
</span>
{children}
@@ -133,9 +133,9 @@ const DropdownMenuRadioItem = React.forwardRef<
)}
{...props}
>
- <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
+ <span className="absolute left-2 flex size-3.5 items-center justify-center">
<DropdownMenuPrimitive.ItemIndicator>
- <DotFilledIcon className="h-4 w-4 fill-current" />
+ <DotFilledIcon className="size-4 fill-current" />
</DropdownMenuPrimitive.ItemIndicator>
</span>
{children}
diff --git a/components/ui/hover-card.tsx b/components/ui/hover-card.tsx
index e54d91cf..9e8c62d3 100644
--- a/components/ui/hover-card.tsx
+++ b/components/ui/hover-card.tsx
@@ -1,13 +1,13 @@
-"use client"
+"use client";
-import * as React from "react"
-import * as HoverCardPrimitive from "@radix-ui/react-hover-card"
+import * as React from "react";
+import * as HoverCardPrimitive from "@radix-ui/react-hover-card";
-import { cn } from "@/lib/utils"
+import { cn } from "@/lib/utils";
-const HoverCard = HoverCardPrimitive.Root
+const HoverCard = HoverCardPrimitive.Root;
-const HoverCardTrigger = HoverCardPrimitive.Trigger
+const HoverCardTrigger = HoverCardPrimitive.Trigger;
const HoverCardContent = React.forwardRef<
React.ElementRef<typeof HoverCardPrimitive.Content>,
@@ -19,11 +19,11 @@ const HoverCardContent = React.forwardRef<
sideOffset={sideOffset}
className={cn(
"z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
- className
+ className,
)}
{...props}
/>
-))
-HoverCardContent.displayName = HoverCardPrimitive.Content.displayName
+));
+HoverCardContent.displayName = HoverCardPrimitive.Content.displayName;
-export { HoverCard, HoverCardTrigger, HoverCardContent }
+export { HoverCard, HoverCardTrigger, HoverCardContent };
diff --git a/components/ui/scroll-area.tsx b/components/ui/scroll-area.tsx
index a8ac2052..5a04c7c7 100644
--- a/components/ui/scroll-area.tsx
+++ b/components/ui/scroll-area.tsx
@@ -14,7 +14,7 @@ const ScrollArea = React.forwardRef<
className={cn("relative overflow-hidden", className)}
{...props}
>
- <ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]">
+ <ScrollAreaPrimitive.Viewport className="size-full rounded-[inherit]">
{children}
</ScrollAreaPrimitive.Viewport>
<ScrollBar />
@@ -33,9 +33,9 @@ const ScrollBar = React.forwardRef<
className={cn(
"flex touch-none select-none transition-colors",
orientation === "vertical" &&
- "h-full w-2.5 border-l border-l-transparent p-[1px]",
+ "h-full w-2.5 border-l border-l-transparent p-px",
orientation === "horizontal" &&
- "h-2.5 border-t border-t-transparent p-[1px]",
+ "h-2.5 border-t border-t-transparent p-px",
className,
)}
{...props}
diff --git a/components/ui/separator.tsx b/components/ui/separator.tsx
index 3cc446d2..1f7a2a57 100644
--- a/components/ui/separator.tsx
+++ b/components/ui/separator.tsx
@@ -1,7 +1,7 @@
"use client";
-import * as SeparatorPrimitive from "@radix-ui/react-separator";
import * as React from "react";
+import * as SeparatorPrimitive from "@radix-ui/react-separator";
import { cn } from "@/lib/utils";
@@ -19,7 +19,7 @@ const Separator = React.forwardRef<
orientation={orientation}
className={cn(
"shrink-0 bg-border",
- orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
+ orientation === "horizontal" ? "h-px w-full" : "h-full w-px",
className,
)}
{...props}
diff --git a/components/ui/sheet.tsx b/components/ui/sheet.tsx
index efd6e858..1779c6f0 100644
--- a/components/ui/sheet.tsx
+++ b/components/ui/sheet.tsx
@@ -1,19 +1,19 @@
-"use client"
+"use client";
-import * as React from "react"
-import * as SheetPrimitive from "@radix-ui/react-dialog"
-import { Cross2Icon } from "@radix-ui/react-icons"
-import { cva, type VariantProps } from "class-variance-authority"
+import * as React from "react";
+import * as SheetPrimitive from "@radix-ui/react-dialog";
+import { Cross2Icon } from "@radix-ui/react-icons";
+import { cva, type VariantProps } from "class-variance-authority";
-import { cn } from "@/lib/utils"
+import { cn } from "@/lib/utils";
-const Sheet = SheetPrimitive.Root
+const Sheet = SheetPrimitive.Root;
-const SheetTrigger = SheetPrimitive.Trigger
+const SheetTrigger = SheetPrimitive.Trigger;
-const SheetClose = SheetPrimitive.Close
+const SheetClose = SheetPrimitive.Close;
-const SheetPortal = SheetPrimitive.Portal
+const SheetPortal = SheetPrimitive.Portal;
const SheetOverlay = React.forwardRef<
React.ElementRef<typeof SheetPrimitive.Overlay>,
@@ -22,13 +22,13 @@ const SheetOverlay = React.forwardRef<
<SheetPrimitive.Overlay
className={cn(
"fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
- className
+ className,
)}
{...props}
ref={ref}
/>
-))
-SheetOverlay.displayName = SheetPrimitive.Overlay.displayName
+));
+SheetOverlay.displayName = SheetPrimitive.Overlay.displayName;
const sheetVariants = cva(
"fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",
@@ -46,8 +46,8 @@ const sheetVariants = cva(
defaultVariants: {
side: "right",
},
- }
-)
+ },
+);
interface SheetContentProps
extends React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>,
@@ -66,13 +66,13 @@ const SheetContent = React.forwardRef<
>
{children}
<SheetPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary">
- <Cross2Icon className="h-4 w-4" />
+ <Cross2Icon className="size-4" />
<span className="sr-only">Close</span>
</SheetPrimitive.Close>
</SheetPrimitive.Content>
</SheetPortal>
-))
-SheetContent.displayName = SheetPrimitive.Content.displayName
+));
+SheetContent.displayName = SheetPrimitive.Content.displayName;
const SheetHeader = ({
className,
@@ -81,12 +81,12 @@ const SheetHeader = ({
<div
className={cn(
"flex flex-col space-y-2 text-center sm:text-left",
- className
+ className,
)}
{...props}
/>
-)
-SheetHeader.displayName = "SheetHeader"
+);
+SheetHeader.displayName = "SheetHeader";
const SheetFooter = ({
className,
@@ -95,12 +95,12 @@ const SheetFooter = ({
<div
className={cn(
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
- className
+ className,
)}
{...props}
/>
-)
-SheetFooter.displayName = "SheetFooter"
+);
+SheetFooter.displayName = "SheetFooter";
const SheetTitle = React.forwardRef<
React.ElementRef<typeof SheetPrimitive.Title>,
@@ -111,8 +111,8 @@ const SheetTitle = React.forwardRef<
className={cn("text-lg font-semibold text-foreground", className)}
{...props}
/>
-))
-SheetTitle.displayName = SheetPrimitive.Title.displayName
+));
+SheetTitle.displayName = SheetPrimitive.Title.displayName;
const SheetDescription = React.forwardRef<
React.ElementRef<typeof SheetPrimitive.Description>,
@@ -123,8 +123,8 @@ const SheetDescription = React.forwardRef<
className={cn("text-sm text-muted-foreground", className)}
{...props}
/>
-))
-SheetDescription.displayName = SheetPrimitive.Description.displayName
+));
+SheetDescription.displayName = SheetPrimitive.Description.displayName;
export {
Sheet,
@@ -137,4 +137,4 @@ export {
SheetFooter,
SheetTitle,
SheetDescription,
-}
+};
diff --git a/components/ui/sonner.tsx b/components/ui/sonner.tsx
index 452f4d9f..549cf841 100644
--- a/components/ui/sonner.tsx
+++ b/components/ui/sonner.tsx
@@ -1,12 +1,12 @@
-"use client"
+"use client";
-import { useTheme } from "next-themes"
-import { Toaster as Sonner } from "sonner"
+import { useTheme } from "next-themes";
+import { Toaster as Sonner } from "sonner";
-type ToasterProps = React.ComponentProps<typeof Sonner>
+type ToasterProps = React.ComponentProps<typeof Sonner>;
const Toaster = ({ ...props }: ToasterProps) => {
- const { theme = "system" } = useTheme()
+ const { theme = "system" } = useTheme();
return (
<Sonner
@@ -25,7 +25,7 @@ const Toaster = ({ ...props }: ToasterProps) => {
}}
{...props}
/>
- )
-}
+ );
+};
-export { Toaster }
+export { Toaster };
diff --git a/components/ui/switch.tsx b/components/ui/switch.tsx
index 5f4117f0..3aacf7c4 100644
--- a/components/ui/switch.tsx
+++ b/components/ui/switch.tsx
@@ -1,9 +1,9 @@
-"use client"
+"use client";
-import * as React from "react"
-import * as SwitchPrimitives from "@radix-ui/react-switch"
+import * as React from "react";
+import * as SwitchPrimitives from "@radix-ui/react-switch";
-import { cn } from "@/lib/utils"
+import { cn } from "@/lib/utils";
const Switch = React.forwardRef<
React.ElementRef<typeof SwitchPrimitives.Root>,
@@ -12,18 +12,18 @@ const Switch = React.forwardRef<
<SwitchPrimitives.Root
className={cn(
"peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
- className
+ className,
)}
{...props}
ref={ref}
>
<SwitchPrimitives.Thumb
className={cn(
- "pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"
+ "pointer-events-none block size-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0",
)}
/>
</SwitchPrimitives.Root>
-))
-Switch.displayName = SwitchPrimitives.Root.displayName
+));
+Switch.displayName = SwitchPrimitives.Root.displayName;
-export { Switch }
+export { Switch };
diff --git a/components/ui/toast.tsx b/components/ui/toast.tsx
index c3aeb4b0..ce0878f5 100644
--- a/components/ui/toast.tsx
+++ b/components/ui/toast.tsx
@@ -81,7 +81,7 @@ const ToastClose = React.forwardRef<
toast-close=""
{...props}
>
- <Cross2Icon className="h-4 w-4" />
+ <Cross2Icon className="size-4" />
</ToastPrimitives.Close>
));
ToastClose.displayName = ToastPrimitives.Close.displayName;
diff --git a/components/ui/tooltip.tsx b/components/ui/tooltip.tsx
index 9e748210..92a97e46 100644
--- a/components/ui/tooltip.tsx
+++ b/components/ui/tooltip.tsx
@@ -1,15 +1,15 @@
-"use client"
+"use client";
-import * as React from "react"
-import * as TooltipPrimitive from "@radix-ui/react-tooltip"
+import * as React from "react";
+import * as TooltipPrimitive from "@radix-ui/react-tooltip";
-import { cn } from "@/lib/utils"
+import { cn } from "@/lib/utils";
-const TooltipProvider = TooltipPrimitive.Provider
+const TooltipProvider = TooltipPrimitive.Provider;
-const Tooltip = TooltipPrimitive.Root
+const Tooltip = TooltipPrimitive.Root;
-const TooltipTrigger = TooltipPrimitive.Trigger
+const TooltipTrigger = TooltipPrimitive.Trigger;
const TooltipContent = React.forwardRef<
React.ElementRef<typeof TooltipPrimitive.Content>,
@@ -20,11 +20,11 @@ const TooltipContent = React.forwardRef<
sideOffset={sideOffset}
className={cn(
"z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
- className
+ className,
)}
{...props}
/>
-))
-TooltipContent.displayName = TooltipPrimitive.Content.displayName
+));
+TooltipContent.displayName = TooltipPrimitive.Content.displayName;
-export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }
+export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
diff --git a/content/docs/components/animated-gradient-text.mdx b/content/docs/components/animated-gradient-text.mdx
index f4777c25..bd409a70 100644
--- a/content/docs/components/animated-gradient-text.mdx
+++ b/content/docs/components/animated-gradient-text.mdx
@@ -45,7 +45,7 @@ components/magicui/animated-gradient-text.tsx
## Props
-| Prop | Type | Description | Default |
-| ------------ | ------ | -------------------------------------------- | ------- |
-| children | | The children passed into the component | |
-| className | string | The class name to be applied to the shimmer. | |
+| Prop | Type | Description | Default |
+| --------- | ------ | -------------------------------------------- | ------- |
+| children | | The children passed into the component | |
+| className | string | The class name to be applied to the shimmer. | |
diff --git a/content/docs/components/avatar-circles.mdx b/content/docs/components/avatar-circles.mdx
index b6affe53..f50734c5 100644
--- a/content/docs/components/avatar-circles.mdx
+++ b/content/docs/components/avatar-circles.mdx
@@ -24,7 +24,7 @@ components/magicui/avatar-circles.tsx
## Props
-| Prop | Type | Description | Default |
-| ----------- | --------------- | -------------------------------------------------- | ------- |
-| className | string | The class name to be applied to the component | |
-| numPeople | number | The number appearing in the last circle | 99 |
\ No newline at end of file
+| Prop | Type | Description | Default |
+| --------- | ------ | --------------------------------------------- | ------- |
+| className | string | The class name to be applied to the component | |
+| numPeople | number | The number appearing in the last circle | 99 |
diff --git a/content/docs/components/cool-mode.mdx b/content/docs/components/cool-mode.mdx
index d99318af..9b94e0c7 100644
--- a/content/docs/components/cool-mode.mdx
+++ b/content/docs/components/cool-mode.mdx
@@ -30,14 +30,13 @@ components/magicui/cool-mode.tsx
## Props
-| Prop | Type | Description | Default |
-| ------------------------- | ------------------------- | ------------------------------------------------------------ | -------- |
-| particle | String | The particle URL for a custom particle | "circle" |
-| size | Number | Size of the particle | Varies |
-| particleCount | Number | The number of particles to generate | Varies |
-| speedHorz | Number | Horizontal speed of the particles | Varies |
-| speedUp | Number | Upward speed of the particles | Varies |
-
+| Prop | Type | Description | Default |
+| ------------- | ------ | -------------------------------------- | -------- |
+| particle | String | The particle URL for a custom particle | "circle" |
+| size | Number | Size of the particle | Varies |
+| particleCount | Number | The number of particles to generate | Varies |
+| speedHorz | Number | Horizontal speed of the particles | Varies |
+| speedUp | Number | Upward speed of the particles | Varies |
## Credits
diff --git a/content/docs/components/dock.mdx b/content/docs/components/dock.mdx
index 4bc308e1..bc9e6051 100644
--- a/content/docs/components/dock.mdx
+++ b/content/docs/components/dock.mdx
@@ -27,24 +27,24 @@ components/magicui/dock.tsx
### Dock
-| Prop | Type | Description | Default |
-|-----------------|---------|--------------------------------------|--------------------------|
-| className | string | Custom CSS class for styling | - |
-| children | ReactNode | Children elements | - |
-| magnification | number | Level of icon magnification | 60 |
-| distance | number | Distance from cursor to magnify icon | 140 |
+| Prop | Type | Description | Default |
+| ------------- | --------- | ------------------------------------ | ------- |
+| className | string | Custom CSS class for styling | - |
+| children | ReactNode | Children elements | - |
+| magnification | number | Level of icon magnification | 60 |
+| distance | number | Distance from cursor to magnify icon | 140 |
### DockIcon
-| Prop | Type | Description | Default |
-|-----------------|-----------------|--------------------------------------|--------------------------|
-| size | number | Size of the icon | - |
-| magnification | number | Level of icon magnification | 60 |
-| distance | number | Distance from cursor to magnify icon | 140 |
-| mouseX | any | Mouse X position for magnification | - |
-| className | string | Custom CSS class for styling | - |
-| children | React.ReactNode | Children elements | - |
-| props | PropsWithChildren | Additional props | - |
+| Prop | Type | Description | Default |
+| ------------- | ----------------- | ------------------------------------ | ------- |
+| size | number | Size of the icon | - |
+| magnification | number | Level of icon magnification | 60 |
+| distance | number | Distance from cursor to magnify icon | 140 |
+| mouseX | any | Mouse X position for magnification | - |
+| className | string | Custom CSS class for styling | - |
+| children | React.ReactNode | Children elements | - |
+| props | PropsWithChildren | Additional props | - |
## Credits
diff --git a/content/docs/components/gradual-spacing.mdx b/content/docs/components/gradual-spacing.mdx
index 44f6ee08..7b80ca1c 100644
--- a/content/docs/components/gradual-spacing.mdx
+++ b/content/docs/components/gradual-spacing.mdx
@@ -30,4 +30,4 @@ components/magicui/gradual-spacing.tsx
| duration | number | The class name to be applied to the shimmer. | 0.5 |
| delayMultiple | number | The class name to be applied to the shimmer. | 0.1 |
| text | string | An array of words to rotate through | "" |
-| framerProps | HTMLMotionProps | An object containing framer-motion animation props | {} |
\ No newline at end of file
+| framerProps | HTMLMotionProps | An object containing framer-motion animation props | {} |
diff --git a/content/docs/components/letter-pullup.mdx b/content/docs/components/letter-pullup.mdx
index 145b2050..1abd6c73 100644
--- a/content/docs/components/letter-pullup.mdx
+++ b/content/docs/components/letter-pullup.mdx
@@ -6,7 +6,7 @@ author: tomonarifeehan
published: true
---
-<ComponentPreview name = "letter-pullup-demo" />
+<ComponentPreview name="letter-pullup-demo" />
<Steps>
@@ -18,14 +18,14 @@ Copy and paste the following code into your project.
components/magicui/letter-pullup.tsx
```
-<ComponentSource name = "letter-pullup" />
+<ComponentSource name="letter-pullup" />
</Steps>
## Props
-| Prop | Type | Description | Default |
-| ----------- | --------------- | -------------------------------------------------- | -------------------------- |
-| className | string | The class name to be applied to the component | |
-| words | string | Text to animate | "Staggered Letter Pull Up" |
-| delay | number | Delay each letter's animation by this many seconds | 0.05 |
\ No newline at end of file
+| Prop | Type | Description | Default |
+| --------- | ------ | -------------------------------------------------- | -------------------------- |
+| className | string | The class name to be applied to the component | |
+| words | string | Text to animate | "Staggered Letter Pull Up" |
+| delay | number | Delay each letter's animation by this many seconds | 0.05 |
diff --git a/content/docs/components/orbiting-circles.mdx b/content/docs/components/orbiting-circles.mdx
index 93ba4da2..a677df80 100644
--- a/content/docs/components/orbiting-circles.mdx
+++ b/content/docs/components/orbiting-circles.mdx
@@ -25,12 +25,14 @@ module.exports = {
},
keyframes: {
orbit: {
- "0%": {
- transform: "rotate(0deg) translateY(calc(var(--radius) * 1px)) rotate(0deg)",
- },
- "100%": {
- transform: "rotate(360deg) translateY(calc(var(--radius) * 1px)) rotate(-360deg)",
- },
+ "0%": {
+ transform:
+ "rotate(0deg) translateY(calc(var(--radius) * 1px)) rotate(0deg)",
+ },
+ "100%": {
+ transform:
+ "rotate(360deg) translateY(calc(var(--radius) * 1px)) rotate(-360deg)",
+ },
},
},
},
@@ -48,11 +50,11 @@ components/magicui/orbiting-circles.tsx
## Props
-| Prop | Type | Description | Default |
-| ----------- | --------------- | -------------------------------------------- | ------- |
-| className | string | The class name for the component | "" |
-| children | React.ReactNode | The children nodes of the component | null |
-| reverse | boolean | If true, the animation plays in reverse | false |
-| duration | number | The duration of the animation in seconds | 20 |
-| delay | number | The delay before the animation starts in seconds | 10 |
-| radius | number | The radius of the orbit in pixels | 50 |
+| Prop | Type | Description | Default |
+| --------- | --------------- | ------------------------------------------------ | ------- |
+| className | string | The class name for the component | "" |
+| children | React.ReactNode | The children nodes of the component | null |
+| reverse | boolean | If true, the animation plays in reverse | false |
+| duration | number | The duration of the animation in seconds | 20 |
+| delay | number | The delay before the animation starts in seconds | 10 |
+| radius | number | The radius of the orbit in pixels | 50 |
diff --git a/content/docs/components/shine-border.mdx b/content/docs/components/shine-border.mdx
index 9848a63f..3721d2e6 100644
--- a/content/docs/components/shine-border.mdx
+++ b/content/docs/components/shine-border.mdx
@@ -53,14 +53,14 @@ components/magicui/shine-border.tsx
## Props
-| Prop | Type | Description | Default |
-| ------------ | ------------------------------ | --------------------------------------------------- | ---------- |
-| className | string | The class name to be applied to the component. | |
+| Prop | Type | Description | Default |
+| ------------ | ------------------------------ | ------------------------------------------------------------------- | ---------- |
+| className | string | The class name to be applied to the component. | |
| duration | number | Defines the animation duration to be applied on the shining border. | 14 seconds |
-| color | `#${string}` OR `#${string}`[] | A string or string array to define border color. | #FFFFFF |
-| borderRadius | number | Defines the radius of the border. | 8px |
-| borderWidth | number | Defines the width of the border. | 1px |
-| children | ReactNode | Contains react node elements. | {} |
+| color | `#${string}` OR `#${string}`[] | A string or string array to define border color. | #FFFFFF |
+| borderRadius | number | Defines the radius of the border. | 8px |
+| borderWidth | number | Defines the width of the border. | 1px |
+| children | ReactNode | Contains react node elements. | {} |
## Credits
diff --git a/content/docs/components/text-reveal.mdx b/content/docs/components/text-reveal.mdx
index 0209662b..b981fa05 100644
--- a/content/docs/components/text-reveal.mdx
+++ b/content/docs/components/text-reveal.mdx
@@ -1,5 +1,5 @@
---
-title: Text Reveal
+title: Text Reveal
date: 2024-04-08
description: Fade in text as you scroll down the page.
author: dillionverma
@@ -25,12 +25,11 @@ components/magicui/text-reveal.tsx
## Props
-| Prop | Type | Description | Default |
-| ------------ | ------ | -------------------------------------------- | ------- |
-| children | | The text to be shimmered. | |
-| className | string | The class name to be applied to the shimmer. | |
-| text | string | The text to do the animation for | "" |
-
+| Prop | Type | Description | Default |
+| --------- | ------ | -------------------------------------------- | ------- |
+| children | | The text to be shimmered. | |
+| className | string | The class name to be applied to the shimmer. | |
+| text | string | The text to do the animation for | "" |
## Credits
diff --git a/content/docs/components/tweet-card.mdx b/content/docs/components/tweet-card.mdx
index 89117312..affbdfc9 100644
--- a/content/docs/components/tweet-card.mdx
+++ b/content/docs/components/tweet-card.mdx
@@ -47,6 +47,7 @@ To render on client side:
```tsx
"use client";
+
import { ClientTweetCard } from "@/components/magicui/client-tweet-card.tsx";
export default function App() {
diff --git a/content/docs/components/typing-animation.mdx b/content/docs/components/typing-animation.mdx
index b0fb8658..c8048836 100644
--- a/content/docs/components/typing-animation.mdx
+++ b/content/docs/components/typing-animation.mdx
@@ -24,8 +24,8 @@ components/magicui/typing-animation.tsx
## Props
-| Prop | Type | Description | Default |
-| ----------- | --------------- | -------------------------------------------------- | ------- |
-| className | string | The class name to be applied to the component | |
-| duration | number | Duration to wait in between each char type. | 200 |
-| text | string | Text to animate | "" |
+| Prop | Type | Description | Default |
+| --------- | ------ | --------------------------------------------- | ------- |
+| className | string | The class name to be applied to the component | |
+| duration | number | Duration to wait in between each char type. | 200 |
+| text | string | Text to animate | "" |
diff --git a/content/docs/components/wavy-dot-pattern.mdx b/content/docs/components/wavy-dot-pattern.mdx
index 9fc536fb..5cf1a932 100644
--- a/content/docs/components/wavy-dot-pattern.mdx
+++ b/content/docs/components/wavy-dot-pattern.mdx
@@ -6,7 +6,7 @@ author: tomonarifeehan
published: true
---
-<ComponentPreview name = "wavy-dot-pattern-demo" />
+<ComponentPreview name="wavy-dot-pattern-demo" />
<Steps>
@@ -22,7 +22,7 @@ npm i react-anime
components/magicui/wavy-dot-pattern.tsx
```
-<ComponentSource name = "wavy-dot-pattern" />
+<ComponentSource name="wavy-dot-pattern" />
</Steps>
@@ -30,10 +30,10 @@ components/magicui/wavy-dot-pattern.tsx
### Dot Pattern
-| Prop | Type | Description | Default |
-| ---------- | ------ | ----------------------------- | ------- |
-| className | string | Class name of the dot grid | - |
-| gridWidth | number | Width of the dot grid | 30 |
-| gridHeight | number | Height of the dot grid | 15 |
-| dotWidth | number | Width of the dot | 8 |
-| dotWidth | number | Width of the dot | 8 |
\ No newline at end of file
+| Prop | Type | Description | Default |
+| ---------- | ------ | -------------------------- | ------- |
+| className | string | Class name of the dot grid | - |
+| gridWidth | number | Width of the dot grid | 30 |
+| gridHeight | number | Height of the dot grid | 15 |
+| dotWidth | number | Width of the dot | 8 |
+| dotWidth | number | Width of the dot | 8 |
diff --git a/content/docs/index.mdx b/content/docs/index.mdx
index ff4e803c..dcdf27d9 100644
--- a/content/docs/index.mdx
+++ b/content/docs/index.mdx
@@ -3,27 +3,26 @@ title: Introduction
description: Create magical landing pages with components that you can copy and paste into your apps.
---
-
Magic UI is a collection of re-usable components that you can copy and paste into your web apps.
It primarily features components, blocks, and templates geared towards creating landing pages and user-facing marketing materials.
-
## Philosophy
-__I personally believe that good design contributes significant value to software. It's one of the main methods of establishing trust between you and an internet stranger__. Trust is important for internet businesses because it is the first thing a visitor evaluates before pulling out their credit card and becoming a customer.
+**I personally believe that good design contributes significant value to software. It's one of the main methods of establishing trust between you and an internet stranger**. Trust is important for internet businesses because it is the first thing a visitor evaluates before pulling out their credit card and becoming a customer.
Some questions visitors might ask themselves are:
+
- "Is this company legit?"
- "Who else is using it?"
- "Can I trust them with my personal data?"
-__Poor design reflects poorly on your team.__ It comes off as lazy, unfinished, and unstable. It shows that the team doesn't care about user experience.
+**Poor design reflects poorly on your team.** It comes off as lazy, unfinished, and unstable. It shows that the team doesn't care about user experience.
-__Good design indicates that the team behind has their shit together.__ I can probably expect good things from them in the future.
+**Good design indicates that the team behind has their shit together.** I can probably expect good things from them in the future.
-It makes me think "if they care so much about these tiny details, they must care a lot about other things in the company, including their customers!".
+It makes me think "if they care so much about these tiny details, they must care a lot about other things in the company, including their customers!".
-A great example of this in play is https://linear.app landing page which I first came across in 2020. I didn't even need to try the product but I already knew that it *must* be good.
+A great example of this in play is https://linear.app landing page which I first came across in 2020. I didn't even need to try the product but I already knew that it _must_ be good.
-This library is heavily inspired by [https://ui.shadcn.com](https://ui.shadcn.com).
\ No newline at end of file
+This library is heavily inspired by [https://ui.shadcn.com](https://ui.shadcn.com).
diff --git a/content/docs/installation.mdx b/content/docs/installation.mdx
index 9e356f0b..3e337cc4 100644
--- a/content/docs/installation.mdx
+++ b/content/docs/installation.mdx
@@ -6,4 +6,4 @@ published: true
### Frameworks
-<ComponentInstallation />
\ No newline at end of file
+<ComponentInstallation />
diff --git a/content/docs/installation/svelte.mdx b/content/docs/installation/svelte.mdx
index 54dd80f9..8783706a 100644
--- a/content/docs/installation/svelte.mdx
+++ b/content/docs/installation/svelte.mdx
@@ -23,7 +23,7 @@ Copy and paste the following code into your project.
```typescript
// lib/utils.ts
-import { type ClassValue, clsx } from "clsx";
+import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
diff --git a/content/docs/installation/vue.mdx b/content/docs/installation/vue.mdx
index 103a3495..52df1e41 100644
--- a/content/docs/installation/vue.mdx
+++ b/content/docs/installation/vue.mdx
@@ -4,4 +4,4 @@ description: Install and configure Magic UI for Vue.js
published: true
---
-<p>Documentation for Vue.js is coming soon.</p>
\ No newline at end of file
+<p>Documentation for Vue.js is coming soon.</p>
diff --git a/content/docs/story.mdx b/content/docs/story.mdx
index bea82137..fe5f997c 100644
--- a/content/docs/story.mdx
+++ b/content/docs/story.mdx
@@ -4,7 +4,7 @@ description: Learn about how Magic UI started
published: false
---
-Magic UI started because of an annoying problem I faced in the summer of 2023.
+Magic UI started because of an annoying problem I faced in the summer of 2023.
I built my [first SaaS app](https://automatic.chat) a few months earlier and was trying to redesign the landing page for it. However, none of the code I wrote matched my expectations in my head for how it would turn out. I was irritated by the process and I especially didn't like having to deal with responsiveness, and animations in particular. Both were really time consuming for me and I felt like I wasn't making progress on actually delivering value to my SaaS users.
@@ -22,7 +22,7 @@ I started building the foundations of this site as well as a few components and
People seem to love it and we're just getting started.
-<div className="columns-3 [&>*]:mb-4 gap-4">
+<div className="columns-3 gap-4 [&>*]:mb-4">
<Tweet id="1722659583464968612" />
<Tweet id="1668442365625790465" />
<Tweet id="1684613797984800768" />
diff --git a/lib/fonts.ts b/lib/fonts.ts
index b04f537e..72cc30f5 100644
--- a/lib/fonts.ts
+++ b/lib/fonts.ts
@@ -1,5 +1,5 @@
-import { GeistSans } from "geist/font/sans";
import { JetBrains_Mono as FontMono } from "next/font/google";
+import { GeistSans } from "geist/font/sans";
export const fontSans = GeistSans;
diff --git a/lib/rehype-component.ts b/lib/rehype-component.ts
index d1c0bb5a..a3b3c87f 100644
--- a/lib/rehype-component.ts
+++ b/lib/rehype-component.ts
@@ -1,9 +1,12 @@
-import { UnistNode, UnistTree } from "@/types/unist";
import fs from "fs";
import path from "path";
import { u } from "unist-builder";
import { visit } from "unist-util-visit";
+
+import { UnistNode, UnistTree } from "@/types/unist";
+
import { registry } from "../registry";
+
// import { styles } from "../registry/styles"
export function rehypeComponent() {
diff --git a/lib/utils.ts b/lib/utils.ts
index bbe0339c..b57e572a 100644
--- a/lib/utils.ts
+++ b/lib/utils.ts
@@ -1,6 +1,6 @@
+import { Metadata } from "next";
import { env } from "@/env.mjs";
import clsx, { ClassValue } from "clsx";
-import { Metadata } from "next";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
diff --git a/middleware.ts b/middleware.ts
index 2913f0dc..423f0db6 100644
--- a/middleware.ts
+++ b/middleware.ts
@@ -1,15 +1,12 @@
import { NextResponse } from "next/server";
-
import type { NextRequest } from "next/server";
export const config = {
- matcher: [
- "/((?!_next|api|[\\w-]+\\.\\w+).*)",
- ],
+ matcher: ["/((?!_next|api|[\\w-]+\\.\\w+).*)"],
};
export default async function middleware(req: NextRequest) {
- const engyneSubdomain = "magicui" // change this to your Engyne subdomain
+ const engyneSubdomain = "magicui"; // change this to your Engyne subdomain
const url = req.nextUrl.clone();
const { pathname } = req.nextUrl;
@@ -23,18 +20,18 @@ export default async function middleware(req: NextRequest) {
if (pathname === "/engyne-sitemap.xml") {
return NextResponse.rewrite(
- new URL(pathname, `https://${engyneSubdomain}.engyne.page`)
+ new URL(pathname, `https://${engyneSubdomain}.engyne.page`),
);
}
if (pathname.startsWith("/blog") || pathname.startsWith("/tags")) {
return NextResponse.rewrite(
- new URL(pathname, `https://${engyneSubdomain}.engyne.page`)
+ new URL(pathname, `https://${engyneSubdomain}.engyne.page`),
);
}
if (pathname.startsWith("/_engyne")) {
return NextResponse.rewrite(
- new URL(pathname, `https://${engyneSubdomain}.engyne.page`)
+ new URL(pathname, `https://${engyneSubdomain}.engyne.page`),
);
}
diff --git a/packages/cli/src/commands/add.ts b/packages/cli/src/commands/add.ts
index a4c19e31..273965e4 100644
--- a/packages/cli/src/commands/add.ts
+++ b/packages/cli/src/commands/add.ts
@@ -4,22 +4,22 @@ import { getConfig } from "@/src/utils/get-config";
import { getPackageManager } from "@/src/utils/get-package-manager";
import { handleError } from "@/src/utils/handle-error";
import {
- logger,
- tryPro,
- hasPro,
- ASCII_TEXT,
- ASCII_PRO,
- ColorFullText,
+ ASCII_PRO,
+ ASCII_TEXT,
+ ColorFullText,
+ hasPro,
+ logger,
+ tryPro,
} from "@/src/utils/logger";
import {
- fetchTree,
- fetchTreeFromShadcn,
- getItemTargetPath,
- getRegistryBaseColor,
- getRegistryIndexShadcn,
- getRegistryIndexMagicUI,
- resolveTree,
- resolveTreeWithShadcn,
+ fetchTree,
+ fetchTreeFromShadcn,
+ getItemTargetPath,
+ getRegistryBaseColor,
+ getRegistryIndexMagicUI,
+ getRegistryIndexShadcn,
+ resolveTree,
+ resolveTreeWithShadcn,
} from "@/src/utils/registry";
import { transform } from "@/src/utils/transformers";
import chalk from "chalk";
@@ -28,279 +28,277 @@ import { execa } from "execa";
import ora from "ora";
import prompts from "prompts";
import { z } from "zod";
+
import { getEnv, parseEnvFile } from "../utils/get-env";
const addOptionsSchema = z.object({
- components: z.array(z.string()).optional(),
- yes: z.boolean(),
- overwrite: z.boolean(),
- cwd: z.string(),
- all: z.boolean(),
- pro: z.boolean(),
- example: z.boolean(),
- shadcn: z.boolean(),
- path: z.string().optional(),
+ components: z.array(z.string()).optional(),
+ yes: z.boolean(),
+ overwrite: z.boolean(),
+ cwd: z.string(),
+ all: z.boolean(),
+ pro: z.boolean(),
+ example: z.boolean(),
+ shadcn: z.boolean(),
+ path: z.string().optional(),
});
const MAGICUI_PRO_ENV = getEnv();
export const add = new Command()
- .name("add")
- .description("Add ui components to your project")
- .argument("[components...]", "the components to add")
- .option("-y, --yes", "skip confirmation prompt.", true)
- .option("-o, --overwrite", "overwrite existing files.", false)
- .option(
- "-c, --cwd <cwd>",
- "the working directory. defaults to the current directory.",
- process.cwd(),
- )
- .option("-a, --all", "add all available components", false)
- .option(
- "-m, --pro",
- "include pro magic-ui blocks & components (make sure to add your secret .env)",
- false,
- )
- .addHelpText("after", ColorFullText(MAGICUI_PRO_ENV ? hasPro : tryPro))
- .option("-e, --example", "include available examples & demos", false)
- .option("-s, --shadcn", "include available components from shadcn-ui", false)
- .option("-p, --path <path>", "the path to add the component to.")
- .action(async (components, opts) => {
- console.log(
- MAGICUI_PRO_ENV ? ASCII_PRO : ASCII_TEXT,
- ColorFullText(
- !MAGICUI_PRO_ENV
- ? tryPro
- : hasPro,
- ),
- );
- try {
- const options = addOptionsSchema.parse({
- components,
- ...opts,
- });
-
- const cwd = path.resolve(options.cwd);
-
- if (!existsSync(cwd)) {
- logger.error(`The path ${cwd} does not exist. Please try again.`);
- process.exit(1);
- }
-
- const config = await getConfig(cwd);
- if (!config) {
- logger.warn(
- `Configuration is missing. Please run ${chalk.green(
- `init`,
- )} to create a components.json file.`,
- );
- process.exit(1);
- }
-
- if (options.pro && !MAGICUI_PRO_ENV) {
- logger.warn("You're not authenticated to add Magic UI Pro components")
- return
- }
-
- const registryIndex = !options.shadcn
- ? (await getRegistryIndexMagicUI(options.pro))
- : [];
- const shadcnRegistryIndex = await getRegistryIndexShadcn();
-
- let selectedComponents = options.all
- ? (options.shadcn ? shadcnRegistryIndex : registryIndex).map(
- (entry) => entry.name,
- )
- : options.components;
-
- if (!options.components?.length && !options.all) {
- const filterIndex = (): typeof registryIndex => registryIndex.filter((e) => {
- const type = e.type.split(":")[1] as string
- if (options.pro)
- return type === "blocks"
-
- if (options.example)
- return type === "example"
-
- return type === "magicui"
- })
-
- const multiselectChoice = options.shadcn ? shadcnRegistryIndex : filterIndex();
- const { components } = await prompts({
- type: "multiselect",
- name: "components",
- message: "Which components would you like to add?",
- hint: "Space to select. A to toggle all. Enter to submit.",
- instructions: false,
- choices: multiselectChoice.map(
- (entry) => ({
- title: entry.name,
- value: entry.name,
- selected: options.all
- ? true
- : options.components?.includes(entry.name),
- }),
- ),
- });
- selectedComponents = components;
- }
-
- if (!selectedComponents?.length) {
- logger.warn("No components selected. Exiting.");
- process.exit(0);
- }
-
- // const tree = await resolveTree(registryIndex, selectedComponents)
- const { magicuiTree, shadcnTree } = await resolveTreeWithShadcn(
- shadcnRegistryIndex,
- registryIndex,
- selectedComponents,
- options.shadcn,
- );
-
- const magicuiPayload = await fetchTree(magicuiTree, MAGICUI_PRO_ENV);
- const shadcnPayload = await fetchTreeFromShadcn(config.style, shadcnTree);
- const baseColor = await getRegistryBaseColor(config.tailwind.baseColor);
-
- if (!magicuiPayload.length && !shadcnPayload.length) {
- logger.warn("Selected components not found. Exiting.");
- process.exit(0);
- } else {
- magicuiPayload.length !== 0 &&
- logger.info(`Found ${magicuiPayload.length}x Magic UI components.`);
- shadcnPayload.length !== 0 &&
- logger.info(`Found ${shadcnPayload.length}x Shadcn UI components.`);
- }
-
- const totalPayload = [...magicuiPayload, ...shadcnPayload];
-
- if (!options.yes) {
- const { proceed } = await prompts({
- type: "confirm",
- name: "proceed",
- message: `Ready to install components and dependencies. Proceed?`,
- initial: true,
- });
-
- if (!proceed) {
- process.exit(0);
- }
- }
-
- const spinner = ora(`Installing components...`).start();
- for (const item of totalPayload) {
- spinner.text = `Installing ${item.name}...`;
- const targetDir = await getItemTargetPath(
- config,
- item,
- options.path ? path.resolve(cwd, options.path) : undefined,
- );
-
- if (!targetDir) {
- continue;
- }
-
- if (!existsSync(targetDir)) {
- await fs.mkdir(targetDir, { recursive: true });
- }
-
- const existingComponent = item.files.filter((file) =>
- existsSync(path.resolve(targetDir, file.name)),
- );
-
- if (existingComponent.length && !options.overwrite) {
- if (selectedComponents.includes(item.name)) {
- spinner.stop();
- const { overwrite } = await prompts({
- type: "confirm",
- name: "overwrite",
- message: `Component ${item.name} already exists. Would you like to overwrite?`,
- initial: false,
- });
-
- if (!overwrite) {
- logger.info(
- `Skipped ${item.name}. To overwrite, run with the ${chalk.green(
- "--overwrite",
- )} flag.`,
- );
- continue;
- }
-
- spinner.start(`Installing ${item.name}...`);
- } else {
- continue;
- }
- }
-
- for (const file of item.files) {
- let filePath = path.resolve(targetDir, file.name);
-
- // Run transformers.
- const content = await transform({
- filename: file.name,
- raw: file.content,
- config,
- baseColor,
- });
-
- if (!config.tsx) {
- filePath = filePath.replace(/\.tsx$/, ".jsx");
- filePath = filePath.replace(/\.ts$/, ".js");
- }
-
- await fs.writeFile(filePath, content);
- }
-
- const packageManager = await getPackageManager(cwd);
-
- // Install dependencies.
- if (item.dependencies?.length) {
- try {
- await execa(
- packageManager,
- [
- packageManager === "npm" ? "install" : "add",
- ...item.dependencies,
- ],
- {
- cwd,
- },
- );
- } catch (error) {
- logger.warn(
- `\nFailed to install dependencies for ${item.name
- }.\n\t-${item.dependencies.join("\n\t- ")}\n\nReason: ${error}`,
- );
- }
- }
-
- // Install devDependencies.
- if (item.devDependencies?.length) {
- try {
- await execa(
- packageManager,
- [
- packageManager === "npm" ? "install" : "add",
- "-D",
- ...item.devDependencies,
- ],
- {
- cwd,
- },
- );
- } catch (error) {
- logger.warn(
- `\nFailed to install devDependencies for ${item.name
- }.\n\t-${item.devDependencies.join(
- "\n\t- ",
- )}\n\nReason: ${error}`,
- );
- }
- }
- }
- spinner.succeed(`Done.`);
- } catch (error) {
- handleError(error);
- }
- });
+ .name("add")
+ .description("Add ui components to your project")
+ .argument("[components...]", "the components to add")
+ .option("-y, --yes", "skip confirmation prompt.", true)
+ .option("-o, --overwrite", "overwrite existing files.", false)
+ .option(
+ "-c, --cwd <cwd>",
+ "the working directory. defaults to the current directory.",
+ process.cwd(),
+ )
+ .option("-a, --all", "add all available components", false)
+ .option(
+ "-m, --pro",
+ "include pro magic-ui blocks & components (make sure to add your secret .env)",
+ false,
+ )
+ .addHelpText("after", ColorFullText(MAGICUI_PRO_ENV ? hasPro : tryPro))
+ .option("-e, --example", "include available examples & demos", false)
+ .option("-s, --shadcn", "include available components from shadcn-ui", false)
+ .option("-p, --path <path>", "the path to add the component to.")
+ .action(async (components, opts) => {
+ console.log(
+ MAGICUI_PRO_ENV ? ASCII_PRO : ASCII_TEXT,
+ ColorFullText(!MAGICUI_PRO_ENV ? tryPro : hasPro),
+ );
+ try {
+ const options = addOptionsSchema.parse({
+ components,
+ ...opts,
+ });
+
+ const cwd = path.resolve(options.cwd);
+
+ if (!existsSync(cwd)) {
+ logger.error(`The path ${cwd} does not exist. Please try again.`);
+ process.exit(1);
+ }
+
+ const config = await getConfig(cwd);
+ if (!config) {
+ logger.warn(
+ `Configuration is missing. Please run ${chalk.green(
+ `init`,
+ )} to create a components.json file.`,
+ );
+ process.exit(1);
+ }
+
+ if (options.pro && !MAGICUI_PRO_ENV) {
+ logger.warn("You're not authenticated to add Magic UI Pro components");
+ return;
+ }
+
+ const registryIndex = !options.shadcn
+ ? await getRegistryIndexMagicUI(options.pro)
+ : [];
+ const shadcnRegistryIndex = await getRegistryIndexShadcn();
+
+ let selectedComponents = options.all
+ ? (options.shadcn ? shadcnRegistryIndex : registryIndex).map(
+ (entry) => entry.name,
+ )
+ : options.components;
+
+ if (!options.components?.length && !options.all) {
+ const filterIndex = (): typeof registryIndex =>
+ registryIndex.filter((e) => {
+ const type = e.type.split(":")[1] as string;
+ if (options.pro) return type === "blocks";
+
+ if (options.example) return type === "example";
+
+ return type === "magicui";
+ });
+
+ const multiselectChoice = options.shadcn
+ ? shadcnRegistryIndex
+ : filterIndex();
+ const { components } = await prompts({
+ type: "multiselect",
+ name: "components",
+ message: "Which components would you like to add?",
+ hint: "Space to select. A to toggle all. Enter to submit.",
+ instructions: false,
+ choices: multiselectChoice.map((entry) => ({
+ title: entry.name,
+ value: entry.name,
+ selected: options.all
+ ? true
+ : options.components?.includes(entry.name),
+ })),
+ });
+ selectedComponents = components;
+ }
+
+ if (!selectedComponents?.length) {
+ logger.warn("No components selected. Exiting.");
+ process.exit(0);
+ }
+
+ // const tree = await resolveTree(registryIndex, selectedComponents)
+ const { magicuiTree, shadcnTree } = await resolveTreeWithShadcn(
+ shadcnRegistryIndex,
+ registryIndex,
+ selectedComponents,
+ options.shadcn,
+ );
+
+ const magicuiPayload = await fetchTree(magicuiTree, MAGICUI_PRO_ENV);
+ const shadcnPayload = await fetchTreeFromShadcn(config.style, shadcnTree);
+ const baseColor = await getRegistryBaseColor(config.tailwind.baseColor);
+
+ if (!magicuiPayload.length && !shadcnPayload.length) {
+ logger.warn("Selected components not found. Exiting.");
+ process.exit(0);
+ } else {
+ magicuiPayload.length !== 0 &&
+ logger.info(`Found ${magicuiPayload.length}x Magic UI components.`);
+ shadcnPayload.length !== 0 &&
+ logger.info(`Found ${shadcnPayload.length}x Shadcn UI components.`);
+ }
+
+ const totalPayload = [...magicuiPayload, ...shadcnPayload];
+
+ if (!options.yes) {
+ const { proceed } = await prompts({
+ type: "confirm",
+ name: "proceed",
+ message: `Ready to install components and dependencies. Proceed?`,
+ initial: true,
+ });
+
+ if (!proceed) {
+ process.exit(0);
+ }
+ }
+
+ const spinner = ora(`Installing components...`).start();
+ for (const item of totalPayload) {
+ spinner.text = `Installing ${item.name}...`;
+ const targetDir = await getItemTargetPath(
+ config,
+ item,
+ options.path ? path.resolve(cwd, options.path) : undefined,
+ );
+
+ if (!targetDir) {
+ continue;
+ }
+
+ if (!existsSync(targetDir)) {
+ await fs.mkdir(targetDir, { recursive: true });
+ }
+
+ const existingComponent = item.files.filter((file) =>
+ existsSync(path.resolve(targetDir, file.name)),
+ );
+
+ if (existingComponent.length && !options.overwrite) {
+ if (selectedComponents.includes(item.name)) {
+ spinner.stop();
+ const { overwrite } = await prompts({
+ type: "confirm",
+ name: "overwrite",
+ message: `Component ${item.name} already exists. Would you like to overwrite?`,
+ initial: false,
+ });
+
+ if (!overwrite) {
+ logger.info(
+ `Skipped ${item.name}. To overwrite, run with the ${chalk.green(
+ "--overwrite",
+ )} flag.`,
+ );
+ continue;
+ }
+
+ spinner.start(`Installing ${item.name}...`);
+ } else {
+ continue;
+ }
+ }
+
+ for (const file of item.files) {
+ let filePath = path.resolve(targetDir, file.name);
+
+ // Run transformers.
+ const content = await transform({
+ filename: file.name,
+ raw: file.content,
+ config,
+ baseColor,
+ });
+
+ if (!config.tsx) {
+ filePath = filePath.replace(/\.tsx$/, ".jsx");
+ filePath = filePath.replace(/\.ts$/, ".js");
+ }
+
+ await fs.writeFile(filePath, content);
+ }
+
+ const packageManager = await getPackageManager(cwd);
+
+ // Install dependencies.
+ if (item.dependencies?.length) {
+ try {
+ await execa(
+ packageManager,
+ [
+ packageManager === "npm" ? "install" : "add",
+ ...item.dependencies,
+ ],
+ {
+ cwd,
+ },
+ );
+ } catch (error) {
+ logger.warn(
+ `\nFailed to install dependencies for ${
+ item.name
+ }.\n\t-${item.dependencies.join("\n\t- ")}\n\nReason: ${error}`,
+ );
+ }
+ }
+
+ // Install devDependencies.
+ if (item.devDependencies?.length) {
+ try {
+ await execa(
+ packageManager,
+ [
+ packageManager === "npm" ? "install" : "add",
+ "-D",
+ ...item.devDependencies,
+ ],
+ {
+ cwd,
+ },
+ );
+ } catch (error) {
+ logger.warn(
+ `\nFailed to install devDependencies for ${
+ item.name
+ }.\n\t-${item.devDependencies.join(
+ "\n\t- ",
+ )}\n\nReason: ${error}`,
+ );
+ }
+ }
+ }
+ spinner.succeed(`Done.`);
+ } catch (error) {
+ handleError(error);
+ }
+ });
diff --git a/packages/cli/src/commands/auth.ts b/packages/cli/src/commands/auth.ts
index 7bcccd91..9a7d23fc 100644
--- a/packages/cli/src/commands/auth.ts
+++ b/packages/cli/src/commands/auth.ts
@@ -1,68 +1,65 @@
import { Command } from "commander";
+import prompts from "prompts";
+import { z } from "zod";
+
import { clearAll, getEnv, login } from "../utils/get-env";
import {
- ASCII_TEXT,
- ASCII_PRO,
- ColorFullText,
- tryPro,
- hasPro,
- authMessage,
+ ASCII_PRO,
+ ASCII_TEXT,
+ authMessage,
+ ColorFullText,
+ hasPro,
+ tryPro,
} from "../utils/logger";
-import { z } from "zod";
-import prompts from "prompts";
const optionSchema = z.object({
- clear: z.boolean(),
- login: z.string().optional(),
+ clear: z.boolean(),
+ login: z.string().optional(),
});
const MAGICUI_PRO_ENV = getEnv();
export const auth = new Command()
- .addHelpText("before", MAGICUI_PRO_ENV ? ASCII_PRO : ASCII_TEXT)
- .name("auth")
- .description("For the Magic UI Pro Users. Authenticate your account.")
- .option("-l, --login <env>", "the secret env to authenticate.")
- .option("-d, --clear", "clear the auth secrets.", false)
- .action(async (opts) => {
- const options = optionSchema.parse(opts);
+ .addHelpText("before", MAGICUI_PRO_ENV ? ASCII_PRO : ASCII_TEXT)
+ .name("auth")
+ .description("For the Magic UI Pro Users. Authenticate your account.")
+ .option("-l, --login <env>", "the secret env to authenticate.")
+ .option("-d, --clear", "clear the auth secrets.", false)
+ .action(async (opts) => {
+ const options = optionSchema.parse(opts);
- switch (true) {
- case options.clear: {
+ switch (true) {
+ case options.clear: {
+ const isClear = await prompts({
+ type: "confirm",
+ name: "value",
+ message:
+ "Are you sure you want to log out and clear the auth secrets?",
+ choices: [
+ { title: "Yes", value: true },
+ { title: "No", value: false },
+ ],
+ });
- const isClear = await prompts({
- type: "confirm",
- name: "value",
- message: "Are you sure you want to log out and clear the auth secrets?",
- choices: [
- { title: "Yes", value: true },
- { title: "No", value: false },
- ]
- })
+ if (isClear.value) {
+ clearAll();
+ console.log("Logged out ✅");
+ }
- if (isClear.value) {
- clearAll()
- console.log("Logged out ✅")
- }
-
- break;
- }
- case options.login !== undefined: {
- const isLogined = await login(options.login)
- if (isLogined) {
- console.log(ColorFullText(hasPro))
- }
- break;
- }
- default: {
- console.log(
- MAGICUI_PRO_ENV ? ASCII_PRO : ASCII_TEXT,
- ColorFullText(
- !MAGICUI_PRO_ENV
- ? authMessage
- : hasPro,
- ),
- );
- }
- }
- });
+ break;
+ }
+ case options.login !== undefined: {
+ const isLogined = await login(options.login);
+ if (isLogined) {
+ console.log(ColorFullText(hasPro));
+ }
+ break;
+ }
+ default: {
+ console.log(
+ MAGICUI_PRO_ENV ? ASCII_PRO : ASCII_TEXT,
+ ColorFullText(!MAGICUI_PRO_ENV ? authMessage : hasPro),
+ );
+ }
+ }
+ });
diff --git a/packages/cli/src/commands/diff.ts b/packages/cli/src/commands/diff.ts
index 29beb4be..cc9a9ab7 100644
--- a/packages/cli/src/commands/diff.ts
+++ b/packages/cli/src/commands/diff.ts
@@ -8,8 +8,8 @@ import {
fetchTreeFromShadcn,
getItemTargetPath,
getRegistryBaseColor,
- getRegistryIndexShadcn,
getRegistryIndexMagicUI,
+ getRegistryIndexShadcn,
} from "@/src/utils/registry";
import { registryIndexSchema } from "@/src/utils/registry/schema";
import { transform } from "@/src/utils/transformers";
@@ -99,7 +99,7 @@ export const diff = new Command()
});
}
}
-
+
// Check for updates in shadcn primitives.
const componentsShadcnWithUpdates = [];
for (const component of projectShadcnComponents) {
diff --git a/packages/cli/src/commands/init.ts b/packages/cli/src/commands/init.ts
index 1fb05360..352ceb14 100644
--- a/packages/cli/src/commands/init.ts
+++ b/packages/cli/src/commands/init.ts
@@ -1,5 +1,5 @@
-import { existsSync, promises as fs } from "fs"
-import path from "path"
+import { existsSync, promises as fs } from "fs";
+import path from "path";
import {
DEFAULT_COMPONENTS,
DEFAULT_TAILWIND_CONFIG,
@@ -9,26 +9,26 @@ import {
rawConfigSchema,
resolveConfigPaths,
type Config,
-} from "@/src/utils/get-config"
-import { getPackageManager } from "@/src/utils/get-package-manager"
-import { getProjectConfig, preFlight } from "@/src/utils/get-project-info"
-import { handleError } from "@/src/utils/handle-error"
-import { logger } from "@/src/utils/logger"
+} from "@/src/utils/get-config";
+import { getPackageManager } from "@/src/utils/get-package-manager";
+import { getProjectConfig, preFlight } from "@/src/utils/get-project-info";
+import { handleError } from "@/src/utils/handle-error";
+import { logger } from "@/src/utils/logger";
import {
getRegistryBaseColor,
getRegistryBaseColors,
getRegistryStyles,
-} from "@/src/utils/registry"
-import * as templates from "@/src/utils/templates"
-import chalk from "chalk"
-import { Command } from "commander"
-import { execa } from "execa"
-import template from "lodash.template"
-import ora from "ora"
-import prompts from "prompts"
-import { z } from "zod"
-
-import { applyPrefixesCss } from "../utils/transformers/transform-tw-prefix"
+} from "@/src/utils/registry";
+import * as templates from "@/src/utils/templates";
+import chalk from "chalk";
+import { Command } from "commander";
+import { execa } from "execa";
+import template from "lodash.template";
+import ora from "ora";
+import prompts from "prompts";
+import { z } from "zod";
+
+import { applyPrefixesCss } from "../utils/transformers/transform-tw-prefix";
const PROJECT_DEPENDENCIES = [
"tailwindcss-animate",
@@ -36,13 +36,13 @@ const PROJECT_DEPENDENCIES = [
"clsx",
"tailwind-merge",
"framer-motion",
-]
+];
const initOptionsSchema = z.object({
cwd: z.string(),
yes: z.boolean(),
defaults: z.boolean(),
-})
+});
export const init = new Command()
.name("init")
@@ -52,64 +52,64 @@ export const init = new Command()
.option(
"-c, --cwd <cwd>",
"the working directory. defaults to the current directory.",
- process.cwd()
+ process.cwd(),
)
.action(async (opts) => {
try {
- const options = initOptionsSchema.parse(opts)
- const cwd = path.resolve(options.cwd)
+ const options = initOptionsSchema.parse(opts);
+ const cwd = path.resolve(options.cwd);
// Ensure target directory exists.
if (!existsSync(cwd)) {
- logger.error(`The path ${cwd} does not exist. Please try again.`)
- process.exit(1)
+ logger.error(`The path ${cwd} does not exist. Please try again.`);
+ process.exit(1);
}
- preFlight(cwd)
+ preFlight(cwd);
- const projectConfig = await getProjectConfig(cwd)
+ const projectConfig = await getProjectConfig(cwd);
if (projectConfig) {
const config = await promptForMinimalConfig(
cwd,
projectConfig,
- opts.defaults
- )
- await runInit(cwd, config)
+ opts.defaults,
+ );
+ await runInit(cwd, config);
} else {
// Read config.
- const existingConfig = await getConfig(cwd)
- const config = await promptForConfig(cwd, existingConfig, options.yes)
- await runInit(cwd, config)
+ const existingConfig = await getConfig(cwd);
+ const config = await promptForConfig(cwd, existingConfig, options.yes);
+ await runInit(cwd, config);
}
- logger.info("")
+ logger.info("");
logger.info(
`${chalk.green(
- "Success!"
- )} Project initialization completed. You may now add both shadcn-ui and magic-ui components.`
- )
- logger.info("")
+ "Success!",
+ )} Project initialization completed. You may now add both shadcn-ui and magic-ui components.`,
+ );
+ logger.info("");
} catch (error) {
- handleError(error)
+ handleError(error);
}
- })
+ });
export async function promptForConfig(
cwd: string,
defaultConfig: Config | null = null,
- skip = false
+ skip = false,
) {
- const highlight = (text: string) => chalk.cyan(text)
+ const highlight = (text: string) => chalk.cyan(text);
- const styles = await getRegistryStyles()
- const baseColors = await getRegistryBaseColors()
+ const styles = await getRegistryStyles();
+ const baseColors = await getRegistryBaseColors();
const options = await prompts([
{
type: "toggle",
name: "typescript",
message: `Would you like to use ${highlight(
- "TypeScript"
+ "TypeScript",
)} (recommended)?`,
initial: defaultConfig?.tsx ?? true,
active: "yes",
@@ -128,7 +128,7 @@ export async function promptForConfig(
type: "select",
name: "tailwindBaseColor",
message: `Which color would you like to use as ${highlight(
- "base color"
+ "base color",
)}?`,
choices: baseColors.map((color) => ({
title: color.label,
@@ -145,7 +145,7 @@ export async function promptForConfig(
type: "toggle",
name: "tailwindCssVariables",
message: `Would you like to use ${highlight(
- "CSS variables"
+ "CSS variables",
)} for colors?`,
initial: defaultConfig?.tailwind.cssVariables ?? true,
active: "yes",
@@ -155,7 +155,7 @@ export async function promptForConfig(
type: "text",
name: "tailwindPrefix",
message: `Are you using a custom ${highlight(
- "tailwind prefix eg. tw-"
+ "tailwind prefix eg. tw-",
)}? (Leave blank if not)`,
initial: "",
},
@@ -185,7 +185,7 @@ export async function promptForConfig(
active: "yes",
inactive: "no",
},
- ])
+ ]);
const config = rawConfigSchema.parse({
$schema: "https://ui.shadcn.com/schema.json",
@@ -205,46 +205,46 @@ export async function promptForConfig(
ui: `${options.components}/ui`,
magicui: `${options.components}/magicui`,
},
- })
+ });
if (!skip) {
const { proceed } = await prompts({
type: "confirm",
name: "proceed",
message: `Write configuration to ${highlight(
- "components.json"
+ "components.json",
)}. Proceed?`,
initial: true,
- })
+ });
if (!proceed) {
- process.exit(0)
+ process.exit(0);
}
}
// Write to file.
- logger.info("")
- const spinner = ora(`Writing components.json...`).start()
- const targetPath = path.resolve(cwd, "components.json")
- await fs.writeFile(targetPath, JSON.stringify(config, null, 2), "utf8")
- spinner.succeed()
+ logger.info("");
+ const spinner = ora(`Writing components.json...`).start();
+ const targetPath = path.resolve(cwd, "components.json");
+ await fs.writeFile(targetPath, JSON.stringify(config, null, 2), "utf8");
+ spinner.succeed();
- return await resolveConfigPaths(cwd, config)
+ return await resolveConfigPaths(cwd, config);
}
export async function promptForMinimalConfig(
cwd: string,
defaultConfig: Config,
- defaults = false
+ defaults = false,
) {
- const highlight = (text: string) => chalk.cyan(text)
- let style = defaultConfig.style
- let baseColor = defaultConfig.tailwind.baseColor
- let cssVariables = defaultConfig.tailwind.cssVariables
+ const highlight = (text: string) => chalk.cyan(text);
+ let style = defaultConfig.style;
+ let baseColor = defaultConfig.tailwind.baseColor;
+ let cssVariables = defaultConfig.tailwind.cssVariables;
if (!defaults) {
- const styles = await getRegistryStyles()
- const baseColors = await getRegistryBaseColors()
+ const styles = await getRegistryStyles();
+ const baseColors = await getRegistryBaseColors();
const options = await prompts([
{
@@ -260,7 +260,7 @@ export async function promptForMinimalConfig(
type: "select",
name: "tailwindBaseColor",
message: `Which color would you like to use as ${highlight(
- "base color"
+ "base color",
)}?`,
choices: baseColors.map((color) => ({
title: color.label,
@@ -271,17 +271,17 @@ export async function promptForMinimalConfig(
type: "toggle",
name: "tailwindCssVariables",
message: `Would you like to use ${highlight(
- "CSS variables"
+ "CSS variables",
)} for colors?`,
initial: defaultConfig?.tailwind.cssVariables,
active: "yes",
inactive: "no",
},
- ])
+ ]);
- style = options.style
- baseColor = options.tailwindBaseColor
- cssVariables = options.tailwindCssVariables
+ style = options.style;
+ baseColor = options.tailwindBaseColor;
+ cssVariables = options.tailwindCssVariables;
}
const content = {
@@ -295,22 +295,22 @@ export async function promptForMinimalConfig(
rsc: defaultConfig?.rsc,
tsx: defaultConfig?.tsx,
aliases: defaultConfig?.aliases,
- }
+ };
- const config = rawConfigSchema.parse(content)
+ const config = rawConfigSchema.parse(content);
// Write to file.
- logger.info("")
- const spinner = ora(`Writing components.json...`).start()
- const targetPath = path.resolve(cwd, "components.json")
- await fs.writeFile(targetPath, JSON.stringify(config, null, 2), "utf8")
- spinner.succeed()
+ logger.info("");
+ const spinner = ora(`Writing components.json...`).start();
+ const targetPath = path.resolve(cwd, "components.json");
+ await fs.writeFile(targetPath, JSON.stringify(config, null, 2), "utf8");
+ spinner.succeed();
- return await resolveConfigPaths(cwd, config)
+ return await resolveConfigPaths(cwd, config);
}
export async function runInit(cwd: string, config: Config) {
- const spinner = ora(`Initializing project...`)?.start()
+ const spinner = ora(`Initializing project...`)?.start();
// Ensure all resolved paths directories exist.
for (const [key, resolvedPath] of Object.entries(config.resolvedPaths)) {
@@ -318,36 +318,36 @@ export async function runInit(cwd: string, config: Config) {
// TODO: is there a better way to do this?
let dirname = path.extname(resolvedPath)
? path.dirname(resolvedPath)
- : resolvedPath
+ : resolvedPath;
// If the utils alias is set to something like "@/lib/utils",
// assume this is a file and remove the "utils" file name.
// TODO: In future releases we should add support for individual utils.
if (key === "utils" && resolvedPath.endsWith("/utils")) {
// Remove /utils at the end.
- dirname = dirname.replace(/\/utils$/, "")
+ dirname = dirname.replace(/\/utils$/, "");
}
if (!existsSync(dirname)) {
- await fs.mkdir(dirname, { recursive: true })
+ await fs.mkdir(dirname, { recursive: true });
}
}
- const extension = config.tsx ? "ts" : "js"
+ const extension = config.tsx ? "ts" : "js";
const tailwindConfigExtension = path.extname(
- config.resolvedPaths.tailwindConfig
- )
+ config.resolvedPaths.tailwindConfig,
+ );
- let tailwindConfigTemplate: string
+ let tailwindConfigTemplate: string;
if (tailwindConfigExtension === ".ts") {
tailwindConfigTemplate = config.tailwind.cssVariables
? templates.TAILWIND_CONFIG_TS_WITH_VARIABLES
- : templates.TAILWIND_CONFIG_TS
+ : templates.TAILWIND_CONFIG_TS;
} else {
tailwindConfigTemplate = config.tailwind.cssVariables
? templates.TAILWIND_CONFIG_WITH_VARIABLES
- : templates.TAILWIND_CONFIG
+ : templates.TAILWIND_CONFIG;
}
// Write tailwind config.
@@ -357,11 +357,11 @@ export async function runInit(cwd: string, config: Config) {
extension,
prefix: config.tailwind.prefix,
}),
- "utf8"
- )
+ "utf8",
+ );
// Write css file.
- const baseColor = await getRegistryBaseColor(config.tailwind.baseColor)
+ const baseColor = await getRegistryBaseColor(config.tailwind.baseColor);
if (baseColor) {
await fs.writeFile(
config.resolvedPaths.tailwindCss,
@@ -370,35 +370,35 @@ export async function runInit(cwd: string, config: Config) {
? applyPrefixesCss(baseColor.cssVarsTemplate, config.tailwind.prefix)
: baseColor.cssVarsTemplate
: baseColor.inlineColorsTemplate,
- "utf8"
- )
+ "utf8",
+ );
}
// Write cn file.
await fs.writeFile(
`${config.resolvedPaths.utils}.${extension}`,
extension === "ts" ? templates.UTILS : templates.UTILS_JS,
- "utf8"
- )
+ "utf8",
+ );
- spinner?.succeed()
+ spinner?.succeed();
// Install dependencies.
- const dependenciesSpinner = ora(`Installing dependencies...`)?.start()
- const packageManager = await getPackageManager(cwd)
+ const dependenciesSpinner = ora(`Installing dependencies...`)?.start();
+ const packageManager = await getPackageManager(cwd);
// TODO: add support for other icon libraries.
const deps = [
...PROJECT_DEPENDENCIES,
config.style === "new-york" ? "@radix-ui/react-icons" : "lucide-react",
- ]
+ ];
await execa(
packageManager,
[packageManager === "npm" ? "install" : "add", ...deps],
{
cwd,
- }
- )
- dependenciesSpinner?.succeed()
+ },
+ );
+ dependenciesSpinner?.succeed();
}
diff --git a/packages/cli/src/commands/template.ts b/packages/cli/src/commands/template.ts
index 99a65a97..0dbdbc85 100644
--- a/packages/cli/src/commands/template.ts
+++ b/packages/cli/src/commands/template.ts
@@ -1,95 +1,93 @@
import { Command } from "commander";
+import prompts from "prompts";
+import { z } from "zod";
+
import { clearAll, getEnv, login } from "../utils/get-env";
-import { getAllProjectTemplates, getProjectLink, getDataAndWrite } from "../utils/install-project";
import {
- ASCII_TEXT,
- ASCII_PRO,
- ColorFullText,
- tryPro,
- hasPro,
- authMessage,
+ getAllProjectTemplates,
+ getDataAndWrite,
+ getProjectLink,
+} from "../utils/install-project";
+import {
+ ASCII_PRO,
+ ASCII_TEXT,
+ authMessage,
+ ColorFullText,
+ hasPro,
+ logger,
+ tryPro,
} from "../utils/logger";
-import { z } from "zod";
-import prompts from "prompts";
-import { logger } from "../utils/logger";
const optionSchema = z.object({
- template: z.string().optional(),
+ template: z.string().optional(),
});
const MAGICUI_PRO_ENV = getEnv();
export const project = new Command()
- .name("project")
- .description("Download premium template & start new project.")
- .option("-t, --template <env>", "the secret env to authenticate.")
- .action(async (opts) => {
- console.log(
- MAGICUI_PRO_ENV ? ASCII_PRO : ASCII_TEXT,
- ColorFullText(
- !MAGICUI_PRO_ENV
- ? authMessage
- : hasPro,
- ),
- );
+ .name("project")
+ .description("Download premium template & start new project.")
+ .option("-t, --template <env>", "the secret env to authenticate.")
+ .action(async (opts) => {
+ console.log(
+ MAGICUI_PRO_ENV ? ASCII_PRO : ASCII_TEXT,
+ ColorFullText(!MAGICUI_PRO_ENV ? authMessage : hasPro),
+ );
- const options = optionSchema.parse(opts);
- const allTemplates = await getAllProjectTemplates()
+ const options = optionSchema.parse(opts);
+ const allTemplates = await getAllProjectTemplates();
- const getSelectedTemplates = async () => {
- if (!options.template) {
+ const getSelectedTemplates = async () => {
+ if (!options.template) {
+ const { templates } = (await prompts({
+ type: "select",
+ name: "templates",
+ message: "Which project templates would you like to download?",
+ hint: "Enter/Space to select",
+ instructions: false,
+ choices: allTemplates.map((entry) => ({
+ title: entry.repo,
+ value: entry.repo,
+ description: `${entry.description}\n preview → ${entry.preview}`,
+ })),
+ })) as { templates?: string };
- const { templates } = await prompts({
- type: "select",
- name: "templates",
- message: "Which project templates would you like to download?",
- hint: "Enter/Space to select",
- instructions: false,
- choices: allTemplates.map(
- (entry) => ({
- title: entry.repo,
- value: entry.repo,
- description: `${entry.description}\n preview → ${entry.preview}`
- }),
- ),
- }) as { templates?: string }
+ return templates;
+ }
+ return options.template;
+ };
- return templates
- }
- return options.template
- }
+ const name = await getSelectedTemplates();
- const name = await getSelectedTemplates()
+ if (!name) {
+ logger.warn("Invalid template selection");
+ return;
+ }
- if (!name) {
- logger.warn("Invalid template selection")
- return;
- }
+ const data = allTemplates.find((e) => e.repo === name);
- const data = allTemplates.find(e => e.repo === name)
+ if (!data) {
+ logger.warn("Selected Template is not exist");
+ return;
+ }
- if (!data) {
- logger.warn("Selected Template is not exist")
- return;
- }
-
- if (!MAGICUI_PRO_ENV) {
- logger.warn("You are not authenticated to download premium templates.")
- return;
- }
+ if (!MAGICUI_PRO_ENV) {
+ logger.warn("You are not authenticated to download premium templates.");
+ return;
+ }
- const file = await getProjectLink(data.repo, data.owner, MAGICUI_PRO_ENV)
+ const file = await getProjectLink(data.repo, data.owner, MAGICUI_PRO_ENV);
- if (!file.success) {
- logger.error("Failed to fetch project downloading link")
- return;
- }
- const fileName = `${data.repo}.zip`
- const success = await getDataAndWrite(file.downloadUrl, fileName)
+ if (!file.success) {
+ logger.error("Failed to fetch project downloading link");
+ return;
+ }
+ const fileName = `${data.repo}.zip`;
+ const success = await getDataAndWrite(file.downloadUrl, fileName);
- if (!success) {
- logger.error("Failed to fetch/write project zip file")
- return;
- }
- logger.success(`Downloaded ${fileName} on current directory`)
- });
+ if (!success) {
+ logger.error("Failed to fetch/write project zip file");
+ return;
+ }
+ logger.success(`Downloaded ${fileName} on current directory`);
+ });
diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts
index 384c7adc..3f8265ea 100644
--- a/packages/cli/src/index.ts
+++ b/packages/cli/src/index.ts
@@ -4,39 +4,39 @@ import { diff } from "@/src/commands/diff";
import { init } from "@/src/commands/init";
import { Command } from "commander";
-import { getPackageInfo } from "./utils/get-package-info";
+import { auth } from "./commands/auth";
+import { project } from "./commands/template";
import { getEnv } from "./utils/get-env";
+import { getPackageInfo } from "./utils/get-package-info";
import {
- ASCII_TEXT,
- ASCII_PRO,
- ColorFullText,
- tryPro,
- hasPro,
+ ASCII_PRO,
+ ASCII_TEXT,
+ ColorFullText,
+ hasPro,
+ tryPro,
} from "./utils/logger";
-import { auth } from "./commands/auth";
-import { project } from "./commands/template";
process.on("SIGINT", () => process.exit(0));
process.on("SIGTERM", () => process.exit(0));
async function main() {
- const packageInfo = await getPackageInfo();
- const MAGICUI_PRO_ENV = getEnv();
+ const packageInfo = await getPackageInfo();
+ const MAGICUI_PRO_ENV = getEnv();
- const program = new Command()
- .addHelpText("before", MAGICUI_PRO_ENV ? ASCII_PRO : ASCII_TEXT)
- .addHelpText("after", ColorFullText(MAGICUI_PRO_ENV ? hasPro : tryPro))
- .name("magicui-cli")
- .description("Add Magic UI components to your apps.")
- .version(
- packageInfo.version || "1.0.0",
- "-v, --version",
- "display the version number",
- );
+ const program = new Command()
+ .addHelpText("before", MAGICUI_PRO_ENV ? ASCII_PRO : ASCII_TEXT)
+ .addHelpText("after", ColorFullText(MAGICUI_PRO_ENV ? hasPro : tryPro))
+ .name("magicui-cli")
+ .description("Add Magic UI components to your apps.")
+ .version(
+ packageInfo.version || "1.0.0",
+ "-v, --version",
+ "display the version number",
+ );
- program.addCommand(init).addCommand(add).addCommand(auth).addCommand(project)
+ program.addCommand(init).addCommand(add).addCommand(auth).addCommand(project);
- program.parse();
+ program.parse();
}
main();
diff --git a/packages/cli/src/utils/get-config.ts b/packages/cli/src/utils/get-config.ts
index 22eebd85..812693f9 100644
--- a/packages/cli/src/utils/get-config.ts
+++ b/packages/cli/src/utils/get-config.ts
@@ -1,23 +1,23 @@
-import path from "path"
-import { resolveImport } from "@/src/utils/resolve-import"
-import { cosmiconfig } from "cosmiconfig"
-import { loadConfig } from "tsconfig-paths"
-import { z } from "zod"
-
-export const DEFAULT_STYLE = "default"
-export const DEFAULT_COMPONENTS = "@/components"
-export const DEFAULT_COMPONENTS_UI = "@/components/ui"
-export const DEFAULT_COMPONENTS_MAGICUI = "@/components/magicui"
-export const DEFAULT_UTILS = "@/lib/utils"
-export const DEFAULT_TAILWIND_CSS = "app/globals.css"
-export const DEFAULT_TAILWIND_CONFIG = "tailwind.config.js"
-export const DEFAULT_TAILWIND_BASE_COLOR = "slate"
+import path from "path";
+import { resolveImport } from "@/src/utils/resolve-import";
+import { cosmiconfig } from "cosmiconfig";
+import { loadConfig } from "tsconfig-paths";
+import { z } from "zod";
+
+export const DEFAULT_STYLE = "default";
+export const DEFAULT_COMPONENTS = "@/components";
+export const DEFAULT_COMPONENTS_UI = "@/components/ui";
+export const DEFAULT_COMPONENTS_MAGICUI = "@/components/magicui";
+export const DEFAULT_UTILS = "@/lib/utils";
+export const DEFAULT_TAILWIND_CSS = "app/globals.css";
+export const DEFAULT_TAILWIND_CONFIG = "tailwind.config.js";
+export const DEFAULT_TAILWIND_BASE_COLOR = "slate";
// TODO: Figure out if we want to support all cosmiconfig formats.
// A simple components.json file would be nice.
const explorer = cosmiconfig("components", {
searchPlaces: ["components.json"],
-})
+});
export const rawConfigSchema = z
.object({
@@ -39,9 +39,9 @@ export const rawConfigSchema = z
magicui: z.string().optional(),
}),
})
- .strict()
+ .strict();
-export type RawConfig = z.infer<typeof rawConfigSchema>
+export type RawConfig = z.infer<typeof rawConfigSchema>;
export const configSchema = rawConfigSchema.extend({
resolvedPaths: z.object({
@@ -52,44 +52,48 @@ export const configSchema = rawConfigSchema.extend({
ui: z.string(),
magicui: z.string(),
}),
-})
+});
-export type Config = z.infer<typeof configSchema>
+export type Config = z.infer<typeof configSchema>;
export async function getConfig(cwd: string) {
- const config = await getRawConfig(cwd)
+ const config = await getRawConfig(cwd);
if (!config) {
- return null
+ return null;
}
- return await resolveConfigPaths(cwd, config)
+ return await resolveConfigPaths(cwd, config);
}
export async function resolveConfigPaths(cwd: string, config: RawConfig) {
// Read tsconfig.json.
- const tsConfig = await loadConfig(cwd)
+ const tsConfig = await loadConfig(cwd);
if (tsConfig.resultType === "failed") {
throw new Error(
- `Failed to load ${config.tsx ? "tsconfig" : "jsconfig"}.json. ${tsConfig.message ?? ""
- }`.trim()
- )
+ `Failed to load ${config.tsx ? "tsconfig" : "jsconfig"}.json. ${
+ tsConfig.message ?? ""
+ }`.trim(),
+ );
}
- const components = await resolveImport(config.aliases["components"], tsConfig)
- const ui = `${components}/ui`
- const magicui = `${components}/magicui`
+ const components = await resolveImport(
+ config.aliases["components"],
+ tsConfig,
+ );
+ const ui = `${components}/ui`;
+ const magicui = `${components}/magicui`;
const newAliases = {
ui: `${config.aliases.components}/ui`,
- magicui: `${config.aliases.components}/magicui`
- }
+ magicui: `${config.aliases.components}/magicui`,
+ };
const newConfig = {
...config,
aliases: {
...config.aliases,
- ...newAliases
+ ...newAliases,
},
resolvedPaths: {
tailwindConfig: path.resolve(cwd, config.tailwind.config),
@@ -104,20 +108,20 @@ export async function resolveConfigPaths(cwd: string, config: RawConfig) {
// : config.aliases["ui"] ? await resolveImport(config.aliases["ui"], tsConfig)
// : await resolveImport(config.aliases["components"], tsConfig)
},
- }
- return configSchema.parse(newConfig)
+ };
+ return configSchema.parse(newConfig);
}
export async function getRawConfig(cwd: string): Promise<RawConfig | null> {
try {
- const configResult = await explorer.search(cwd)
+ const configResult = await explorer.search(cwd);
if (!configResult) {
- return null
+ return null;
}
- return rawConfigSchema.parse(configResult.config)
+ return rawConfigSchema.parse(configResult.config);
} catch (error) {
- throw new Error(`Invalid configuration found in ${cwd}/components.json.`)
+ throw new Error(`Invalid configuration found in ${cwd}/components.json.`);
}
}
diff --git a/packages/cli/src/utils/get-env.ts b/packages/cli/src/utils/get-env.ts
index 7f13e97d..92fa2efc 100644
--- a/packages/cli/src/utils/get-env.ts
+++ b/packages/cli/src/utils/get-env.ts
@@ -1,20 +1,20 @@
import fs from "fs";
import path from "path";
+import Configstore from "configstore";
import dotenv from "dotenv";
-import Configstore from 'configstore';
const envName = "MAGICUI_PRO_ENV";
const config = new Configstore("magicui");
-export const getEnv = () => config.get(envName) as string | undefined
+export const getEnv = () => config.get(envName) as string | undefined;
export const setEnv = (env: string) => config.set(envName, env);
-export const clearAll = () => config.clear()
+export const clearAll = () => config.clear();
export const login = async (env: string) => {
- try {
- setEnv(env);
- return "Logged in ✅"
- } catch (error) {
- return;
- }
-}
\ No newline at end of file
+ try {
+ setEnv(env);
+ return "Logged in ✅";
+ } catch (error) {
+ return;
+ }
+};
diff --git a/packages/cli/src/utils/get-package-info.ts b/packages/cli/src/utils/get-package-info.ts
index c7f49619..34f19a0f 100644
--- a/packages/cli/src/utils/get-package-info.ts
+++ b/packages/cli/src/utils/get-package-info.ts
@@ -1,9 +1,9 @@
-import path from "path"
-import fs from "fs-extra"
-import { type PackageJson } from "type-fest"
+import path from "path";
+import fs from "fs-extra";
+import { type PackageJson } from "type-fest";
export function getPackageInfo() {
- const packageJsonPath = path.join("package.json")
+ const packageJsonPath = path.join("package.json");
- return fs.readJSONSync(packageJsonPath) as PackageJson
+ return fs.readJSONSync(packageJsonPath) as PackageJson;
}
diff --git a/packages/cli/src/utils/get-package-manager.ts b/packages/cli/src/utils/get-package-manager.ts
index 91efb416..6afed08b 100644
--- a/packages/cli/src/utils/get-package-manager.ts
+++ b/packages/cli/src/utils/get-package-manager.ts
@@ -1,13 +1,13 @@
-import { detect } from "@antfu/ni"
+import { detect } from "@antfu/ni";
export async function getPackageManager(
- targetDir: string
+ targetDir: string,
): Promise<"yarn" | "pnpm" | "bun" | "npm"> {
- const packageManager = await detect({ programmatic: true, cwd: targetDir })
+ const packageManager = await detect({ programmatic: true, cwd: targetDir });
- if (packageManager === "yarn@berry") return "yarn"
- if (packageManager === "pnpm@6") return "pnpm"
- if (packageManager === "bun") return "bun"
+ if (packageManager === "yarn@berry") return "yarn";
+ if (packageManager === "pnpm@6") return "pnpm";
+ if (packageManager === "bun") return "bun";
- return packageManager ?? "npm"
+ return packageManager ?? "npm";
}
diff --git a/packages/cli/src/utils/get-project-info.ts b/packages/cli/src/utils/get-project-info.ts
index 63f3ee83..21baab50 100644
--- a/packages/cli/src/utils/get-project-info.ts
+++ b/packages/cli/src/utils/get-project-info.ts
@@ -1,14 +1,14 @@
-import { existsSync } from "fs"
-import path from "path"
+import { existsSync } from "fs";
+import path from "path";
import {
Config,
- RawConfig,
getConfig,
+ RawConfig,
resolveConfigPaths,
-} from "@/src/utils/get-config"
-import fg from "fast-glob"
-import fs, { pathExists } from "fs-extra"
-import { loadConfig } from "tsconfig-paths"
+} from "@/src/utils/get-config";
+import fg from "fast-glob";
+import fs, { pathExists } from "fs-extra";
+import { loadConfig } from "tsconfig-paths";
// TODO: Add support for more frameworks.
// We'll start with Next.js for now.
@@ -17,9 +17,9 @@ const PROJECT_TYPES = [
"next-app-src",
"next-pages",
"next-pages-src",
-] as const
+] as const;
-type ProjectType = (typeof PROJECT_TYPES)[number]
+type ProjectType = (typeof PROJECT_TYPES)[number];
const PROJECT_SHARED_IGNORE = [
"**/node_modules/**",
@@ -27,7 +27,7 @@ const PROJECT_SHARED_IGNORE = [
"public",
"dist",
"build",
-]
+];
export async function getProjectInfo() {
const info = {
@@ -36,10 +36,10 @@ export async function getProjectInfo() {
appDir: false,
srcComponentsUiDir: false,
componentsUiDir: false,
- }
+ };
try {
- const tsconfig = await getTsConfig()
+ const tsconfig = await getTsConfig();
return {
tsconfig,
@@ -49,43 +49,43 @@ export async function getProjectInfo() {
existsSync(path.resolve("./src/app")),
srcComponentsUiDir: existsSync(path.resolve("./src/components/ui")),
componentsUiDir: existsSync(path.resolve("./components/ui")),
- }
+ };
} catch (error) {
- return info
+ return info;
}
}
export async function getTsConfig() {
try {
- const tsconfigPath = path.join("tsconfig.json")
- const tsconfig = await fs.readJSON(tsconfigPath)
+ const tsconfigPath = path.join("tsconfig.json");
+ const tsconfig = await fs.readJSON(tsconfigPath);
if (!tsconfig) {
- throw new Error("tsconfig.json is missing")
+ throw new Error("tsconfig.json is missing");
}
- return tsconfig
+ return tsconfig;
} catch (error) {
- return null
+ return null;
}
}
export async function getProjectConfig(cwd: string): Promise<Config | null> {
// Check for existing component config.
- const existingConfig = await getConfig(cwd)
+ const existingConfig = await getConfig(cwd);
if (existingConfig) {
- return existingConfig
+ return existingConfig;
}
- const projectType = await getProjectType(cwd)
- const tailwindCssFile = await getTailwindCssFile(cwd)
- const tsConfigAliasPrefix = await getTsConfigAliasPrefix(cwd)
+ const projectType = await getProjectType(cwd);
+ const tailwindCssFile = await getTailwindCssFile(cwd);
+ const tsConfigAliasPrefix = await getTsConfigAliasPrefix(cwd);
if (!projectType || !tailwindCssFile || !tsConfigAliasPrefix) {
- return null
+ return null;
}
- const isTsx = await isTypeScriptProject(cwd)
+ const isTsx = await isTypeScriptProject(cwd);
const config: RawConfig = {
$schema: "https://ui.shadcn.com/schema.json",
@@ -105,9 +105,9 @@ export async function getProjectConfig(cwd: string): Promise<Config | null> {
magicui: `${tsConfigAliasPrefix}/components/magicui`,
ui: `${tsConfigAliasPrefix}/components/ui`,
},
- }
+ };
- return await resolveConfigPaths(cwd, config)
+ return await resolveConfigPaths(cwd, config);
}
export async function getProjectType(cwd: string): Promise<ProjectType | null> {
@@ -115,23 +115,23 @@ export async function getProjectType(cwd: string): Promise<ProjectType | null> {
cwd,
deep: 3,
ignore: PROJECT_SHARED_IGNORE,
- })
+ });
- const isNextProject = files.find((file) => file.startsWith("next.config."))
+ const isNextProject = files.find((file) => file.startsWith("next.config."));
if (!isNextProject) {
- return null
+ return null;
}
- const isUsingSrcDir = await fs.pathExists(path.resolve(cwd, "src"))
+ const isUsingSrcDir = await fs.pathExists(path.resolve(cwd, "src"));
const isUsingAppDir = await fs.pathExists(
- path.resolve(cwd, `${isUsingSrcDir ? "src/" : ""}app`)
- )
+ path.resolve(cwd, `${isUsingSrcDir ? "src/" : ""}app`),
+ );
if (isUsingAppDir) {
- return isUsingSrcDir ? "next-app-src" : "next-app"
+ return isUsingSrcDir ? "next-app-src" : "next-app";
}
- return isUsingSrcDir ? "next-pages-src" : "next-pages"
+ return isUsingSrcDir ? "next-pages-src" : "next-pages";
}
export async function getTailwindCssFile(cwd: string) {
@@ -139,43 +139,43 @@ export async function getTailwindCssFile(cwd: string) {
cwd,
deep: 3,
ignore: PROJECT_SHARED_IGNORE,
- })
+ });
if (!files.length) {
- return null
+ return null;
}
for (const file of files) {
- const contents = await fs.readFile(path.resolve(cwd, file), "utf8")
+ const contents = await fs.readFile(path.resolve(cwd, file), "utf8");
// Assume that if the file contains `@tailwind base` it's the main css file.
if (contents.includes("@tailwind base")) {
- return file
+ return file;
}
}
- return null
+ return null;
}
export async function getTsConfigAliasPrefix(cwd: string) {
- const tsConfig = await loadConfig(cwd)
+ const tsConfig = await loadConfig(cwd);
if (tsConfig?.resultType === "failed" || !tsConfig?.paths) {
- return null
+ return null;
}
// This assume that the first alias is the prefix.
for (const [alias, paths] of Object.entries(tsConfig.paths)) {
if (paths.includes("./*") || paths.includes("./src/*")) {
- return alias.at(0)
+ return alias.at(0);
}
}
- return null
+ return null;
}
export async function isTypeScriptProject(cwd: string) {
// Check if cwd has a tsconfig.json file.
- return pathExists(path.resolve(cwd, "tsconfig.json"))
+ return pathExists(path.resolve(cwd, "tsconfig.json"));
}
export async function preFlight(cwd: string) {
@@ -184,13 +184,13 @@ export async function preFlight(cwd: string) {
cwd,
deep: 3,
ignore: PROJECT_SHARED_IGNORE,
- })
+ });
if (!tailwindConfig.length) {
throw new Error(
- "Tailwind CSS is not installed. Visit https://tailwindcss.com/docs/installation to get started."
- )
+ "Tailwind CSS is not installed. Visit https://tailwindcss.com/docs/installation to get started.",
+ );
}
- return true
+ return true;
}
diff --git a/packages/cli/src/utils/handle-error.ts b/packages/cli/src/utils/handle-error.ts
index 3e366636..cf8d5bc8 100644
--- a/packages/cli/src/utils/handle-error.ts
+++ b/packages/cli/src/utils/handle-error.ts
@@ -1,16 +1,16 @@
-import { logger } from "@/src/utils/logger"
+import { logger } from "@/src/utils/logger";
export function handleError(error: unknown) {
if (typeof error === "string") {
- logger.error(error)
- process.exit(1)
+ logger.error(error);
+ process.exit(1);
}
if (error instanceof Error) {
- logger.error(error.message)
- process.exit(1)
+ logger.error(error.message);
+ process.exit(1);
}
- logger.error("Something went wrong. Please try again.")
- process.exit(1)
+ logger.error("Something went wrong. Please try again.");
+ process.exit(1);
}
diff --git a/packages/cli/src/utils/install-project.ts b/packages/cli/src/utils/install-project.ts
index 74802b8a..1cb7163e 100644
--- a/packages/cli/src/utils/install-project.ts
+++ b/packages/cli/src/utils/install-project.ts
@@ -1,45 +1,57 @@
-import { z } from 'zod'
-import { logger } from './logger'
-import { Readable } from 'node:stream'
-import { createWriteStream } from 'node:fs'
+import { createWriteStream } from "node:fs";
+import { Readable } from "node:stream";
+import { z } from "zod";
-const baseUrl = process.env.PRO_REGISTRY_URL ?? "https://pro.magicui.design"
+import { logger } from "./logger";
+
+const baseUrl = process.env.PRO_REGISTRY_URL ?? "https://pro.magicui.design";
const projectTemplatesSchema = z.object({
- repo: z.string(),
- owner: z.string(),
- description: z.string(),
- preview: z.string()
-})
+ repo: z.string(),
+ owner: z.string(),
+ description: z.string(),
+ preview: z.string(),
+});
export const getAllProjectTemplates = async () => {
- return z.array(projectTemplatesSchema).parse(await fetch(`${baseUrl}/registry/templates.json`).then(e => e.json()))
-}
-
-export const getProjectLink = async (repo: string, owner: string, env:string) => {
- const project = await fetch(`${baseUrl}/api/repo/download`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({ repo, owner, env }),
- }).then(e => e.json())
-
- const linkZod = z.object({
- success: z.boolean(),
- status: z.number(),
- downloadUrl: z.string()
- })
-
- return linkZod.parse(project)
-}
-
-export const getDataAndWrite = async (link:string, pathWithExtension:string) => {
- const response = await fetch(link);
- if (response.ok && response.body) {
- const writer = createWriteStream(pathWithExtension);
- Readable.fromWeb(response.body as any).pipe(writer)
- return true
- }
- return false
-}
\ No newline at end of file
+ return z
+ .array(projectTemplatesSchema)
+ .parse(
+ await fetch(`${baseUrl}/registry/templates.json`).then((e) => e.json()),
+ );
+};
+
+export const getProjectLink = async (
+ repo: string,
+ owner: string,
+ env: string,
+) => {
+ const project = await fetch(`${baseUrl}/api/repo/download`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({ repo, owner, env }),
+ }).then((e) => e.json());
+
+ const linkZod = z.object({
+ success: z.boolean(),
+ status: z.number(),
+ downloadUrl: z.string(),
+ });
+
+ return linkZod.parse(project);
+};
+
+export const getDataAndWrite = async (
+ link: string,
+ pathWithExtension: string,
+) => {
+ const response = await fetch(link);
+ if (response.ok && response.body) {
+ const writer = createWriteStream(pathWithExtension);
+ Readable.fromWeb(response.body as any).pipe(writer);
+ return true;
+ }
+ return false;
+};
diff --git a/packages/cli/src/utils/logger.ts b/packages/cli/src/utils/logger.ts
index 0e61b185..0d6b6a5f 100644
--- a/packages/cli/src/utils/logger.ts
+++ b/packages/cli/src/utils/logger.ts
@@ -1,23 +1,23 @@
-import chalk from "chalk"
+import chalk from "chalk";
import gradient from "gradient-string";
export const logger = {
error(...args: unknown[]) {
- console.log(chalk.red(...args))
+ console.log(chalk.red(...args));
},
warn(...args: unknown[]) {
- console.log(chalk.yellow(...args))
+ console.log(chalk.yellow(...args));
},
info(...args: unknown[]) {
- console.log(chalk.cyan(...args))
+ console.log(chalk.cyan(...args));
},
success(...args: unknown[]) {
- console.log(chalk.green(...args))
+ console.log(chalk.green(...args));
},
break() {
- console.log("")
+ console.log("");
},
-}
+};
const TEXT = `
## ## ## ## ## ####
@@ -28,7 +28,7 @@ const TEXT = `
## ## ## ## ##### ## ## ## ## ## ##
## ## ##### ## #### #### ##### ####
#####
-`
+`;
const PRO = `
## ## ## ## ## #### ######
@@ -39,7 +39,7 @@ const PRO = `
## ## ## ## ##### ## ## ## ## ## ## ## ## ## ##
## ## ##### ## #### #### ##### #### #### #### ####
#####
-`
+`;
const LOGO = `
...:::::::::::::::::::::::::::::::::::::::..
@@ -72,7 +72,7 @@ const LOGO = `
::---------------:::::::::::::::::::::::::............
.::-----------:::::::::::::::::::::::::............
..:::-----::::::::::::::::::::::::::::.......
-`
+`;
const theme = {
// blue: "#add7ff",
@@ -85,9 +85,9 @@ const theme = {
const printer = gradient(Object.values(theme));
-export const ASCII_TEXT = printer.multiline(TEXT)
-export const ASCII_LOGO = printer.multiline(LOGO)
-export const ASCII_PRO = printer.multiline(PRO)
+export const ASCII_TEXT = printer.multiline(TEXT);
+export const ASCII_LOGO = printer.multiline(LOGO);
+export const ASCII_PRO = printer.multiline(PRO);
export const tryPro = `
Try Magic UI Pro for more premium components & blocks.
@@ -112,5 +112,4 @@ Go to Magic UI Pro website for auth secrets.
`;
-
-export const ColorFullText = (string: string) => printer.multiline(string)
\ No newline at end of file
+export const ColorFullText = (string: string) => printer.multiline(string);
diff --git a/packages/cli/src/utils/registry/index.ts b/packages/cli/src/utils/registry/index.ts
index 73cbc95a..ca22297d 100644
--- a/packages/cli/src/utils/registry/index.ts
+++ b/packages/cli/src/utils/registry/index.ts
@@ -1,59 +1,59 @@
-import path from "path"
-import { Config } from "@/src/utils/get-config"
+import path from "path";
+import { Config } from "@/src/utils/get-config";
import {
registryBaseColorSchema,
registryIndexSchema,
registryItemWithContentSchema,
registryWithContentSchema,
stylesSchema,
-} from "@/src/utils/registry/schema"
-import { HttpsProxyAgent } from "https-proxy-agent"
-import fetch from "node-fetch"
-import { z } from "zod"
+} from "@/src/utils/registry/schema";
+import { HttpsProxyAgent } from "https-proxy-agent";
+import fetch from "node-fetch";
+import { z } from "zod";
-const baseUrl = process.env.COMPONENTS_REGISTRY_URL ?? "https://magicui.design"
-const proBaseUrl = process.env.PRO_REGISTRY_URL ?? "https://pro.magicui.design"
-const shadcnBaseUrl = "https://ui.shadcn.com"
+const baseUrl = process.env.COMPONENTS_REGISTRY_URL ?? "https://magicui.design";
+const proBaseUrl = process.env.PRO_REGISTRY_URL ?? "https://pro.magicui.design";
+const shadcnBaseUrl = "https://ui.shadcn.com";
-type theTree = z.infer<typeof registryIndexSchema>
+type theTree = z.infer<typeof registryIndexSchema>;
const agent = process.env.https_proxy
? new HttpsProxyAgent(process.env.https_proxy)
- : undefined
+ : undefined;
-
-export async function getRegistryIndexMagicUI(env?:boolean) {
+export async function getRegistryIndexMagicUI(env?: boolean) {
try {
-
- const [result] = await fetchRegistry(["index.json"], baseUrl)
- const [resultPro] = env ? await fetchRegistry(["index.json"], proBaseUrl) : [[]]
+ const [result] = await fetchRegistry(["index.json"], baseUrl);
+ const [resultPro] = env
+ ? await fetchRegistry(["index.json"], proBaseUrl)
+ : [[]];
// @ts-ignore
- return registryIndexSchema.parse([...result, ...resultPro])
+ return registryIndexSchema.parse([...result, ...resultPro]);
} catch (error) {
- console.error(error)
- throw new Error("Failed to fetch components from Magic UI registry.")
+ console.error(error);
+ throw new Error("Failed to fetch components from Magic UI registry.");
}
}
export async function getRegistryIndexShadcn() {
try {
- const [result] = await fetchRegistry(["index.json"], shadcnBaseUrl)
+ const [result] = await fetchRegistry(["index.json"], shadcnBaseUrl);
- return registryIndexSchema.parse(result)
+ return registryIndexSchema.parse(result);
} catch (error) {
- console.error(error)
- throw new Error("Failed to fetch components from Shadcn UI registry.")
+ console.error(error);
+ throw new Error("Failed to fetch components from Shadcn UI registry.");
}
}
export async function getRegistryStyles() {
try {
- const [result] = await fetchRegistry(["styles/index.json"], shadcnBaseUrl)
+ const [result] = await fetchRegistry(["styles/index.json"], shadcnBaseUrl);
- return stylesSchema.parse(result)
+ return stylesSchema.parse(result);
} catch (error) {
- throw new Error("Failed to fetch styles from registry.")
+ throw new Error("Failed to fetch styles from registry.");
}
}
@@ -79,16 +79,19 @@ export async function getRegistryBaseColors() {
name: "stone",
label: "Stone",
},
- ]
+ ];
}
export async function getRegistryBaseColor(baseColor: string) {
try {
- const [result] = await fetchRegistry([`colors/${baseColor}.json`], shadcnBaseUrl)
+ const [result] = await fetchRegistry(
+ [`colors/${baseColor}.json`],
+ shadcnBaseUrl,
+ );
- return registryBaseColorSchema.parse(result)
+ return registryBaseColorSchema.parse(result);
} catch (error) {
- throw new Error("Failed to fetch base color from registry.")
+ throw new Error("Failed to fetch base color from registry.");
}
}
@@ -96,177 +99,185 @@ export async function resolveTreeWithShadcn(
shadcnIndex: theTree,
index: theTree,
names: string[],
- calledByShadcn = false
-): Promise<{ shadcnTree: theTree, magicuiTree: theTree }> {
-
- const shadcnTree: theTree = []
- const magicuiTree: theTree = []
+ calledByShadcn = false,
+): Promise<{ shadcnTree: theTree; magicuiTree: theTree }> {
+ const shadcnTree: theTree = [];
+ const magicuiTree: theTree = [];
for (const name of names) {
if (!calledByShadcn) {
- const entry = index.find((e) => e.name === name)
+ const entry = index.find((e) => e.name === name);
if (!entry) {
- const newName = name.split(":")[1]
- const shadcnEntry = shadcnIndex.find((e) => e.name === newName)
+ const newName = name.split(":")[1];
+ const shadcnEntry = shadcnIndex.find((e) => e.name === newName);
if (!shadcnEntry) {
- continue
+ continue;
}
- shadcnTree.push(shadcnEntry)
+ shadcnTree.push(shadcnEntry);
if (shadcnEntry.registryDependencies) {
- const { shadcnTree: shadcnTreeDependencies } = await resolveTreeWithShadcn(shadcnIndex,
- index,
- shadcnEntry.registryDependencies,
- true
- )
- shadcnTree.push(...shadcnTreeDependencies)
+ const { shadcnTree: shadcnTreeDependencies } =
+ await resolveTreeWithShadcn(
+ shadcnIndex,
+ index,
+ shadcnEntry.registryDependencies,
+ true,
+ );
+ shadcnTree.push(...shadcnTreeDependencies);
}
}
- entry && magicuiTree.push(entry)
+ entry && magicuiTree.push(entry);
if (entry && entry.registryDependencies) {
-
- const { magicuiTree: magicuiTreeDependencies, shadcnTree: shadcnTreeDependencies } = await resolveTreeWithShadcn(shadcnIndex,
+ const {
+ magicuiTree: magicuiTreeDependencies,
+ shadcnTree: shadcnTreeDependencies,
+ } = await resolveTreeWithShadcn(
+ shadcnIndex,
index,
entry.registryDependencies,
- false
- )
- shadcnTree.push(...shadcnTreeDependencies)
- magicuiTree.push(...magicuiTreeDependencies)
+ false,
+ );
+ shadcnTree.push(...shadcnTreeDependencies);
+ magicuiTree.push(...magicuiTreeDependencies);
}
-
- }
- else {
- const entry = shadcnIndex.find((e) => e.name === name)
+ } else {
+ const entry = shadcnIndex.find((e) => e.name === name);
if (!entry) {
- continue
+ continue;
}
- shadcnTree.push(entry)
+ shadcnTree.push(entry);
if (entry.registryDependencies) {
- const { shadcnTree: shadcnTreeDependencies } = await resolveTreeWithShadcn(shadcnIndex,
- index,
- entry.registryDependencies,
- true
- )
- shadcnTree.push(...shadcnTreeDependencies)
+ const { shadcnTree: shadcnTreeDependencies } =
+ await resolveTreeWithShadcn(
+ shadcnIndex,
+ index,
+ entry.registryDependencies,
+ true,
+ );
+ shadcnTree.push(...shadcnTreeDependencies);
}
}
}
return {
- shadcnTree: shadcnTree.filter((component, index, self) => self.findIndex((c) => c.name === component.name) === index),
- magicuiTree: magicuiTree.filter((component, index, self) => self.findIndex((c) => c.name === component.name) === index),
- }
+ shadcnTree: shadcnTree.filter(
+ (component, index, self) =>
+ self.findIndex((c) => c.name === component.name) === index,
+ ),
+ magicuiTree: magicuiTree.filter(
+ (component, index, self) =>
+ self.findIndex((c) => c.name === component.name) === index,
+ ),
+ };
}
-export async function resolveTree(
- index: theTree,
- names: string[]
-) {
- const tree: theTree = []
+export async function resolveTree(index: theTree, names: string[]) {
+ const tree: theTree = [];
for (const name of names) {
- const entry = index.find((entry) => entry.name === name)
+ const entry = index.find((entry) => entry.name === name);
if (!entry) {
- continue
+ continue;
}
- tree.push(entry)
+ tree.push(entry);
if (entry.registryDependencies) {
- const dependencies = await resolveTree(index, entry.registryDependencies)
- tree.push(...dependencies)
+ const dependencies = await resolveTree(index, entry.registryDependencies);
+ tree.push(...dependencies);
}
}
return tree.filter(
(component, index, self) =>
- self.findIndex((c) => c.name === component.name) === index
- )
+ self.findIndex((c) => c.name === component.name) === index,
+ );
}
-export async function fetchTree(
- tree: theTree, env?: string
-) {
+export async function fetchTree(tree: theTree, env?: string) {
try {
- const treeNormal = tree.filter((item) => !item.type.includes("blocks"))
- const treePro = tree.filter((item) => item.type.includes("blocks"))
+ const treeNormal = tree.filter((item) => !item.type.includes("blocks"));
+ const treePro = tree.filter((item) => item.type.includes("blocks"));
// {baseUrl}/registry/components/magicui/[name].json.
const paths = treeNormal.map((item) => {
- const [parent, subfolder] = item.type.split(":")
- return `${parent}/${subfolder}/${item.name}.json`
- })
- const result = await fetchRegistry(paths, baseUrl)
+ const [parent, subfolder] = item.type.split(":");
+ return `${parent}/${subfolder}/${item.name}.json`;
+ });
+ const result = await fetchRegistry(paths, baseUrl);
const pathsPro = treePro.map((item) => {
- const [parent, subfolder] = item.type.split(":")
- return `${parent}/${subfolder}/${item.name}.json`
- })
- const resultPro = await fetchRegistry(pathsPro, proBaseUrl, env)
+ const [parent, subfolder] = item.type.split(":");
+ return `${parent}/${subfolder}/${item.name}.json`;
+ });
+ const resultPro = await fetchRegistry(pathsPro, proBaseUrl, env);
- return registryWithContentSchema.parse([...result, ...resultPro])
+ return registryWithContentSchema.parse([...result, ...resultPro]);
} catch (error) {
- throw new Error(`Failed to fetch tree from Magic UI registry.`)
+ throw new Error(`Failed to fetch tree from Magic UI registry.`);
}
}
-export async function fetchTreeFromShadcn(
- style: string,
- tree: theTree
-) {
+export async function fetchTreeFromShadcn(style: string, tree: theTree) {
try {
- const paths = tree.map((item) => `styles/${style}/${item.name}.json`)
- const result = await fetchRegistry(paths, shadcnBaseUrl)
+ const paths = tree.map((item) => `styles/${style}/${item.name}.json`);
+ const result = await fetchRegistry(paths, shadcnBaseUrl);
- return registryWithContentSchema.parse(result)
+ return registryWithContentSchema.parse(result);
} catch (error) {
- throw new Error(`Failed to fetch tree from Shadcn UI registry.`)
+ throw new Error(`Failed to fetch tree from Shadcn UI registry.`);
}
}
export async function getItemTargetPath(
config: Config,
item: Pick<z.infer<typeof registryItemWithContentSchema>, "type">,
- override?: string
+ override?: string,
) {
if (override) {
- return override
+ return override;
}
- const [parent, type] = item.type.split(":")
+ const [parent, type] = item.type.split(":");
if (!(parent in config.resolvedPaths)) {
- return null
+ return null;
}
return path.join(
config.resolvedPaths[parent as keyof typeof config.resolvedPaths],
- type
- )
+ type,
+ );
}
-async function fetchRegistry(paths: string[], fetchBaseUrl = baseUrl, env?: string) {
+async function fetchRegistry(
+ paths: string[],
+ fetchBaseUrl = baseUrl,
+ env?: string,
+) {
try {
const results = await Promise.all(
paths.map(async (path) => {
const response = await fetch(`${fetchBaseUrl}/registry/${path}`, {
agent,
- headers: env ? {
- // the Pro registry route will valid this env cookie
- cookie: `x-magicui-env=${env}`
- } : {}
- })
- return await response.json()
- })
- )
- return results
+ headers: env
+ ? {
+ // the Pro registry route will valid this env cookie
+ cookie: `x-magicui-env=${env}`,
+ }
+ : {},
+ });
+ return await response.json();
+ }),
+ );
+ return results;
} catch (error) {
- throw new Error(`Failed to fetch registry from ${fetchBaseUrl}.`)
+ throw new Error(`Failed to fetch registry from ${fetchBaseUrl}.`);
}
}
diff --git a/packages/cli/src/utils/registry/schema.ts b/packages/cli/src/utils/registry/schema.ts
index e4d17636..1443082a 100644
--- a/packages/cli/src/utils/registry/schema.ts
+++ b/packages/cli/src/utils/registry/schema.ts
@@ -1,4 +1,4 @@
-import { z } from "zod"
+import { z } from "zod";
// TODO: Extract this to a shared package.
export const registryItemSchema = z.object({
@@ -7,28 +7,34 @@ export const registryItemSchema = z.object({
devDependencies: z.array(z.string()).optional(),
registryDependencies: z.array(z.string()).optional(),
files: z.array(z.string()),
- type: z.enum(["components:ui", "components:component", "components:example", "components:magicui", "components:blocks",]),
-})
+ type: z.enum([
+ "components:ui",
+ "components:component",
+ "components:example",
+ "components:magicui",
+ "components:blocks",
+ ]),
+});
-export const registryIndexSchema = z.array(registryItemSchema)
+export const registryIndexSchema = z.array(registryItemSchema);
export const registryItemWithContentSchema = registryItemSchema.extend({
files: z.array(
z.object({
name: z.string(),
content: z.string(),
- })
+ }),
),
-})
+});
-export const registryWithContentSchema = z.array(registryItemWithContentSchema)
+export const registryWithContentSchema = z.array(registryItemWithContentSchema);
export const stylesSchema = z.array(
z.object({
name: z.string(),
label: z.string(),
- })
-)
+ }),
+);
export const registryBaseColorSchema = z.object({
inlineColors: z.object({
@@ -41,4 +47,4 @@ export const registryBaseColorSchema = z.object({
}),
inlineColorsTemplate: z.string(),
cssVarsTemplate: z.string(),
-})
+});
diff --git a/packages/cli/src/utils/resolve-import.ts b/packages/cli/src/utils/resolve-import.ts
index 0f029844..18ac294e 100644
--- a/packages/cli/src/utils/resolve-import.ts
+++ b/packages/cli/src/utils/resolve-import.ts
@@ -1,13 +1,16 @@
-import { createMatchPath, type ConfigLoaderSuccessResult } from "tsconfig-paths"
+import {
+ createMatchPath,
+ type ConfigLoaderSuccessResult,
+} from "tsconfig-paths";
export async function resolveImport(
importPath: string,
- config: Pick<ConfigLoaderSuccessResult, "absoluteBaseUrl" | "paths">
+ config: Pick<ConfigLoaderSuccessResult, "absoluteBaseUrl" | "paths">,
) {
return createMatchPath(config.absoluteBaseUrl, config.paths)(
importPath,
undefined,
() => true,
- [".ts", ".tsx"]
- )
+ [".ts", ".tsx"],
+ );
}
diff --git a/packages/cli/src/utils/templates.ts b/packages/cli/src/utils/templates.ts
index f602416b..17c790c1 100644
--- a/packages/cli/src/utils/templates.ts
+++ b/packages/cli/src/utils/templates.ts
@@ -4,7 +4,7 @@ import { twMerge } from "tailwind-merge"
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
-`
+`;
export const UTILS_JS = `import { clsx } from "clsx"
import { twMerge } from "tailwind-merge"
@@ -12,7 +12,7 @@ import { twMerge } from "tailwind-merge"
export function cn(...inputs) {
return twMerge(clsx(inputs))
}
-`
+`;
export const TAILWIND_CONFIG = `/** @type {import('tailwindcss').Config} */
module.exports = {
@@ -50,7 +50,7 @@ module.exports = {
},
},
plugins: [require("tailwindcss-animate")],
-}`
+}`;
export const TAILWIND_CONFIG_WITH_VARIABLES = `/** @type {import('tailwindcss').Config} */
module.exports = {
@@ -128,7 +128,7 @@ module.exports = {
},
},
plugins: [require("tailwindcss-animate")],
-}`
+}`;
export const TAILWIND_CONFIG_TS = `import type { Config } from "tailwindcss"
@@ -169,7 +169,7 @@ const config = {
plugins: [require("tailwindcss-animate")],
} satisfies Config
-export default config`
+export default config`;
export const TAILWIND_CONFIG_TS_WITH_VARIABLES = `import type { Config } from "tailwindcss"
@@ -250,4 +250,4 @@ const config = {
plugins: [require("tailwindcss-animate")],
} satisfies Config
-export default config`
+export default config`;
diff --git a/packages/cli/src/utils/transformers/index.ts b/packages/cli/src/utils/transformers/index.ts
index 88cdb3f3..71a903d4 100644
--- a/packages/cli/src/utils/transformers/index.ts
+++ b/packages/cli/src/utils/transformers/index.ts
@@ -1,58 +1,58 @@
-import { promises as fs } from "fs"
-import { tmpdir } from "os"
-import path from "path"
-import { Config } from "@/src/utils/get-config"
-import { registryBaseColorSchema } from "@/src/utils/registry/schema"
-import { transformCssVars } from "@/src/utils/transformers/transform-css-vars"
-import { transformImport } from "@/src/utils/transformers/transform-import"
-import { transformJsx } from "@/src/utils/transformers/transform-jsx"
-import { transformRsc } from "@/src/utils/transformers/transform-rsc"
-import { Project, ScriptKind, type SourceFile } from "ts-morph"
-import { z } from "zod"
-
-import { transformTwPrefixes } from "./transform-tw-prefix"
+import { promises as fs } from "fs";
+import { tmpdir } from "os";
+import path from "path";
+import { Config } from "@/src/utils/get-config";
+import { registryBaseColorSchema } from "@/src/utils/registry/schema";
+import { transformCssVars } from "@/src/utils/transformers/transform-css-vars";
+import { transformImport } from "@/src/utils/transformers/transform-import";
+import { transformJsx } from "@/src/utils/transformers/transform-jsx";
+import { transformRsc } from "@/src/utils/transformers/transform-rsc";
+import { Project, ScriptKind, type SourceFile } from "ts-morph";
+import { z } from "zod";
+
+import { transformTwPrefixes } from "./transform-tw-prefix";
export type TransformOpts = {
- filename: string
- raw: string
- config: Config
- baseColor?: z.infer<typeof registryBaseColorSchema>
-}
+ filename: string;
+ raw: string;
+ config: Config;
+ baseColor?: z.infer<typeof registryBaseColorSchema>;
+};
export type Transformer<Output = SourceFile> = (
opts: TransformOpts & {
- sourceFile: SourceFile
- }
-) => Promise<Output>
+ sourceFile: SourceFile;
+ },
+) => Promise<Output>;
const transformers: Transformer[] = [
transformImport,
transformRsc,
transformCssVars,
transformTwPrefixes,
-]
+];
const project = new Project({
compilerOptions: {},
-})
+});
async function createTempSourceFile(filename: string) {
- const dir = await fs.mkdtemp(path.join(tmpdir(), "shadcn-"))
- return path.join(dir, filename)
+ const dir = await fs.mkdtemp(path.join(tmpdir(), "shadcn-"));
+ return path.join(dir, filename);
}
export async function transform(opts: TransformOpts) {
- const tempFile = await createTempSourceFile(opts.filename)
+ const tempFile = await createTempSourceFile(opts.filename);
const sourceFile = project.createSourceFile(tempFile, opts.raw, {
scriptKind: ScriptKind.TSX,
- })
+ });
for (const transformer of transformers) {
- transformer({ sourceFile, ...opts })
+ transformer({ sourceFile, ...opts });
}
return await transformJsx({
sourceFile,
...opts,
- })
+ });
}
diff --git a/packages/cli/src/utils/transformers/transform-css-vars.ts b/packages/cli/src/utils/transformers/transform-css-vars.ts
index 95cf973d..13e48591 100644
--- a/packages/cli/src/utils/transformers/transform-css-vars.ts
+++ b/packages/cli/src/utils/transformers/transform-css-vars.ts
@@ -1,7 +1,7 @@
-import { registryBaseColorSchema } from "@/src/utils/registry/schema"
-import { Transformer } from "@/src/utils/transformers"
-import { ScriptKind, SyntaxKind } from "ts-morph"
-import { z } from "zod"
+import { registryBaseColorSchema } from "@/src/utils/registry/schema";
+import { Transformer } from "@/src/utils/transformers";
+import { ScriptKind, SyntaxKind } from "ts-morph";
+import { z } from "zod";
export const transformCssVars: Transformer = async ({
sourceFile,
@@ -10,7 +10,7 @@ export const transformCssVars: Transformer = async ({
}) => {
// No transform if using css variables.
if (config.tailwind?.cssVariables || !baseColor?.inlineColors) {
- return sourceFile
+ return sourceFile;
}
// Find jsx attributes with the name className.
@@ -31,18 +31,18 @@ export const transformCssVars: Transformer = async ({
// }
// }
sourceFile.getDescendantsOfKind(SyntaxKind.StringLiteral).forEach((node) => {
- const value = node.getText()
+ const value = node.getText();
if (value) {
const valueWithColorMapping = applyColorMapping(
value.replace(/"/g, ""),
- baseColor.inlineColors
- )
- node.replaceWithText(`"${valueWithColorMapping.trim()}"`)
+ baseColor.inlineColors,
+ );
+ node.replaceWithText(`"${valueWithColorMapping.trim()}"`);
}
- })
+ });
- return sourceFile
-}
+ return sourceFile;
+};
// export default function transformer(file: FileInfo, api: API) {
// const j = api.jscodeshift.withParser("tsx")
@@ -106,78 +106,78 @@ export const transformCssVars: Transformer = async ({
// eg. hover:bg-primary-100 -> [hover, bg-primary, 100]
export function splitClassName(className: string): (string | null)[] {
if (!className.includes("/") && !className.includes(":")) {
- return [null, className, null]
+ return [null, className, null];
}
- const parts: (string | null)[] = []
+ const parts: (string | null)[] = [];
// First we split to find the alpha.
- let [rest, alpha] = className.split("/")
+ let [rest, alpha] = className.split("/");
// Check if rest has a colon.
if (!rest.includes(":")) {
- return [null, rest, alpha]
+ return [null, rest, alpha];
}
// Next we split the rest by the colon.
- const split = rest.split(":")
+ const split = rest.split(":");
// We take the last item from the split as the name.
- const name = split.pop()
+ const name = split.pop();
// We glue back the rest of the split.
- const variant = split.join(":")
+ const variant = split.join(":");
// Finally we push the variant, name and alpha.
- parts.push(variant ?? null, name ?? null, alpha ?? null)
+ parts.push(variant ?? null, name ?? null, alpha ?? null);
- return parts
+ return parts;
}
-const PREFIXES = ["bg-", "text-", "border-", "ring-offset-", "ring-"]
+const PREFIXES = ["bg-", "text-", "border-", "ring-offset-", "ring-"];
export function applyColorMapping(
input: string,
- mapping: z.infer<typeof registryBaseColorSchema>["inlineColors"]
+ mapping: z.infer<typeof registryBaseColorSchema>["inlineColors"],
) {
// Handle border classes.
if (input.includes(" border ")) {
- input = input.replace(" border ", " border border-border ")
+ input = input.replace(" border ", " border border-border ");
}
// Build color mappings.
- const classNames = input.split(" ")
- const lightMode = new Set<string>()
- const darkMode = new Set<string>()
+ const classNames = input.split(" ");
+ const lightMode = new Set<string>();
+ const darkMode = new Set<string>();
for (let className of classNames) {
- const [variant, value, modifier] = splitClassName(className)
- const prefix = PREFIXES.find((prefix) => value?.startsWith(prefix))
+ const [variant, value, modifier] = splitClassName(className);
+ const prefix = PREFIXES.find((prefix) => value?.startsWith(prefix));
if (!prefix) {
if (!lightMode.has(className)) {
- lightMode.add(className)
+ lightMode.add(className);
}
- continue
+ continue;
}
- const needle = value?.replace(prefix, "")
+ const needle = value?.replace(prefix, "");
if (needle && needle in mapping.light) {
lightMode.add(
[variant, `${prefix}${mapping.light[needle]}`]
.filter(Boolean)
- .join(":") + (modifier ? `/${modifier}` : "")
- )
+ .join(":") + (modifier ? `/${modifier}` : ""),
+ );
darkMode.add(
["dark", variant, `${prefix}${mapping.dark[needle]}`]
.filter(Boolean)
- .join(":") + (modifier ? `/${modifier}` : "")
- )
- continue
+ .join(":") + (modifier ? `/${modifier}` : ""),
+ );
+ continue;
}
if (!lightMode.has(className)) {
- lightMode.add(className)
+ lightMode.add(className);
}
}
- return [...Array.from(lightMode), ...Array.from(darkMode)].join(" ").trim()
+ return [...Array.from(lightMode), ...Array.from(darkMode)].join(" ").trim();
}
diff --git a/packages/cli/src/utils/transformers/transform-import.ts b/packages/cli/src/utils/transformers/transform-import.ts
index 0b912001..5d17a165 100644
--- a/packages/cli/src/utils/transformers/transform-import.ts
+++ b/packages/cli/src/utils/transformers/transform-import.ts
@@ -1,38 +1,38 @@
-import { Transformer } from "@/src/utils/transformers"
+import { Transformer } from "@/src/utils/transformers";
export const transformImport: Transformer = async ({ sourceFile, config }) => {
- const importDeclarations = sourceFile.getImportDeclarations()
+ const importDeclarations = sourceFile.getImportDeclarations();
for (const importDeclaration of importDeclarations) {
- const moduleSpecifier = importDeclaration.getModuleSpecifierValue()
+ const moduleSpecifier = importDeclaration.getModuleSpecifierValue();
// Replace @/registry/[style] with the components alias.
if (moduleSpecifier.startsWith("@/registry/")) {
if (config.aliases.ui) {
importDeclaration.setModuleSpecifier(
- moduleSpecifier.replace(/^@\/registry\/[^/]+\/ui/, config.aliases.ui)
- )
+ moduleSpecifier.replace(/^@\/registry\/[^/]+\/ui/, config.aliases.ui),
+ );
} else {
importDeclaration.setModuleSpecifier(
moduleSpecifier.replace(
/^@\/registry\/[^/]+/,
- config.aliases.components
- )
- )
+ config.aliases.components,
+ ),
+ );
}
}
// Replace `import { cn } from "@/lib/utils"`
if (moduleSpecifier == "@/lib/utils") {
- const namedImports = importDeclaration.getNamedImports()
- const cnImport = namedImports.find((i) => i.getName() === "cn")
+ const namedImports = importDeclaration.getNamedImports();
+ const cnImport = namedImports.find((i) => i.getName() === "cn");
if (cnImport) {
importDeclaration.setModuleSpecifier(
- moduleSpecifier.replace(/^@\/lib\/utils/, config.aliases.utils)
- )
+ moduleSpecifier.replace(/^@\/lib\/utils/, config.aliases.utils),
+ );
}
}
}
- return sourceFile
-}
+ return sourceFile;
+};
diff --git a/packages/cli/src/utils/transformers/transform-jsx.ts b/packages/cli/src/utils/transformers/transform-jsx.ts
index 81f6bb59..348f17a1 100644
--- a/packages/cli/src/utils/transformers/transform-jsx.ts
+++ b/packages/cli/src/utils/transformers/transform-jsx.ts
@@ -1,9 +1,9 @@
-import { type Transformer } from "@/src/utils/transformers"
-import { transformFromAstSync } from "@babel/core"
-import { ParserOptions, parse } from "@babel/parser"
+import { type Transformer } from "@/src/utils/transformers";
+import { transformFromAstSync } from "@babel/core";
+import { parse, ParserOptions } from "@babel/parser";
// @ts-ignore
-import transformTypescript from "@babel/plugin-transform-typescript"
-import * as recast from "recast"
+import transformTypescript from "@babel/plugin-transform-typescript";
+import * as recast from "recast";
// TODO.
// I'm using recast for the AST here.
@@ -59,25 +59,25 @@ const PARSE_OPTIONS: ParserOptions = {
"typescript",
"jsx",
],
-}
+};
export const transformJsx: Transformer<String> = async ({
sourceFile,
config,
}) => {
- const output = sourceFile.getFullText()
+ const output = sourceFile.getFullText();
if (config.tsx) {
- return output
+ return output;
}
const ast = recast.parse(output, {
parser: {
parse: (code: string) => {
- return parse(code, PARSE_OPTIONS)
+ return parse(code, PARSE_OPTIONS);
},
},
- })
+ });
const result = transformFromAstSync(ast, output, {
cloneInputAst: false,
@@ -85,11 +85,11 @@ export const transformJsx: Transformer<String> = async ({
ast: true,
plugins: [transformTypescript],
configFile: false,
- })
+ });
if (!result || !result.ast) {
- throw new Error("Failed to transform JSX")
+ throw new Error("Failed to transform JSX");
}
- return recast.print(result.ast).code
-}
+ return recast.print(result.ast).code;
+};
diff --git a/packages/cli/src/utils/transformers/transform-rsc.ts b/packages/cli/src/utils/transformers/transform-rsc.ts
index b7d24a07..89c483a2 100644
--- a/packages/cli/src/utils/transformers/transform-rsc.ts
+++ b/packages/cli/src/utils/transformers/transform-rsc.ts
@@ -1,16 +1,16 @@
-import { Transformer } from "@/src/utils/transformers"
-import { SyntaxKind } from "ts-morph"
+import { Transformer } from "@/src/utils/transformers";
+import { SyntaxKind } from "ts-morph";
export const transformRsc: Transformer = async ({ sourceFile, config }) => {
if (config.rsc) {
- return sourceFile
+ return sourceFile;
}
// Remove "use client" from the top of the file.
- const first = sourceFile.getFirstChildByKind(SyntaxKind.ExpressionStatement)
+ const first = sourceFile.getFirstChildByKind(SyntaxKind.ExpressionStatement);
if (first?.getText() === `"use client"`) {
- first.remove()
+ first.remove();
}
- return sourceFile
-}
+ return sourceFile;
+};
diff --git a/packages/cli/src/utils/transformers/transform-tw-prefix.ts b/packages/cli/src/utils/transformers/transform-tw-prefix.ts
index 1fed9a88..611f7d7d 100644
--- a/packages/cli/src/utils/transformers/transform-tw-prefix.ts
+++ b/packages/cli/src/utils/transformers/transform-tw-prefix.ts
@@ -1,14 +1,14 @@
-import { Transformer } from "@/src/utils/transformers"
-import { SyntaxKind } from "ts-morph"
+import { Transformer } from "@/src/utils/transformers";
+import { SyntaxKind } from "ts-morph";
-import { splitClassName } from "./transform-css-vars"
+import { splitClassName } from "./transform-css-vars";
export const transformTwPrefixes: Transformer = async ({
sourceFile,
config,
}) => {
if (!config.tailwind?.prefix) {
- return sourceFile
+ return sourceFile;
}
// Find the cva function calls.
@@ -18,14 +18,14 @@ export const transformTwPrefixes: Transformer = async ({
.forEach((node) => {
// cva(base, ...)
if (node.getArguments()[0]?.isKind(SyntaxKind.StringLiteral)) {
- const defaultClassNames = node.getArguments()[0]
+ const defaultClassNames = node.getArguments()[0];
if (defaultClassNames) {
defaultClassNames.replaceWithText(
`"${applyPrefix(
defaultClassNames.getText()?.replace(/"/g, ""),
- config.tailwind.prefix
- )}"`
- )
+ config.tailwind.prefix,
+ )}"`,
+ );
}
}
@@ -41,34 +41,34 @@ export const transformTwPrefixes: Transformer = async ({
.getDescendantsOfKind(SyntaxKind.PropertyAssignment)
.forEach((node) => {
const classNames = node.getInitializerIfKind(
- SyntaxKind.StringLiteral
- )
+ SyntaxKind.StringLiteral,
+ );
if (classNames) {
classNames?.replaceWithText(
`"${applyPrefix(
classNames.getText()?.replace(/"/g, ""),
- config.tailwind.prefix
- )}"`
- )
+ config.tailwind.prefix,
+ )}"`,
+ );
}
- })
- })
+ });
+ });
}
- })
+ });
// Find all jsx attributes with the name className.
sourceFile.getDescendantsOfKind(SyntaxKind.JsxAttribute).forEach((node) => {
if (node.getName() === "className") {
// className="..."
if (node.getInitializer()?.isKind(SyntaxKind.StringLiteral)) {
- const value = node.getInitializer()
+ const value = node.getInitializer();
if (value) {
value.replaceWithText(
`"${applyPrefix(
value.getText()?.replace(/"/g, ""),
- config.tailwind.prefix
- )}"`
- )
+ config.tailwind.prefix,
+ )}"`,
+ );
}
}
@@ -78,7 +78,7 @@ export const transformTwPrefixes: Transformer = async ({
const callExpression = node
.getInitializer()
?.getDescendantsOfKind(SyntaxKind.CallExpression)
- .find((node) => node.getExpression().getText() === "cn")
+ .find((node) => node.getExpression().getText() === "cn");
if (callExpression) {
// Loop through the arguments.
callExpression.getArguments().forEach((node) => {
@@ -92,21 +92,21 @@ export const transformTwPrefixes: Transformer = async ({
node.replaceWithText(
`"${applyPrefix(
node.getText()?.replace(/"/g, ""),
- config.tailwind.prefix
- )}"`
- )
- })
+ config.tailwind.prefix,
+ )}"`,
+ );
+ });
}
if (node.isKind(SyntaxKind.StringLiteral)) {
node.replaceWithText(
`"${applyPrefix(
node.getText()?.replace(/"/g, ""),
- config.tailwind.prefix
- )}"`
- )
+ config.tailwind.prefix,
+ )}"`,
+ );
}
- })
+ });
}
}
}
@@ -119,8 +119,8 @@ export const transformTwPrefixes: Transformer = async ({
.forEach((node) => {
if (node.getInitializer()?.isKind(SyntaxKind.CallExpression)) {
const callExpression = node.getInitializerIfKind(
- SyntaxKind.CallExpression
- )
+ SyntaxKind.CallExpression,
+ );
if (callExpression) {
// Loop through the arguments.
callExpression.getArguments().forEach((arg) => {
@@ -131,71 +131,71 @@ export const transformTwPrefixes: Transformer = async ({
node.replaceWithText(
`"${applyPrefix(
node.getText()?.replace(/"/g, ""),
- config.tailwind.prefix
- )}"`
- )
- })
+ config.tailwind.prefix,
+ )}"`,
+ );
+ });
}
if (arg.isKind(SyntaxKind.StringLiteral)) {
arg.replaceWithText(
`"${applyPrefix(
arg.getText()?.replace(/"/g, ""),
- config.tailwind.prefix
- )}"`
- )
+ config.tailwind.prefix,
+ )}"`,
+ );
}
- })
+ });
}
}
if (node.getInitializer()?.isKind(SyntaxKind.StringLiteral)) {
if (node.getName() !== "variant") {
- const classNames = node.getInitializer()
+ const classNames = node.getInitializer();
if (classNames) {
classNames.replaceWithText(
`"${applyPrefix(
classNames.getText()?.replace(/"/g, ""),
- config.tailwind.prefix
- )}"`
- )
+ config.tailwind.prefix,
+ )}"`,
+ );
}
}
}
- })
+ });
}
}
- })
+ });
- return sourceFile
-}
+ return sourceFile;
+};
export function applyPrefix(input: string, prefix: string = "") {
- const classNames = input.split(" ")
- const prefixed: string[] = []
+ const classNames = input.split(" ");
+ const prefixed: string[] = [];
for (let className of classNames) {
- const [variant, value, modifier] = splitClassName(className)
+ const [variant, value, modifier] = splitClassName(className);
if (variant) {
modifier
? prefixed.push(`${variant}:${prefix}${value}/${modifier}`)
- : prefixed.push(`${variant}:${prefix}${value}`)
+ : prefixed.push(`${variant}:${prefix}${value}`);
} else {
modifier
? prefixed.push(`${prefix}${value}/${modifier}`)
- : prefixed.push(`${prefix}${value}`)
+ : prefixed.push(`${prefix}${value}`);
}
}
- return prefixed.join(" ")
+ return prefixed.join(" ");
}
export function applyPrefixesCss(css: string, prefix: string) {
- const lines = css.split("\n")
+ const lines = css.split("\n");
for (let line of lines) {
if (line.includes("@apply")) {
- const originalTWCls = line.replace("@apply", "").trim()
- const prefixedTwCls = applyPrefix(originalTWCls, prefix)
- css = css.replace(originalTWCls, prefixedTwCls)
+ const originalTWCls = line.replace("@apply", "").trim();
+ const prefixedTwCls = applyPrefix(originalTWCls, prefix);
+ css = css.replace(originalTWCls, prefixedTwCls);
}
}
- return css
+ return css;
}
diff --git a/packages/cli/tsup.config.ts b/packages/cli/tsup.config.ts
index bfcc1790..5ef30a3b 100644
--- a/packages/cli/tsup.config.ts
+++ b/packages/cli/tsup.config.ts
@@ -1,4 +1,4 @@
-import { defineConfig } from "tsup"
+import { defineConfig } from "tsup";
export default defineConfig({
clean: true,
@@ -9,4 +9,4 @@ export default defineConfig({
minify: true,
target: "esnext",
outDir: "dist",
-})
+});
diff --git a/registry/components/example/animated-beam-bidirectional.tsx b/registry/components/example/animated-beam-bidirectional.tsx
index 9ecd6181..5263f9bc 100644
--- a/registry/components/example/animated-beam-bidirectional.tsx
+++ b/registry/components/example/animated-beam-bidirectional.tsx
@@ -1,8 +1,9 @@
"use client";
+import React, { forwardRef, useRef } from "react";
+
import { cn } from "@/lib/utils";
import { AnimatedBeam } from "@/components/magicui/animated-beam";
-import React, { forwardRef, useRef } from "react";
const Circle = forwardRef<
HTMLDivElement,
diff --git a/registry/components/example/animated-beam-demo.tsx b/registry/components/example/animated-beam-demo.tsx
index 98d839ba..da49fb34 100644
--- a/registry/components/example/animated-beam-demo.tsx
+++ b/registry/components/example/animated-beam-demo.tsx
@@ -1,9 +1,10 @@
"use client";
-import { AnimatedBeam } from "@/components/magicui/animated-beam";
-import { cn } from "@/lib/utils";
import React, { forwardRef, useRef } from "react";
+import { cn } from "@/lib/utils";
+import { AnimatedBeam } from "@/components/magicui/animated-beam";
+
const Circle = forwardRef<
HTMLDivElement,
{ className?: string; children?: React.ReactNode }
diff --git a/registry/components/example/animated-beam-multiple-inputs.tsx b/registry/components/example/animated-beam-multiple-inputs.tsx
index c8f7b4b0..f42f2bea 100644
--- a/registry/components/example/animated-beam-multiple-inputs.tsx
+++ b/registry/components/example/animated-beam-multiple-inputs.tsx
@@ -1,8 +1,9 @@
"use client";
+import React, { forwardRef, useRef } from "react";
+
import { cn } from "@/lib/utils";
import { AnimatedBeam } from "@/components/magicui/animated-beam";
-import React, { forwardRef, useRef } from "react";
const Circle = forwardRef<
HTMLDivElement,
diff --git a/registry/components/example/animated-beam-multiple-outputs.tsx b/registry/components/example/animated-beam-multiple-outputs.tsx
index 81303908..708bc647 100644
--- a/registry/components/example/animated-beam-multiple-outputs.tsx
+++ b/registry/components/example/animated-beam-multiple-outputs.tsx
@@ -1,9 +1,10 @@
"use client";
-import { AnimatedBeam } from "@/components/magicui/animated-beam";
-import { cn } from "@/lib/utils";
import React, { forwardRef, useRef } from "react";
+import { cn } from "@/lib/utils";
+import { AnimatedBeam } from "@/components/magicui/animated-beam";
+
const Circle = forwardRef<
HTMLDivElement,
{ className?: string; children?: React.ReactNode }
diff --git a/registry/components/example/animated-beam-unidirectional.tsx b/registry/components/example/animated-beam-unidirectional.tsx
index f2c468fb..e8fda522 100644
--- a/registry/components/example/animated-beam-unidirectional.tsx
+++ b/registry/components/example/animated-beam-unidirectional.tsx
@@ -1,8 +1,9 @@
"use client";
+import React, { forwardRef, useRef } from "react";
+
import { cn } from "@/lib/utils";
import { AnimatedBeam } from "@/components/magicui/animated-beam";
-import React, { forwardRef, useRef } from "react";
const Circle = forwardRef<
HTMLDivElement,
diff --git a/registry/components/example/animated-feature-card-10.tsx b/registry/components/example/animated-feature-card-10.tsx
index 62eb433a..dc7e330d 100644
--- a/registry/components/example/animated-feature-card-10.tsx
+++ b/registry/components/example/animated-feature-card-10.tsx
@@ -1,5 +1,6 @@
"use client";
+import { useEffect, useRef } from "react";
import {
AnimatePresence,
cubicBezier,
@@ -7,7 +8,6 @@ import {
useAnimation,
useInView,
} from "framer-motion";
-import { useEffect, useRef } from "react";
const cardImage = [
{
diff --git a/registry/components/example/animated-feature-card-7.tsx b/registry/components/example/animated-feature-card-7.tsx
index 45ce373e..8deaf8f9 100644
--- a/registry/components/example/animated-feature-card-7.tsx
+++ b/registry/components/example/animated-feature-card-7.tsx
@@ -1,7 +1,6 @@
"use client";
-import { cn } from "@/lib/utils";
-import Marquee from "@/components/magicui/marquee";
+import { useEffect, useId, useRef, useState } from "react";
import { motion, useAnimation, useInView } from "framer-motion";
import {
BarChart,
@@ -11,7 +10,9 @@ import {
Rss,
Shield,
} from "lucide-react";
-import { useEffect, useId, useRef, useState } from "react";
+
+import { cn } from "@/lib/utils";
+import Marquee from "@/components/magicui/marquee";
const tiles = [
{
diff --git a/registry/components/example/animated-feature-card-9.tsx b/registry/components/example/animated-feature-card-9.tsx
index eb3e252a..21a91de3 100644
--- a/registry/components/example/animated-feature-card-9.tsx
+++ b/registry/components/example/animated-feature-card-9.tsx
@@ -1,8 +1,9 @@
"use client";
-import { cn } from "@/lib/utils";
-import { AnimatePresence, motion } from "framer-motion";
import React, { ReactElement, useEffect, useMemo, useState } from "react";
+import { AnimatePresence, motion } from "framer-motion";
+
+import { cn } from "@/lib/utils";
export const AnimatedList = React.memo(
({
diff --git a/registry/components/example/animated-gradient-text-demo.tsx b/registry/components/example/animated-gradient-text-demo.tsx
index a3e17284..317990d8 100644
--- a/registry/components/example/animated-gradient-text-demo.tsx
+++ b/registry/components/example/animated-gradient-text-demo.tsx
@@ -1,6 +1,7 @@
+import { ChevronRight } from "lucide-react";
+
import { cn } from "@/lib/utils";
import AnimatedGradientText from "@/components/magicui/animated-gradient-text";
-import { ChevronRight } from "lucide-react";
export default async function AnimatedGradientTextDemo() {
return (
diff --git a/registry/components/example/animated-shiny-text-demo.tsx b/registry/components/example/animated-shiny-text-demo.tsx
index d3a71247..a06b630d 100644
--- a/registry/components/example/animated-shiny-text-demo.tsx
+++ b/registry/components/example/animated-shiny-text-demo.tsx
@@ -1,7 +1,8 @@
-import AnimatedShinyText from "@/components/magicui/animated-shiny-text";
-import { cn } from "@/lib/utils";
import { ArrowRightIcon } from "@radix-ui/react-icons";
+import { cn } from "@/lib/utils";
+import AnimatedShinyText from "@/components/magicui/animated-shiny-text";
+
export default async function AnimatedShinyTextDemo() {
return (
<div className="z-10 flex min-h-[16rem] items-center justify-center">
diff --git a/registry/components/example/animated-subscribe-button-demo.tsx b/registry/components/example/animated-subscribe-button-demo.tsx
index 5f730b14..97aba8a3 100644
--- a/registry/components/example/animated-subscribe-button-demo.tsx
+++ b/registry/components/example/animated-subscribe-button-demo.tsx
@@ -1,6 +1,7 @@
-import { AnimatedSubscribeButton } from "@/components/magicui/animated-subscribe-button";
import { CheckIcon, ChevronRightIcon } from "lucide-react";
+import { AnimatedSubscribeButton } from "@/components/magicui/animated-subscribe-button";
+
export default function AnimatedSubscribeButtonDemo() {
return (
<AnimatedSubscribeButton
diff --git a/registry/components/example/bento-demo-vertical.tsx b/registry/components/example/bento-demo-vertical.tsx
index 9e7f0407..ca5496ba 100644
--- a/registry/components/example/bento-demo-vertical.tsx
+++ b/registry/components/example/bento-demo-vertical.tsx
@@ -1,4 +1,3 @@
-import { BentoCard, BentoGrid } from "@/components/magicui/bento-grid";
import {
BellIcon,
CalendarIcon,
@@ -7,6 +6,8 @@ import {
InputIcon,
} from "@radix-ui/react-icons";
+import { BentoCard, BentoGrid } from "@/components/magicui/bento-grid";
+
const features = [
{
Icon: FileTextIcon,
diff --git a/registry/components/example/bento-demo.tsx b/registry/components/example/bento-demo.tsx
index 5046d13f..823a2e6d 100644
--- a/registry/components/example/bento-demo.tsx
+++ b/registry/components/example/bento-demo.tsx
@@ -1,6 +1,7 @@
-import AnimatedBeamMultipleOutputDemo from "@/components/example/animated-beam-multiple-outputs";
-import { BentoCard, BentoGrid } from "@/components/magicui/bento-grid";
-import Marquee from "@/components/magicui/marquee";
+import { CalendarIcon, FileTextIcon, InputIcon } from "@radix-ui/react-icons";
+import { Share2Icon } from "lucide-react";
+
+import { cn } from "@/lib/utils";
import { Calendar } from "@/components/ui/calendar";
import {
Command,
@@ -10,9 +11,9 @@ import {
CommandItem,
CommandList,
} from "@/components/ui/command";
-import { cn } from "@/lib/utils";
-import { CalendarIcon, FileTextIcon, InputIcon } from "@radix-ui/react-icons";
-import { Share2Icon } from "lucide-react";
+import AnimatedBeamMultipleOutputDemo from "@/components/example/animated-beam-multiple-outputs";
+import { BentoCard, BentoGrid } from "@/components/magicui/bento-grid";
+import Marquee from "@/components/magicui/marquee";
const files = [
{
diff --git a/registry/components/example/blur-in-demo.tsx b/registry/components/example/blur-in-demo.tsx
index c36b7484..e527f0e9 100644
--- a/registry/components/example/blur-in-demo.tsx
+++ b/registry/components/example/blur-in-demo.tsx
@@ -1,4 +1,5 @@
import BlurIn from "@/components/magicui/blur-in";
+
const BlurInDemo = () => {
return (
<BlurIn
diff --git a/registry/components/example/box-reveal-demo.tsx b/registry/components/example/box-reveal-demo.tsx
index 0f62b45a..1cad1ccb 100644
--- a/registry/components/example/box-reveal-demo.tsx
+++ b/registry/components/example/box-reveal-demo.tsx
@@ -1,5 +1,5 @@
-import BoxReveal from "@/components/magicui/box-reveal";
import { Button } from "@/components/ui/button";
+import BoxReveal from "@/components/magicui/box-reveal";
export default async function BoxRevealDemo() {
return (
diff --git a/registry/components/example/confetti-basic-cannon.tsx b/registry/components/example/confetti-basic-cannon.tsx
index 71a3e8e0..9237d022 100644
--- a/registry/components/example/confetti-basic-cannon.tsx
+++ b/registry/components/example/confetti-basic-cannon.tsx
@@ -1,9 +1,9 @@
-import { ConfettiButton } from "@/components/magicui/confetti";
-
-export default function ConfettiButtonDemo() {
- return (
- <div className="relative">
- <ConfettiButton>Confetti 🎉</ConfettiButton>
- </div>
- );
-}
+import { ConfettiButton } from "@/components/magicui/confetti";
+
+export default function ConfettiButtonDemo() {
+ return (
+ <div className="relative">
+ <ConfettiButton>Confetti 🎉</ConfettiButton>
+ </div>
+ );
+}
diff --git a/registry/components/example/confetti-custom-shapes.tsx b/registry/components/example/confetti-custom-shapes.tsx
index b65201b7..d22e93ea 100644
--- a/registry/components/example/confetti-custom-shapes.tsx
+++ b/registry/components/example/confetti-custom-shapes.tsx
@@ -1,59 +1,60 @@
-import { Button } from "@/components/ui/button";
-import confetti from "canvas-confetti";
-
-export default function ConfettiCustomShapes() {
- const handleClick = () => {
- const scalar = 2;
- const triangle = confetti.shapeFromPath({
- path: "M0 10 L5 0 L10 10z",
- });
- const square = confetti.shapeFromPath({
- path: "M0 0 L10 0 L10 10 L0 10 Z",
- });
- const coin = confetti.shapeFromPath({
- path: "M5 0 A5 5 0 1 0 5 10 A5 5 0 1 0 5 0 Z",
- });
- const tree = confetti.shapeFromPath({
- path: "M5 0 L10 10 L0 10 Z",
- });
-
- const defaults = {
- spread: 360,
- ticks: 60,
- gravity: 0,
- decay: 0.96,
- startVelocity: 20,
- shapes: [triangle, square, coin, tree],
- scalar,
- };
-
- const shoot = () => {
- confetti({
- ...defaults,
- particleCount: 30,
- });
-
- confetti({
- ...defaults,
- particleCount: 5,
- });
-
- confetti({
- ...defaults,
- particleCount: 15,
- scalar: scalar / 2,
- shapes: ["circle"],
- });
- };
-
- setTimeout(shoot, 0);
- setTimeout(shoot, 100);
- setTimeout(shoot, 200);
- };
-
- return (
- <div className="relative flex items-center justify-center">
- <Button onClick={handleClick}>Trigger Shapes</Button>
- </div>
- );
-}
+import confetti from "canvas-confetti";
+
+import { Button } from "@/components/ui/button";
+
+export default function ConfettiCustomShapes() {
+ const handleClick = () => {
+ const scalar = 2;
+ const triangle = confetti.shapeFromPath({
+ path: "M0 10 L5 0 L10 10z",
+ });
+ const square = confetti.shapeFromPath({
+ path: "M0 0 L10 0 L10 10 L0 10 Z",
+ });
+ const coin = confetti.shapeFromPath({
+ path: "M5 0 A5 5 0 1 0 5 10 A5 5 0 1 0 5 0 Z",
+ });
+ const tree = confetti.shapeFromPath({
+ path: "M5 0 L10 10 L0 10 Z",
+ });
+
+ const defaults = {
+ spread: 360,
+ ticks: 60,
+ gravity: 0,
+ decay: 0.96,
+ startVelocity: 20,
+ shapes: [triangle, square, coin, tree],
+ scalar,
+ };
+
+ const shoot = () => {
+ confetti({
+ ...defaults,
+ particleCount: 30,
+ });
+
+ confetti({
+ ...defaults,
+ particleCount: 5,
+ });
+
+ confetti({
+ ...defaults,
+ particleCount: 15,
+ scalar: scalar / 2,
+ shapes: ["circle"],
+ });
+ };
+
+ setTimeout(shoot, 0);
+ setTimeout(shoot, 100);
+ setTimeout(shoot, 200);
+ };
+
+ return (
+ <div className="relative flex items-center justify-center">
+ <Button onClick={handleClick}>Trigger Shapes</Button>
+ </div>
+ );
+}
diff --git a/registry/components/example/confetti-emoji.tsx b/registry/components/example/confetti-emoji.tsx
index 23145c5d..d09a05c1 100644
--- a/registry/components/example/confetti-emoji.tsx
+++ b/registry/components/example/confetti-emoji.tsx
@@ -1,48 +1,49 @@
-import { Button } from "@/components/ui/button";
-import confetti from "canvas-confetti";
-
-export default function ConfettiEmoji() {
- const handleClick = () => {
- const scalar = 2;
- const unicorn = confetti.shapeFromText({ text: "🦄", scalar });
-
- const defaults = {
- spread: 360,
- ticks: 60,
- gravity: 0,
- decay: 0.96,
- startVelocity: 20,
- shapes: [unicorn],
- scalar,
- };
-
- const shoot = () => {
- confetti({
- ...defaults,
- particleCount: 30,
- });
-
- confetti({
- ...defaults,
- particleCount: 5,
- });
-
- confetti({
- ...defaults,
- particleCount: 15,
- scalar: scalar / 2,
- shapes: ["circle"],
- });
- };
-
- setTimeout(shoot, 0);
- setTimeout(shoot, 100);
- setTimeout(shoot, 200);
- };
-
- return (
- <div className="relative justify-center">
- <Button onClick={handleClick}>Trigger Emoji</Button>
- </div>
- );
-}
+import confetti from "canvas-confetti";
+
+import { Button } from "@/components/ui/button";
+
+export default function ConfettiEmoji() {
+ const handleClick = () => {
+ const scalar = 2;
+ const unicorn = confetti.shapeFromText({ text: "🦄", scalar });
+
+ const defaults = {
+ spread: 360,
+ ticks: 60,
+ gravity: 0,
+ decay: 0.96,
+ startVelocity: 20,
+ shapes: [unicorn],
+ scalar,
+ };
+
+ const shoot = () => {
+ confetti({
+ ...defaults,
+ particleCount: 30,
+ });
+
+ confetti({
+ ...defaults,
+ particleCount: 5,
+ });
+
+ confetti({
+ ...defaults,
+ particleCount: 15,
+ scalar: scalar / 2,
+ shapes: ["circle"],
+ });
+ };
+
+ setTimeout(shoot, 0);
+ setTimeout(shoot, 100);
+ setTimeout(shoot, 200);
+ };
+
+ return (
+ <div className="relative justify-center">
+ <Button onClick={handleClick}>Trigger Emoji</Button>
+ </div>
+ );
+}
diff --git a/registry/components/example/confetti-fireworks.tsx b/registry/components/example/confetti-fireworks.tsx
index 86de29a9..19e1f0d5 100644
--- a/registry/components/example/confetti-fireworks.tsx
+++ b/registry/components/example/confetti-fireworks.tsx
@@ -1,39 +1,40 @@
-import { Button } from "@/components/ui/button";
-import confetti from "canvas-confetti";
-
-export default function ConfettiFireworks() {
- const handleClick = () => {
- const duration = 5 * 1000;
- const animationEnd = Date.now() + duration;
- const defaults = { startVelocity: 30, spread: 360, ticks: 60, zIndex: 0 };
-
- const randomInRange = (min: number, max: number) =>
- Math.random() * (max - min) + min;
-
- const interval = window.setInterval(() => {
- const timeLeft = animationEnd - Date.now();
-
- if (timeLeft <= 0) {
- return clearInterval(interval);
- }
-
- const particleCount = 50 * (timeLeft / duration);
- confetti({
- ...defaults,
- particleCount,
- origin: { x: randomInRange(0.1, 0.3), y: Math.random() - 0.2 },
- });
- confetti({
- ...defaults,
- particleCount,
- origin: { x: randomInRange(0.7, 0.9), y: Math.random() - 0.2 },
- });
- }, 250);
- };
-
- return (
- <div className="relative">
- <Button onClick={handleClick}>Trigger Fireworks</Button>
- </div>
- );
-}
+import confetti from "canvas-confetti";
+
+import { Button } from "@/components/ui/button";
+
+export default function ConfettiFireworks() {
+ const handleClick = () => {
+ const duration = 5 * 1000;
+ const animationEnd = Date.now() + duration;
+ const defaults = { startVelocity: 30, spread: 360, ticks: 60, zIndex: 0 };
+
+ const randomInRange = (min: number, max: number) =>
+ Math.random() * (max - min) + min;
+
+ const interval = window.setInterval(() => {
+ const timeLeft = animationEnd - Date.now();
+
+ if (timeLeft <= 0) {
+ return clearInterval(interval);
+ }
+
+ const particleCount = 50 * (timeLeft / duration);
+ confetti({
+ ...defaults,
+ particleCount,
+ origin: { x: randomInRange(0.1, 0.3), y: Math.random() - 0.2 },
+ });
+ confetti({
+ ...defaults,
+ particleCount,
+ origin: { x: randomInRange(0.7, 0.9), y: Math.random() - 0.2 },
+ });
+ }, 250);
+ };
+
+ return (
+ <div className="relative">
+ <Button onClick={handleClick}>Trigger Fireworks</Button>
+ </div>
+ );
+}
diff --git a/registry/components/example/confetti-hover.tsx b/registry/components/example/confetti-hover.tsx
index 9fb7ab61..5af8d244 100644
--- a/registry/components/example/confetti-hover.tsx
+++ b/registry/components/example/confetti-hover.tsx
@@ -1,8 +1,9 @@
"use client";
+import { useRef } from "react";
+
import type { ConfettiRef } from "@/components/magicui/confetti";
import Confetti from "@/components/magicui/confetti";
-import { useRef } from "react";
export default function ConfettiBasicCannon() {
const confettiRef = useRef<ConfettiRef>(null);
diff --git a/registry/components/example/confetti-random-direction.tsx b/registry/components/example/confetti-random-direction.tsx
index 9b28808b..755f1759 100644
--- a/registry/components/example/confetti-random-direction.tsx
+++ b/registry/components/example/confetti-random-direction.tsx
@@ -1,17 +1,17 @@
-import { ConfettiButton } from "@/components/magicui/confetti";
-
-export default function ConfettiButtonDemo() {
- return (
- <div className="relative">
- <ConfettiButton
- options={{
- get angle() {
- return Math.random() * 360;
- },
- }}
- >
- Random Confetti 🎉
- </ConfettiButton>
- </div>
- );
-}
+import { ConfettiButton } from "@/components/magicui/confetti";
+
+export default function ConfettiButtonDemo() {
+ return (
+ <div className="relative">
+ <ConfettiButton
+ options={{
+ get angle() {
+ return Math.random() * 360;
+ },
+ }}
+ >
+ Random Confetti 🎉
+ </ConfettiButton>
+ </div>
+ );
+}
diff --git a/registry/components/example/confetti-side-cannons.tsx b/registry/components/example/confetti-side-cannons.tsx
index f6a4e746..01a29508 100644
--- a/registry/components/example/confetti-side-cannons.tsx
+++ b/registry/components/example/confetti-side-cannons.tsx
@@ -1,40 +1,41 @@
-import { Button } from "@/components/ui/button";
-import confetti from "canvas-confetti";
-
-export default function ConfettiSideCannons() {
- const handleClick = () => {
- const end = Date.now() + 3 * 1000; // 3 seconds
- const colors = ["#a786ff", "#fd8bbc", "#eca184", "#f8deb1"];
-
- const frame = () => {
- if (Date.now() > end) return;
-
- confetti({
- particleCount: 2,
- angle: 60,
- spread: 55,
- startVelocity: 60,
- origin: { x: 0, y: 0.5 },
- colors: colors,
- });
- confetti({
- particleCount: 2,
- angle: 120,
- spread: 55,
- startVelocity: 60,
- origin: { x: 1, y: 0.5 },
- colors: colors,
- });
-
- requestAnimationFrame(frame);
- };
-
- frame();
- };
-
- return (
- <div className="relative">
- <Button onClick={handleClick}>Trigger Side Cannons</Button>
- </div>
- );
-}
+import confetti from "canvas-confetti";
+
+import { Button } from "@/components/ui/button";
+
+export default function ConfettiSideCannons() {
+ const handleClick = () => {
+ const end = Date.now() + 3 * 1000; // 3 seconds
+ const colors = ["#a786ff", "#fd8bbc", "#eca184", "#f8deb1"];
+
+ const frame = () => {
+ if (Date.now() > end) return;
+
+ confetti({
+ particleCount: 2,
+ angle: 60,
+ spread: 55,
+ startVelocity: 60,
+ origin: { x: 0, y: 0.5 },
+ colors: colors,
+ });
+ confetti({
+ particleCount: 2,
+ angle: 120,
+ spread: 55,
+ startVelocity: 60,
+ origin: { x: 1, y: 0.5 },
+ colors: colors,
+ });
+
+ requestAnimationFrame(frame);
+ };
+
+ frame();
+ };
+
+ return (
+ <div className="relative">
+ <Button onClick={handleClick}>Trigger Side Cannons</Button>
+ </div>
+ );
+}
diff --git a/registry/components/example/confetti-stars.tsx b/registry/components/example/confetti-stars.tsx
index 9c62e350..6cc9b884 100644
--- a/registry/components/example/confetti-stars.tsx
+++ b/registry/components/example/confetti-stars.tsx
@@ -1,41 +1,42 @@
-import { Button } from "@/components/ui/button";
-import confetti from "canvas-confetti";
-
-export default function ConfettiStars() {
- const handleClick = () => {
- const defaults = {
- spread: 360,
- ticks: 50,
- gravity: 0,
- decay: 0.94,
- startVelocity: 30,
- colors: ["#FFE400", "#FFBD00", "#E89400", "#FFCA6C", "#FDFFB8"],
- };
-
- const shoot = () => {
- confetti({
- ...defaults,
- particleCount: 40,
- scalar: 1.2,
- shapes: ["star"],
- });
-
- confetti({
- ...defaults,
- particleCount: 10,
- scalar: 0.75,
- shapes: ["circle"],
- });
- };
-
- setTimeout(shoot, 0);
- setTimeout(shoot, 100);
- setTimeout(shoot, 200);
- };
-
- return (
- <div className="relative">
- <Button onClick={handleClick}>Trigger Stars</Button>
- </div>
- );
-}
+import confetti from "canvas-confetti";
+
+import { Button } from "@/components/ui/button";
+
+export default function ConfettiStars() {
+ const handleClick = () => {
+ const defaults = {
+ spread: 360,
+ ticks: 50,
+ gravity: 0,
+ decay: 0.94,
+ startVelocity: 30,
+ colors: ["#FFE400", "#FFBD00", "#E89400", "#FFCA6C", "#FDFFB8"],
+ };
+
+ const shoot = () => {
+ confetti({
+ ...defaults,
+ particleCount: 40,
+ scalar: 1.2,
+ shapes: ["star"],
+ });
+
+ confetti({
+ ...defaults,
+ particleCount: 10,
+ scalar: 0.75,
+ shapes: ["circle"],
+ });
+ };
+
+ setTimeout(shoot, 0);
+ setTimeout(shoot, 100);
+ setTimeout(shoot, 200);
+ };
+
+ return (
+ <div className="relative">
+ <Button onClick={handleClick}>Trigger Stars</Button>
+ </div>
+ );
+}
diff --git a/registry/components/example/cool-mode-custom.tsx b/registry/components/example/cool-mode-custom.tsx
index 64f386fb..7bffa6f0 100644
--- a/registry/components/example/cool-mode-custom.tsx
+++ b/registry/components/example/cool-mode-custom.tsx
@@ -1,17 +1,17 @@
-import { CoolMode } from "@/components/magicui/cool-mode";
-import { Button } from "@/components/ui/button";
-
-export default function CoolModeCustom() {
- return (
- <div className="relative justify-center">
- <CoolMode
- options={{
- particle:
- "https://pbs.twimg.com/profile_images/1782811051504885763/YR5-kWOI_400x400.jpg",
- }}
- >
- <Button>Click Me!</Button>
- </CoolMode>
- </div>
- );
-}
+import { Button } from "@/components/ui/button";
+import { CoolMode } from "@/components/magicui/cool-mode";
+
+export default function CoolModeCustom() {
+ return (
+ <div className="relative justify-center">
+ <CoolMode
+ options={{
+ particle:
+ "https://pbs.twimg.com/profile_images/1782811051504885763/YR5-kWOI_400x400.jpg",
+ }}
+ >
+ <Button>Click Me!</Button>
+ </CoolMode>
+ </div>
+ );
+}
diff --git a/registry/components/example/cool-mode-demo.tsx b/registry/components/example/cool-mode-demo.tsx
index 32457a51..b73e7d85 100644
--- a/registry/components/example/cool-mode-demo.tsx
+++ b/registry/components/example/cool-mode-demo.tsx
@@ -1,12 +1,12 @@
-import { CoolMode } from "@/components/magicui/cool-mode";
-import { Button } from "@/components/ui/button";
-
-export default function CoolModeDemo() {
- return (
- <div className="relative justify-center">
- <CoolMode>
- <Button>Click Me!</Button>
- </CoolMode>
- </div>
- );
-}
+import { Button } from "@/components/ui/button";
+import { CoolMode } from "@/components/magicui/cool-mode";
+
+export default function CoolModeDemo() {
+ return (
+ <div className="relative justify-center">
+ <CoolMode>
+ <Button>Click Me!</Button>
+ </CoolMode>
+ </div>
+ );
+}
diff --git a/registry/components/example/dock-demo.tsx b/registry/components/example/dock-demo.tsx
index 83fcde72..5cbc8e6c 100644
--- a/registry/components/example/dock-demo.tsx
+++ b/registry/components/example/dock-demo.tsx
@@ -1,6 +1,7 @@
-import { Dock, DockIcon } from "@/components/magicui/dock";
import React from "react";
+import { Dock, DockIcon } from "@/components/magicui/dock";
+
export type IconProps = React.HTMLAttributes<SVGElement>;
export default function DockDemo() {
diff --git a/registry/components/example/gauge-circle-demo.tsx b/registry/components/example/gauge-circle-demo.tsx
index 5afc03ed..edf5021f 100644
--- a/registry/components/example/gauge-circle-demo.tsx
+++ b/registry/components/example/gauge-circle-demo.tsx
@@ -1,8 +1,9 @@
"use client";
-import GaugeCircle from "@/components/magicui/gauge-circle";
import { useEffect, useState } from "react";
+import GaugeCircle from "@/components/magicui/gauge-circle";
+
export default function GaugeCircleDemo() {
const [value, setValue] = useState(0);
diff --git a/registry/components/example/magic-card-demo.tsx b/registry/components/example/magic-card-demo.tsx
index 445adbf9..dd9697d4 100644
--- a/registry/components/example/magic-card-demo.tsx
+++ b/registry/components/example/magic-card-demo.tsx
@@ -1,7 +1,4 @@
-import {
- MagicCard,
- MagicContainer,
-} from "@/components/magicui/magic-card";
+import { MagicCard, MagicContainer } from "@/components/magicui/magic-card";
export default function MagicCardDemo() {
return (
diff --git a/registry/components/example/magic-card-gradient.tsx b/registry/components/example/magic-card-gradient.tsx
index 5aa56419..deb7a34f 100644
--- a/registry/components/example/magic-card-gradient.tsx
+++ b/registry/components/example/magic-card-gradient.tsx
@@ -1,7 +1,4 @@
-import {
- MagicCard,
- MagicContainer,
-} from "@/components/magicui/magic-card";
+import { MagicCard, MagicContainer } from "@/components/magicui/magic-card";
export default function MagicCardGradient() {
return (
diff --git a/registry/components/example/particles-demo.tsx b/registry/components/example/particles-demo.tsx
index 68dfef9b..b6bd3c81 100644
--- a/registry/components/example/particles-demo.tsx
+++ b/registry/components/example/particles-demo.tsx
@@ -1,8 +1,9 @@
"use client";
-import Particles from "@/components/magicui/particles";
-import { useTheme } from "next-themes";
import { useEffect, useState } from "react";
+import { useTheme } from "next-themes";
+
+import Particles from "@/components/magicui/particles";
const ParticlesDemo = () => {
const { theme } = useTheme();
diff --git a/registry/components/magicui/animated-beam.tsx b/registry/components/magicui/animated-beam.tsx
index 50bdbf15..2f64c65b 100644
--- a/registry/components/magicui/animated-beam.tsx
+++ b/registry/components/magicui/animated-beam.tsx
@@ -1,8 +1,9 @@
"use client";
-import { cn } from "@/lib/utils";
-import { motion } from "framer-motion";
import { RefObject, useEffect, useId, useState } from "react";
+import { motion } from "framer-motion";
+
+import { cn } from "@/lib/utils";
export interface AnimatedBeamProps {
className?: string;
diff --git a/registry/components/magicui/animated-gradient-text.tsx b/registry/components/magicui/animated-gradient-text.tsx
index 5f2a90e0..19b0e628 100644
--- a/registry/components/magicui/animated-gradient-text.tsx
+++ b/registry/components/magicui/animated-gradient-text.tsx
@@ -1,6 +1,7 @@
-import { cn } from "@/lib/utils";
import { ReactNode } from "react";
+import { cn } from "@/lib/utils";
+
export default function AnimatedGradientText({
children,
className,
diff --git a/registry/components/magicui/animated-grid-pattern.tsx b/registry/components/magicui/animated-grid-pattern.tsx
index 117521ac..b74dc0c5 100644
--- a/registry/components/magicui/animated-grid-pattern.tsx
+++ b/registry/components/magicui/animated-grid-pattern.tsx
@@ -1,8 +1,9 @@
"use client";
-import { cn } from "@/lib/utils";
-import { motion } from "framer-motion";
import { useEffect, useId, useRef, useState } from "react";
+import { motion } from "framer-motion";
+
+import { cn } from "@/lib/utils";
interface GridPatternProps {
width?: number;
diff --git a/registry/components/magicui/animated-list.tsx b/registry/components/magicui/animated-list.tsx
index ac69de20..d9928c9a 100644
--- a/registry/components/magicui/animated-list.tsx
+++ b/registry/components/magicui/animated-list.tsx
@@ -1,7 +1,7 @@
"use client";
-import { AnimatePresence, motion } from "framer-motion";
import React, { ReactElement, useEffect, useMemo, useState } from "react";
+import { AnimatePresence, motion } from "framer-motion";
export const AnimatedList = React.memo(
({
diff --git a/registry/components/magicui/animated-shiny-text.tsx b/registry/components/magicui/animated-shiny-text.tsx
index 602b914b..7071ceb7 100644
--- a/registry/components/magicui/animated-shiny-text.tsx
+++ b/registry/components/magicui/animated-shiny-text.tsx
@@ -1,6 +1,7 @@
-import { cn } from "@/lib/utils";
import { CSSProperties, FC, ReactNode } from "react";
+import { cn } from "@/lib/utils";
+
interface AnimatedShinyTextProps {
children: ReactNode;
className?: string;
diff --git a/registry/components/magicui/animated-subscribe-button.tsx b/registry/components/magicui/animated-subscribe-button.tsx
index 236554fe..707f2ef7 100644
--- a/registry/components/magicui/animated-subscribe-button.tsx
+++ b/registry/components/magicui/animated-subscribe-button.tsx
@@ -1,7 +1,7 @@
"use client";
-import { AnimatePresence, motion } from "framer-motion";
import React, { useState } from "react";
+import { AnimatePresence, motion } from "framer-motion";
interface AnimatedSubscribeButtonProps {
buttonColor: string;
diff --git a/registry/components/magicui/avatar-circles.tsx b/registry/components/magicui/avatar-circles.tsx
index ca6eb0ce..aa69cef9 100644
--- a/registry/components/magicui/avatar-circles.tsx
+++ b/registry/components/magicui/avatar-circles.tsx
@@ -1,15 +1,20 @@
"use client";
-import { cn } from "@/lib/utils";
import React from "react";
+import { cn } from "@/lib/utils";
+
interface AvatarCirclesProps {
className?: string;
numPeople?: number;
avatarUrls: string[];
}
-const AvatarCircles = ({ numPeople, className, avatarUrls }: AvatarCirclesProps) => {
+const AvatarCircles = ({
+ numPeople,
+ className,
+ avatarUrls,
+}: AvatarCirclesProps) => {
return (
<div className={cn("z-10 flex -space-x-4 rtl:space-x-reverse", className)}>
{avatarUrls.map((url, index) => (
diff --git a/registry/components/magicui/bento-grid.tsx b/registry/components/magicui/bento-grid.tsx
index f7c1ef2f..342a9575 100644
--- a/registry/components/magicui/bento-grid.tsx
+++ b/registry/components/magicui/bento-grid.tsx
@@ -1,7 +1,8 @@
-import { Button } from "@/components/ui/button";
-import { cn } from "@/lib/utils";
-import { ArrowRightIcon } from "@radix-ui/react-icons";
import { ReactNode } from "react";
+import { ArrowRightIcon } from "@radix-ui/react-icons";
+
+import { cn } from "@/lib/utils";
+import { Button } from "@/components/ui/button";
const BentoGrid = ({
children,
diff --git a/registry/components/magicui/blur-in.tsx b/registry/components/magicui/blur-in.tsx
index e003669f..2a2dd0af 100644
--- a/registry/components/magicui/blur-in.tsx
+++ b/registry/components/magicui/blur-in.tsx
@@ -1,5 +1,7 @@
"use client";
+
import { motion } from "framer-motion";
+
import { cn } from "@/lib/utils";
interface BlurIntProps {
diff --git a/registry/components/magicui/box-reveal.tsx b/registry/components/magicui/box-reveal.tsx
index acf5f1d3..b3535416 100644
--- a/registry/components/magicui/box-reveal.tsx
+++ b/registry/components/magicui/box-reveal.tsx
@@ -1,7 +1,7 @@
"use client";
-import { motion, useAnimation, useInView } from "framer-motion";
import { useEffect, useRef } from "react";
+import { motion, useAnimation, useInView } from "framer-motion";
interface BoxRevealProps {
children: JSX.Element;
diff --git a/registry/components/magicui/client-tweet-card.tsx b/registry/components/magicui/client-tweet-card.tsx
index babeefce..7e44d23e 100644
--- a/registry/components/magicui/client-tweet-card.tsx
+++ b/registry/components/magicui/client-tweet-card.tsx
@@ -1,11 +1,12 @@
"use client";
+import { TweetProps, useTweet } from "react-tweet";
+
import {
MagicTweet,
TweetNotFound,
TweetSkeleton,
} from "@/components/magicui/tweet-card";
-import { TweetProps, useTweet } from "react-tweet";
const ClientTweetCard = ({
id,
diff --git a/registry/components/magicui/confetti-button.tsx b/registry/components/magicui/confetti-button.tsx
index 32b12c81..5583632c 100644
--- a/registry/components/magicui/confetti-button.tsx
+++ b/registry/components/magicui/confetti-button.tsx
@@ -1,14 +1,14 @@
"use client";
-import { Button, ButtonProps } from "@/components/ui/button";
-import confetti from "canvas-confetti";
import React from "react";
-
+import confetti from "canvas-confetti";
import type {
GlobalOptions as ConfettiGlobalOptions,
Options as ConfettiOptions,
} from "canvas-confetti";
+import { Button, ButtonProps } from "@/components/ui/button";
+
interface ConfettiButtonProps extends ButtonProps {
options?: ConfettiOptions &
ConfettiGlobalOptions & { canvas?: HTMLCanvasElement };
diff --git a/registry/components/magicui/confetti.tsx b/registry/components/magicui/confetti.tsx
index 2f59dd9c..c28443cf 100644
--- a/registry/components/magicui/confetti.tsx
+++ b/registry/components/magicui/confetti.tsx
@@ -1,126 +1,125 @@
-import { Button, ButtonProps } from "@/components/ui/button";
-import confetti from "canvas-confetti";
-import type { ReactNode } from "react";
-import React, {
- createContext,
- forwardRef,
- useCallback,
- useEffect,
- useImperativeHandle,
- useMemo,
- useRef,
-} from "react";
-
-import type {
- GlobalOptions as ConfettiGlobalOptions,
- Options as ConfettiOptions,
-} from "canvas-confetti";
-
-import type { CreateTypes as ConfettiInstance } from "canvas-confetti";
-
-type Api = {
- fire: (options?: ConfettiOptions) => void;
-};
-
-type Props = React.ComponentPropsWithRef<"canvas"> & {
- options?: ConfettiOptions;
- globalOptions?: ConfettiGlobalOptions;
- manualstart?: boolean;
- children?: ReactNode;
-};
-
-export type ConfettiRef = Api | null;
-
-const ConfettiContext = createContext<Api>({} as Api);
-
-const Confetti = forwardRef<ConfettiRef, Props>((props, ref) => {
- const {
- options,
- globalOptions = { resize: true, useWorker: true },
- manualstart = false,
- children,
- ...rest
- } = props;
- const instanceRef = useRef<ConfettiInstance | null>(null); // confetti instance
-
- const canvasRef = useCallback(
- // https://react.dev/reference/react-dom/components/common#ref-callback
- // https://reactjs.org/docs/refs-and-the-dom.html#callback-refs
- (node: HTMLCanvasElement) => {
- if (node !== null) {
- // <canvas> is mounted => create the confetti instance
- if (instanceRef.current) return; // if not already created
- instanceRef.current = confetti.create(node, {
- ...globalOptions,
- resize: true,
- });
- } else {
- // <canvas> is unmounted => reset and destroy instanceRef
- if (instanceRef.current) {
- instanceRef.current.reset();
- instanceRef.current = null;
- }
- }
- },
- [globalOptions],
- );
-
- // `fire` is a function that calls the instance() with `opts` merged with `options`
- const fire = useCallback(
- (opts = {}) => instanceRef.current?.({ ...options, ...opts }),
- [options],
- );
-
- const api = useMemo(
- () => ({
- fire,
- }),
- [fire],
- );
-
- useImperativeHandle(ref, () => api, [api]);
-
- useEffect(() => {
- if (!manualstart) {
- fire();
- }
- }, [manualstart, fire]);
-
- return (
- <ConfettiContext.Provider value={api}>
- <canvas ref={canvasRef} {...rest} />
- {children}
- </ConfettiContext.Provider>
- );
-});
-
-interface ConfettiButtonProps extends ButtonProps {
- options?: ConfettiOptions &
- ConfettiGlobalOptions & { canvas?: HTMLCanvasElement };
- children?: React.ReactNode;
-}
-
-function ConfettiButton({ options, children, ...props }: ConfettiButtonProps) {
- const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
- const rect = event.currentTarget.getBoundingClientRect();
- const x = rect.left + rect.width / 2;
- const y = rect.top + rect.height / 2;
- confetti({
- ...options,
- origin: {
- x: x / window.innerWidth,
- y: y / window.innerHeight,
- },
- });
- };
-
- return (
- <Button onClick={handleClick} {...props}>
- {children}
- </Button>
- );
-}
-
-export { Confetti, ConfettiButton };
-
-export default Confetti;
+import type { ReactNode } from "react";
+import React, {
+ createContext,
+ forwardRef,
+ useCallback,
+ useEffect,
+ useImperativeHandle,
+ useMemo,
+ useRef,
+} from "react";
+import confetti from "canvas-confetti";
+import type {
+ GlobalOptions as ConfettiGlobalOptions,
+ CreateTypes as ConfettiInstance,
+ Options as ConfettiOptions,
+} from "canvas-confetti";
+
+import { Button, ButtonProps } from "@/components/ui/button";
+
+type Api = {
+ fire: (options?: ConfettiOptions) => void;
+};
+
+type Props = React.ComponentPropsWithRef<"canvas"> & {
+ options?: ConfettiOptions;
+ globalOptions?: ConfettiGlobalOptions;
+ manualstart?: boolean;
+ children?: ReactNode;
+};
+
+export type ConfettiRef = Api | null;
+
+const ConfettiContext = createContext<Api>({} as Api);
+
+const Confetti = forwardRef<ConfettiRef, Props>((props, ref) => {
+ const {
+ options,
+ globalOptions = { resize: true, useWorker: true },
+ manualstart = false,
+ children,
+ ...rest
+ } = props;
+ const instanceRef = useRef<ConfettiInstance | null>(null); // confetti instance
+
+ const canvasRef = useCallback(
+ // https://react.dev/reference/react-dom/components/common#ref-callback
+ // https://reactjs.org/docs/refs-and-the-dom.html#callback-refs
+ (node: HTMLCanvasElement) => {
+ if (node !== null) {
+ // <canvas> is mounted => create the confetti instance
+ if (instanceRef.current) return; // if not already created
+ instanceRef.current = confetti.create(node, {
+ ...globalOptions,
+ resize: true,
+ });
+ } else {
+ // <canvas> is unmounted => reset and destroy instanceRef
+ if (instanceRef.current) {
+ instanceRef.current.reset();
+ instanceRef.current = null;
+ }
+ }
+ },
+ [globalOptions],
+ );
+
+ // `fire` is a function that calls the instance() with `opts` merged with `options`
+ const fire = useCallback(
+ (opts = {}) => instanceRef.current?.({ ...options, ...opts }),
+ [options],
+ );
+
+ const api = useMemo(
+ () => ({
+ fire,
+ }),
+ [fire],
+ );
+
+ useImperativeHandle(ref, () => api, [api]);
+
+ useEffect(() => {
+ if (!manualstart) {
+ fire();
+ }
+ }, [manualstart, fire]);
+
+ return (
+ <ConfettiContext.Provider value={api}>
+ <canvas ref={canvasRef} {...rest} />
+ {children}
+ </ConfettiContext.Provider>
+ );
+});
+
+interface ConfettiButtonProps extends ButtonProps {
+ options?: ConfettiOptions &
+ ConfettiGlobalOptions & { canvas?: HTMLCanvasElement };
+ children?: React.ReactNode;
+}
+
+function ConfettiButton({ options, children, ...props }: ConfettiButtonProps) {
+ const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
+ const rect = event.currentTarget.getBoundingClientRect();
+ const x = rect.left + rect.width / 2;
+ const y = rect.top + rect.height / 2;
+ confetti({
+ ...options,
+ origin: {
+ x: x / window.innerWidth,
+ y: y / window.innerHeight,
+ },
+ });
+ };
+
+ return (
+ <Button onClick={handleClick} {...props}>
+ {children}
+ </Button>
+ );
+}
+
+export { Confetti, ConfettiButton };
+
+export default Confetti;
diff --git a/registry/components/magicui/cool-mode.tsx b/registry/components/magicui/cool-mode.tsx
index 6d8d748f..387b9a9a 100644
--- a/registry/components/magicui/cool-mode.tsx
+++ b/registry/components/magicui/cool-mode.tsx
@@ -1,238 +1,238 @@
-import React, { ReactNode, RefObject, useEffect, useRef } from "react";
-
-export interface BaseParticle {
- element: HTMLElement | SVGSVGElement;
- left: number;
- size: number;
- top: number;
-}
-
-export interface BaseParticleOptions {
- particle?: string;
- size?: number;
-}
-
-export interface CoolParticle extends BaseParticle {
- direction: number;
- speedHorz: number;
- speedUp: number;
- spinSpeed: number;
- spinVal: number;
-}
-
-export interface CoolParticleOptions extends BaseParticleOptions {
- particleCount?: number;
- speedHorz?: number;
- speedUp?: number;
-}
-
-const getContainer = () => {
- const id = "_coolMode_effect";
- let existingContainer = document.getElementById(id);
-
- if (existingContainer) {
- return existingContainer;
- }
-
- const container = document.createElement("div");
- container.setAttribute("id", id);
- container.setAttribute(
- "style",
- "overflow:hidden; position:fixed; height:100%; top:0; left:0; right:0; bottom:0; pointer-events:none; z-index:2147483647",
- );
-
- document.body.appendChild(container);
-
- return container;
-};
-
-let instanceCounter = 0;
-
-const applyParticleEffect = (
- element: HTMLElement,
- options?: CoolParticleOptions,
-): (() => void) => {
- instanceCounter++;
-
- const defaultParticle = "circle";
- const particleType = options?.particle || defaultParticle;
- const sizes = [15, 20, 25, 35, 45];
- const limit = 45;
-
- let particles: CoolParticle[] = [];
- let autoAddParticle = false;
- let mouseX = 0;
- let mouseY = 0;
-
- const container = getContainer();
-
- function generateParticle() {
- const size =
- options?.size || sizes[Math.floor(Math.random() * sizes.length)];
- const speedHorz = options?.speedHorz || Math.random() * 10;
- const speedUp = options?.speedUp || Math.random() * 25;
- const spinVal = Math.random() * 360;
- const spinSpeed = Math.random() * 35 * (Math.random() <= 0.5 ? -1 : 1);
- const top = mouseY - size / 2;
- const left = mouseX - size / 2;
- const direction = Math.random() <= 0.5 ? -1 : 1;
-
- const particle = document.createElement("div");
-
- if (particleType === "circle") {
- const svgNS = "http://www.w3.org/2000/svg";
- const circleSVG = document.createElementNS(svgNS, "svg");
- const circle = document.createElementNS(svgNS, "circle");
- circle.setAttributeNS(null, "cx", (size / 2).toString());
- circle.setAttributeNS(null, "cy", (size / 2).toString());
- circle.setAttributeNS(null, "r", (size / 2).toString());
- circle.setAttributeNS(
- null,
- "fill",
- `hsl(${Math.random() * 360}, 70%, 50%)`,
- );
-
- circleSVG.appendChild(circle);
- circleSVG.setAttribute("width", size.toString());
- circleSVG.setAttribute("height", size.toString());
-
- particle.appendChild(circleSVG);
- } else {
- particle.innerHTML = `<img src="${particleType}" width="${size}" height="${size}" style="border-radius: 50%">`;
- }
-
- particle.style.position = "absolute";
- particle.style.transform = `translate3d(${left}px, ${top}px, 0px) rotate(${spinVal}deg)`;
-
- container.appendChild(particle);
-
- particles.push({
- direction,
- element: particle,
- left,
- size,
- speedHorz,
- speedUp,
- spinSpeed,
- spinVal,
- top,
- });
- }
-
- function refreshParticles() {
- particles.forEach((p) => {
- p.left = p.left - p.speedHorz * p.direction;
- p.top = p.top - p.speedUp;
- p.speedUp = Math.min(p.size, p.speedUp - 1);
- p.spinVal = p.spinVal + p.spinSpeed;
-
- if (
- p.top >=
- Math.max(window.innerHeight, document.body.clientHeight) + p.size
- ) {
- particles = particles.filter((o) => o !== p);
- p.element.remove();
- }
-
- p.element.setAttribute(
- "style",
- [
- "position:absolute",
- "will-change:transform",
- `top:${p.top}px`,
- `left:${p.left}px`,
- `transform:rotate(${p.spinVal}deg)`,
- ].join(";"),
- );
- });
- }
-
- let animationFrame: number | undefined;
-
- let lastParticleTimestamp = 0;
- const particleGenerationDelay = 30;
-
- function loop() {
- const currentTime = performance.now();
- if (
- autoAddParticle &&
- particles.length < limit &&
- currentTime - lastParticleTimestamp > particleGenerationDelay
- ) {
- generateParticle();
- lastParticleTimestamp = currentTime;
- }
-
- refreshParticles();
- animationFrame = requestAnimationFrame(loop);
- }
-
- loop();
-
- const isTouchInteraction = "ontouchstart" in window;
-
- const tap = isTouchInteraction ? "touchstart" : "mousedown";
- const tapEnd = isTouchInteraction ? "touchend" : "mouseup";
- const move = isTouchInteraction ? "touchmove" : "mousemove";
-
- const updateMousePosition = (e: MouseEvent | TouchEvent) => {
- if ("touches" in e) {
- mouseX = e.touches?.[0].clientX;
- mouseY = e.touches?.[0].clientY;
- } else {
- mouseX = e.clientX;
- mouseY = e.clientY;
- }
- };
-
- const tapHandler = (e: MouseEvent | TouchEvent) => {
- updateMousePosition(e);
- autoAddParticle = true;
- };
-
- const disableAutoAddParticle = () => {
- autoAddParticle = false;
- };
-
- element.addEventListener(move, updateMousePosition, { passive: true });
- element.addEventListener(tap, tapHandler, { passive: true });
- element.addEventListener(tapEnd, disableAutoAddParticle, { passive: true });
- element.addEventListener("mouseleave", disableAutoAddParticle, {
- passive: true,
- });
-
- return () => {
- element.removeEventListener(move, updateMousePosition);
- element.removeEventListener(tap, tapHandler);
- element.removeEventListener(tapEnd, disableAutoAddParticle);
- element.removeEventListener("mouseleave", disableAutoAddParticle);
-
- const interval = setInterval(() => {
- if (animationFrame && particles.length === 0) {
- cancelAnimationFrame(animationFrame);
- clearInterval(interval);
-
- if (--instanceCounter === 0) {
- container.remove();
- }
- }
- }, 500);
- };
-};
-
-interface CoolModeProps {
- children: ReactNode;
- options?: CoolParticleOptions;
-}
-
-export const CoolMode: React.FC<CoolModeProps> = ({ children, options }) => {
- const ref = useRef<HTMLElement>(null);
-
- useEffect(() => {
- if (ref.current) {
- return applyParticleEffect(ref.current, options);
- }
- }, [options]);
-
- return React.cloneElement(children as React.ReactElement, { ref });
-};
+import React, { ReactNode, RefObject, useEffect, useRef } from "react";
+
+export interface BaseParticle {
+ element: HTMLElement | SVGSVGElement;
+ left: number;
+ size: number;
+ top: number;
+}
+
+export interface BaseParticleOptions {
+ particle?: string;
+ size?: number;
+}
+
+export interface CoolParticle extends BaseParticle {
+ direction: number;
+ speedHorz: number;
+ speedUp: number;
+ spinSpeed: number;
+ spinVal: number;
+}
+
+export interface CoolParticleOptions extends BaseParticleOptions {
+ particleCount?: number;
+ speedHorz?: number;
+ speedUp?: number;
+}
+
+const getContainer = () => {
+ const id = "_coolMode_effect";
+ let existingContainer = document.getElementById(id);
+
+ if (existingContainer) {
+ return existingContainer;
+ }
+
+ const container = document.createElement("div");
+ container.setAttribute("id", id);
+ container.setAttribute(
+ "style",
+ "overflow:hidden; position:fixed; height:100%; top:0; left:0; right:0; bottom:0; pointer-events:none; z-index:2147483647",
+ );
+
+ document.body.appendChild(container);
+
+ return container;
+};
+
+let instanceCounter = 0;
+
+const applyParticleEffect = (
+ element: HTMLElement,
+ options?: CoolParticleOptions,
+): (() => void) => {
+ instanceCounter++;
+
+ const defaultParticle = "circle";
+ const particleType = options?.particle || defaultParticle;
+ const sizes = [15, 20, 25, 35, 45];
+ const limit = 45;
+
+ let particles: CoolParticle[] = [];
+ let autoAddParticle = false;
+ let mouseX = 0;
+ let mouseY = 0;
+
+ const container = getContainer();
+
+ function generateParticle() {
+ const size =
+ options?.size || sizes[Math.floor(Math.random() * sizes.length)];
+ const speedHorz = options?.speedHorz || Math.random() * 10;
+ const speedUp = options?.speedUp || Math.random() * 25;
+ const spinVal = Math.random() * 360;
+ const spinSpeed = Math.random() * 35 * (Math.random() <= 0.5 ? -1 : 1);
+ const top = mouseY - size / 2;
+ const left = mouseX - size / 2;
+ const direction = Math.random() <= 0.5 ? -1 : 1;
+
+ const particle = document.createElement("div");
+
+ if (particleType === "circle") {
+ const svgNS = "http://www.w3.org/2000/svg";
+ const circleSVG = document.createElementNS(svgNS, "svg");
+ const circle = document.createElementNS(svgNS, "circle");
+ circle.setAttributeNS(null, "cx", (size / 2).toString());
+ circle.setAttributeNS(null, "cy", (size / 2).toString());
+ circle.setAttributeNS(null, "r", (size / 2).toString());
+ circle.setAttributeNS(
+ null,
+ "fill",
+ `hsl(${Math.random() * 360}, 70%, 50%)`,
+ );
+
+ circleSVG.appendChild(circle);
+ circleSVG.setAttribute("width", size.toString());
+ circleSVG.setAttribute("height", size.toString());
+
+ particle.appendChild(circleSVG);
+ } else {
+ particle.innerHTML = `<img src="${particleType}" width="${size}" height="${size}" style="border-radius: 50%">`;
+ }
+
+ particle.style.position = "absolute";
+ particle.style.transform = `translate3d(${left}px, ${top}px, 0px) rotate(${spinVal}deg)`;
+
+ container.appendChild(particle);
+
+ particles.push({
+ direction,
+ element: particle,
+ left,
+ size,
+ speedHorz,
+ speedUp,
+ spinSpeed,
+ spinVal,
+ top,
+ });
+ }
+
+ function refreshParticles() {
+ particles.forEach((p) => {
+ p.left = p.left - p.speedHorz * p.direction;
+ p.top = p.top - p.speedUp;
+ p.speedUp = Math.min(p.size, p.speedUp - 1);
+ p.spinVal = p.spinVal + p.spinSpeed;
+
+ if (
+ p.top >=
+ Math.max(window.innerHeight, document.body.clientHeight) + p.size
+ ) {
+ particles = particles.filter((o) => o !== p);
+ p.element.remove();
+ }
+
+ p.element.setAttribute(
+ "style",
+ [
+ "position:absolute",
+ "will-change:transform",
+ `top:${p.top}px`,
+ `left:${p.left}px`,
+ `transform:rotate(${p.spinVal}deg)`,
+ ].join(";"),
+ );
+ });
+ }
+
+ let animationFrame: number | undefined;
+
+ let lastParticleTimestamp = 0;
+ const particleGenerationDelay = 30;
+
+ function loop() {
+ const currentTime = performance.now();
+ if (
+ autoAddParticle &&
+ particles.length < limit &&
+ currentTime - lastParticleTimestamp > particleGenerationDelay
+ ) {
+ generateParticle();
+ lastParticleTimestamp = currentTime;
+ }
+
+ refreshParticles();
+ animationFrame = requestAnimationFrame(loop);
+ }
+
+ loop();
+
+ const isTouchInteraction = "ontouchstart" in window;
+
+ const tap = isTouchInteraction ? "touchstart" : "mousedown";
+ const tapEnd = isTouchInteraction ? "touchend" : "mouseup";
+ const move = isTouchInteraction ? "touchmove" : "mousemove";
+
+ const updateMousePosition = (e: MouseEvent | TouchEvent) => {
+ if ("touches" in e) {
+ mouseX = e.touches?.[0].clientX;
+ mouseY = e.touches?.[0].clientY;
+ } else {
+ mouseX = e.clientX;
+ mouseY = e.clientY;
+ }
+ };
+
+ const tapHandler = (e: MouseEvent | TouchEvent) => {
+ updateMousePosition(e);
+ autoAddParticle = true;
+ };
+
+ const disableAutoAddParticle = () => {
+ autoAddParticle = false;
+ };
+
+ element.addEventListener(move, updateMousePosition, { passive: true });
+ element.addEventListener(tap, tapHandler, { passive: true });
+ element.addEventListener(tapEnd, disableAutoAddParticle, { passive: true });
+ element.addEventListener("mouseleave", disableAutoAddParticle, {
+ passive: true,
+ });
+
+ return () => {
+ element.removeEventListener(move, updateMousePosition);
+ element.removeEventListener(tap, tapHandler);
+ element.removeEventListener(tapEnd, disableAutoAddParticle);
+ element.removeEventListener("mouseleave", disableAutoAddParticle);
+
+ const interval = setInterval(() => {
+ if (animationFrame && particles.length === 0) {
+ cancelAnimationFrame(animationFrame);
+ clearInterval(interval);
+
+ if (--instanceCounter === 0) {
+ container.remove();
+ }
+ }
+ }, 500);
+ };
+};
+
+interface CoolModeProps {
+ children: ReactNode;
+ options?: CoolParticleOptions;
+}
+
+export const CoolMode: React.FC<CoolModeProps> = ({ children, options }) => {
+ const ref = useRef<HTMLElement>(null);
+
+ useEffect(() => {
+ if (ref.current) {
+ return applyParticleEffect(ref.current, options);
+ }
+ }, [options]);
+
+ return React.cloneElement(children as React.ReactElement, { ref });
+};
diff --git a/registry/components/magicui/dock.tsx b/registry/components/magicui/dock.tsx
index 423b09c5..22acdfe5 100644
--- a/registry/components/magicui/dock.tsx
+++ b/registry/components/magicui/dock.tsx
@@ -1,8 +1,10 @@
"use client";
-import { cn } from "@/lib/utils";
+
+import React, { PropsWithChildren, useRef } from "react";
import { cva, type VariantProps } from "class-variance-authority";
import { motion, useMotionValue, useSpring, useTransform } from "framer-motion";
-import React, { PropsWithChildren, useRef } from "react";
+
+import { cn } from "@/lib/utils";
export interface DockProps extends VariantProps<typeof dockVariants> {
className?: string;
diff --git a/registry/components/magicui/dot-pattern.tsx b/registry/components/magicui/dot-pattern.tsx
index fb1b659b..ea42a5eb 100644
--- a/registry/components/magicui/dot-pattern.tsx
+++ b/registry/components/magicui/dot-pattern.tsx
@@ -1,6 +1,7 @@
-import { cn } from "@/lib/utils";
import { useId } from "react";
+import { cn } from "@/lib/utils";
+
interface DotPatternProps {
width?: any;
height?: any;
diff --git a/registry/components/magicui/fade-in.tsx b/registry/components/magicui/fade-in.tsx
index 6f8e5e33..fafdb24c 100644
--- a/registry/components/magicui/fade-in.tsx
+++ b/registry/components/magicui/fade-in.tsx
@@ -1,7 +1,7 @@
"use client";
-import { motion, useInView } from "framer-motion";
import { useRef } from "react";
+import { motion, useInView } from "framer-motion";
export default function FadeIn({
children,
diff --git a/registry/components/magicui/fade-text.tsx b/registry/components/magicui/fade-text.tsx
index 7e5adfc9..b322a838 100644
--- a/registry/components/magicui/fade-text.tsx
+++ b/registry/components/magicui/fade-text.tsx
@@ -1,7 +1,7 @@
"use client";
-import { motion, Variants } from "framer-motion";
import { useMemo } from "react";
+import { motion, Variants } from "framer-motion";
type FadeTextProps = {
className?: string;
diff --git a/registry/components/magicui/flip-text.tsx b/registry/components/magicui/flip-text.tsx
index 1d18e7a3..a92dc67e 100644
--- a/registry/components/magicui/flip-text.tsx
+++ b/registry/components/magicui/flip-text.tsx
@@ -1,7 +1,8 @@
"use client";
+import { AnimatePresence, motion, Variants } from "framer-motion";
+
import { cn } from "@/lib/utils";
-import { AnimatePresence, Variants, motion } from "framer-motion";
interface SlightFlipProps {
word: string;
diff --git a/registry/components/magicui/globe.tsx b/registry/components/magicui/globe.tsx
index 793c62ae..fe0eb48a 100644
--- a/registry/components/magicui/globe.tsx
+++ b/registry/components/magicui/globe.tsx
@@ -1,10 +1,11 @@
"use client";
-import { cn } from "@/lib/utils";
-import createGlobe, { COBEOptions } from "cobe";
import { useCallback, useEffect, useRef } from "react";
+import createGlobe, { COBEOptions } from "cobe";
import { useSpring } from "react-spring";
+import { cn } from "@/lib/utils";
+
const GLOBE_CONFIG: COBEOptions = {
width: 800,
height: 800,
diff --git a/registry/components/magicui/gradual-spacing.tsx b/registry/components/magicui/gradual-spacing.tsx
index 3157f248..9f620602 100644
--- a/registry/components/magicui/gradual-spacing.tsx
+++ b/registry/components/magicui/gradual-spacing.tsx
@@ -1,7 +1,8 @@
"use client";
+import { AnimatePresence, motion, Variants } from "framer-motion";
+
import { cn } from "@/lib/utils";
-import { AnimatePresence, Variants, motion } from "framer-motion";
interface GradualSpacingProps {
text: string;
diff --git a/registry/components/magicui/grid-pattern.tsx b/registry/components/magicui/grid-pattern.tsx
index b1f1b2fa..7ee2dcad 100644
--- a/registry/components/magicui/grid-pattern.tsx
+++ b/registry/components/magicui/grid-pattern.tsx
@@ -1,6 +1,7 @@
-import { cn } from "@/lib/utils";
import { useId } from "react";
+import { cn } from "@/lib/utils";
+
interface GridPatternProps {
width?: any;
height?: any;
diff --git a/registry/components/magicui/icon-cloud.tsx b/registry/components/magicui/icon-cloud.tsx
index 555c234e..3161ce06 100644
--- a/registry/components/magicui/icon-cloud.tsx
+++ b/registry/components/magicui/icon-cloud.tsx
@@ -1,7 +1,7 @@
"use client";
-import { useTheme } from "next-themes";
import { useEffect, useMemo, useState } from "react";
+import { useTheme } from "next-themes";
import {
Cloud,
fetchSimpleIcons,
diff --git a/registry/components/magicui/letter-pullup.tsx b/registry/components/magicui/letter-pullup.tsx
index fd7f35a7..360df2c4 100644
--- a/registry/components/magicui/letter-pullup.tsx
+++ b/registry/components/magicui/letter-pullup.tsx
@@ -1,8 +1,9 @@
"use client";
-import { cn } from "@/lib/utils";
import { motion } from "framer-motion";
+import { cn } from "@/lib/utils";
+
interface LetterPullupProps {
className?: string;
words: string;
diff --git a/registry/components/magicui/linear-mask.tsx b/registry/components/magicui/linear-mask.tsx
index f16c5382..8f3906ab 100644
--- a/registry/components/magicui/linear-mask.tsx
+++ b/registry/components/magicui/linear-mask.tsx
@@ -1,6 +1,7 @@
-import { cn } from "@/lib/utils";
import React, { ReactNode } from "react";
+import { cn } from "@/lib/utils";
+
// interface LinearMaskProps {
// color?: string;
// innerOpacity?: number;
diff --git a/registry/components/magicui/magic-card.tsx b/registry/components/magicui/magic-card.tsx
index a786c4c3..9b951c23 100644
--- a/registry/components/magicui/magic-card.tsx
+++ b/registry/components/magicui/magic-card.tsx
@@ -1,6 +1,5 @@
"use client";
-import { cn } from "@/lib/utils";
import {
CSSProperties,
ReactElement,
@@ -10,6 +9,8 @@ import {
useState,
} from "react";
+import { cn } from "@/lib/utils";
+
interface MousePosition {
x: number;
y: number;
diff --git a/registry/components/magicui/meteors.tsx b/registry/components/magicui/meteors.tsx
index d6c1bdfc..b52cfa63 100644
--- a/registry/components/magicui/meteors.tsx
+++ b/registry/components/magicui/meteors.tsx
@@ -1,7 +1,7 @@
"use client";
-import clsx from "clsx";
import { useEffect, useState } from "react";
+import clsx from "clsx";
interface MeteorsProps {
number?: number;
diff --git a/registry/components/magicui/neon-gradient-card.tsx b/registry/components/magicui/neon-gradient-card.tsx
index c8426941..aefc3f10 100644
--- a/registry/components/magicui/neon-gradient-card.tsx
+++ b/registry/components/magicui/neon-gradient-card.tsx
@@ -1,6 +1,5 @@
"use client";
-import { cn } from "@/lib/utils";
import {
CSSProperties,
ReactElement,
@@ -10,6 +9,8 @@ import {
useState,
} from "react";
+import { cn } from "@/lib/utils";
+
interface NeonColorsProps {
firstColor: string;
secondColor: string;
diff --git a/registry/components/magicui/number-ticker.tsx b/registry/components/magicui/number-ticker.tsx
index 5e0c5e2a..7577729b 100644
--- a/registry/components/magicui/number-ticker.tsx
+++ b/registry/components/magicui/number-ticker.tsx
@@ -1,8 +1,9 @@
"use client";
-import { cn } from "@/lib/utils";
-import { useInView, useMotionValue, useSpring } from "framer-motion";
import { useEffect, useRef } from "react";
+import { useInView, useMotionValue, useSpring } from "framer-motion";
+
+import { cn } from "@/lib/utils";
export default function NumberTicker({
value,
diff --git a/registry/components/magicui/scroll-based-velocity.tsx b/registry/components/magicui/scroll-based-velocity.tsx
index c0e77f2d..638cab4a 100644
--- a/registry/components/magicui/scroll-based-velocity.tsx
+++ b/registry/components/magicui/scroll-based-velocity.tsx
@@ -1,6 +1,6 @@
"use client";
-import { cn } from "@/lib/utils";
+import React, { useEffect, useRef, useState } from "react";
import {
motion,
useAnimationFrame,
@@ -10,7 +10,8 @@ import {
useTransform,
useVelocity,
} from "framer-motion";
-import React, { useEffect, useRef, useState } from "react";
+
+import { cn } from "@/lib/utils";
interface VelocityScrollProps {
text: string;
diff --git a/registry/components/magicui/separate-away.tsx b/registry/components/magicui/separate-away.tsx
index 4611c4e2..4a1f3929 100644
--- a/registry/components/magicui/separate-away.tsx
+++ b/registry/components/magicui/separate-away.tsx
@@ -1,8 +1,9 @@
"use client";
-import { cn } from "@/lib/utils";
import { motion } from "framer-motion";
+import { cn } from "@/lib/utils";
+
interface SeparateAwayProps {
upper_text: string;
lower_text: string;
diff --git a/registry/components/magicui/shimmer-button.tsx b/registry/components/magicui/shimmer-button.tsx
index 4db805fb..9699dcd5 100644
--- a/registry/components/magicui/shimmer-button.tsx
+++ b/registry/components/magicui/shimmer-button.tsx
@@ -1,6 +1,7 @@
-import { cn } from "@/lib/utils";
import React, { CSSProperties } from "react";
+import { cn } from "@/lib/utils";
+
export interface ShimmerButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
shimmerColor?: string;
diff --git a/registry/components/magicui/shiny-button.tsx b/registry/components/magicui/shiny-button.tsx
index b7ada9cf..f79ba098 100644
--- a/registry/components/magicui/shiny-button.tsx
+++ b/registry/components/magicui/shiny-button.tsx
@@ -1,5 +1,6 @@
"use client";
-import { type AnimationProps, motion } from "framer-motion";
+
+import { motion, type AnimationProps } from "framer-motion";
const animationProps = {
initial: { "--x": "100%", scale: 0.8 },
diff --git a/registry/components/magicui/sparkles-text.tsx b/registry/components/magicui/sparkles-text.tsx
index e25d048a..3e777be1 100644
--- a/registry/components/magicui/sparkles-text.tsx
+++ b/registry/components/magicui/sparkles-text.tsx
@@ -1,8 +1,9 @@
"use client";
-import { cn } from "@/lib/utils";
-import { motion } from "framer-motion";
import { CSSProperties, ReactElement, useEffect, useState } from "react";
+import { motion } from "framer-motion";
+
+import { cn } from "@/lib/utils";
interface Sparkle {
id: string;
diff --git a/registry/components/magicui/text-reveal.tsx b/registry/components/magicui/text-reveal.tsx
index 23f6c4b9..efc1f124 100644
--- a/registry/components/magicui/text-reveal.tsx
+++ b/registry/components/magicui/text-reveal.tsx
@@ -1,8 +1,9 @@
"use client";
-import { cn } from "@/lib/utils";
-import { motion, useScroll, useTransform } from "framer-motion";
import { FC, ReactNode, useRef } from "react";
+import { motion, useScroll, useTransform } from "framer-motion";
+
+import { cn } from "@/lib/utils";
interface TextRevealByWordProps {
text: string;
diff --git a/registry/components/magicui/tweet-card.tsx b/registry/components/magicui/tweet-card.tsx
index b04aa0b8..4f10108d 100644
--- a/registry/components/magicui/tweet-card.tsx
+++ b/registry/components/magicui/tweet-card.tsx
@@ -1,4 +1,3 @@
-import { cn } from "@/lib/utils";
import { Suspense } from "react";
import {
enrichTweet,
@@ -8,6 +7,8 @@ import {
} from "react-tweet";
import { getTweet, type Tweet } from "react-tweet/api";
+import { cn } from "@/lib/utils";
+
interface TwitterIconProps {
className?: string;
[key: string]: any;
diff --git a/registry/components/magicui/typing-animation.tsx b/registry/components/magicui/typing-animation.tsx
index 8b1a7230..637890d6 100644
--- a/registry/components/magicui/typing-animation.tsx
+++ b/registry/components/magicui/typing-animation.tsx
@@ -1,8 +1,9 @@
"use client";
-import { cn } from "@/lib/utils";
import { useEffect, useState } from "react";
+import { cn } from "@/lib/utils";
+
interface TypingAnimationProps {
text: string;
duration?: number;
diff --git a/registry/components/magicui/wavy-dot-pattern.tsx b/registry/components/magicui/wavy-dot-pattern.tsx
index 63eb63c8..4f2f5f38 100644
--- a/registry/components/magicui/wavy-dot-pattern.tsx
+++ b/registry/components/magicui/wavy-dot-pattern.tsx
@@ -1,7 +1,8 @@
-import { cn } from "@/lib/utils";
import { useState } from "react";
import { anime } from "react-anime";
+import { cn } from "@/lib/utils";
+
interface WavyDotPatternProps {
className?: string;
gridWidth?: number;
diff --git a/registry/components/magicui/wavy-text.tsx b/registry/components/magicui/wavy-text.tsx
index 2e3e3326..d7e828bc 100644
--- a/registry/components/magicui/wavy-text.tsx
+++ b/registry/components/magicui/wavy-text.tsx
@@ -1,8 +1,9 @@
"use client";
-import { cn } from "@/lib/utils";
-import { AnimatePresence, motion } from "framer-motion";
import { useMemo } from "react";
+import { AnimatePresence, motion } from "framer-motion";
+
+import { cn } from "@/lib/utils";
interface WavyTextProps {
word: string;
diff --git a/registry/components/magicui/word-fade-in.tsx b/registry/components/magicui/word-fade-in.tsx
index 6c122dc9..5072c418 100644
--- a/registry/components/magicui/word-fade-in.tsx
+++ b/registry/components/magicui/word-fade-in.tsx
@@ -1,7 +1,8 @@
"use client";
+import { motion, Variants } from "framer-motion";
+
import { cn } from "@/lib/utils";
-import { Variants, motion } from "framer-motion";
interface WordFadeInProps {
words: string;
diff --git a/registry/components/magicui/word-pull-up.tsx b/registry/components/magicui/word-pull-up.tsx
index 6a52c99d..ed53da90 100644
--- a/registry/components/magicui/word-pull-up.tsx
+++ b/registry/components/magicui/word-pull-up.tsx
@@ -1,8 +1,9 @@
"use client";
-import { cn } from "@/lib/utils";
import { motion, Variants } from "framer-motion";
+import { cn } from "@/lib/utils";
+
interface WordPullUpProps {
words: string;
delayMultiple?: number;
diff --git a/registry/components/magicui/word-rotate.tsx b/registry/components/magicui/word-rotate.tsx
index 5325d671..f4427c60 100644
--- a/registry/components/magicui/word-rotate.tsx
+++ b/registry/components/magicui/word-rotate.tsx
@@ -1,8 +1,9 @@
"use client";
-import { cn } from "@/lib/utils";
-import { AnimatePresence, HTMLMotionProps, motion } from "framer-motion";
import { useEffect, useState } from "react";
+import { AnimatePresence, HTMLMotionProps, motion } from "framer-motion";
+
+import { cn } from "@/lib/utils";
interface WordRotateProps {
words: string[];
diff --git a/registry/index.tsx b/registry/index.tsx
index ab24b1b9..80231f06 100644
--- a/registry/index.tsx
+++ b/registry/index.tsx
@@ -1,6 +1,7 @@
-import { Registry } from "@/registry/schema";
import * as React from "react";
+import { Registry } from "@/registry/schema";
+
const ui: Registry = {
"magic-card": {
name: "magic-card",
diff --git a/scripts/build-registry.ts b/scripts/build-registry.ts
index 5fa71af8..093fb9b6 100644
--- a/scripts/build-registry.ts
+++ b/scripts/build-registry.ts
@@ -1,74 +1,73 @@
// @ts-nocheck
-import fs from "fs"
-import path, { basename } from "path"
-import { rimraf } from "rimraf"
-import { downloadRegistry } from "../registry/index.tsx"
-import { registrySchema } from "../registry/schema.ts"
+import fs from "fs";
+import path, { basename } from "path";
+import { rimraf } from "rimraf";
-const REGISTRY_PATH = path.join(process.cwd(), "public/registry")
+import { downloadRegistry } from "../registry/index.tsx";
+import { registrySchema } from "../registry/schema.ts";
-const result = registrySchema.safeParse(downloadRegistry)
+const REGISTRY_PATH = path.join(process.cwd(), "public/registry");
-console.log("Building Registry...")
+const result = registrySchema.safeParse(downloadRegistry);
+
+console.log("Building Registry...");
if (!result.success) {
- console.error(result.error)
- process.exit(1)
+ console.error(result.error);
+ process.exit(1);
}
// ----------------------------------------------------------------------------
// Build registry/index.json.
// ----------------------------------------------------------------------------
-const data = Object.values(result.data).sort((a, b) => a.name.localeCompare(b.name));
-const names = data //.filter((item) => item.type === "components:ui")
-const registryJson = JSON.stringify(names, null, 2)
+const data = Object.values(result.data).sort((a, b) =>
+ a.name.localeCompare(b.name),
+);
+const names = data; //.filter((item) => item.type === "components:ui")
+const registryJson = JSON.stringify(names, null, 2);
// Create directory if it doesn't exist.
if (!fs.existsSync(REGISTRY_PATH)) {
- fs.mkdirSync(REGISTRY_PATH, { recursive: true })
+ fs.mkdirSync(REGISTRY_PATH, { recursive: true });
}
-rimraf.sync(path.join(REGISTRY_PATH, "index.json"))
-fs.writeFileSync(path.join(REGISTRY_PATH, "index.json"), registryJson, "utf8")
+rimraf.sync(path.join(REGISTRY_PATH, "index.json"));
+fs.writeFileSync(path.join(REGISTRY_PATH, "index.json"), registryJson, "utf8");
// ----------------------------------------------------------------------------
// Build registry/components/["magicui" | "ui" | "example"]/[name].json.
// ----------------------------------------------------------------------------
for (const item of data) {
- const [parent, subfolder] = item.type.split(":")
+ const [parent, subfolder] = item.type.split(":");
if (!parent || !subfolder) {
- console.warn(`Invalid type: ${item.type} for ${item.name}`)
- continue
+ console.warn(`Invalid type: ${item.type} for ${item.name}`);
+ continue;
}
- const targetPath = path.join(REGISTRY_PATH, parent, subfolder)
+ const targetPath = path.join(REGISTRY_PATH, parent, subfolder);
// Create directory if it doesn't exist.
if (!fs.existsSync(targetPath)) {
- fs.mkdirSync(targetPath, { recursive: true })
+ fs.mkdirSync(targetPath, { recursive: true });
}
-
const files = item.files?.map((file) => {
- const content = fs.readFileSync(
- path.join(process.cwd(), file),
- "utf8"
- )
+ const content = fs.readFileSync(path.join(process.cwd(), file), "utf8");
return {
name: basename(file),
content,
- }
- })
+ };
+ });
const payload = {
...item,
files,
- }
+ };
fs.writeFileSync(
path.join(targetPath, `${item.name}.json`),
JSON.stringify(payload, null, 2),
- "utf8"
- )
+ "utf8",
+ );
}
-console.log("Build Registry Done ✅")
\ No newline at end of file
+console.log("Build Registry Done ✅");
diff --git a/tailwind.config.ts b/tailwind.config.ts
index c2da4324..d3f1c98d 100644
--- a/tailwind.config.ts
+++ b/tailwind.config.ts
@@ -197,8 +197,5 @@ module.exports = {
},
},
},
- plugins: [
- require("tailwindcss-animate"),
- require("@tailwindcss/typography"),
- ],
+ plugins: [require("tailwindcss-animate"), require("@tailwindcss/typography")],
};
diff --git a/types/next-auth.d.ts b/types/next-auth.d.ts
index 2c17fb66..adbec01a 100644
--- a/types/next-auth.d.ts
+++ b/types/next-auth.d.ts
@@ -1,4 +1,5 @@
import { User } from "next-auth";
+
import "next-auth/jwt";
type UserId = string;