Skip to content

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

✨ feat: Add new components + refactor code so its easier (#3)

Dillion Verma010d1557cc97
diff --git a/.eslintrc.json b/.eslintrc.json
index bffb357a..9413ce81 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -1,3 +1,9 @@
{
- "extends": "next/core-web-vitals"
-}
+ "extends": [
+ "next/core-web-vitals",
+ "turbo",
+ "prettier",
+ "plugin:tailwindcss/recommended"
+ ],
+ "plugins": ["tailwindcss"]
+}
\ No newline at end of file
diff --git a/app/(docs)/components/[slug]/not-found.tsx b/app/(docs)/components/[slug]/not-found.tsx
index 5ec5a9bb..59ae1fab 100644
--- a/app/(docs)/components/[slug]/not-found.tsx
+++ b/app/(docs)/components/[slug]/not-found.tsx
@@ -1,39 +1,5 @@
-import { EmptyPlaceholder } from "@/components/empty-placeholder";
-import { buttonVariants } from "@/components/ui/button";
-import { getCurrentUser } from "@/lib/session";
-import Link from "next/link";
-import { env } from "process";
+import PreOrder from "@/components/preorder";
export default async function NotFound() {
- const user = await getCurrentUser();
- const url = new URL(
- env.NODE_ENV === "development"
- ? "https://buy.stripe.com/test_bIY7uvbbzecfcw09AB"
- : "https://buy.stripe.com/3cs8zHafOdUa0tG9AA"
- );
-
- if (user && user.email) {
- url.searchParams.append("prefilled_email", user.email);
- }
-
- return (
- <EmptyPlaceholder className="w-full">
- <EmptyPlaceholder.Icon name="logo" />
- <EmptyPlaceholder.Title>
- Pre-order to get access Magic UI
- </EmptyPlaceholder.Title>
- <EmptyPlaceholder.Description>
- You get the complete source code of all components and templates so you
- can use them in your projects 🎉
- </EmptyPlaceholder.Description>
- <Link
- href={url.toString()}
- target="_blank"
- rel="noreferrer"
- className={buttonVariants({ variant: "default" })}
- >
- Pre-order
- </Link>
- </EmptyPlaceholder>
- );
+ return <PreOrder />;
}
diff --git a/app/(docs)/components/[slug]/page.tsx b/app/(docs)/components/[slug]/page.tsx
index f3c2b3e1..90ca38b8 100644
--- a/app/(docs)/components/[slug]/page.tsx
+++ b/app/(docs)/components/[slug]/page.tsx
@@ -1,8 +1,6 @@
-import ComponentWrapper from "@/components/component-wrapper";
import Facebook from "@/components/icons/facebook";
import LinkedIn from "@/components/icons/linkedin";
import Twitter from "@/components/icons/twitter";
-import { MagicCard, MagicContainer } from "@/components/magicui/magic-card";
import { Mdx } from "@/components/mdx-components";
import { DashboardTableOfContents } from "@/components/toc";
import { ScrollArea } from "@/components/ui/scroll-area";
@@ -17,7 +15,6 @@ import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
import Balancer from "react-wrap-balancer";
-import NotFound from "./not-found";
// TODO: Fix this in future
// https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#dynamicparams
@@ -156,7 +153,7 @@ export default async function Component({ params }: Props) {
</div>
<div className="flex flex-col pt-8 gap-4">
- {component.video && (
+ {/* {component.video && (
<div className="flex md:hidden overflow-hidden relative rounded-xl border dark:border-slate-800 md:p-8 justify-center items-center flex-col max-w-[65ch]">
<video
src={component.video}
@@ -167,28 +164,8 @@ export default async function Component({ params }: Props) {
className="relative -bottom-1 aspect-video" // needed because random black line at bottom of video
/>
</div>
- )}
- <ComponentWrapper className={"hidden md:flex"}>
- <MagicContainer
- className={
- "grid w-full lg:grid-cols-2 grid-cols-1 gap-4 min-h-[500px] lg:min-h-[300px] p-8"
- }
- >
- <MagicCard className="cursor-pointer shadow-2xl flex flex-col justify-center items-center overflow-hidden bg-background p-6">
- <p className="text-4xl font-medium whitespace-nowrap text-gray-800 dark:text-gray-200">
- Magic
- </p>
- </MagicCard>
- <MagicCard className="cursor-pointer shadow-2xl flex justify-center items-center overflow-hidden bg-background">
- <p className="text-4xl font-medium whitespace-nowrap text-gray-800 dark:text-gray-200">
- Card
- </p>
- </MagicCard>
- </MagicContainer>
- </ComponentWrapper>
-
- {user && paid && <Mdx code={component.body.code} />}
- {(!user || !paid) && <NotFound />}
+ )} */}
+ <Mdx code={component.body.code} />
</div>
</div>
diff --git a/app/(docs)/components/page.tsx b/app/(docs)/components/page.tsx
index 8dca064f..ebd6347b 100644
--- a/app/(docs)/components/page.tsx
+++ b/app/(docs)/components/page.tsx
@@ -1,5 +1,5 @@
-import { FadeIn } from "@/components/magicui/FadeIn";
import { constructMetadata } from "@/lib/utils";
+import { FadeIn } from "@/registry/components/magicui/fade-in";
import { allComponents } from "contentlayer/generated";
import { compareDesc } from "date-fns";
import Link from "next/link";
@@ -12,8 +12,7 @@ export const metadata = constructMetadata({
export default async function ComponentPage() {
const posts = allComponents
- .filter((post) => post.date)
- .filter((post) => post.published)
+ .filter((post) => post.date && post.published)
.sort((a, b) => {
return compareDesc(new Date(a.date), new Date(b.date));
});
diff --git a/app/(docs)/templates/page.tsx b/app/(docs)/templates/page.tsx
index 67747a30..63197712 100644
--- a/app/(docs)/templates/page.tsx
+++ b/app/(docs)/templates/page.tsx
@@ -1,6 +1,6 @@
import { Component } from "@/.contentlayer/generated";
-import { FadeIn } from "@/components/magicui/FadeIn";
import { constructMetadata } from "@/lib/utils";
+import { FadeIn } from "@/registry/components/magicui/fade-in";
import Link from "next/link";
export const metadata = constructMetadata({
diff --git a/app/(marketing)/page.tsx b/app/(marketing)/page.tsx
index cbad00b7..d141ef0f 100644
--- a/app/(marketing)/page.tsx
+++ b/app/(marketing)/page.tsx
@@ -1,11 +1,10 @@
-import { FadeIn } from "@/components/magicui/FadeIn";
import { buttonVariants } from "@/components/ui/button";
import { Separator } from "@/components/ui/separator";
import { getCurrentUser } from "@/lib/session";
import { cn } from "@/lib/utils";
+import { FadeIn } from "@/registry/components/magicui/fade-in";
import { ChevronRight } from "lucide-react";
import Link from "next/link";
-import { env } from "process";
import { CSSProperties } from "react";
export default async function Home() {
@@ -53,16 +52,16 @@ export default async function Home() {
</Link>
</FadeIn>
<FadeIn
- delay={0.1}
+ // delay={0.0}
className="z-10 flex flex-col items-center justify-center w-full h-full"
>
- <h1 className="font-medium text-5xl sm:text-6xl md:text-7xl lg:text-8xl">
+ <h1 className="font-medium text-5xl sm:text-6xl md:text-7xl lg:text-9xl tracking-tight">
Create Magical <br /> Landing Pages
</h1>
</FadeIn>
<FadeIn
className="z-10 flex flex-col items-center justify-center w-full h-full"
- delay={0.2}
+ delay={0.1}
>
<p className="max-w-[42rem] leading-normal text-muted-foreground sm:text-xl sm:leading-8">
Magic UI is a curated collection of React + Tailwind CSS + Framer
@@ -71,32 +70,31 @@ export default async function Home() {
</FadeIn>
<FadeIn
className="z-10 flex flex-col items-center justify-center w-full h-full"
- delay={0.3}
+ delay={0.2}
>
<div className="flex flex-col md:flex-row gap-4">
- {user && (
+ <Link
+ href="/components"
+ className={cn(buttonVariants({ size: "lg" }))}
+ >
+ Get Started
+ </Link>
+ {/* {!user && (
<Link
href="/components"
- className={cn(buttonVariants({ size: "lg" }))}
- >
- Get Started
- </Link>
- )}
- {!user && (
- <Link
- href={
- env.NODE_ENV === "development"
- ? "https://buy.stripe.com/test_bIY7uvbbzecfcw09AB"
- : "https://buy.stripe.com/3cs8zHafOdUa0tG9AA"
- }
+ // href={
+ // env.NODE_ENV === "development"
+ // ? "https://buy.stripe.com/test_bIY7uvbbzecfcw09AB"
+ // : "https://buy.stripe.com/3cs8zHafOdUa0tG9AA"
+ // }
// href="https://buy.stripe.com/3cs8zHafOdUa0tG9AA"
- target="_blank"
- rel="noreferrer"
+ // target="_blank"
+ // rel="noreferrer"
className={cn(buttonVariants({ size: "lg" }))}
>
- Pre-order
+ Get Started
</Link>
- )}
+ )} */}
<Link
href="https://twitter.com/dillionverma"
className={cn(
diff --git a/app/layout.tsx b/app/layout.tsx
index 9621b9de..b1f929fd 100644
--- a/app/layout.tsx
+++ b/app/layout.tsx
@@ -1,4 +1,5 @@
import { Analytics } from "@/components/analytics";
+import SessionProvider from "@/components/session-provider";
import { ThemeProvider } from "@/components/theme-provider";
import { Toaster } from "@/components/ui/toaster";
import { fontSans } from "@/lib/fonts";
@@ -28,12 +29,14 @@ export default function RootLayout({
fontSans.variable
)}
>
- <ThemeProvider attribute="class" defaultTheme="system" enableSystem>
- {children}
- <Toaster />
- <Analytics />
- {/* <TailwindIndicator /> */}
- </ThemeProvider>
+ <SessionProvider>
+ <ThemeProvider attribute="class" defaultTheme="system" enableSystem>
+ {children}
+ <Toaster />
+ <Analytics />
+ {/* <TailwindIndicator /> */}
+ </ThemeProvider>
+ </SessionProvider>
</body>
</html>
);
diff --git a/components/code-block-wrapper.tsx b/components/code-block-wrapper.tsx
index fda4d515..721ebe56 100644
--- a/components/code-block-wrapper.tsx
+++ b/components/code-block-wrapper.tsx
@@ -40,7 +40,7 @@ export function CodeBlockWrapper({
</CollapsibleContent>
<div
className={cn(
- "absolute flex items-center justify-center bg-gradient-to-b from-gray-700/30 to-gray-900/90 p-2",
+ "absolute flex items-center justify-center bg-gradient-to-b from-background/10 to-background/90 p-2",
isOpened ? "inset-x-0 bottom-0 h-12 from-gray-900/30" : "inset-0 "
)}
>
diff --git a/components/component-preview.tsx b/components/component-preview.tsx
new file mode 100644
index 00000000..4a7ea806
--- /dev/null
+++ b/components/component-preview.tsx
@@ -0,0 +1,87 @@
+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 * as React from "react";
+
+interface ComponentPreviewProps extends React.HTMLAttributes<HTMLDivElement> {
+ name: string;
+ align?: "center" | "start" | "end";
+}
+
+export async function ComponentPreview({
+ name,
+ children,
+ className,
+ align = "center",
+ ...props
+}: ComponentPreviewProps) {
+ const Codes = React.Children.toArray(children) as React.ReactElement[];
+ const Code = Codes[0]; // first child
+
+ const Preview = React.useMemo(() => {
+ const Component = registry[name]?.component;
+
+ if (!Component) {
+ return (
+ <p className="text-sm text-muted-foreground">
+ Component{" "}
+ <code className="relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm">
+ {name}
+ </code>{" "}
+ not found in registry.
+ </p>
+ );
+ }
+
+ return <Component />;
+ }, [name]);
+
+ return (
+ <div
+ className={cn("group relative my-4 flex flex-col space-y-2", className)}
+ {...props}
+ >
+ <Tabs defaultValue="preview" className="relative mr-auto w-full">
+ <div className="flex items-center justify-between pb-3">
+ <TabsList className="w-full justify-start rounded-none border-b bg-transparent p-0">
+ <TabsTrigger
+ value="preview"
+ className="relative h-9 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 font-semibold text-muted-foreground shadow-none transition-none data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none"
+ >
+ Preview
+ </TabsTrigger>
+ <TabsTrigger
+ value="code"
+ className="relative h-9 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 font-semibold text-muted-foreground shadow-none transition-none data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none"
+ >
+ Code
+ </TabsTrigger>
+ </TabsList>
+ </div>
+ <TabsContent value="preview" className="relative rounded-md">
+ <ComponentWrapper>
+ <React.Suspense
+ fallback={
+ <div className="flex items-center text-sm text-muted-foreground">
+ <Icons.spinner className="mr-2 h-4 w-4 animate-spin" />
+ Loading...
+ </div>
+ }
+ >
+ {Preview}
+ </React.Suspense>
+ </ComponentWrapper>
+ </TabsContent>
+ <TabsContent value="code">
+ <div className="flex flex-col space-y-4">
+ <div className="w-full rounded-md [&_pre]:my-0 [&_pre]:max-h-[350px] [&_pre]:overflow-auto">
+ {Code}
+ </div>
+ </div>
+ </TabsContent>
+ </Tabs>
+ </div>
+ );
+}
diff --git a/components/component-source.tsx b/components/component-source.tsx
index 608b3b90..17a48743 100644
--- a/components/component-source.tsx
+++ b/components/component-source.tsx
@@ -1,9 +1,10 @@
"use client";
-import * as React from "react";
-
import { CodeBlockWrapper } from "@/components/code-block-wrapper";
+import PreOrder from "@/components/preorder";
import { cn } from "@/lib/utils";
+import { useSession } from "next-auth/react";
+import * as React from "react";
interface ComponentSourceProps extends React.HTMLAttributes<HTMLDivElement> {
src: string;
@@ -14,6 +15,12 @@ export function ComponentSource({
className,
...props
}: ComponentSourceProps) {
+ const { data: session, status } = useSession();
+ const user = session?.user;
+
+ if (status === "loading") return null;
+ if (status === "unauthenticated") return <PreOrder />;
+
return (
<CodeBlockWrapper
expandButtonTitle="Expand"
diff --git a/components/component-wrapper.tsx b/components/component-wrapper.tsx
index 18495d0c..98b081fc 100644
--- a/components/component-wrapper.tsx
+++ b/components/component-wrapper.tsx
@@ -1,20 +1,18 @@
import { cn } from "@/lib/utils";
import { CSSProperties } from "react";
-const ComponentWrapper = ({
- className,
- children,
-}: {
- className: string;
+interface ComponentWrapperProps {
+ className?: string;
children: any;
-}) => {
+}
+const ComponentWrapper = ({ className, children }: ComponentWrapperProps) => {
const mask =
"linear-gradient(to bottom,transparent,#fff var(--mask-offset) calc(100% - var(--mask-offset)),transparent),linear-gradient(to right,transparent,#fff var(--mask-offset) calc(100% - var(--mask-offset)),transparent)";
return (
<div
className={cn(
- "relative rounded-xl border dark:border-slate-800 md:p-8 flex justify-center items-center flex-col max-w-[65ch]",
+ "relative rounded-xl border md:p-20 p-10 flex justify-center items-center flex-col max-w-[65ch]",
className
)}
>
@@ -23,11 +21,11 @@ const ComponentWrapper = ({
<div
className={cn(
`absolute inset-0 -z-10 h-full w-full [background-size:16px_16px]`,
- `bg-[radial-gradient(#e5e7eb_1px,transparent_1px)] dark:bg-[radial-gradient(#1f2937_1px,transparent_1px)]`
+ `bg-[radial-gradient(#00000055_1px,transparent_1px)] dark:bg-[radial-gradient(#ffffff22_1px,transparent_1px)]`
)}
style={
{
- "--mask-offset": "80px",
+ "--mask-offset": "60px",
mask: mask,
WebkitMask: mask,
maskComposite: "intersect",
diff --git a/components/copy-button.tsx b/components/copy-button.tsx
index 4c63ab62..23ceefdd 100644
--- a/components/copy-button.tsx
+++ b/components/copy-button.tsx
@@ -53,7 +53,7 @@ export function CopyButton({
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 h-6 w-6 text-zinc-50 hover:bg-background hover:text-zinc-50",
className
)}
onClick={() => {
diff --git a/components/mdx-components.tsx b/components/mdx-components.tsx
index f23f68dd..7cc3d3dc 100644
--- a/components/mdx-components.tsx
+++ b/components/mdx-components.tsx
@@ -4,6 +4,7 @@ import { cn } from "@/lib/utils";
import { useMDXComponent } from "next-contentlayer/hooks";
import Image from "next/image";
import Link from "next/link";
+import { ComponentPreview } from "./component-preview";
import { ComponentSource } from "./component-source";
import { CopyButton } from "./copy-button";
@@ -29,8 +30,9 @@ const components = {
a: CustomLink,
Image,
ComponentSource,
+ ComponentPreview,
table: ({ className, ...props }: React.HTMLAttributes<HTMLTableElement>) => (
- <div className="my-6 w-full overflow-y-auto">
+ <div className="w-full overflow-y-auto">
<table className={cn("w-full", className)} {...props} />
</div>
),
@@ -132,8 +134,11 @@ export function Mdx({ code }: MDXProps) {
className={cn(
`prose dark:prose-invert prose-gray leading-tighter tracking-tighter`,
// `md:prose-lg lg:prose-xl`,
- `prose-a:transition-colors prose-a:duration-200 prose-a:ease-out`,
- `dark:prose-a:text-gray-200 prose-a:underline-offset-4 dark:hover:prose-a:text-gray-700 prose-a:font-semibold hover:prose-a:text-gray-400`,
+
+ // no underline on links
+ `prose-a:no-underline`,
+ // `prose-a:transition-colors prose-a:duration-200 prose-a:ease-out`,
+ // `dark:prose-a:text-gray-200 prose-a:underline-offset-4 dark:hover:prose-a:text-gray-700 prose-a:font-semibold hover:prose-a:text-gray-400`,
// `prose-pre:bg-gray-900 prose-pre:rounded-xl prose-pre:overflow-x-auto prose-pre:border prose-pre:px-0 `,
`prose-pre:mb-4 prose-pre:mt-6 prose-pre:max-h-[650px] prose-pre:overflow-x-auto prose-pre:rounded-lg prose-pre:border prose-pre:bg-gray-900 prose-pre:py-4 prose-pre:dark:bg-gray-900 prose-pre:px-0 prose-pre:text-xs md:prose-pre:text-sm prose-pre:tracking-tighter`
)}
diff --git a/components/preorder.tsx b/components/preorder.tsx
new file mode 100644
index 00000000..ef0b832e
--- /dev/null
+++ b/components/preorder.tsx
@@ -0,0 +1,42 @@
+"use client";
+
+import { EmptyPlaceholder } from "@/components/empty-placeholder";
+import { buttonVariants } from "@/components/ui/button";
+import { useSession } from "next-auth/react";
+import Link from "next/link";
+
+export default function PreOrder() {
+ const { data: session } = useSession();
+ const user = session?.user;
+
+ const url = new URL(
+ process.env.NODE_ENV === "development"
+ ? "https://buy.stripe.com/test_bIY7uvbbzecfcw09AB"
+ : "https://buy.stripe.com/3cs8zHafOdUa0tG9AA"
+ );
+
+ if (user && user.email) {
+ url.searchParams.append("prefilled_email", user.email);
+ }
+
+ return (
+ <EmptyPlaceholder className="w-full">
+ <EmptyPlaceholder.Icon name="logo" />
+ <EmptyPlaceholder.Title className="lg:text-2xl">
+ Pre-order to get access Magic UI 🪄
+ </EmptyPlaceholder.Title>
+ <EmptyPlaceholder.Description>
+ You get the complete source code of all components and templates so you
+ can use them in your projects 🎉
+ </EmptyPlaceholder.Description>
+ <Link
+ href={url.toString()}
+ target="_blank"
+ rel="noreferrer"
+ className={buttonVariants({ variant: "default", size: "lg" })}
+ >
+ Pre-order
+ </Link>
+ </EmptyPlaceholder>
+ );
+}
diff --git a/components/site-header.tsx b/components/site-header.tsx
index 372f98e0..f4ab969a 100644
--- a/components/site-header.tsx
+++ b/components/site-header.tsx
@@ -2,6 +2,7 @@ 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 { UserAccountNav } from "@/components/user-account-nav";
import { siteConfig } from "@/config/site";
@@ -58,7 +59,7 @@ export function SiteHeader({ user }: SiteHeaderProps) {
<span className="sr-only">Twitter</span>
</div>
</Link>
- {/* <ModeToggle /> */}
+ <ModeToggle />
{user && (
<UserAccountNav
@@ -88,9 +89,9 @@ export function SiteHeader({ user }: SiteHeaderProps) {
className="absolute w-full h-px bottom-0"
style={{
background:
- "radial-gradient(50% 100% at 50% 100%,rgba(255,255,255,.12) 0%,rgba(255,255,255,0) 100%)",
+ "radial-gradient(50% 100% at 50% 100%,rgba(255,255,255,.32) 0%,rgba(255,255,255,0) 100%)",
}}
- ></div>
+ />
</header>
);
}
diff --git a/components/ui/tabs.tsx b/components/ui/tabs.tsx
new file mode 100644
index 00000000..0f4caebb
--- /dev/null
+++ b/components/ui/tabs.tsx
@@ -0,0 +1,55 @@
+"use client"
+
+import * as React from "react"
+import * as TabsPrimitive from "@radix-ui/react-tabs"
+
+import { cn } from "@/lib/utils"
+
+const Tabs = TabsPrimitive.Root
+
+const TabsList = React.forwardRef<
+ React.ElementRef<typeof TabsPrimitive.List>,
+ React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>
+>(({ className, ...props }, ref) => (
+ <TabsPrimitive.List
+ ref={ref}
+ className={cn(
+ "inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",
+ className
+ )}
+ {...props}
+ />
+))
+TabsList.displayName = TabsPrimitive.List.displayName
+
+const TabsTrigger = React.forwardRef<
+ React.ElementRef<typeof TabsPrimitive.Trigger>,
+ React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
+>(({ className, ...props }, ref) => (
+ <TabsPrimitive.Trigger
+ ref={ref}
+ className={cn(
+ "inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",
+ className
+ )}
+ {...props}
+ />
+))
+TabsTrigger.displayName = TabsPrimitive.Trigger.displayName
+
+const TabsContent = React.forwardRef<
+ React.ElementRef<typeof TabsPrimitive.Content>,
+ React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
+>(({ className, ...props }, ref) => (
+ <TabsPrimitive.Content
+ ref={ref}
+ className={cn(
+ "mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
+ className
+ )}
+ {...props}
+ />
+))
+TabsContent.displayName = TabsPrimitive.Content.displayName
+
+export { Tabs, TabsList, TabsTrigger, TabsContent }
diff --git a/config/docs.ts b/config/docs.ts
index 595edc68..36eb244b 100644
--- a/config/docs.ts
+++ b/config/docs.ts
@@ -1,5 +1,6 @@
import { allComponents } from "@/.contentlayer/generated";
import { MainNavItem, SidebarNavItem } from "@/types";
+import { compareDesc } from "date-fns";
interface DocsConfig {
mainNav: MainNavItem[];
@@ -21,8 +22,10 @@ export const docsConfig: DocsConfig = {
{
title: "Components",
items: allComponents
- .filter((post) => post.date)
- .filter((post) => post.published)
+ .filter((post) => post.date && post.published)
+ .sort((a, b) => {
+ return compareDesc(new Date(a.date), new Date(b.date));
+ })
.map((component) => ({
title: component.title,
href: `/components/${component.slugAsParams}`,
diff --git a/content/components/animated-text.mdx b/content/components/animated-text.mdx
deleted file mode 100644
index 37178ab0..00000000
--- a/content/components/animated-text.mdx
+++ /dev/null
@@ -1,44 +0,0 @@
----
-title: Animated Text
-date: 2023-06-24
-summary: Animated text with React and Framer Motion
-published: false
-author: dillionverma
----
-
-This is a list in markdown:
-
-- One
-- Two
-- Three
-
-Checkout my React component:
-
-## My MDX page 2
-
-{/* <Hello /> */}
-
-{/* <Image src="/next.svg" width="718" height="404" alt="Image" /> */}
-
-```tsx showLineNumbers title="app/payments/columns.tsx" {3,14-27}
-"use client";
-
-import { ColumnDef } from "@tanstack/react-table";
-
-// This type is used to define the shape of our data.
-// You can use a Zod schema here if you want.
-export type Payment = {
- id: string;
- amount: number;
- status: "pending" | "processing" | "success" | "failed";
- email: string;
-};
-```
-
-```css
-body {
- background: red;
-}
-```
-
-[Link](https://www.google.com)
diff --git a/content/components/linear-gradient.mdx b/content/components/linear-gradient.mdx
new file mode 100644
index 00000000..47dc45bb
--- /dev/null
+++ b/content/components/linear-gradient.mdx
@@ -0,0 +1,44 @@
+---
+title: Linear Gradient
+date: 2023-07-12
+summary: A linear gradient that can be used as a background for a component.
+author: dillionverma
+published: true
+video: https://cdn.magicuikit.com/linear-gradient.mp4
+---
+
+<ComponentPreview name="linear-gradient-demo" />
+
+<Steps>
+
+<Step>
+
+## Installation
+
+Copy and page the following code into your project.
+
+```text
+components/magicui/linear-gradient.tsx
+```
+
+<ComponentSource name="linear-gradient" >
+
+</ComponentSource>
+
+</Step>
+
+</Steps>
+
+## Props
+
+### Linear Gradient
+
+| Prop | Type | Description | Default |
+| --------------- | ------ | --------------------------------------------------------------------------------------- | --------- |
+| from | string | The starting color of the gradient | #00000000 |
+| to | string | The ending color of the gradient | #290A5C |
+| width | string | The width of the gradient | 100% |
+| height | string | The height of the gradient | 100% |
+| transitionPoint | string | The point at which the gradient transitions from the starting color to the ending color | 50% |
+| direction | string | The direction of the gradient | bottom |
+| className | string | The class name of the component | "" |
diff --git a/content/components/magic-card.mdx b/content/components/magic-card.mdx
index f5e3256e..70c5ffb2 100644
--- a/content/components/magic-card.mdx
+++ b/content/components/magic-card.mdx
@@ -7,6 +7,8 @@ published: true
video: https://cdn.magicuikit.com/magic-card.mp4
---
+<ComponentPreview name="magic-card-demo" />
+
<Steps>
<Step>
@@ -29,287 +31,12 @@ Copy and page the following code into your project.
components/magicui/magic-card.tsx
```
-<ComponentSource name="magic-card" >
-
-```tsx
-"use client";
-
-import clsx, { ClassValue } from "clsx";
-import { CSSProperties, ReactNode, useEffect, useRef, useState } from "react";
-import { twMerge } from "tailwind-merge";
-
-export function cn(...inputs: ClassValue[]) {
- return twMerge(clsx(inputs));
-}
-
-interface MousePosition {
- x: number;
- y: number;
-}
-
-export default function useMousePosition(): MousePosition {
- const [mousePosition, setMousePosition] = useState<MousePosition>({
- x: 0,
- y: 0,
- });
-
- useEffect(() => {
- const handleMouseMove = (event: globalThis.MouseEvent) => {
- setMousePosition({ x: event.clientX, y: event.clientY });
- };
-
- window.addEventListener("mousemove", handleMouseMove);
-
- return () => {
- window.removeEventListener("mousemove", handleMouseMove);
- };
- }, []);
-
- return mousePosition;
-}
-
-export const MagicContainer = ({
- children,
- className,
-}: {
- children?: ReactNode;
- className?: any;
-}) => {
- const containerRef = useRef<HTMLDivElement>(null);
- const mousePosition = useMousePosition();
- const mouse = useRef<{ x: number; y: number }>({ x: 0, y: 0 });
- const containerSize = useRef<{ w: number; h: number }>({ w: 0, h: 0 });
- const [boxes, setBoxes] = useState<Array<HTMLElement>>([]);
-
- useEffect(() => {
- init();
- containerRef.current &&
- setBoxes(
- Array.from(containerRef.current.children).map((el) => el as HTMLElement)
- );
- }, []);
-
- useEffect(() => {
- init();
- window.addEventListener("resize", init);
-
- return () => {
- window.removeEventListener("resize", init);
- };
- }, [setBoxes]);
-
- useEffect(() => {
- onMouseMove();
- }, [mousePosition]);
-
- const init = () => {
- if (containerRef.current) {
- containerSize.current.w = containerRef.current.offsetWidth;
- containerSize.current.h = containerRef.current.offsetHeight;
- }
- };
-
- const onMouseMove = () => {
- if (containerRef.current) {
- const rect = containerRef.current.getBoundingClientRect();
- const { w, h } = containerSize.current;
- const x = mousePosition.x - rect.left;
- const y = mousePosition.y - rect.top;
- const inside = x < w && x > 0 && y < h && y > 0;
-
- mouse.current.x = x;
- mouse.current.y = y;
- boxes.forEach((box) => {
- const boxX =
- -(box.getBoundingClientRect().left - rect.left) + mouse.current.x;
- const boxY =
- -(box.getBoundingClientRect().top - rect.top) + mouse.current.y;
- box.style.setProperty("--mouse-x", `${boxX}px`);
- box.style.setProperty("--mouse-y", `${boxY}px`);
-
- if (inside) {
- box.style.setProperty("--opacity", `1`);
- } else {
- box.style.setProperty("--opacity", `0`);
- }
- });
- }
- };
-
- return (
- <div className={className} ref={containerRef}>
- {children}
- </div>
- );
-};
-
-interface MagicCardProps {
- /**
- * @default ""
- * @type string
- * @description
- * The className of the card
- */
- className?: string;
-
- /**
- * @default ""
- * @type ReactNode
- * @description
- * The children of the card
- * */
- children?: ReactNode;
-
- /**
- * @default 600
- * @type number
- * @description
- * The size of the spotlight effect in pixels
- * */
- size?: number;
-
- /**
- * ]@default "#475569"
- * @type string
- * @description
- * The border color of the card
- */
- borderColor?: string;
-
- /**
- * @default 1
- * @type number
- * @description
- * The border width of the card
- * */
- borderWidth?: number;
-
- /**
- * @default 16
- * @type number
- * @description
- * The border radius of the card
- * */
- borderRadius?: number;
-
- /**
- * @default true
- * @type boolean
- * @description
- * Whether to show the spotlight
- * */
- spotlight?: boolean;
-
- /**
- * @default "rgba(255,255,255,0.03)"
- * @type string
- * @description
- * The color of the spotlight
- * */
- spotlightColor?: string;
-
- /**
- * @default true
- * @type boolean
- * @description
- * Whether to isolate the card which is being hovered
- * */
- isolated?: boolean;
-
- /**
- * @default "rgba(255,255,255,0.03)"
- * @type string
- * @description
- * The background of the card
- * */
- background?: string;
-}
-
-export function MagicCard({
- className,
- children,
- size = 600,
- borderColor = "rgba(120,119,198)",
- borderWidth = 1,
- borderRadius = 16,
- spotlight = true,
- spotlightColor = "rgba(120,119,198,0.08)",
- isolated = true,
- background = `rgba(255,255,255,0.1)`,
-}: MagicCardProps) {
- const spotlightStyles =
- "before:pointer-events-none before:absolute before:w-full before:h-full before:rounded-[var(--border-radius)] before:top-0 before:left-0 before:duration-500 before:transition-opacity before:bg-[radial-gradient(var(--mask-size)_circle_at_var(--mouse-x)_var(--mouse-y),var(--spotlight-color),transparent_40%)] before:z-[3] before:blur-xs";
-
- const borderStyles =
- "after:pointer-events-none after:absolute after:w-full after:h-full after:rounded-[var(--border-radius)] after:top-0 after:left-0 after:duration-500 after:transition-opacity after:bg-[radial-gradient(var(--mask-size)_circle_at_var(--mouse-x)_var(--mouse-y),var(--border-color),transparent_40%)] after:z-[1]";
-
- return (
- <div
- style={
- {
- "--border-radius": `${borderRadius}px`,
- "--border-width": `${borderWidth}px`,
- "--border-color": `${borderColor}`,
- "--mask-size": `${size}px`,
- "--spotlight-color": `${spotlightColor}`,
- background,
- } as CSSProperties
- }
- className={cn(
- "relative rounded-[var(--border-radius)] overflow-hidden",
- isolated && [borderStyles, "after:opacity-0 after:hover:opacity-100"],
- isolated &&
- spotlight && [
- spotlightStyles,
- "before:opacity-0 before:hover:opacity-100",
- ],
- !isolated && [borderStyles, "after:opacity-[var(--opacity)]"],
- !isolated &&
- spotlight && [spotlightStyles, "before:opacity-[var(--opacity)]"]
- )}
- >
- <div
- className={cn(
- "absolute inset-[var(--border-width)] rounded-[var(--border-radius)] z-[2]",
- className
- )}
- >
- {children}
- </div>
- </div>
- );
-}
-```
-
-</ComponentSource>
+<ComponentSource name="magic-card" />
</Step>
</Steps>
-## Usage
-
-Now you can use the `MagicContainer` and `MagicCard` components to create a magic card effect.
-
-```tsx
-<MagicContainer
- className={
- "grid w-full lg:grid-cols-2 grid-cols-1 gap-4 min-h-[500px] lg:min-h-[300px] p-8"
- }
->
- <MagicCard className="cursor-pointer shadow-2xl flex flex-col justify-center items-center overflow-hidden bg-background p-6">
- <p className="text-4xl font-medium whitespace-nowrap text-gray-800 dark:text-gray-200">
- Magic
- </p>
- </MagicCard>
- <MagicCard className="cursor-pointer shadow-2xl flex justify-center items-center overflow-hidden bg-background">
- <p className="text-4xl font-medium whitespace-nowrap text-gray-800 dark:text-gray-200">
- Card
- </p>
- </MagicCard>
-</MagicContainer>
-```
-
## Props
### MagicContainer
diff --git a/content/components/radial-gradient.mdx b/content/components/radial-gradient.mdx
new file mode 100644
index 00000000..4bb24a4f
--- /dev/null
+++ b/content/components/radial-gradient.mdx
@@ -0,0 +1,41 @@
+---
+title: Radial Gradient
+date: 2023-07-12
+summary: A circular gradient that can be used as a background for a component.
+author: dillionverma
+published: true
+video: https://cdn.magicuikit.com/radial-gradient.mp4
+---
+
+<ComponentPreview name="radial-gradient-demo" />
+
+<Steps>
+
+<Step>
+
+## Installation
+
+Copy and page the following code into your project.
+
+```text
+components/magicui/radial-gradient.tsx
+```
+
+<ComponentSource name="radial-gradient" />
+
+</Step>
+
+</Steps>
+
+## Props
+
+### Radial Gradient
+
+| Prop | Type | Description | Default |
+| --------- | ------ | --------------------------- | ------------------ |
+| type | string | Shape of the gradient | circle |
+| from | string | Color of the gradient start | #290A5C |
+| to | string | Color of the gradient end | hsla(0, 0%, 0%, 0) |
+| size | number | Size of the gradient | 300 |
+| origin | string | Origin of the gradient | center |
+| className | string | Class name of the gradient | "" |
diff --git a/contentlayer.config.ts b/contentlayer.config.ts
index a24993fe..e49827f8 100644
--- a/contentlayer.config.ts
+++ b/contentlayer.config.ts
@@ -7,6 +7,7 @@ import remarkGfm from "remark-gfm";
import { BlogPosting, WithContext } from "schema-dts";
import { visit } from "unist-util-visit";
import { env } from "./env.mjs";
+import { rehypeComponent } from "./lib/rehype-component";
/** @type {import('contentlayer/source-files').ComputedFields} */
const computedFields = {
@@ -89,6 +90,7 @@ export default makeSource({
remarkPlugins: [remarkGfm],
rehypePlugins: [
rehypeSlug,
+ rehypeComponent,
() => (tree) => {
visit(tree, (node) => {
if (node?.type === "element" && node?.tagName === "pre") {
@@ -135,6 +137,36 @@ export default makeSource({
},
},
],
+ () => (tree) => {
+ visit(tree, (node) => {
+ if (node?.type === "element" && node?.tagName === "div") {
+ if (!("data-rehype-pretty-code-fragment" in node.properties)) {
+ return;
+ }
+
+ const preElement = node.children.at(-1);
+ if (preElement.tagName !== "pre") {
+ return;
+ }
+
+ preElement.properties["__withMeta__"] =
+ node.children.at(0).tagName === "div";
+ preElement.properties["__rawString__"] = node.__rawString__;
+
+ if (node.__src__) {
+ preElement.properties["__src__"] = node.__src__;
+ }
+
+ if (node.__event__) {
+ preElement.properties["__event__"] = node.__event__;
+ }
+
+ if (node.__style__) {
+ preElement.properties["__style__"] = node.__style__;
+ }
+ }
+ });
+ },
[
rehypeAutolinkHeadings,
{
diff --git a/lib/rehype-component.ts b/lib/rehype-component.ts
new file mode 100644
index 00000000..48e04a58
--- /dev/null
+++ b/lib/rehype-component.ts
@@ -0,0 +1,145 @@
+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 { registry } from "../registry";
+// import { styles } from "../registry/styles"
+
+export function rehypeComponent() {
+ return async (tree: UnistTree) => {
+ visit(tree, (node: UnistNode) => {
+ const { value: src } = getNodeAttributeByName(node, "src") || {};
+
+ if (node.name === "ComponentSource") {
+ const name = getNodeAttributeByName(node, "name")?.value as string;
+
+ if (!name) {
+ return null;
+ }
+
+ try {
+ // for (const style of styles) {
+ const component = registry[name];
+ const src = component.files[0];
+
+ // Read the source file.
+ const filePath = path.join(process.cwd(), src);
+ let source = fs.readFileSync(filePath, "utf8");
+
+ // Replace imports.
+ // TODO: Use @swc/core and a visitor to replace this.
+ // For now a simple regex should do.
+ source = source.replaceAll(`@/registry/`, "@/");
+ source = source.replaceAll("export default", "export");
+
+ // Add code as children so that rehype can take over at build time.
+ node.children?.push(
+ u("element", {
+ tagName: "pre",
+ properties: {
+ __src__: src,
+ },
+ // attributes: [
+ // {
+ // name: "styleName",
+ // type: "mdxJsxAttribute",
+ // value: style.name,
+ // },
+ // ],
+ children: [
+ u("element", {
+ tagName: "code",
+ properties: {
+ className: ["language-tsx"],
+ },
+ children: [
+ {
+ type: "text",
+ value: source,
+ },
+ ],
+ }),
+ ],
+ })
+ );
+ // }
+ } catch (error) {
+ console.error(error);
+ }
+ }
+
+ if (node.name === "ComponentPreview") {
+ const name = getNodeAttributeByName(node, "name")?.value as string;
+
+ if (!name) {
+ return null;
+ }
+
+ try {
+ // for (const style of styles) {
+ const component = registry[name];
+ const src = component.files[0];
+
+ // Read the source file.
+ const filePath = path.join(process.cwd(), src);
+ let source = fs.readFileSync(filePath, "utf8");
+
+ console.log("name ", name);
+ console.log("source ", source);
+
+ // Replace imports.
+ // TODO: Use @swc/core and a visitor to replace this.
+ // For now a simple regex should do.
+ source = source.replaceAll(`@/registry/`, "@/");
+ source = source.replaceAll("export default", "export");
+
+ // Add code as children so that rehype can take over at build time.
+ node.children?.push(
+ u("element", {
+ tagName: "pre",
+ properties: {
+ __src__: src,
+ },
+ children: [
+ u("element", {
+ tagName: "code",
+ properties: {
+ className: ["language-tsx"],
+ },
+ children: [
+ {
+ type: "text",
+ value: source,
+ },
+ ],
+ }),
+ ],
+ })
+ );
+ // }
+ } catch (error) {
+ console.error(error);
+ }
+ }
+ });
+ };
+}
+
+function getNodeAttributeByName(node: UnistNode, name: string) {
+ return node.attributes?.find((attribute) => attribute.name === name);
+}
+
+// function getComponentSourceFileContent(node: UnistNode) {
+// const src = getNodeAttributeByName(node, "src")?.value as string;
+
+// if (!src) {
+// return null;
+// }
+
+// // Read the source file.
+// const filePath = path.join(process.cwd(), src);
+// const source = fs.readFileSync(filePath, "utf8");
+
+// return source;
+// }
diff --git a/package.json b/package.json
index 4df74065..e6651497 100644
--- a/package.json
+++ b/package.json
@@ -30,6 +30,7 @@
"@radix-ui/react-scroll-area": "^1.0.4",
"@radix-ui/react-separator": "^1.0.3",
"@radix-ui/react-slot": "^1.0.2",
+ "@radix-ui/react-tabs": "^1.0.4",
"@radix-ui/react-toast": "^1.1.4",
"@react-email/body": "0.0.2",
"@react-email/button": "0.0.9",
@@ -60,7 +61,6 @@
"framer-motion": "^10.12.16",
"gray-matter": "^4.0.3",
"lucide-react": "^0.248.0",
- "mdast-util-toc": "^6.1.1",
"next": "13.4.7",
"next-auth": "^4.22.1",
"next-contentlayer": "^0.3.3",
@@ -72,17 +72,10 @@
"react-email": "1.9.4",
"react-hook-form": "^7.45.0",
"react-wrap-balancer": "^1.0.0",
- "rehype-autolink-headings": "^6.1.1",
- "rehype-pretty-code": "^0.9.11",
- "rehype-slug": "^5.1.0",
- "remark": "^14.0.3",
- "remark-gfm": "^3.0.1",
"resend": "^0.16.0",
"schema-dts": "^1.1.2",
- "shiki": "^0.14.2",
"stripe": "^12.10.0",
"tailwind-merge": "^1.13.2",
- "unist-util-visit": "^4.1.2",
"zod": "^3.21.4"
},
"devDependencies": {
@@ -90,10 +83,19 @@
"@types/node": "^20.3.2",
"@types/react": "18.2.12",
"@types/react-dom": "18.2.5",
+ "mdast-util-toc": "^6.1.1",
"prisma": "^4.16.1",
+ "rehype-autolink-headings": "^6.1.1",
+ "rehype-pretty-code": "^0.9.11",
+ "rehype-slug": "^5.1.0",
+ "remark": "^14.0.3",
+ "remark-gfm": "^3.0.1",
+ "shiki": "^0.14.2",
"tailwindcss": "3.3.2",
"tailwindcss-animate": "^1.0.6",
"ts-node": "^10.9.1",
- "typescript": "^5.1.6"
+ "typescript": "^5.1.6",
+ "unist-builder": "^3.0.0",
+ "unist-util-visit": "^4.1.2"
}
}
diff --git a/registry/components/example/linear-gradient-demo.tsx b/registry/components/example/linear-gradient-demo.tsx
new file mode 100644
index 00000000..1b8f1074
--- /dev/null
+++ b/registry/components/example/linear-gradient-demo.tsx
@@ -0,0 +1,12 @@
+import LinearGradient from "@/registry/components/magicui/linear-gradient";
+
+export default function LinearGradientDemo() {
+ return (
+ <div className="border rounded-lg h-full w-full relative flex justify-center items-center bg-background">
+ <p className="text-5xl font-medium tracking-tighter whitespace-nowrap text-white z-10">
+ Linear Gradient
+ </p>
+ <LinearGradient />
+ </div>
+ );
+}
diff --git a/registry/components/example/magic-card-demo.tsx b/registry/components/example/magic-card-demo.tsx
new file mode 100644
index 00000000..abf87060
--- /dev/null
+++ b/registry/components/example/magic-card-demo.tsx
@@ -0,0 +1,25 @@
+import {
+ MagicCard,
+ MagicContainer,
+} from "@/registry/components/magicui/magic-card";
+
+export default function MagicCardWithGradient() {
+ return (
+ <MagicContainer
+ className={
+ "grid w-full lg:grid-cols-2 grid-cols-1 gap-4 min-h-[500px] lg:min-h-[250px]"
+ }
+ >
+ <MagicCard className="cursor-pointer shadow-2xl flex flex-col justify-center items-center overflow-hidden bg-background p-6">
+ <p className="text-4xl font-medium whitespace-nowrap text-gray-800 dark:text-gray-200 z-10">
+ Magic
+ </p>
+ </MagicCard>
+ <MagicCard className="cursor-pointer shadow-2xl flex justify-center items-center overflow-hidden bg-background">
+ <p className="text-4xl font-medium whitespace-nowrap text-gray-800 dark:text-gray-200 z-10">
+ Card
+ </p>
+ </MagicCard>
+ </MagicContainer>
+ );
+}
diff --git a/registry/components/example/radial-gradient-demo.tsx b/registry/components/example/radial-gradient-demo.tsx
new file mode 100644
index 00000000..1374006b
--- /dev/null
+++ b/registry/components/example/radial-gradient-demo.tsx
@@ -0,0 +1,12 @@
+import RadialGradient from "@/registry/components/magicui/radial-gradient";
+
+export default function RadialGradientDemo() {
+ return (
+ <div className="border rounded-lg h-full w-full relative flex justify-center items-center bg-background">
+ <p className="text-5xl font-medium tracking-tighter whitespace-nowrap text-white z-10">
+ Radial Gradient
+ </p>
+ <RadialGradient />
+ </div>
+ );
+}
diff --git a/components/magicui/FadeIn.tsx b/registry/components/magicui/fade-in.tsx
similarity index 100%
rename from components/magicui/FadeIn.tsx
rename to registry/components/magicui/fade-in.tsx
diff --git a/components/magicui/GridPattern.tsx b/registry/components/magicui/grid-pattern.tsx
similarity index 100%
rename from components/magicui/GridPattern.tsx
rename to registry/components/magicui/grid-pattern.tsx
diff --git a/registry/components/magicui/linear-gradient.tsx b/registry/components/magicui/linear-gradient.tsx
new file mode 100644
index 00000000..38de3005
--- /dev/null
+++ b/registry/components/magicui/linear-gradient.tsx
@@ -0,0 +1,84 @@
+import { CSSProperties } from "react";
+
+type Direction =
+ | "top"
+ | "bottom"
+ | "left"
+ | "right"
+ | "top left"
+ | "top right"
+ | "bottom left"
+ | "bottom right";
+
+interface LinearGradientProps {
+ /**
+ * The color to transition from
+ * @default #00000000
+ * @type string
+ * */
+ from?: string;
+
+ /**
+ * The color to transition to
+ * @default #290A5C
+ * @type string
+ * */
+ to?: string;
+
+ /**
+ * The width of the gradient
+ * @default 100%
+ * @type string
+ * */
+ width?: string;
+
+ /**
+ * The height of the gradient
+ * @default 100%
+ * @type string
+ * */
+ height?: string;
+
+ /**
+ * The direction of the gradient
+ * @default bottom
+ * @type string
+ * */
+ direction?: Direction;
+
+ /**
+ * The point at which the transition occurs
+ * @default 50%
+ * @type string
+ * */
+ transitionPoint?: string;
+
+ /**
+ * The class name to apply to the gradient
+ * @default ""
+ * @type string
+ * */
+ className?: string;
+}
+
+const LinearGradient = ({
+ from = "#00000000",
+ to = "#290A5C",
+ width = "100%",
+ height = "100%",
+ transitionPoint = "50%",
+ direction = "bottom",
+ className,
+}: LinearGradientProps) => {
+ const styles: CSSProperties = {
+ position: "absolute",
+ pointerEvents: "none",
+ inset: 0,
+ width: width,
+ height: height,
+ background: `linear-gradient(to ${direction}, ${from}, ${transitionPoint}, ${to})`,
+ };
+ return <div className={className} style={styles} />;
+};
+
+export default LinearGradient;
diff --git a/registry/components/magicui/linear-mask.tsx b/registry/components/magicui/linear-mask.tsx
new file mode 100644
index 00000000..5a6c3625
--- /dev/null
+++ b/registry/components/magicui/linear-mask.tsx
@@ -0,0 +1,49 @@
+import { cn } from "@/lib/utils";
+import React, { ReactNode } from "react";
+
+// interface LinearMaskProps {
+// color?: string;
+// innerOpacity?: number;
+// outerOpacity?: number;
+// children?: ReactNode;
+// className?: string;
+// }
+
+// const LinearMask: React.FC<LinearMaskProps> = ({
+// children,
+// className,
+// color = "#fff",
+// }) => {
+// const maskImage = `linear-gradient(180deg,hsla(0,0%,100%,0),${color} 28.81%,${color} 75%,hsla(0,0%,100%,0))`;
+
+// const styles: CSSProperties = {
+// maskImage,
+// WebkitMaskImage: maskImage,
+// };
+
+// return (
+// <div style={styles} className={className}>
+// {children}
+// </div>
+// );
+// };
+
+interface Props {
+ className?: string;
+ children?: ReactNode;
+}
+
+const LinearMask: React.FC<Props> = ({ className, children }) => {
+ return (
+ <div
+ className={cn(
+ "[mask:linear-gradient(180deg,transparent,#fff_30%,#fff_70%,transparent)]",
+ className
+ )}
+ >
+ {children}
+ </div>
+ );
+};
+
+export default LinearMask;
diff --git a/components/magicui/magic-card.tsx b/registry/components/magicui/magic-card.tsx
similarity index 95%
rename from components/magicui/magic-card.tsx
rename to registry/components/magicui/magic-card.tsx
index f803a82d..93d92ffc 100644
--- a/components/magicui/magic-card.tsx
+++ b/registry/components/magicui/magic-card.tsx
@@ -13,7 +13,7 @@ interface MousePosition {
y: number;
}
-export default function useMousePosition(): MousePosition {
+function useMousePosition(): MousePosition {
const [mousePosition, setMousePosition] = useState<MousePosition>({
x: 0,
y: 0,
@@ -34,13 +34,12 @@ export default function useMousePosition(): MousePosition {
return mousePosition;
}
-export const MagicContainer = ({
- children,
- className,
-}: {
+interface MagicContainerProps {
children?: ReactNode;
className?: any;
-}) => {
+}
+
+const MagicContainer = ({ children, className }: MagicContainerProps) => {
const containerRef = useRef<HTMLDivElement>(null);
const mousePosition = useMousePosition();
const mouse = useRef<{ x: number; y: number }>({ x: 0, y: 0 });
@@ -191,7 +190,7 @@ interface MagicCardProps {
background?: string;
}
-export function MagicCard({
+const MagicCard = ({
className,
children,
size = 600,
@@ -201,8 +200,8 @@ export function MagicCard({
spotlight = true,
spotlightColor = "rgba(120,119,198,0.08)",
isolated = true,
- background = `rgba(255,255,255,0.1)`,
-}: MagicCardProps) {
+ background = `rgba(120,119,198, 0.2)`,
+}: MagicCardProps) => {
const spotlightStyles =
"before:pointer-events-none before:absolute before:w-full before:h-full before:rounded-[var(--border-radius)] before:top-0 before:left-0 before:duration-500 before:transition-opacity before:bg-[radial-gradient(var(--mask-size)_circle_at_var(--mouse-x)_var(--mouse-y),var(--spotlight-color),transparent_40%)] before:z-[3] before:blur-xs";
@@ -244,4 +243,6 @@ export function MagicCard({
</div>
</div>
);
-}
+};
+
+export { MagicCard, MagicContainer };
diff --git a/registry/components/magicui/radial-gradient.tsx b/registry/components/magicui/radial-gradient.tsx
new file mode 100644
index 00000000..c1499ec1
--- /dev/null
+++ b/registry/components/magicui/radial-gradient.tsx
@@ -0,0 +1,77 @@
+import { CSSProperties } from "react";
+
+type Type = "circle" | "ellipse";
+
+type Origin =
+ | "center"
+ | "top"
+ | "bottom"
+ | "left"
+ | "right"
+ | "top left"
+ | "top right"
+ | "bottom left"
+ | "bottom right";
+
+interface RadialProps {
+ /**
+ * The type of radial gradient
+ * @default circle
+ * @type string
+ */
+ type?: Type;
+ /**
+ * The color to transition from
+ * @default #00000000
+ * @type string
+ * */
+ from?: string;
+
+ /**
+ * The color to transition to
+ * @default #290A5C
+ * @type string
+ * */
+ to?: string;
+
+ /**
+ * The size of the gradient in pixels
+ * @default 300
+ * @type number
+ * */
+ size?: number;
+
+ /**
+ * The origin of the gradient
+ * @default center
+ * @type string
+ * */
+ origin?: Origin;
+
+ /**
+ * The class name to apply to the gradient
+ * @default ""
+ * @type string
+ * */
+ className?: string;
+}
+
+const RadialGradient = ({
+ type = "circle",
+ from = "hsla(263, 80%, 20%, 1)",
+ to = "hsla(0, 0%, 0%, 0)",
+ size = 300,
+ origin = "center",
+ className,
+}: RadialProps) => {
+ const styles: CSSProperties = {
+ position: "absolute",
+ pointerEvents: "none",
+ inset: 0,
+ backgroundImage: `radial-gradient(${type} ${size}px at ${origin}, ${from}, ${to})`,
+ };
+
+ return <div className={className} style={styles} />;
+};
+
+export default RadialGradient;
diff --git a/registry/index.tsx b/registry/index.tsx
new file mode 100644
index 00000000..fb4fbe3b
--- /dev/null
+++ b/registry/index.tsx
@@ -0,0 +1,52 @@
+import { Registry } from "@/registry/schema";
+import * as React from "react";
+
+const ui: Registry = {
+ "magic-card": {
+ name: "magic-card",
+ type: "components:ui",
+ files: ["registry/components/magicui/magic-card.tsx"],
+ },
+ "linear-gradient": {
+ name: "linear-gradient",
+ type: "components:ui",
+ files: ["registry/components/magicui/linear-gradient.tsx"],
+ },
+ "radial-gradient": {
+ name: "radial-gradient",
+ type: "components:ui",
+ files: ["registry/components/magicui/radial-gradient.tsx"],
+ },
+};
+
+const example: Registry = {
+ "magic-card-demo": {
+ name: "magic-card-demo",
+ type: "components:example",
+ files: ["registry/components/example/magic-card-demo.tsx"],
+ component: React.lazy(
+ () => import("@/registry/components/example/magic-card-demo")
+ ),
+ },
+ "linear-gradient-demo": {
+ name: "linear-gradient-demo",
+ type: "components:example",
+ files: ["registry/components/example/linear-gradient-demo.tsx"],
+ component: React.lazy(
+ () => import("@/registry/components/example/linear-gradient-demo")
+ ),
+ },
+ "radial-gradient-demo": {
+ name: "radial-gradient-demo",
+ type: "components:example",
+ files: ["registry/components/example/radial-gradient-demo.tsx"],
+ component: React.lazy(
+ () => import("@/registry/components/example/radial-gradient-demo")
+ ),
+ },
+};
+
+export const registry: Registry = {
+ ...ui,
+ ...example,
+};
diff --git a/registry/schema.ts b/registry/schema.ts
new file mode 100644
index 00000000..ded9febe
--- /dev/null
+++ b/registry/schema.ts
@@ -0,0 +1,19 @@
+import * as z from "zod";
+
+export const registrySchema = z.record(
+ z.string(),
+ z.object({
+ name: z.string(),
+ dependencies: 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",
+ ]),
+ component: z.function().args(z.any()).returns(z.any()).optional(),
+ })
+);
+
+export type Registry = z.infer<typeof registrySchema>;
diff --git a/styles/globals.css b/styles/globals.css
index 2259c0e3..0063f595 100644
--- a/styles/globals.css
+++ b/styles/globals.css
@@ -27,12 +27,12 @@
--secondary-foreground: 240 5.9% 10%;
--accent: 240 4.8% 95.9%;
- --accent-foreground: ;
+ --accent-foreground: 240 5.9% 10%;
--destructive: 0 84.2% 60.2%;
--destructive-foreground: 0 0% 98%;
- --ring: 220 9% 46%;
+ --ring: 240 5% 64.9%;
--radius: 0.5rem;
}
@@ -41,9 +41,8 @@
--background: 233 100% 4%;
--foreground: 0 0% 98%;
- --muted: 216 34% 10%;
-
- --muted-foreground: 220 9% 46%;
+ --muted: 240 3.7% 15.9%;
+ --muted-foreground: 240 5% 64.9%;
--popover: var(--background);
--popover-foreground: var(--foreground);
diff --git a/tailwind.config.js b/tailwind.config.js
index 6a1f87d8..22f21ed2 100644
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -3,7 +3,12 @@ const colors = require("tailwindcss/colors");
module.exports = {
darkMode: ["class"],
- content: ["./components/**/*.{ts,tsx}", "./app/**/*.{ts,tsx}"],
+ content: [
+ "./components/**/*.{ts,tsx}",
+ "./app/**/*.{ts,tsx}",
+ "./content/**/*.mdx",
+ "./registry/**/*.{ts,tsx}",
+ ],
theme: {
container: {
center: true,
diff --git a/types/unist.ts b/types/unist.ts
new file mode 100644
index 00000000..29b635c1
--- /dev/null
+++ b/types/unist.ts
@@ -0,0 +1,30 @@
+import { Node } from "unist-builder/lib";
+
+export interface UnistNode extends Node {
+ type: string;
+ name?: string;
+ tagName?: string;
+ value?: string;
+ properties?: {
+ __rawString__?: string;
+ __className__?: string;
+ __event__?: string;
+ [key: string]: unknown;
+ } & NpmCommands;
+ attributes?: {
+ name: string;
+ value: unknown;
+ type?: string;
+ }[];
+ children?: UnistNode[];
+}
+
+export interface UnistTree extends Node {
+ children: UnistNode[];
+}
+
+export interface NpmCommands {
+ __npmCommand__?: string;
+ __yarnCommand__?: string;
+ __pnpmCommand__?: string;
+}
diff --git a/yarn.lock b/yarn.lock
index ff1cc80f..820cbf32 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1485,6 +1485,21 @@
"@babel/runtime" "^7.13.10"
"@radix-ui/react-compose-refs" "1.0.1"
+"@radix-ui/react-tabs@^1.0.4":
+ version "1.0.4"
+ resolved "https://registry.yarnpkg.com/@radix-ui/react-tabs/-/react-tabs-1.0.4.tgz#993608eec55a5d1deddd446fa9978d2bc1053da2"
+ integrity sha512-egZfYY/+wRNCflXNHx+dePvnz9FbmssDTJBtgRfDY7e8SE5oIo3Py2eCB1ckAbh1Q7cQ/6yJZThJ++sgbxibog==
+ dependencies:
+ "@babel/runtime" "^7.13.10"
+ "@radix-ui/primitive" "1.0.1"
+ "@radix-ui/react-context" "1.0.1"
+ "@radix-ui/react-direction" "1.0.1"
+ "@radix-ui/react-id" "1.0.1"
+ "@radix-ui/react-presence" "1.0.1"
+ "@radix-ui/react-primitive" "1.0.3"
+ "@radix-ui/react-roving-focus" "1.0.4"
+ "@radix-ui/react-use-controllable-state" "1.0.1"
+
"@radix-ui/react-toast@^1.1.4":
version "1.1.4"
resolved "https://registry.yarnpkg.com/@radix-ui/react-toast/-/react-toast-1.1.4.tgz#9a7fc2d71700886f3292f7699c905f1e01be59e1"
@@ -7016,6 +7031,13 @@ unified@^10.0.0, unified@^10.1.2:
trough "^2.0.0"
vfile "^5.0.0"
+unist-builder@^3.0.0:
+ version "3.0.1"
+ resolved "https://registry.yarnpkg.com/unist-builder/-/unist-builder-3.0.1.tgz#258b89dcadd3c973656b2327b347863556907f58"
+ integrity sha512-gnpOw7DIpCA0vpr6NqdPvTWnlPTApCTRzr+38E6hCWx3rz/cjo83SsKIlS1Z+L5ttScQ2AwutNnb8+tAvpb6qQ==
+ dependencies:
+ "@types/unist" "^2.0.0"
+
unist-util-generated@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/unist-util-generated/-/unist-util-generated-2.0.1.tgz#e37c50af35d3ed185ac6ceacb6ca0afb28a85cae"