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 template demos to free repo

Dillion Verma44fc3bbefbb0
diff --git a/components/main-nav.tsx b/components/main-nav.tsx
index 6649b738..0f1d906c 100644
--- a/components/main-nav.tsx
+++ b/components/main-nav.tsx
@@ -3,6 +3,7 @@
import Link from "next/link";
import { usePathname } from "next/navigation";
import { ExternalLinkIcon } from "@radix-ui/react-icons";
+import posthog from "posthog-js";
import { docsConfig } from "@/config/docs";
import { siteConfig } from "@/config/site";
@@ -27,6 +28,7 @@ export function MainNav() {
<Link
key={item.href}
href={item.href!}
+ onClick={() => item.event && posthog.capture(item.event)}
target={item.external ? "_blank" : undefined}
className={cn(
"flex items-center justify-center transition-colors hover:text-foreground/80",
diff --git a/components/mdx-components.tsx b/components/mdx-components.tsx
index 69e36f91..56fe5471 100644
--- a/components/mdx-components.tsx
+++ b/components/mdx-components.tsx
@@ -11,7 +11,9 @@ import {
AccordionTrigger,
} from "@/components/ui/accordion";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
+import RepoDownload from "@/components/repo-download";
import TechStack from "@/components/tech-stack";
+import TemplatePreview from "@/components/template-preview";
import TweetCard from "@/registry/components/magicui/tweet-card";
import { ComponentInstallation } from "./component-installation";
@@ -43,6 +45,8 @@ const components = {
AccordionItem,
AccordionTrigger,
TechStack,
+ RepoDownload,
+ TemplatePreview,
h1: ({ className, ...props }: React.HTMLAttributes<HTMLHeadingElement>) => (
<h1
className={cn(
diff --git a/components/repo-download.tsx b/components/repo-download.tsx
new file mode 100644
index 00000000..0b5159fc
--- /dev/null
+++ b/components/repo-download.tsx
@@ -0,0 +1,83 @@
+"use client";
+
+import { useState } from "react";
+import Link from "next/link";
+import { ArrowRightIcon, Download } from "lucide-react";
+import { toast } from "sonner";
+
+import { cn } from "@/lib/utils";
+import { Button, buttonVariants } from "@/components/ui/button";
+import { Icons } from "@/components/icons";
+
+interface RepoDownloadProps {
+ repo: string;
+ owner: string;
+ free?: boolean;
+}
+
+export default function RepoDownload({
+ repo,
+ owner,
+ free = false,
+}: RepoDownloadProps) {
+ const [loading, setLoading] = useState(false);
+
+ const handleDownload = async () => {
+ setLoading(true);
+
+ try {
+ const response = await fetch(
+ `${process.env.NEXT_PUBLIC_APP_URL}/api/repo/download`,
+ {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({ repo, owner }),
+ },
+ );
+ if (!response.ok) {
+ throw new Error(`HTTP error! status: ${response.status}`);
+ }
+ const data = await response.json();
+ const downloadUrl = data.downloadUrl;
+ /* window.open(downloadUrl, "_blank"); */
+ window.location.href = downloadUrl;
+ } catch (error) {
+ toast.error("Error occured while downloading. Please try again.");
+ console.error("error", error);
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ if (free) {
+ return (
+ <Button
+ onClick={handleDownload}
+ disabled={loading}
+ className="not-prose group relative w-full gap-2"
+ >
+ {loading ? "Downloading" : "Free Download"}
+ {!loading && <Download className="size-4" />}
+ {loading && <Icons.spinner className="size-4 animate-spin" />}
+ </Button>
+ );
+ }
+
+ return (
+ <Link
+ href="https://pro.magicui.design/pricing"
+ target="_blank"
+ className={cn(
+ buttonVariants({
+ variant: "default",
+ }),
+ "not-prose group relative w-full gap-1",
+ )}
+ >
+ Buy Now
+ <ArrowRightIcon className="size-4 transition-all duration-300 ease-out group-hover:translate-x-1" />
+ </Link>
+ );
+}
diff --git a/components/sidebar-nav.tsx b/components/sidebar-nav.tsx
index efeb523f..ec938623 100644
--- a/components/sidebar-nav.tsx
+++ b/components/sidebar-nav.tsx
@@ -3,6 +3,8 @@
import Link from "next/link";
import { usePathname } from "next/navigation";
import { SidebarNavItem } from "@/types";
+import { ExternalLinkIcon } from "@radix-ui/react-icons";
+import posthog from "posthog-js";
import { cn } from "@/lib/utils";
@@ -45,6 +47,7 @@ export function DocsSidebarNavItems({
<Link
key={index}
href={item.href}
+ onClick={() => item.event && posthog.capture(item.event)}
className={cn(
"group flex w-full items-center rounded-md border border-transparent px-2 py-1 hover:underline",
item.disabled && "cursor-not-allowed opacity-60",
@@ -61,6 +64,7 @@ export function DocsSidebarNavItems({
{item.label}
</span>
)}
+ {item.external && <ExternalLinkIcon className="ml-2 size-4" />}
</Link>
) : (
<span
diff --git a/components/template-preview.tsx b/components/template-preview.tsx
new file mode 100644
index 00000000..a3eae613
--- /dev/null
+++ b/components/template-preview.tsx
@@ -0,0 +1,30 @@
+import { ReactNode } from "react";
+import Link from "next/link";
+import { ExternalLinkIcon } from "@radix-ui/react-icons";
+
+import { cn } from "@/lib/utils";
+import { buttonVariants } from "@/components/ui/button";
+
+export default function TemplatePreview({
+ href,
+ children,
+}: {
+ href: string;
+ children: ReactNode;
+}) {
+ return (
+ <Link
+ className={cn(
+ buttonVariants({
+ variant: "outline",
+ }),
+ "not-prose group relative w-full gap-2",
+ )}
+ href={href}
+ target="_blank"
+ >
+ {children}
+ <ExternalLinkIcon className="size-4" />
+ </Link>
+ );
+}
diff --git a/config/docs.ts b/config/docs.ts
index c0b20491..b8a5bda3 100644
--- a/config/docs.ts
+++ b/config/docs.ts
@@ -15,6 +15,7 @@ export const docsConfig: DocsConfig = {
title: "Templates",
href: "https://pro.magicui.design",
external: true,
+ event: "header_cta_clicked",
},
],
sidebarNav: [
@@ -54,6 +55,41 @@ export const docsConfig: DocsConfig = {
},
],
},
+ {
+ title: "Templates",
+ items: [
+ {
+ title: "Portfolio",
+ href: `/docs/templates/portfolio`,
+ items: [],
+ label: "New",
+ event: "template_portfolio_clicked",
+ },
+ {
+ title: "Startup",
+ href: `/docs/templates/startup`,
+ items: [],
+ label: "",
+ event: "template_startup_clicked",
+ },
+ {
+ title: "SaaS",
+ href: `/docs/templates/saas`,
+ items: [],
+ disabled: true,
+ label: "Coming soon",
+ event: "template_saas_clicked",
+ },
+ {
+ title: "Mobile App",
+ href: `/docs/templates/app`,
+ items: [],
+ disabled: true,
+ label: "Coming soon",
+ event: "template_app_clicked",
+ },
+ ],
+ },
{
title: "Components",
items: [
diff --git a/content/docs/templates/portfolio.mdx b/content/docs/templates/portfolio.mdx
new file mode 100644
index 00000000..2a7672cb
--- /dev/null
+++ b/content/docs/templates/portfolio.mdx
@@ -0,0 +1,60 @@
+---
+title: Portfolio Template
+date: 2024-06-18
+description: A minimal portfolio template to showcase your work and experience
+author: dillionverma
+published: true
+---
+
+<div className="flex max-w-[800px] flex-col gap-4">
+ <video
+ autoPlay
+ loop
+ muted
+ src="/portfolio-demo.mp4"
+ className="w-full rounded-xl border shadow-2xl"
+ />
+ <div className="flex w-full flex-col gap-2 sm:flex-row">
+ <RepoDownload repo={"portfolio"} owner={"dillionverma"} free />
+ <TemplatePreview href="https://portfolio-magicui.vercel.app/">
+ Live Preview{" "}
+ </TemplatePreview>
+ </div>
+</div>
+
+### What is this?
+
+A complete template to market yourself and your portfolio to the world as a developer
+
+### Why should I use this?
+
+- ✅ Save 100+ hours of work
+- ✅ No need to learn advanced animations
+- ✅ Easy to configure and change
+- ✅ 1-click download and setup.
+- ✅ 5 minutes to update the text and images.
+- ✅ Deploy live to vercel
+
+### Features
+
+- Hero Section
+- About Section
+- Work Section
+- Education Section
+- Projects Section
+- Hackathon Section
+- Contact Section
+- Blog
+
+### Tech Stack
+
+<TechStack
+ technologies={[
+ "nextjs",
+ "react",
+ "typescript",
+ "tailwindcss",
+ "framermotion",
+ "shadcn",
+ ]}
+/>
diff --git a/content/docs/templates/startup.mdx b/content/docs/templates/startup.mdx
new file mode 100644
index 00000000..b9a8ffd7
--- /dev/null
+++ b/content/docs/templates/startup.mdx
@@ -0,0 +1,65 @@
+---
+title: Startup Template
+date: 2024-04-12
+description: The best landing page template for launching new ideas. Perfect for bootstrappers and pre-PMF VC backed startups.
+author: dillionverma
+published: true
+---
+
+<div className="flex max-w-[800px] flex-col gap-4">
+ <video
+ autoPlay
+ loop
+ muted
+ src="/startup-template-demo.mp4"
+ className="w-full rounded-xl border shadow-2xl"
+ />
+ <div className="flex w-full flex-col gap-2 sm:flex-row">
+ <RepoDownload repo={"startup-template"} owner={"dillionverma"} />
+ <TemplatePreview href="https://startup-template-sage.vercel.app/">
+ Live Preview{" "}
+ </TemplatePreview>
+ </div>
+</div>
+
+### What is this?
+
+A complete landing page template to launch a new project or idea (frontend only). Uses the latest frontend technologies and best practices to unblock you and delight your customers.
+
+### Who is this for?
+
+You are an indiehacker, bootstrapper, YC startup, solopreneur, VC-backed startup, developer, or student. You are thinking about launching a new idea or already have a prototype. Maybe it's an AI SaaS, a crazy drone robot company, or just a simple digital product. But... you dread the idea of learning react or anything frontend 😩
+
+**This template is exactly what you're looking for.**
+
+### Why should I use this?
+
+- ✅ Save 100+ hours of work
+- ✅ No need to learn advanced animations
+- ✅ Easy to configure and change
+- ✅ 1-click download and setup.
+- ✅ 5 minutes to update the text and images.
+- ✅ Deploy live to vercel
+
+### Features
+
+- Header Section
+- Hero Section
+- Social Proof Section
+- Pricing Section
+- Call To Action Section
+- Footer Section
+- Mobile Reponsive Navbar
+
+### Tech Stack
+
+<TechStack
+ technologies={[
+ "nextjs",
+ "react",
+ "typescript",
+ "tailwindcss",
+ "framermotion",
+ "shadcn",
+ ]}
+/>
diff --git a/public/portfolio-demo.mp4 b/public/portfolio-demo.mp4
new file mode 100644
index 00000000..4c8237ca
Binary files /dev/null and b/public/portfolio-demo.mp4 differ
diff --git a/public/portfolio-template-demo.mp4 b/public/portfolio-template-demo.mp4
deleted file mode 100644
index a4b2bf89..00000000
Binary files a/public/portfolio-template-demo.mp4 and /dev/null differ
diff --git a/types/index.d.ts b/types/index.d.ts
index 33f1946c..a52ba516 100644
--- a/types/index.d.ts
+++ b/types/index.d.ts
@@ -7,6 +7,7 @@ export interface NavItem {
external?: boolean;
icon?: keyof typeof Icons;
label?: string;
+ event?: string;
}
export interface NavItemWithChildren extends NavItem {