UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.
✨ feat: Update magic ui component + add not found page
Dillion Verma6d5d5eda608e
diff --git a/app/(dashboard)/dashboard/loading.tsx b/app/(dashboard)/dashboard/loading.tsxindex 86c02cb5..79160ab5 100644--- a/app/(dashboard)/dashboard/loading.tsx+++ b/app/(dashboard)/dashboard/loading.tsx@@ -1,6 +1,4 @@import { DashboardHeader } from "@/components/dashboard/header";-// import { PostCreateButton } from "@/components/post-create-button"-// import { PostItem } from "@/components/post-item"import { DashboardShell } from "@/components/dashboard/shell";import { Skeleton } from "@/components/ui/skeleton";@@ -18,9 +16,10 @@ function SkeletonRow() {export default function DashboardLoading() {return (<DashboardShell>- <DashboardHeader heading="Dashboard" text="Manage account">- {/* <PostCreateButton /> */}- </DashboardHeader>+ <DashboardHeader+ heading="Dashboard"+ text="Manage account"+ ></DashboardHeader><div className="divide-border-200 divide-y rounded-md border"><SkeletonRow /><SkeletonRow />diff --git a/app/(docs)/components/[slug]/not-found.tsx b/app/(docs)/components/[slug]/not-found.tsxindex a4032847..fd490fbc 100644--- a/app/(docs)/components/[slug]/not-found.tsx+++ b/app/(docs)/components/[slug]/not-found.tsx@@ -4,19 +4,18 @@ import Link from "next/link";export default function NotFound() {return (- <main className="relative py-6 lg:gap-10 lg:py-8 xl:grid xl:grid-cols-[1fr_300px]">- <EmptyPlaceholder className="w-full">- <EmptyPlaceholder.Icon name="logo" />- <EmptyPlaceholder.Title>- Pre-order to access Magic UI- </EmptyPlaceholder.Title>- <EmptyPlaceholder.Description>- You will get access to all the components of Magic UI- </EmptyPlaceholder.Description>- <Link href="/" className={buttonVariants({ variant: "outline" })}>- Pre-order- </Link>- </EmptyPlaceholder>- </main>+ <EmptyPlaceholder className="w-full">+ <EmptyPlaceholder.Icon name="logo" />+ <EmptyPlaceholder.Title>+ Pre-order to access Magic UI+ </EmptyPlaceholder.Title>+ <EmptyPlaceholder.Description>+ You will get access to all future components and their source code so+ you can use them in your projects 🎉+ </EmptyPlaceholder.Description>+ <Link href="/" className={buttonVariants({ variant: "outline" })}>+ Pre-order+ </Link>+ </EmptyPlaceholder>);}diff --git a/app/(docs)/components/[slug]/page.tsx b/app/(docs)/components/[slug]/page.tsxindex fe98cf76..1310d14e 100644--- a/app/(docs)/components/[slug]/page.tsx+++ b/app/(docs)/components/[slug]/page.tsx@@ -2,10 +2,7 @@ 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 {- MagicBorderCard,- MagicBorderContainer,-} from "@/components/magicui/magic-border";+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";@@ -18,6 +15,7 @@ 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@@ -81,10 +79,6 @@ export async function generateMetadata({export default async function Post({ params }: { params: { slug: string } }) {const user = await getCurrentUser();- if (!user) {- notFound();- }-const component = allComponents.find((component) => component.slugAsParams === params.slug);@@ -129,7 +123,6 @@ export default async function Post({ params }: { params: { slug: string } }) {href={`https://twitter.com/intent/tweet?text=${component.title}&url=https://magicuikit.com/components/${component.slugAsParams}&via=${component.author}`}target="_blank"rel="noopener noreferrer"- className="transition-all hover:scale-110"><Twitter className="h-6 w-6" /></Link>@@ -138,7 +131,6 @@ export default async function Post({ params }: { params: { slug: string } }) {http://www.linkedin.com/shareArticle?mini=true&url=https://magicuikit.com/components/${component.slugAsParams}`}target="_blank"rel="noopener noreferrer"- className="transition-all hover:scale-110"><LinkedIn className="h-6 w-6" /></Link>@@ -146,33 +138,40 @@ export default async function Post({ params }: { params: { slug: string } }) {href={`https://www.facebook.com/sharer/sharer.php?u=https://magicuikit.com/components/${component.slugAsParams}`}target="_blank"rel="noopener noreferrer"- className="transition-all hover:scale-110"><Facebook className="h-6 w-6" /></Link></div></div>- <div className="pb-12 pt-8">+ <div className="flex flex-col pt-8 gap-4"><ComponentWrapper>- <MagicBorderContainer+ <MagicContainerclassName={- "grid w-full sm:grid-cols-2 grid-cols-1 gap-4 min-h-[300px] p-8"+ "grid w-full lg:grid-cols-2 grid-cols-1 gap-4 min-h-[500px] lg:min-h-[300px] p-8"}>- <MagicBorderCard className="group relative rounded-xl bg-gray-200 dark:bg-gray-800 p-4 shadow-2xl flex justify-center items-center overflow-hidden border dark:border-gray-800 border-gray-200 bg-gradient-to-br dark:from-gray-800 dark:to-gray-900 from-gray-100 to-gray-200">+ <MagicCard+ borderRadius={16}+ className="cursor-pointer shadow-2xl flex flex-col justify-center items-center overflow-hidden bg-gradient-to-br dark:from-gray-800 dark:to-gray-900 from-gray-100 to-gray-200 p-6"+ ><p className="text-4xl font-semibold whitespace-nowrap text-gray-800 dark:text-gray-200">Magic</p>- </MagicBorderCard>- <MagicBorderCard className="group relative rounded-xl bg-gray-200 dark:bg-gray-800 p-4 shadow-2xl flex justify-center items-center dark:to-gray-900 overflow-hidden border dark:border-gray-800 border-gray-200 bg-gradient-to-br dark:from-gray-800 from-gray-100 to-gray-200">+ </MagicCard>+ <MagicCard+ borderRadius={16}+ className="cursor-pointer shadow-2xl flex justify-center items-center overflow-hidden bg-gradient-to-br dark:from-gray-800 dark:to-gray-900 from-gray-100 to-gray-200"+ ><p className="text-4xl font-semibold whitespace-nowrap text-gray-800 dark:text-gray-200">- Border+ Card</p>- </MagicBorderCard>- </MagicBorderContainer>+ </MagicCard>+ </MagicContainer></ComponentWrapper>- <Mdx code={component.body.code} />++ {user && <Mdx code={component.body.code} />}+ {!user && <NotFound />}</div></div>diff --git a/app/(marketing)/not-found.tsx b/app/(marketing)/not-found.tsxnew file mode 100644index 00000000..5bb587e6--- /dev/null+++ b/app/(marketing)/not-found.tsx@@ -0,0 +1,41 @@+"use client";++import { Icons } from "@/components/icons";+import { Button, buttonVariants } from "@/components/ui/button";+import Link from "next/link";+import { useRouter } from "next/navigation";++export default function NotFound() {+ const router = useRouter();+ return (+ <section>+ <div className="container flex items-center min-h-[calc(100vh-8rem)] px-6 py-12 mx-auto">+ <div className="flex flex-col items-center max-w-sm mx-auto text-center">+ <p className="p-3 text-sm font-medium rounded-full bg-blue-50 dark:bg-gray-800">+ <Icons.warning className="w-6 h-6" />+ </p>+ <h1 className="mt-3 text-2xl font-semibold text-gray-800 dark:text-white md:text-3xl">+ Page not found+ </h1>+ <p className="mt-4 text-gray-500 dark:text-gray-400">+ The page you are looking for doesn't exist.+ </p>++ <div className="flex items-center w-full mt-6 gap-x-3 shrink-0 sm:w-auto group">+ <Button+ onClick={() => router.back()}+ className={buttonVariants({ variant: "secondary" })}+ >+ <Icons.chevronLeft className="w-4 h-4 group-hover:-translate-x-1 transition-transform" />+ <span>Go back</span>+ </Button>++ <Link href="/" className={buttonVariants({ variant: "default" })}>+ Take me home+ </Link>+ </div>+ </div>+ </div>+ </section>+ );+}diff --git a/app/(marketing)/page.tsx b/app/(marketing)/page.tsxindex 16ee5132..38ada54e 100644--- a/app/(marketing)/page.tsx+++ b/app/(marketing)/page.tsx@@ -1,8 +1,8 @@-import Twitter from "@/components/icons/twitter";import { FadeIn } from "@/components/magicui/FadeIn";import { buttonVariants } from "@/components/ui/button";-import { siteConfig } from "@/config/site";+import { Separator } from "@/components/ui/separator";import { cn } from "@/lib/utils";+import { ChevronRight } from "lucide-react";import Link from "next/link";import { CSSProperties } from "react";@@ -13,7 +13,7 @@ export default function Home() {<div className="container flex max-w-[64rem] flex-col items-center gap-4 text-center"><FadeIn className="z-10 flex flex-col items-center justify-center w-full h-full"><Link- href={siteConfig.links.twitter}+ href="/components/magic-border"className={cn("flex justify-center items-center flex-row","rounded-2xl px-4 py-1.5 text-sm font-medium shadow-[inset_0_-8px_10px_#8fdfff1f]",@@ -21,21 +21,31 @@ export default function Home() {"relative after:block after:w-full after:h-full after:absolute after:inset-0 after:p-[1px] after:[border-radius:inherit] after:bg-gradient-to-r after:from-[#ffaa40]/50 after:via-[#9c40ff]/50 after:to-[#ffaa40]/50 after:[mask:linear-gradient(#fff_0_0)_content-box,linear-gradient(#fff_0_0)] after:content-[''] after:[mask-composite:xor]","after:animate-gradient after:bg-[length:var(--bg-size)_100%]")}- target="_blank"style={{"--bg-size": "300%",} as CSSProperties}>- <Twitter className="h-4 w-4 mr-2 inline-block" />+ {/* <Twitter className="h-4 w-4 mr-2 inline-block" /><divclassName={cn(`bg-clip-text text-transparent bg-gradient-to-r from-[#ffaa40] via-[#9c40ff] to-[#ffaa40] animate-gradient bg-[length:var(--bg-size)_100%]`)}>Follow along on Twitter- </div>+ </div> */}+ 🎉 <Separator className="mx-2 h-4" orientation="vertical" />{" "}+ <span className="sm:hidden">Style, a new CLI and more.</span>+ <span+ className={cn(+ `bg-clip-text text-transparent bg-gradient-to-r from-[#ffaa40] via-[#9c40ff] to-[#ffaa40] animate-gradient bg-[length:var(--bg-size)_100%]`,+ `hidden sm:inline`+ )}+ >+ Introducing Magic Card+ </span>+ <ChevronRight className="ml-1 h-4 w-4 text-gray-500" /></Link></FadeIn><FadeIn@@ -61,20 +71,20 @@ export default function Home() {><div className="space-x-4"><Link- href="/components"+ href="https://buy.stripe.com/3cs8zHafOdUa0tG9AA"+ target="_blank"+ rel="noreferrer"className={cn(buttonVariants({ size: "lg" }))}>- Get Started+ Pre-order</Link><Link- href={siteConfig.links.twitter}- target="_blank"- rel="noreferrer"+ href="/components"className={cn(buttonVariants({ variant: "outline", size: "lg" }))}>+ Components</Link></div></FadeIn>diff --git a/components/command-menu.tsx b/components/command-menu.tsxindex 3591060b..9c6a9e4f 100644--- a/components/command-menu.tsx+++ b/components/command-menu.tsx@@ -78,7 +78,7 @@ export function CommandMenu({ ...props }: DialogProps) {</CommandGroup>{docsConfig.sidebarNav.map((group) => (<CommandGroup key={group.title} heading={group.title}>- {group.items.map((navItem) => (+ {group.items?.map((navItem) => (<CommandItemkey={navItem.href}value={navItem.title}diff --git a/components/component-wrapper.tsx b/components/component-wrapper.tsxindex 9ef8bca3..f6b9bd8d 100644--- a/components/component-wrapper.tsx+++ b/components/component-wrapper.tsx@@ -1,12 +1,16 @@+import { cn } from "@/lib/utils";import { CSSProperties } from "react";const ComponentWrapper = ({ children }: { children: any }) => {return (- <div className="relative rounded-xl border border-dashed p-8 dark:border-slate-800 md:p-8 flex justify-center items-center flex-col max-w-[65ch]">+ <div className="relative rounded-xl border dark:border-slate-800 md:p-8 flex justify-center items-center flex-col max-w-[65ch]">{children}<div- className="absolute inset-0 -z-10 h-full w-full bg-[radial-gradient(#e5e7eb_1px,transparent_1px)] [background-size:16px_16px] dark:bg-[radial-gradient(#1f2937_1px,transparent_1px)]"+ 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)]`+ )}style={{"--mask-offset": "50px",@@ -15,6 +19,7 @@ const ComponentWrapper = ({ children }: { children: any }) => {"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)",maskComposite: "intersect",WebkitMaskComposite: "source-in, xor",+ // backgroundImage: `linear-gradient(to right,#1f2937 1px, transparent 1px), linear-gradient(to bottom,#1f2937 1px,transparent 1px)`,} as CSSProperties}/>diff --git a/components/magicui/magic-border.tsx b/components/magicui/magic-border.tsxdeleted file mode 100644index 20e85b33..00000000--- a/components/magicui/magic-border.tsx+++ /dev/null@@ -1,141 +0,0 @@-"use client";--import { ReactNode, useEffect, useRef, useState } from "react";--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 MagicBorderContainer = ({- 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>>([]);-- 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;- if (inside) {- 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`);- box.style.setProperty("--opacity", `1`);- });- } else {- boxes.forEach((box) => {- box.style.setProperty("--opacity", `0`);- });- }- }- };-- useEffect(() => {- 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]);-- useEffect(() => {- init();- }, []);-- return (- <div className={className} ref={containerRef}>- {children}- </div>- );-};--export function MagicBorderCard({- className,- children,- maskSize = 200,- borderColor = "#475569",- borderWidth = 1,-}: {- className?: string;- children?: ReactNode;- maskSize?: number;- borderColor?: string;- borderWidth?: number;-}) {- let borderMask = `radial-gradient(${maskSize}px ${maskSize}px at var(--mouse-x) var(--mouse-y), black 45%, transparent)`;-- let borderStyle = {- opacity: `var(--opacity, 0)`,- border: `${borderWidth}px solid ${borderColor}`,- maskImage: borderMask,- WebkitMaskImage: borderMask,- };-- return (- <div className={className}>- {children}- {/* Border Spotlight */}- <div- style={borderStyle}- className={`pointer-events-none absolute inset-0 z-10 h-full w-full cursor-default rounded-xl border bg-[transparent] opacity-0 transition-opacity duration-500 placeholder:select-none group-hover:opacity-100`}- />- </div>- );-}diff --git a/components/magicui/magic-card.tsx b/components/magicui/magic-card.tsxnew file mode 100644index 00000000..f7ca9bf8--- /dev/null+++ b/components/magicui/magic-card.tsx@@ -0,0 +1,246 @@+"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 = "#475569",+ borderWidth = 1,+ borderRadius = 16,+ spotlight = true,+ spotlightColor = "rgba(255,255,255,0.03)",+ 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:opacity-[var(--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-lg";++ 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:opacity-[var(--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, "before:opacity-0 before:hover:opacity-100"],+ isolated &&+ spotlight && [+ spotlightStyles,+ "after:opacity-0 after:hover:opacity-100",+ ],+ !isolated && borderStyles,+ !isolated && spotlight && spotlightStyles+ )}+ >+ <div+ className={cn(+ "absolute inset-[var(--border-width)] rounded-[var(--border-radius)] z-[2]",+ className+ )}+ >+ {children}+ </div>+ </div>+ );+}diff --git a/components/site-footer.tsx b/components/site-footer.tsxindex 8d131b8a..64b871dc 100644--- a/components/site-footer.tsx+++ b/components/site-footer.tsx@@ -2,8 +2,8 @@ import { siteConfig } from "@/config/site";export function SiteFooter() {return (- <footer className="py-6 md:px-8 md:py-0">- <div className="container flex flex-col items-center justify-between gap-4 md:h-24 md:flex-row">+ <footer className="py-6 md:px-8 md:py-0 border-t">+ <div className="container flex flex-col items-center justify-between gap-4 md:h-16 md:flex-row"><p className="text-center text-sm leading-loose text-muted-foreground md:text-left">Brought to you by{" "}<adiff --git a/components/site-header.tsx b/components/site-header.tsxindex c33dded0..27d63132 100644--- a/components/site-header.tsx+++ b/components/site-header.tsx@@ -17,7 +17,7 @@ interface SiteHeaderProps {export function SiteHeader({ user }: SiteHeaderProps) {return (<header className="supports-backdrop-blur:bg-background/60 sticky top-0 z-40 w-full border-b bg-background/60 backdrop-blur">- <div className="container flex h-14 items-center">+ <div className="container flex h-16 items-center"><MainNav /><MobileNav /><div className="flex flex-1 items-center justify-between space-x-2 md:justify-end">diff --git a/components/ui/separator.tsx b/components/ui/separator.tsxnew file mode 100644index 00000000..12d81c4a--- /dev/null+++ b/components/ui/separator.tsx@@ -0,0 +1,31 @@+"use client"++import * as React from "react"+import * as SeparatorPrimitive from "@radix-ui/react-separator"++import { cn } from "@/lib/utils"++const Separator = React.forwardRef<+ React.ElementRef<typeof SeparatorPrimitive.Root>,+ React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>+>(+ (+ { className, orientation = "horizontal", decorative = true, ...props },+ ref+ ) => (+ <SeparatorPrimitive.Root+ ref={ref}+ decorative={decorative}+ orientation={orientation}+ className={cn(+ "shrink-0 bg-border",+ orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",+ className+ )}+ {...props}+ />+ )+)+Separator.displayName = SeparatorPrimitive.Root.displayName++export { Separator }diff --git a/config/dashboard.ts b/config/dashboard.tsindex ce8becf5..96205050 100644--- a/config/dashboard.ts+++ b/config/dashboard.ts@@ -1,23 +1,8 @@import { DashboardConfig } from "@/types";export const dashboardConfig: DashboardConfig = {- mainNav: [- // {- // title: "Documentation",- // href: "/docs",- // },- // {- // title: "Support",- // href: "/support",- // disabled: true,- // },- ],+ mainNav: [],sidebarNav: [- // {- // title: "Posts",- // href: "/dashboard",- // icon: "post",- // },{title: "Billing",href: "/dashboard/billing",diff --git a/content/components/magic-border.mdx b/content/components/magic-border.mdxindex 2170cf22..f6479c79 100644--- a/content/components/magic-border.mdx+++ b/content/components/magic-border.mdx@@ -1,9 +1,9 @@----title: Magic Border+title: Magic Carddate: 2023-06-25-summary: A spotlight effect that highlights element borders on hover.+summary: A spotlight effect that follows your mouse cursor and highlights borders on hover.author: dillionverma-published: true+published: falsevideo: https://cdn.magicuikit.com/magic-border.webm---@@ -14,7 +14,7 @@ video: https://cdn.magicuikit.com/magic-border.webm## Prerequisites```bash-npm install -D tailwindcss+npm install -D tailwindcss tailwind-merge clsx```</Step>@@ -26,7 +26,7 @@ npm install -D tailwindcssCopy and page the following code into your project.```text-app/components/magicui/magic-border.tsx+components/magicui/magic-border.tsx```<ComponentSource name="magic-border" >@@ -34,7 +34,13 @@ app/components/magicui/magic-border.tsx```tsx showLineNumbers"use client";-import { ReactNode, useEffect, useRef, useState } from "react";+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;@@ -62,7 +68,7 @@ export default function useMousePosition(): MousePosition {return mousePosition;}-export const MagicBorderContainer = ({+export const MagicContainer = ({children,className,}: {@@ -76,6 +82,7 @@ export const MagicBorderContainer = ({const [boxes, setBoxes] = useState<Array<HTMLElement>>([]);useEffect(() => {+ init();containerRef.current &&setBoxes(Array.from(containerRef.current.children).map((el) => el as HTMLElement)@@ -95,10 +102,6 @@ export const MagicBorderContainer = ({onMouseMove();}, [mousePosition]);- useEffect(() => {- init();- }, []);-const init = () => {if (containerRef.current) {containerSize.current.w = containerRef.current.offsetWidth;@@ -113,23 +116,23 @@ export const MagicBorderContainer = ({const x = mousePosition.x - rect.left;const y = mousePosition.y - rect.top;const inside = x < w && x > 0 && y < h && y > 0;- if (inside) {- 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`);++ 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 {- boxes.forEach((box) => {+ } else {box.style.setProperty("--opacity", `0`);- });- }+ }+ });}};@@ -140,36 +143,138 @@ export const MagicBorderContainer = ({);};-export function MagicBorderCard({- className,- children,- maskSize = 200,- borderColor = "#475569",- borderWidth = 1,-}: {+interface MagicCardProps {+ /**+ * @default ""+ * @type string+ * @description+ * The className of the card+ */className?: string;++ /**+ * @default ""+ * @type ReactNode+ * @description+ * The children of the card+ * */children?: ReactNode;- maskSize?: number;++ /**+ * @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;-}) {- let borderMask = `radial-gradient(${maskSize}px ${maskSize}px at var(--mouse-x) var(--mouse-y), black 45%, transparent)`;-- let borderStyle = {- opacity: `var(--opacity, 0)`,- border: `${borderWidth}px solid ${borderColor}`,- maskImage: borderMask,- WebkitMaskImage: borderMask,- };++ /**+ * @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 = "#475569",+ borderWidth = 1,+ borderRadius = 16,+ spotlight = true,+ spotlightColor = "rgba(255,255,255,0.03)",+ 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:opacity-[var(--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-lg";++ 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:opacity-[var(--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 className={className}>- {children}- {/* Border Spotlight */}+ <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, "before:opacity-0 before:hover:opacity-100"],+ isolated &&+ spotlight && [+ spotlightStyles,+ "after:opacity-0 after:hover:opacity-100",+ ],+ !isolated && borderStyles,+ !isolated && spotlight && spotlightStyles+ )}+ ><div- style={borderStyle}- className={`pointer-events-none absolute inset-0 z-10 h-full w-full cursor-default rounded-xl border bg-[transparent] opacity-0 transition-opacity duration-500 placeholder:select-none group-hover:opacity-100`}- />+ className={cn(+ "absolute inset-[var(--border-width)] rounded-[var(--border-radius)] z-[2]",+ className+ )}+ >+ {children}+ </div></div>);}@@ -183,23 +288,31 @@ export function MagicBorderCard({## Usage-Now you can use the `MagicBorderContainer` and `MagicBorderCard` components to create a magic border effect.+Now you can use the `MagicContainer` and `MagicCard` components to create a magic card effect.```tsx-<MagicBorderContainer- className={"grid w-full sm:grid-cols-2 grid-cols-1 gap-4 min-h-[300px] p-8"}+<MagicContainer+ className={+ "grid w-full lg:grid-cols-2 grid-cols-1 gap-4 min-h-[500px] lg:min-h-[300px] p-8"+ }>- <MagicBorderCard className="group relative rounded-xl bg-gray-200 dark:bg-gray-800 p-4 shadow-2xl flex justify-center items-center overflow-hidden border dark:border-gray-800 border-gray-200 bg-gradient-to-br dark:from-gray-800 dark:to-gray-900 from-gray-100 to-gray-200">- <h2 className="text-4xl font-semibold whitespace-nowrap text-gray-800 dark:text-gray-200">+ <MagicCard+ borderRadius={16}+ className="cursor-pointer shadow-2xl flex flex-col justify-center items-center overflow-hidden bg-gradient-to-br dark:from-gray-800 dark:to-gray-900 from-gray-100 to-gray-200 p-6"+ >+ <p className="text-4xl font-semibold whitespace-nowrap text-gray-800 dark:text-gray-200">Magic- </h2>- </MagicBorderCard>- <MagicBorderCard className="group relative rounded-xl bg-gray-200 dark:bg-gray-800 p-4 shadow-2xl flex justify-center items-center overflow-hidden border dark:border-gray-800 border-gray-200 bg-gradient-to-br dark:from-gray-800 dark:to-gray-900 from-gray-100 to-gray-200">- <h2 className="text-4xl font-semibold whitespace-nowrap text-gray-800 dark:text-gray-200">+ </p>+ </MagicCard>+ <MagicCard+ borderRadius={16}+ className="cursor-pointer shadow-2xl flex justify-center items-center overflow-hidden bg-gradient-to-br dark:from-gray-800 dark:to-gray-900 from-gray-100 to-gray-200"+ >+ <p className="text-4xl font-semibold whitespace-nowrap text-gray-800 dark:text-gray-200">Border- </h2>- </MagicBorderCard>-</MagicBorderContainer>+ </p>+ </MagicCard>+</MagicContainer>```## Props@@ -213,13 +326,18 @@ Now you can use the `MagicBorderContainer` and `MagicBorderCard` components to c### MagicBorderCard-| Prop name | Type | Default | Description |-| ----------- | --------- | ------- | ---------------------------------- |-| children | ReactNode | - | The children to render |-| className | string | - | The className to apply to the card |-| maskSize | number | 200 | The size of the spotlight mask |-| borderColor | string | #475569 | The color of the border |-| borderWidth | number | 1 | The width of the border |+| Prop name | Type | Default | Description |+| -------------- | --------- | ---------------------- | ---------------------------------- |+| children | ReactNode | - | The children to render |+| className | string | - | The className to apply to the card |+| maskSize | number | 200 | The size of the spotlight mask |+| borderColor | string | #475569 | The color of the border |+| borderWidth | number | 1 | The width of the border |+| borderRadius | number | 16 | The radius of the border |+| spotlight | boolean | true | Whether to show the spotlight |+| spotlightColor | string | rgba(255,255,255,0.03) | The color of the spotlight |+| isolated | boolean | true | Whether to isolate the card |+| background | string | rgba(255,255,255,0.1) | The background of the card |## Creditsdiff --git a/lib/subscription.ts b/lib/subscription.tsindex 25ad495b..1f312b7a 100644--- a/lib/subscription.ts+++ b/lib/subscription.ts@@ -1,34 +1,37 @@// @ts-nocheck-// export async function getUserSubscriptionPlan(-// userId: string-// ): Promise<UserSubscriptionPlan> {-// const user = await db.user.findFirst({-// where: {-// id: userId,-// },-// select: {-// stripeSubscriptionId: true,-// stripeCurrentPeriodEnd: true,-// stripeCustomerId: true,-// stripePriceId: true,-// },-// });+import { freePlan, proPlan } from "@/config/subscriptions";+import { db } from "@/lib/db";-// if (!user) {-// throw new Error("User not found");-// }+export async function getUserSubscriptionPlan(+ userId: string+): Promise<UserSubscriptionPlan> {+ const user = await db.user.findFirst({+ where: {+ id: userId,+ },+ select: {+ // stripeSubscriptionId: true,+ // stripeCurrentPeriodEnd: true,+ // stripeCustomerId: true,+ // stripePriceId: true,+ },+ });-// // Check if user is on a pro plan.-// const isPro = user.stripePriceId === proPlan.stripePriceId;-// // user.stripeCurrentPeriodEnd?.getTime() + 86_400_000 > Date.now();+ if (!user) {+ throw new Error("User not found");+ }-// const plan = isPro ? proPlan : freePlan;+ // Check if user is on a pro plan.+ const isPro = user.stripePriceId === proPlan.stripePriceId;+ // user.stripeCurrentPeriodEnd?.getTime() + 86_400_000 > Date.now();-// return {-// ...plan,-// ...user,-// // stripeCurrentPeriodEnd: user.stripeCurrentPeriodEnd?.getTime(),-// isPro,-// };-// }+ const plan = isPro ? proPlan : freePlan;++ return {+ ...plan,+ ...user,+ // stripeCurrentPeriodEnd: user.stripeCurrentPeriodEnd?.getTime(),+ isPro,+ };+}diff --git a/package.json b/package.jsonindex bc5090d8..d9d48284 100644--- a/package.json+++ b/package.json@@ -26,6 +26,7 @@"@radix-ui/react-icons": "^1.3.0","@radix-ui/react-label": "^2.0.2","@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-toast": "^1.1.4","@react-email/body": "0.0.2",diff --git a/types/index.d.ts b/types/index.d.tsindex 96700a27..f96833dd 100644--- a/types/index.d.ts+++ b/types/index.d.ts@@ -22,14 +22,14 @@ export type DashboardConfig = {sidebarNav: SidebarNavItem[];};-// export type SubscriptionPlan = {-// name: string;-// description: string;-// stripePriceId: string;-// };+export type SubscriptionPlan = {+ name: string;+ description: string;+ stripePriceId: string;+};-// export type UserSubscriptionPlan = SubscriptionPlan &-// Pick<User, "stripeCustomerId" | "stripeSubscriptionId"> & {-// stripeCurrentPeriodEnd: number;-// isPro: boolean;-// };+export type UserSubscriptionPlan = SubscriptionPlan &+ Pick<User, "stripeCustomerId" | "stripeSubscriptionId"> & {+ stripeCurrentPeriodEnd: number;+ isPro: boolean;+ };diff --git a/yarn.lock b/yarn.lockindex b5a05329..62c88a04 100644--- a/yarn.lock+++ b/yarn.lock@@ -1456,6 +1456,14 @@"@radix-ui/react-use-callback-ref" "1.0.1""@radix-ui/react-use-layout-effect" "1.0.1"+"@radix-ui/react-separator@^1.0.3":+ version "1.0.3"+ resolved "https://registry.yarnpkg.com/@radix-ui/react-separator/-/react-separator-1.0.3.tgz#be5a931a543d5726336b112f465f58585c04c8aa"+ integrity sha512-itYmTy/kokS21aiV5+Z56MZB54KrhPgn6eHDKkFeOLR34HMN2s8PaN47qZZAGnvupcjxHaFZnW4pQEh0BvvVuw==+ dependencies:+ "@babel/runtime" "^7.13.10"+ "@radix-ui/react-primitive" "1.0.3"+"@radix-ui/[email protected]":version "1.0.0"resolved "https://registry.yarnpkg.com/@radix-ui/react-slot/-/react-slot-1.0.0.tgz#7fa805b99891dea1e862d8f8fbe07f4d6d0fd698"