Skip to content

armgit / mapcn

Public Imported from GitHub
0

Beautiful map components. 100% Free, Zero config, one command setup.

TypeScript

refactor: replace get-started dropdown with copy-prompt chip

anmolc7d6d0ba9e7b
diff --git a/src/app/(main)/(home)/_components/agent-prompt.tsx b/src/app/(main)/(home)/_components/agent-prompt.tsx
new file mode 100644
index 0000000..e934dd6
--- /dev/null
+++ b/src/app/(main)/(home)/_components/agent-prompt.tsx
@@ -0,0 +1,37 @@
+"use client";
+
+import { useState } from "react";
+import { Check } from "lucide-react";
+
+import { mapInstallAgentPrompt } from "@/lib/llm-prompts";
+import { Button } from "@/components/ui/button";
+
+export function AgentPrompt() {
+ const [copied, setCopied] = useState(false);
+
+ async function copyPrompt() {
+ try {
+ await navigator.clipboard.writeText(mapInstallAgentPrompt);
+ setCopied(true);
+ setTimeout(() => setCopied(false), 2500);
+ } catch (error) {
+ console.error("Failed to copy prompt:", error);
+ }
+ }
+
+ return (
+ <Button
+ type="button"
+ onClick={copyPrompt}
+ aria-live="polite"
+ variant="ghost"
+ size="xs"
+ className="border-border/50 text-muted-foreground hover:text-foreground hover:bg-muted/50 h-7 gap-1.5 rounded-full border"
+ >
+ {copied && <Check />}
+ {copied
+ ? "Copied - paste it into your coding agent"
+ : "Building with an agent? Copy the prompt"}
+ </Button>
+ );
+}
diff --git a/src/app/(main)/(home)/_components/get-started-actions.tsx b/src/app/(main)/(home)/_components/get-started-actions.tsx
deleted file mode 100644
index 48d7ebc..0000000
--- a/src/app/(main)/(home)/_components/get-started-actions.tsx
+++ /dev/null
@@ -1,105 +0,0 @@
-"use client";
-
-import Link from "next/link";
-import { useState } from "react";
-import { Bot, Check, ChevronDown, Users } from "lucide-react";
-
-import { Button } from "@/components/ui/button";
-import {
- ButtonGroup,
- ButtonGroupSeparator,
-} from "@/components/ui/button-group";
-import {
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuTrigger,
-} from "@/components/ui/dropdown-menu";
-import { cn } from "@/lib/utils";
-import { mapInstallAgentPrompt } from "@/lib/llm-prompts";
-
-type Mode = "humans" | "agents";
-
-export function GetStartedActions() {
- const [mode, setMode] = useState<Mode>("humans");
- const [copied, setCopied] = useState(false);
-
- async function copyPrompt() {
- try {
- await navigator.clipboard.writeText(mapInstallAgentPrompt);
- setCopied(true);
- setTimeout(() => setCopied(false), 2500);
- } catch (error) {
- console.error("Failed to copy prompt:", error);
- }
- }
-
- return (
- <div className="relative">
- <ButtonGroup>
- {mode === "humans" ? (
- <Button asChild className="group/link min-w-30 justify-center">
- <Link href="/docs">Get Started</Link>
- </Button>
- ) : (
- <Button
- onClick={copyPrompt}
- className="min-w-30 justify-center"
- aria-live="polite"
- >
- {copied ? "Copied" : "Copy prompt"}
- </Button>
- )}
-
- <ButtonGroupSeparator />
-
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button
- size="icon"
- aria-label="Switch get started mode"
- className="group/trigger w-8"
- >
- <ChevronDown className="transition-transform duration-200 group-data-[state=open]/trigger:rotate-180" />
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end" className="grid w-56 gap-1">
- <DropdownMenuItem
- onSelect={() => setMode("humans")}
- className={cn(mode === "humans" && "bg-accent")}
- >
- <Users />
- <div className="flex flex-col">
- <span className="text-foreground">For humans</span>
- <span className="text-muted-foreground text-xs">
- Read the documentation
- </span>
- </div>
- {mode === "humans" && <Check className="ml-auto" />}
- </DropdownMenuItem>
- <DropdownMenuItem
- onSelect={() => setMode("agents")}
- className={cn(mode === "agents" && "bg-accent")}
- >
- <Bot />
- <div className="flex flex-col">
- <span className="text-foreground">For agents</span>
- <span className="text-muted-foreground text-xs">
- Copy a prompt for your AI
- </span>
- </div>
- {mode === "agents" && <Check className="ml-auto" />}
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- </ButtonGroup>
-
- {copied && (
- <p className="animate-fade-up text-muted-foreground absolute top-full left-0 mt-2 flex items-center gap-1 text-xs whitespace-nowrap">
- <Check className="size-3.5" />
- Copied - paste this into your coding agent!
- </p>
- )}
- </div>
- );
-}
diff --git a/src/app/(main)/(home)/page.tsx b/src/app/(main)/(home)/page.tsx
index 4edc02b..c8e92e4 100644
--- a/src/app/(main)/(home)/page.tsx
+++ b/src/app/(main)/(home)/page.tsx
@@ -1,8 +1,8 @@
import Link from "next/link";
import { CSSProperties } from "react";
+import { AgentPrompt } from "./_components/agent-prompt";
import { ExamplesGrid } from "./_components/examples-grid";
-import { GetStartedActions } from "./_components/get-started-actions";
import { Footer } from "@/components/footer";
import {
PageHeader,
@@ -22,16 +22,25 @@ export default function Page() {
<br className="hidden sm:block" />
Built on MapLibre. Styled with Tailwind.
</PageHeaderDescription>
- <PageActions>
- <GetStartedActions />
- <Button variant="outline" asChild>
- <Link href="/docs/basic-map">View Components</Link>
- </Button>
+ <PageActions className="mt-5 flex-col gap-4">
+ <div className="flex flex-wrap items-center justify-center gap-3">
+ <Button asChild className="min-w-36 justify-center">
+ <Link href="/docs">Get Started</Link>
+ </Button>
+ <Button
+ variant="outline"
+ asChild
+ className="min-w-36 justify-center"
+ >
+ <Link href="/docs/basic-map">View Components</Link>
+ </Button>
+ </div>
+ <AgentPrompt />
</PageActions>
</PageHeader>
<section
- className="animate-fade-in animate-stagger container-wide pt-4"
+ className="animate-fade-in animate-stagger container-wide"
style={
{
"--stagger": 4,
diff --git a/src/app/(main)/blocks/page.tsx b/src/app/(main)/blocks/page.tsx
index acf24a2..f002191 100644
--- a/src/app/(main)/blocks/page.tsx
+++ b/src/app/(main)/blocks/page.tsx
@@ -21,7 +21,7 @@ export default async function Page() {
return (
<>
<PageHeader align="left" size="sm">
- <PageHeaderHeading>Map Blocks</PageHeaderHeading>
+ <PageHeaderHeading>Blocks</PageHeaderHeading>
<PageHeaderDescription>
Pre-built, ready-to-use map blocks. Browse, preview, and copy them
into your app with one command.
diff --git a/src/components/page-header.tsx b/src/components/page-header.tsx
index 5bf2c59..8790307 100644
--- a/src/components/page-header.tsx
+++ b/src/components/page-header.tsx
@@ -39,8 +39,8 @@ function PageHeader({
className={cn(
"container mx-auto flex w-full max-w-6xl flex-col",
size === "sm"
- ? "gap-3 py-14 md:py-16"
- : "gap-4 py-16 md:py-20 lg:py-24",
+ ? "gap-3 py-14 md:py-18"
+ : "gap-4 py-16 md:py-20 lg:py-24 lg:pb-20",
align === "center"
? "items-center text-center"
: "items-start text-left",
@@ -71,7 +71,7 @@ function PageHeaderHeading({
className={cn(
"animate-fade-up animate-stagger max-w-4xl font-bold tracking-tight",
size === "sm"
- ? "text-3xl font-semibold md:text-4xl"
+ ? "text-4xl font-semibold md:text-5xl"
: "text-4xl sm:text-5xl md:text-6xl",
align === "center" ? "text-center" : "text-left",
className,
diff --git a/src/styles/globals.css b/src/styles/globals.css
index 656a73f..5198450 100644
--- a/src/styles/globals.css
+++ b/src/styles/globals.css
@@ -146,7 +146,7 @@
}
.container-wide {
- @apply max-w-[1640px] mx-auto px-6;
+ @apply max-w-[1650px] mx-auto px-6;
}
@keyframes fade-up {