Skip to content

armgit / mapcn

Public Imported from GitHub
0

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

TypeScript

feat(site): image map wall on home, per-block pages

Anmol63375cdcb577
diff --git a/.claude/launch.json b/.claude/launch.json
new file mode 100644
index 0000000..c5350e3
--- /dev/null
+++ b/.claude/launch.json
@@ -0,0 +1,11 @@
+{
+ "version": "0.0.1",
+ "configurations": [
+ {
+ "name": "mapcn",
+ "runtimeExecutable": "npm",
+ "runtimeArgs": ["run", "dev", "--", "-p", "3100"],
+ "port": 3100
+ }
+ ]
+}
diff --git a/AGENTS.md b/AGENTS.md
index a83c415..561503b 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -90,3 +90,13 @@ npm run build # Production build
npm run lint # ESLint
npm run registry:build # Build distributable registry to public/r/
```
+
+<!-- BEGIN:nextjs-agent-rules -->
+
+# This is NOT the Next.js you know
+
+This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in `node_modules/next/dist/docs/` (resolved from this file's directory; in monorepos the `next` package may not be visible from the repo root) before writing any code. Heed deprecation notices.
+
+This block is written and re-added by `next dev` — verify at `node_modules/next/dist/server/lib/generate-agent-files.js`. Removing it from a diff only re-creates the uncommitted change; committing it with your work keeps the tree clean.
+
+<!-- END:nextjs-agent-rules -->
diff --git a/README.md b/README.md
index 3d27862..9a39921 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,10 @@
</p>
<p align="center">
- <img src="public/banner.png" alt="mapcn banner" />
+ <picture>
+ <source media="(prefers-color-scheme: light)" srcset="public/banner-light.png" />
+ <img src="public/banner.png" alt="mapcn banner" />
+ </picture>
</p>
## Features
diff --git a/public/banner-light.png b/public/banner-light.png
new file mode 100644
index 0000000..ca60747
Binary files /dev/null and b/public/banner-light.png differ
diff --git a/public/banner.png b/public/banner.png
index 1a52e30..5c9be65 100644
Binary files a/public/banner.png and b/public/banner.png differ
diff --git a/public/showcase/analytics-card-dark.jpg b/public/showcase/analytics-card-dark.jpg
new file mode 100644
index 0000000..e14833d
Binary files /dev/null and b/public/showcase/analytics-card-dark.jpg differ
diff --git a/public/showcase/analytics-card-light.jpg b/public/showcase/analytics-card-light.jpg
new file mode 100644
index 0000000..4dc60ef
Binary files /dev/null and b/public/showcase/analytics-card-light.jpg differ
diff --git a/public/showcase/analytics-map-dark.jpg b/public/showcase/analytics-map-dark.jpg
new file mode 100644
index 0000000..3573e77
Binary files /dev/null and b/public/showcase/analytics-map-dark.jpg differ
diff --git a/public/showcase/analytics-map-light.jpg b/public/showcase/analytics-map-light.jpg
new file mode 100644
index 0000000..ed813a4
Binary files /dev/null and b/public/showcase/analytics-map-light.jpg differ
diff --git a/public/showcase/arcs-dark.jpg b/public/showcase/arcs-dark.jpg
new file mode 100644
index 0000000..bc0add5
Binary files /dev/null and b/public/showcase/arcs-dark.jpg differ
diff --git a/public/showcase/arcs-light.jpg b/public/showcase/arcs-light.jpg
new file mode 100644
index 0000000..3e52d45
Binary files /dev/null and b/public/showcase/arcs-light.jpg differ
diff --git a/public/showcase/choropleth-dark.jpg b/public/showcase/choropleth-dark.jpg
new file mode 100644
index 0000000..1eedacd
Binary files /dev/null and b/public/showcase/choropleth-dark.jpg differ
diff --git a/public/showcase/choropleth-light.jpg b/public/showcase/choropleth-light.jpg
new file mode 100644
index 0000000..7a809a0
Binary files /dev/null and b/public/showcase/choropleth-light.jpg differ
diff --git a/public/showcase/clusters-dark.jpg b/public/showcase/clusters-dark.jpg
new file mode 100644
index 0000000..da089bc
Binary files /dev/null and b/public/showcase/clusters-dark.jpg differ
diff --git a/public/showcase/clusters-light.jpg b/public/showcase/clusters-light.jpg
new file mode 100644
index 0000000..e814b60
Binary files /dev/null and b/public/showcase/clusters-light.jpg differ
diff --git a/public/showcase/custom-layer-dark.jpg b/public/showcase/custom-layer-dark.jpg
new file mode 100644
index 0000000..c04f1d8
Binary files /dev/null and b/public/showcase/custom-layer-dark.jpg differ
diff --git a/public/showcase/custom-layer-light.jpg b/public/showcase/custom-layer-light.jpg
new file mode 100644
index 0000000..312fc8c
Binary files /dev/null and b/public/showcase/custom-layer-light.jpg differ
diff --git a/public/showcase/delivery-tracker-dark.jpg b/public/showcase/delivery-tracker-dark.jpg
new file mode 100644
index 0000000..1db3cc5
Binary files /dev/null and b/public/showcase/delivery-tracker-dark.jpg differ
diff --git a/public/showcase/delivery-tracker-light.jpg b/public/showcase/delivery-tracker-light.jpg
new file mode 100644
index 0000000..7349d3d
Binary files /dev/null and b/public/showcase/delivery-tracker-light.jpg differ
diff --git a/public/showcase/geojson-overlay-dark.jpg b/public/showcase/geojson-overlay-dark.jpg
new file mode 100644
index 0000000..039aeae
Binary files /dev/null and b/public/showcase/geojson-overlay-dark.jpg differ
diff --git a/public/showcase/geojson-overlay-light.jpg b/public/showcase/geojson-overlay-light.jpg
new file mode 100644
index 0000000..3073e6e
Binary files /dev/null and b/public/showcase/geojson-overlay-light.jpg differ
diff --git a/public/showcase/globe-dark.jpg b/public/showcase/globe-dark.jpg
new file mode 100644
index 0000000..d5cd36f
Binary files /dev/null and b/public/showcase/globe-dark.jpg differ
diff --git a/public/showcase/globe-light.jpg b/public/showcase/globe-light.jpg
new file mode 100644
index 0000000..ba98943
Binary files /dev/null and b/public/showcase/globe-light.jpg differ
diff --git a/public/showcase/heatmap-dark.jpg b/public/showcase/heatmap-dark.jpg
new file mode 100644
index 0000000..a1624e4
Binary files /dev/null and b/public/showcase/heatmap-dark.jpg differ
diff --git a/public/showcase/heatmap-light.jpg b/public/showcase/heatmap-light.jpg
new file mode 100644
index 0000000..5699b5e
Binary files /dev/null and b/public/showcase/heatmap-light.jpg differ
diff --git a/public/showcase/logistics-network-dark.jpg b/public/showcase/logistics-network-dark.jpg
new file mode 100644
index 0000000..4c42251
Binary files /dev/null and b/public/showcase/logistics-network-dark.jpg differ
diff --git a/public/showcase/logistics-network-light.jpg b/public/showcase/logistics-network-light.jpg
new file mode 100644
index 0000000..a76f1b2
Binary files /dev/null and b/public/showcase/logistics-network-light.jpg differ
diff --git a/public/showcase/marker-popup-dark.jpg b/public/showcase/marker-popup-dark.jpg
new file mode 100644
index 0000000..b829175
Binary files /dev/null and b/public/showcase/marker-popup-dark.jpg differ
diff --git a/public/showcase/marker-popup-light.jpg b/public/showcase/marker-popup-light.jpg
new file mode 100644
index 0000000..a8341bc
Binary files /dev/null and b/public/showcase/marker-popup-light.jpg differ
diff --git a/public/showcase/popup-dark.jpg b/public/showcase/popup-dark.jpg
new file mode 100644
index 0000000..e5e351a
Binary files /dev/null and b/public/showcase/popup-dark.jpg differ
diff --git a/public/showcase/popup-light.jpg b/public/showcase/popup-light.jpg
new file mode 100644
index 0000000..b7f9752
Binary files /dev/null and b/public/showcase/popup-light.jpg differ
diff --git a/public/showcase/route-alternatives-dark.jpg b/public/showcase/route-alternatives-dark.jpg
new file mode 100644
index 0000000..d4a5afb
Binary files /dev/null and b/public/showcase/route-alternatives-dark.jpg differ
diff --git a/public/showcase/route-alternatives-light.jpg b/public/showcase/route-alternatives-light.jpg
new file mode 100644
index 0000000..de2488e
Binary files /dev/null and b/public/showcase/route-alternatives-light.jpg differ
diff --git a/public/showcase/route-dark.jpg b/public/showcase/route-dark.jpg
new file mode 100644
index 0000000..8e42fec
Binary files /dev/null and b/public/showcase/route-dark.jpg differ
diff --git a/public/showcase/route-light.jpg b/public/showcase/route-light.jpg
new file mode 100644
index 0000000..d5f5c83
Binary files /dev/null and b/public/showcase/route-light.jpg differ
diff --git a/public/showcase/route-progress-dark.jpg b/public/showcase/route-progress-dark.jpg
new file mode 100644
index 0000000..04b9913
Binary files /dev/null and b/public/showcase/route-progress-dark.jpg differ
diff --git a/public/showcase/route-progress-light.jpg b/public/showcase/route-progress-light.jpg
new file mode 100644
index 0000000..a09153d
Binary files /dev/null and b/public/showcase/route-progress-light.jpg differ
diff --git a/public/showcase/uptime-monitor-dark.jpg b/public/showcase/uptime-monitor-dark.jpg
new file mode 100644
index 0000000..3c0f5cc
Binary files /dev/null and b/public/showcase/uptime-monitor-dark.jpg differ
diff --git a/public/showcase/uptime-monitor-light.jpg b/public/showcase/uptime-monitor-light.jpg
new file mode 100644
index 0000000..d0e96f9
Binary files /dev/null and b/public/showcase/uptime-monitor-light.jpg differ
diff --git a/scripts/capture-block-thumbnails.ts b/scripts/capture-block-thumbnails.ts
index 0c732e6..afc7404 100644
--- a/scripts/capture-block-thumbnails.ts
+++ b/scripts/capture-block-thumbnails.ts
@@ -1,22 +1,116 @@
-import { mkdir } from "fs/promises";
+import { mkdir, readFile, writeFile } from "fs/promises";
import path from "path";
-import { chromium } from "playwright";
+import { chromium, type Locator, type Page } from "playwright";
import registry from "../registry.json";
const baseUrl = process.env.BASE_URL ?? "http://localhost:3000";
-const outDir = path.join(process.cwd(), "public", "blocks");
+const blocksDir = path.join(process.cwd(), "public", "blocks");
+const showcaseDir = path.join(process.cwd(), "public", "showcase");
+const sizesFile = path.join(
+ process.cwd(),
+ "src/app/(main)/(home)/_components/showcase-sizes.json",
+);
const viewport = { width: 1280, height: 800 };
const schemes = ["light", "dark"] as const;
-const only = process.argv.slice(2);
-const blocks = registry.items
- .filter((item) => item.type === "registry:block")
- .map((item) => item.name)
- .filter((name) => only.length === 0 || only.includes(name));
+// Smaller than the default, so block UI matches the docs maps in scale.
+const blockViewport = { width: 960, height: 640 };
+
+// Home page wall tiles. `click` presses something first (and hides it if it is
+// a button), `zoom` and `pan` (in pixels) reframe the map, and `trim` cuts
+// pixels off the top and bottom.
+const showcaseMaps: ShowcaseMap[] = [
+ { name: "globe", path: "/docs/arcs" },
+ { name: "arcs", path: "/docs/arcs", index: 1 },
+ { name: "clusters", path: "/docs/clusters", zoom: -0.4 },
+ { name: "geojson-overlay", path: "/docs/geojson", index: 1 },
+ {
+ name: "marker-popup",
+ path: "/docs/markers",
+ index: 1,
+ click: '.maplibregl-marker:has-text("Museum") .bg-rose-500',
+ zoom: -0.6,
+ pan: [-120, 40],
+ },
+ { name: "popup", path: "/docs/popups" },
+ { name: "route", path: "/docs/routes" },
+ { name: "route-progress", path: "/docs/routes", index: 1 },
+ { name: "route-alternatives", path: "/docs/routes", index: 2 },
+ {
+ name: "custom-layer",
+ path: "/docs/advanced-usage",
+ index: 1,
+ click: 'button:has-text("Show Parks")',
+ },
+ { name: "analytics-card", path: "/view/analytics-card" },
+ {
+ name: "delivery-tracker",
+ path: "/view/delivery-tracker",
+ zoom: -0.55,
+ trim: [90, 95],
+ },
+ { name: "uptime-monitor", path: "/view/uptime-monitor", trim: [25, 65] },
+ { name: "analytics-map", path: "/view/analytics-map" },
+ {
+ name: "choropleth",
+ path: "/view/choropleth",
+ viewport: blockViewport,
+ zoom: -0.4,
+ pan: [-45, -35],
+ },
+ {
+ name: "heatmap",
+ path: "/view/heatmap",
+ viewport: blockViewport,
+ zoom: -0.4,
+ },
+ {
+ name: "logistics-network",
+ path: "/view/logistics-network",
+ viewport: { width: 1100, height: 600 },
+ zoom: -0.8,
+ trim: [0, 70],
+ },
+];
+
+// The page credits the map data once, so tiles leave out map chrome.
+const hideControls = `
+ .maplibregl-ctrl,
+ .maplibregl-map div:has(> div > button:is(
+ [aria-label="Zoom in"],
+ [aria-label="Find my location"],
+ [aria-label="Toggle fullscreen"],
+ [aria-label="Reset bearing to north"]
+ )) { display: none !important; }
+`;
+
+// Names limit the run to those blocks and tiles; `--blocks` or `--showcase`
+// limits it to one set.
+const args = process.argv.slice(2);
+const names = args.filter((arg) => !arg.startsWith("--"));
+const include = (name: string) => names.length === 0 || names.includes(name);
+
+const blocks = args.includes("--showcase")
+ ? []
+ : registry.items
+ .filter((item) => item.type === "registry:block")
+ .map((item) => item.name)
+ .filter(include);
+
+// Maps sharing a page and viewport are captured from one page load.
+const showcasePages = new Map<string, ShowcaseMap[]>();
+if (!args.includes("--blocks")) {
+ for (const map of showcaseMaps.filter((map) => include(map.name))) {
+ const key = JSON.stringify([map.path, map.viewport ?? viewport]);
+ showcasePages.set(key, [...(showcasePages.get(key) ?? []), map]);
+ }
+}
async function main() {
- await mkdir(outDir, { recursive: true });
+ await mkdir(blocksDir, { recursive: true });
+ await mkdir(showcaseDir, { recursive: true });
const browser = await chromium.launch();
+ const sizes: Sizes = {};
for (const scheme of schemes) {
const context = await browser.newContext({
@@ -26,28 +120,163 @@ async function main() {
const page = await context.newPage();
for (const name of blocks) {
- await page.goto(`${baseUrl}/view/${name}`, { waitUntil: "load" });
- await page.addStyleTag({
- content: "nextjs-portal { display: none !important; }",
- });
- await page.waitForSelector(".maplibregl-canvas", { timeout: 15_000 });
- await page
- .waitForLoadState("networkidle", { timeout: 10_000 })
- .catch(() => {});
- await page.waitForTimeout(1_500);
-
- const file = path.join(outDir, `${name}-${scheme}.jpg`);
+ await open(page, `/view/${name}`);
+ const file = path.join(blocksDir, `${name}-${scheme}.jpg`);
await page.screenshot({ path: file, type: "jpeg", quality: 85 });
- console.log(`✓ ${path.relative(process.cwd(), file)}`);
+ logSaved(file);
+ }
+
+ for (const maps of showcasePages.values()) {
+ await page.setViewportSize(maps[0].viewport ?? viewport);
+ await open(page, maps[0].path);
+ await page.addStyleTag({ content: hideControls });
+
+ for (const map of maps) {
+ const element = page.locator(".maplibregl-map").nth(map.index ?? 0);
+ await element.scrollIntoViewIfNeeded();
+ if (map.zoom || map.pan) await adjustView(element, map.zoom, map.pan);
+ if (map.click) {
+ const target = await page.locator(map.click).elementHandle();
+ await target?.click();
+ await target?.evaluate((node) => {
+ if (node.tagName === "BUTTON") node.style.visibility = "hidden";
+ });
+ }
+ await page.waitForTimeout(2_000);
+ sizes[map.name] = await captureMap(
+ page,
+ element,
+ path.join(showcaseDir, `${map.name}-${scheme}.jpg`),
+ map.trim,
+ );
+ }
}
await context.close();
}
await browser.close();
+ if (Object.keys(sizes).length > 0) await saveSizes(sizes);
+}
+
+async function open(page: Page, route: string) {
+ await page.goto(`${baseUrl}${route}`, { waitUntil: "load" });
+ await page.addStyleTag({
+ content: "nextjs-portal { display: none !important; }",
+ });
+ await page.waitForSelector(".maplibregl-canvas", { timeout: 15_000 });
+ await page
+ .waitForLoadState("networkidle", { timeout: 10_000 })
+ .catch(() => {});
+ await page.waitForTimeout(1_500);
+}
+
+// The Map component keeps its MapLibre instance in React state, so this walks
+// React's internals to reach it. It throws if a React upgrade moves them.
+async function adjustView(
+ element: Locator,
+ zoom = 0,
+ [x, y]: [number, number] = [0, 0],
+) {
+ await element.evaluate(
+ async (node, { zoom, x, y }) => {
+ type MapInstance = {
+ getZoom(): number;
+ setMinZoom(zoom: number | null): void;
+ unproject(point: [number, number]): unknown;
+ jumpTo(options: { zoom: number; center: unknown }): void;
+ once(event: string, listener: () => void): void;
+ };
+ type Hook = { memoizedState: unknown; next: Hook | null };
+ type Fiber = { memoizedState: Hook | null; return: Fiber | null };
+
+ const key = Object.keys(node).find((key) =>
+ key.startsWith("__reactFiber"),
+ );
+ let map: MapInstance | undefined;
+ for (
+ let fiber = (node as unknown as Record<string, Fiber>)[key ?? ""];
+ fiber && !map;
+ fiber = fiber.return!
+ ) {
+ for (let hook = fiber.memoizedState; hook && !map; hook = hook.next) {
+ const state = hook.memoizedState as Partial<MapInstance> | null;
+ if (typeof state?.getZoom === "function") map = state as MapInstance;
+ }
+ }
+ if (!map) throw new Error("Map instance not found");
+
+ const idle = new Promise<void>((resolve) => map.once("idle", resolve));
+ const { clientWidth: width, clientHeight: height } = node as HTMLElement;
+ map.setMinZoom(null);
+ map.jumpTo({
+ zoom: map.getZoom() + zoom,
+ center: map.unproject([width / 2 + x, height / 2 + y]),
+ });
+ await idle;
+ },
+ { zoom, x, y },
+ );
+}
+
+// Clips to whole pixels so both themes, and the recorded size, always match.
+async function captureMap(
+ page: Page,
+ element: Locator,
+ file: string,
+ [top, bottom]: [number, number] = [0, 0],
+) {
+ await element.scrollIntoViewIfNeeded();
+ const box = await element.boundingBox();
+ if (!box) throw new Error(`Map for ${file} is not visible`);
+
+ const clip = {
+ x: Math.round(box.x),
+ y: Math.round(box.y) + top,
+ width: Math.round(box.width),
+ height: Math.round(box.height) - top - bottom,
+ };
+ await page.screenshot({ path: file, type: "jpeg", quality: 85, clip });
+ logSaved(file);
+ return { width: clip.width, height: clip.height };
+}
+
+// A partial run keeps the other tiles' sizes; tiles no longer listed in
+// `showcaseMaps` are dropped.
+async function saveSizes(sizes: Sizes) {
+ const existing: Sizes = await readFile(sizesFile, "utf8")
+ .then((text) => JSON.parse(text))
+ .catch(() => ({}));
+ const merged = { ...existing, ...sizes };
+ const sorted = Object.fromEntries(
+ showcaseMaps
+ .map((map) => map.name)
+ .filter((name) => name in merged)
+ .sort()
+ .map((name) => [name, merged[name]]),
+ );
+ await writeFile(sizesFile, `${JSON.stringify(sorted, null, 2)}\n`);
+ logSaved(sizesFile);
+}
+
+function logSaved(file: string) {
+ console.log(`✓ ${path.relative(process.cwd(), file)}`);
}
main().catch((error) => {
console.error(error);
process.exit(1);
});
+
+type ShowcaseMap = {
+ name: string;
+ path: string;
+ index?: number;
+ click?: string;
+ zoom?: number;
+ pan?: [number, number];
+ viewport?: typeof viewport;
+ trim?: [number, number];
+};
+
+type Sizes = Record<string, { width: number; height: number }>;
diff --git a/src/app/(main)/(home)/_components/agent-prompt.tsx b/src/app/(main)/(home)/_components/agent-prompt.tsx
deleted file mode 100644
index facef5f..0000000
--- a/src/app/(main)/(home)/_components/agent-prompt.tsx
+++ /dev/null
@@ -1,37 +0,0 @@
-"use client";
-
-import { useState } from "react";
-import { Check, Copy } from "lucide-react";
-
-import { mapInstallAgentPrompt } from "@/lib/llm-prompts";
-import { Button } from "@/components/ui/button";
-import { trackEvent } from "@/lib/events";
-
-export function AgentPrompt() {
- const [copied, setCopied] = useState(false);
-
- async function copyPrompt() {
- try {
- await navigator.clipboard.writeText(mapInstallAgentPrompt);
- setCopied(true);
- setTimeout(() => setCopied(false), 2500);
- trackEvent({ name: "copy_agent_prompt" });
- } catch (error) {
- console.error("Failed to copy prompt:", error);
- }
- }
-
- return (
- <Button
- type="button"
- onClick={copyPrompt}
- aria-live="polite"
- variant="ghost"
- size="xs"
- className="text-muted-foreground hover:text-foreground h-7 px-2.5!"
- >
- {copied ? <Check /> : <Copy />}
- {copied ? "Copied — paste into your agent" : "Copy prompt for your agent"}
- </Button>
- );
-}
diff --git a/src/app/(main)/(home)/_components/examples-grid.tsx b/src/app/(main)/(home)/_components/examples-grid.tsx
deleted file mode 100644
index 52d1e59..0000000
--- a/src/app/(main)/(home)/_components/examples-grid.tsx
+++ /dev/null
@@ -1,44 +0,0 @@
-import {
- AnalyticsExample,
- DeliveryExample,
- EVChargingExample,
- TrailExample,
- FlyToExample,
- ArcExample,
-} from "./examples/index";
-
-export function ExamplesGrid() {
- return (
- <div>
- <div className="grid grid-cols-1 gap-5 sm:grid-cols-2 lg:grid-cols-4">
- <AnalyticsExample />
- <TrailExample />
- <ArcExample />
- <EVChargingExample />
- <FlyToExample />
- <DeliveryExample />
- </div>
-
- <p className="text-muted-foreground mt-3 text-right text-xs">
- Map data ©{" "}
- <a
- href="https://www.openstreetmap.org/copyright"
- target="_blank"
- rel="noopener noreferrer"
- className="hover:text-foreground transition-colors"
- >
- OpenStreetMap
- </a>{" "}
- contributors · ©{" "}
- <a
- href="https://carto.com/attributions"
- target="_blank"
- rel="noopener noreferrer"
- className="hover:text-foreground transition-colors"
- >
- CARTO
- </a>
- </p>
- </div>
- );
-}
diff --git a/src/app/(main)/(home)/_components/examples/analytics-example.tsx b/src/app/(main)/(home)/_components/examples/analytics-example.tsx
deleted file mode 100644
index cbd2996..0000000
--- a/src/app/(main)/(home)/_components/examples/analytics-example.tsx
+++ /dev/null
@@ -1,63 +0,0 @@
-"use client";
-
-import { Map, MapMarker, MarkerContent, MarkerTooltip } from "@/registry/map";
-import { TrendingUp } from "lucide-react";
-import { ExampleCard } from "./example-card";
-
-const analyticsData = [
- { lng: -74.006, lat: 40.7128, city: "New York", users: 847, size: 14 },
- { lng: -0.1276, lat: 51.5074, city: "London", users: 623, size: 12 },
- { lng: 139.6917, lat: 35.6895, city: "Tokyo", users: 412, size: 10 },
- { lng: 114.1694, lat: 22.3193, city: "Hong Kong", users: 364, size: 10 },
- { lng: -122.4194, lat: 37.7749, city: "San Francisco", users: 298, size: 9 },
- { lng: 72.8777, lat: 19.076, city: "Mumbai", users: 271, size: 9 },
- { lng: 13.405, lat: 52.52, city: "Berlin", users: 187, size: 8 },
- { lng: 77.209, lat: 28.6139, city: "Delhi", users: 156, size: 7 },
- { lng: 151.2093, lat: -33.8688, city: "Sydney", users: 134, size: 7 },
- { lng: 18.4241, lat: -33.9249, city: "Cape Town", users: 118, size: 6 },
- { lng: -43.1729, lat: -22.9068, city: "Rio", users: 89, size: 6 },
- { lng: 126.978, lat: 37.5665, city: "Seoul", users: 45, size: 5 },
-];
-
-export function AnalyticsExample() {
- return (
- <ExampleCard className="aspect-square sm:col-span-2 sm:aspect-video lg:aspect-auto">
- <div className="bg-background/95 border-border/50 absolute top-3 left-3 z-10 rounded-lg border p-3 shadow-lg backdrop-blur-md">
- <div className="text-muted-foreground mb-1 text-[10px] tracking-wider uppercase">
- Active Users
- </div>
- <div className="text-2xl leading-tight font-semibold">3,544</div>
- <div className="mt-1 flex items-center gap-1">
- <TrendingUp className="size-3" />
- <span className="text-foreground text-xs">+12.5%</span>
- <span className="text-muted-foreground text-xs">vs last hour</span>
- </div>
- </div>
-
- <Map
- attributionControl={false}
- center={[0, 30]}
- scrollZoom={false}
- dragRotate={false}
- pitchWithRotate={false}
- >
- {analyticsData.map((loc) => (
- <MapMarker key={loc.city} longitude={loc.lng} latitude={loc.lat}>
- <MarkerContent>
- <div
- className="rounded-full bg-blue-500/80 shadow-sm"
- style={{ width: loc.size * 1.8, height: loc.size * 1.8 }}
- />
- </MarkerContent>
- <MarkerTooltip>
- <div className="text-center">
- <div className="font-medium">{loc.city}</div>
- <div className="text-background/80">{loc.users} users</div>
- </div>
- </MarkerTooltip>
- </MapMarker>
- ))}
- </Map>
- </ExampleCard>
- );
-}
diff --git a/src/app/(main)/(home)/_components/examples/arc-example.tsx b/src/app/(main)/(home)/_components/examples/arc-example.tsx
deleted file mode 100644
index eb99081..0000000
--- a/src/app/(main)/(home)/_components/examples/arc-example.tsx
+++ /dev/null
@@ -1,66 +0,0 @@
-"use client";
-
-import {
- Map,
- MapArc,
- MapMarker,
- MarkerContent,
- MarkerLabel,
-} from "@/registry/map";
-import { ExampleCard } from "./example-card";
-
-const hub = { name: "London", lng: -0.1276, lat: 51.5074 };
-
-const destinations = [
- { name: "New York", lng: -74.006, lat: 40.7128 },
- { name: "São Paulo", lng: -46.6333, lat: -23.5505 },
- { name: "Cape Town", lng: 18.4241, lat: -33.9249 },
- { name: "Mumbai", lng: 72.8777, lat: 19.076 },
- { name: "Tokyo", lng: 139.6917, lat: 35.6895 },
-];
-
-const arcs = destinations.map((dest) => ({
- id: dest.name,
- from: [hub.lng, hub.lat] as [number, number],
- to: [dest.lng, dest.lat] as [number, number],
-}));
-
-export function ArcExample() {
- return (
- <ExampleCard className="aspect-square">
- <Map
- attributionControl={false}
- center={[-0.1276, 41.5074]}
- zoom={1}
- projection={{ type: "globe" }}
- scrollZoom={false}
- >
- <MapArc
- data={arcs}
- paint={{
- "line-color": "#3b82f6",
- "line-opacity": 0.9,
- "line-dasharray": [2, 2],
- }}
- interactive={false}
- />
-
- <MapMarker longitude={hub.lng} latitude={hub.lat}>
- <MarkerContent>
- <div className="size-3 rounded-full border-2 border-white bg-blue-500" />
- <MarkerLabel position="top">{hub.name}</MarkerLabel>
- </MarkerContent>
- </MapMarker>
-
- {destinations.map((dest) => (
- <MapMarker key={dest.name} longitude={dest.lng} latitude={dest.lat}>
- <MarkerContent>
- <div className="size-2 rounded-full border-2 border-white bg-blue-500" />
- <MarkerLabel position="top">{dest.name}</MarkerLabel>
- </MarkerContent>
- </MapMarker>
- ))}
- </Map>
- </ExampleCard>
- );
-}
diff --git a/src/app/(main)/(home)/_components/examples/delivery-example.tsx b/src/app/(main)/(home)/_components/examples/delivery-example.tsx
deleted file mode 100644
index 96f4e12..0000000
--- a/src/app/(main)/(home)/_components/examples/delivery-example.tsx
+++ /dev/null
@@ -1,122 +0,0 @@
-"use client";
-
-import {
- Map,
- MapMarker,
- MarkerContent,
- MarkerLabel,
- MarkerTooltip,
- MapRoute,
-} from "@/registry/map";
-import { Truck } from "lucide-react";
-import { ExampleCard } from "./example-card";
-
-const store = { lng: -0.14, lat: 51.5154 };
-const home = { lng: -0.07, lat: 51.51 };
-
-// Precomputed driving route (OSRM result)
-const route: [number, number][] = [
- [-0.14, 51.5155],
- [-0.1418, 51.5153],
- [-0.1417, 51.5145],
- [-0.1414, 51.514],
- [-0.1407, 51.5133],
- [-0.1398, 51.5122],
- [-0.1393, 51.5117],
- [-0.1388, 51.5111],
- [-0.1381, 51.5103],
- [-0.1376, 51.5101],
- [-0.1364, 51.5099],
- [-0.136, 51.5099],
- [-0.1354, 51.5101],
- [-0.1348, 51.5101],
- [-0.134, 51.51],
- [-0.1333, 51.5101],
- [-0.1326, 51.5094],
- [-0.1319, 51.5086],
- [-0.1311, 51.5078],
- [-0.1301, 51.508],
- [-0.1292, 51.5083],
- [-0.129, 51.5082],
- [-0.1286, 51.5075],
- [-0.128, 51.5075],
- [-0.1275, 51.5076],
- [-0.1272, 51.5074],
- [-0.1255, 51.507],
- [-0.1233, 51.5067],
- [-0.1226, 51.5066],
- [-0.1219, 51.5072],
- [-0.1208, 51.5084],
- [-0.1193, 51.5094],
- [-0.1187, 51.5097],
- [-0.1165, 51.5104],
- [-0.1154, 51.5107],
- [-0.1135, 51.5109],
- [-0.112, 51.511],
- [-0.1082, 51.511],
- [-0.1072, 51.511],
- [-0.1035, 51.511],
- [-0.1015, 51.5112],
- [-0.0958, 51.5112],
- [-0.0932, 51.5109],
- [-0.0912, 51.5105],
- [-0.0903, 51.5103],
- [-0.0896, 51.5102],
- [-0.0883, 51.5099],
- [-0.0871, 51.5097],
- [-0.0838, 51.5093],
- [-0.0818, 51.5091],
- [-0.0805, 51.5094],
- [-0.0797, 51.5096],
- [-0.0782, 51.5095],
- [-0.0768, 51.5095],
- [-0.0755, 51.5097],
- [-0.0748, 51.5099],
- [-0.0741, 51.5098],
- [-0.0736, 51.5093],
- [-0.0732, 51.5089],
- [-0.0715, 51.5084],
- [-0.0709, 51.5083],
- [-0.0705, 51.5091],
- [-0.0696, 51.5094],
- [-0.0699, 51.51],
-];
-
-const truckPosition = route[Math.floor(route.length * 0.6)];
-
-export function DeliveryExample() {
- return (
- <ExampleCard className="aspect-square sm:col-span-2 sm:aspect-video lg:aspect-auto">
- <Map
- attributionControl={false}
- center={[-0.105, 51.511]}
- zoom={12.6}
- scrollZoom={false}
- dragRotate={false}
- pitchWithRotate={false}
- >
- <MapRoute coordinates={route} width={4} color="#3b82f6" />
- <MapMarker longitude={store.lng} latitude={store.lat}>
- <MarkerContent>
- <div className="size-3.5 rounded-full border-2 border-white bg-emerald-500 shadow-lg" />
- <MarkerLabel>Store</MarkerLabel>
- </MarkerContent>
- </MapMarker>
- <MapMarker longitude={truckPosition[0]} latitude={truckPosition[1]}>
- <MarkerContent>
- <div className="rounded-full bg-blue-500 p-1.5 shadow-lg">
- <Truck className="size-3 text-white" />
- </div>
- </MarkerContent>
- <MarkerTooltip>On the way</MarkerTooltip>
- </MapMarker>
- <MapMarker longitude={home.lng} latitude={home.lat}>
- <MarkerContent>
- <div className="size-3.5 rounded-full border-2 border-white bg-red-500 shadow-lg" />
- <MarkerLabel>Home</MarkerLabel>
- </MarkerContent>
- </MapMarker>
- </Map>
- </ExampleCard>
- );
-}
diff --git a/src/app/(main)/(home)/_components/examples/ev-charging-example.tsx b/src/app/(main)/(home)/_components/examples/ev-charging-example.tsx
deleted file mode 100644
index 2b27fcc..0000000
--- a/src/app/(main)/(home)/_components/examples/ev-charging-example.tsx
+++ /dev/null
@@ -1,162 +0,0 @@
-"use client";
-
-import { Map, MapMarker, MarkerContent, MarkerTooltip } from "@/registry/map";
-import { Zap } from "lucide-react";
-import { ExampleCard } from "./example-card";
-
-type Status = "available" | "in-use" | "offline";
-
-interface ChargingStation {
- name: string;
- lng: number;
- lat: number;
- status: Status;
- detail: string;
-}
-
-const stations: ChargingStation[] = [
- {
- name: "Union Square",
- lng: -122.4074,
- lat: 37.7879,
- status: "available",
- detail: "50 kW • $0.28/kWh",
- },
- {
- name: "Castro Station",
- lng: -122.435,
- lat: 37.7625,
- status: "in-use",
- detail: "~15 min remaining",
- },
- {
- name: "Hayes Valley",
- lng: -122.4264,
- lat: 37.7759,
- status: "offline",
- detail: "",
- },
- {
- name: "Embarcadero",
- lng: -122.3934,
- lat: 37.7935,
- status: "available",
- detail: "350 kW • $0.40/kWh",
- },
- {
- name: "Marina District",
- lng: -122.437,
- lat: 37.801,
- status: "available",
- detail: "150 kW • $0.32/kWh",
- },
- {
- name: "SoMa Charger",
- lng: -122.401,
- lat: 37.778,
- status: "available",
- detail: "50 kW • $0.30/kWh",
- },
- {
- name: "Noe Valley",
- lng: -122.431,
- lat: 37.75,
- status: "available",
- detail: "150 kW • $0.33/kWh",
- },
- {
- name: "Richmond Charger",
- lng: -122.478,
- lat: 37.781,
- status: "in-use",
- detail: "~8 min remaining",
- },
- {
- name: "Potrero Hill",
- lng: -122.401,
- lat: 37.76,
- status: "offline",
- detail: "",
- },
- {
- name: "Mission Bay",
- lng: -122.391,
- lat: 37.77,
- status: "available",
- detail: "350 kW • $0.38/kWh",
- },
- {
- name: "Golden Gate Park",
- lng: -122.466,
- lat: 37.77,
- status: "available",
- detail: "150 kW • $0.34/kWh",
- },
-];
-
-const statusConfig: Record<
- Status,
- { bg: string; label: string; textClass: string }
-> = {
- available: {
- bg: "bg-emerald-500",
- label: "Available",
- textClass: "text-emerald-500",
- },
- "in-use": {
- bg: "bg-amber-500",
- label: "In Use",
- textClass: "text-amber-500",
- },
- offline: {
- bg: "bg-zinc-400",
- label: "Offline",
- textClass: "text-muted-foreground",
- },
-};
-
-export function EVChargingExample() {
- return (
- <ExampleCard className="aspect-square">
- <Map
- attributionControl={false}
- center={[-122.434, 37.776]}
- zoom={11}
- scrollZoom={false}
- dragRotate={false}
- pitchWithRotate={false}
- >
- {stations.map((station) => {
- const config = statusConfig[station.status];
- return (
- <MapMarker
- key={station.name}
- longitude={station.lng}
- latitude={station.lat}
- >
- <MarkerContent>
- <div className={`${config.bg} rounded-full p-1.5 shadow-lg`}>
- <Zap className="size-3 fill-white text-white" />
- </div>
- </MarkerContent>
- <MarkerTooltip className="bg-popover text-popover-foreground border px-2.5 py-1.5">
- <div className="space-y-1 text-xs">
- <div className="font-medium">{station.name}</div>
- <div className="flex items-center gap-1">
- <span className={`size-1.5 rounded-full ${config.bg}`} />
- <span className={config.textClass}>{config.label}</span>
- </div>
- {station.detail && (
- <div className="text-muted-foreground text-[11px]">
- {station.detail}
- </div>
- )}
- </div>
- </MarkerTooltip>
- </MapMarker>
- );
- })}
- </Map>
- </ExampleCard>
- );
-}
diff --git a/src/app/(main)/(home)/_components/examples/example-card.tsx b/src/app/(main)/(home)/_components/examples/example-card.tsx
deleted file mode 100644
index 17b8a09..0000000
--- a/src/app/(main)/(home)/_components/examples/example-card.tsx
+++ /dev/null
@@ -1,19 +0,0 @@
-import { cn } from "@/lib/utils";
-
-interface ExampleCardProps {
- className?: string;
- children: React.ReactNode;
-}
-
-export function ExampleCard({ className, children }: ExampleCardProps) {
- return (
- <div
- className={cn(
- "bg-card border-border/50 relative overflow-hidden rounded-xl border shadow-sm",
- className,
- )}
- >
- {children}
- </div>
- );
-}
diff --git a/src/app/(main)/(home)/_components/examples/flyto-example.tsx b/src/app/(main)/(home)/_components/examples/flyto-example.tsx
deleted file mode 100644
index f1b5974..0000000
--- a/src/app/(main)/(home)/_components/examples/flyto-example.tsx
+++ /dev/null
@@ -1,67 +0,0 @@
-"use client";
-
-import { useRef, useState } from "react";
-
-import { Map, MapMarker, MapRef, MarkerContent } from "@/registry/map";
-import { Button } from "@/components/ui/button";
-import { ExampleCard } from "./example-card";
-
-const destinations = [
- { name: "New York", center: [-74.006, 40.7128] as [number, number] },
- { name: "London", center: [-0.1276, 51.5074] as [number, number] },
- { name: "Tokyo", center: [139.6917, 35.6895] as [number, number] },
- { name: "Sydney", center: [151.2093, -33.8688] as [number, number] },
-];
-
-export function FlyToExample() {
- const mapRef = useRef<MapRef>(null);
- const [activeIndex, setActiveIndex] = useState(0);
-
- const flyTo = (index: number) => {
- setActiveIndex(index);
- mapRef.current?.flyTo({
- center: destinations[index].center,
- zoom: 6,
- duration: 2000,
- essential: true,
- });
- };
-
- const active = destinations[activeIndex];
-
- return (
- <ExampleCard className="aspect-square">
- <Map
- attributionControl={false}
- ref={mapRef}
- center={active.center}
- zoom={5.5}
- scrollZoom={false}
- dragRotate={false}
- pitchWithRotate={false}
- >
- <MapMarker longitude={active.center[0]} latitude={active.center[1]}>
- <MarkerContent>
- <div className="flex items-center justify-center">
- <div className="size-3.5 rounded-full border-2 border-white bg-blue-500 shadow-lg" />
- </div>
- </MarkerContent>
- </MapMarker>
- </Map>
-
- <div className="absolute inset-x-3 top-3 flex flex-wrap gap-1.5">
- {destinations.map((dest, index) => (
- <Button
- key={dest.name}
- size="xs"
- variant={index === activeIndex ? "default" : "secondary"}
- onClick={() => flyTo(index)}
- className="rounded-full border"
- >
- {dest.name}
- </Button>
- ))}
- </div>
- </ExampleCard>
- );
-}
diff --git a/src/app/(main)/(home)/_components/examples/index.tsx b/src/app/(main)/(home)/_components/examples/index.tsx
deleted file mode 100644
index 8f49777..0000000
--- a/src/app/(main)/(home)/_components/examples/index.tsx
+++ /dev/null
@@ -1,7 +0,0 @@
-export { ExampleCard } from "./example-card";
-export { AnalyticsExample } from "./analytics-example";
-export { DeliveryExample } from "./delivery-example";
-export { EVChargingExample } from "./ev-charging-example";
-export { TrailExample } from "./trail-example";
-export { FlyToExample } from "./flyto-example";
-export { ArcExample } from "./arc-example";
diff --git a/src/app/(main)/(home)/_components/examples/trail-example.tsx b/src/app/(main)/(home)/_components/examples/trail-example.tsx
deleted file mode 100644
index 5e8d4d4..0000000
--- a/src/app/(main)/(home)/_components/examples/trail-example.tsx
+++ /dev/null
@@ -1,85 +0,0 @@
-"use client";
-
-import { Map, MapRoute, MapMarker, MarkerContent } from "@/registry/map";
-import { Bike } from "lucide-react";
-import { ExampleCard } from "./example-card";
-
-// Central Park cycling route
-const trailCoordinates: [number, number][] = [
- [-73.95846730810143, 40.80035246904919],
- [-73.9717593682683, 40.78210942124929],
- [-73.98192123136191, 40.76793032580281],
- [-73.97393759456651, 40.76462909128966],
- [-73.97291537521572, 40.765159628993814],
- [-73.96920618484948, 40.7637106622374],
- [-73.96383691302509, 40.77117117897504],
- [-73.9584024523858, 40.76889223221369],
- [-73.9470773638119, 40.784238113060894],
- [-73.95585246901248, 40.78786547226602],
- [-73.94937945594087, 40.79668351998197],
- [-73.9498273526222, 40.797167598041455],
- [-73.95699644240298, 40.80016017872583],
-];
-const start = trailCoordinates[0];
-const end = trailCoordinates[trailCoordinates.length - 1];
-
-export function TrailExample() {
- return (
- <ExampleCard className="aspect-square">
- <div className="bg-background/95 border-border/50 absolute top-3 left-3 z-10 rounded-lg border p-3 shadow-lg backdrop-blur-md">
- <div className="mb-2 flex items-center gap-1.5">
- <Bike className="text-foreground size-3.5" />
- <span className="text-xs font-medium">Central Park Loop</span>
- </div>
- <div className="grid grid-cols-3 gap-3 text-center">
- <div>
- <div className="text-sm font-semibold">6.2</div>
- <div className="text-muted-foreground text-[9px] uppercase">
- Miles
- </div>
- </div>
- <div>
- <div className="text-sm font-semibold">32</div>
- <div className="text-muted-foreground text-[9px] uppercase">
- Mins
- </div>
- </div>
- <div>
- <div className="text-sm font-semibold">285</div>
- <div className="text-muted-foreground text-[9px] uppercase">
- Cal
- </div>
- </div>
- </div>
- </div>
-
- <Map
- attributionControl={false}
- center={[-73.97, 40.782]}
- zoom={11.8}
- scrollZoom={false}
- dragRotate={false}
- pitchWithRotate={false}
- >
- <MapRoute
- coordinates={trailCoordinates}
- color="#3b82f6"
- width={3}
- opacity={0.9}
- />
-
- <MapMarker longitude={start[0]} latitude={start[1]}>
- <MarkerContent>
- <div className="size-3 rounded-full border-2 border-white bg-emerald-500 shadow-lg" />
- </MarkerContent>
- </MapMarker>
-
- <MapMarker longitude={end[0]} latitude={end[1]}>
- <MarkerContent>
- <div className="size-3 rounded-full border-2 border-white bg-red-500 shadow-lg" />
- </MarkerContent>
- </MapMarker>
- </Map>
- </ExampleCard>
- );
-}
diff --git a/src/app/(main)/(home)/_components/map-wall.tsx b/src/app/(main)/(home)/_components/map-wall.tsx
new file mode 100644
index 0000000..314bf83
--- /dev/null
+++ b/src/app/(main)/(home)/_components/map-wall.tsx
@@ -0,0 +1,113 @@
+import { ThemedImage } from "@/components/themed-image";
+import { cn } from "@/lib/utils";
+import sizes from "./showcase-sizes.json";
+
+export function MapWall({ className }: { className?: string }) {
+ return (
+ <div
+ aria-hidden
+ className={cn(
+ "pointer-events-none relative left-1/2 flex w-[40rem] -translate-x-1/2 gap-3 select-none md:left-0 md:mx-auto md:w-[calc(100%-8rem)] md:max-w-[84rem] md:translate-x-0 md:gap-4 xl:w-[calc(100%-12rem)] xl:gap-6",
+ className,
+ )}
+ >
+ <Rail
+ columns={LEFT_RAIL}
+ className="right-full mr-4 mask-l-from-50% xl:mr-6"
+ />
+
+ {MAIN.map((column, index) => (
+ <div
+ key={index}
+ className={cn(
+ "flex min-w-0 flex-1 flex-col gap-3 md:gap-4 xl:gap-6",
+ index !== 1 && "mt-6 md:mt-8",
+ index === 2 && "md:max-xl:hidden",
+ )}
+ >
+ {column.map((name, row) => (
+ <Tile key={`${name}-${row}`} name={name} sizes={MAIN_SIZES} />
+ ))}
+ </div>
+ ))}
+
+ <Rail
+ columns={RIGHT_RAIL}
+ className="left-full ml-4 mask-r-from-50% xl:ml-6"
+ />
+ </div>
+ );
+}
+
+// Its own layer keeps the blur from being redrawn while the section animates
+// in, and since the tiles are blurred, small images are enough.
+function Rail({
+ columns,
+ className,
+}: {
+ columns: TileName[][];
+ className?: string;
+}) {
+ return (
+ <div
+ className={cn(
+ "absolute top-0 hidden transform-gpu gap-4 opacity-70 blur-[3px] md:flex xl:gap-6",
+ className,
+ )}
+ >
+ {columns.map((column, index) => (
+ <div
+ key={index}
+ className="flex w-60 flex-col gap-4 xl:gap-6"
+ style={{ marginTop: `${RAIL_OFFSETS[index]}rem` }}
+ >
+ {column.map((name, row) => (
+ <Tile key={`${name}-${row}`} name={name} sizes="8rem" />
+ ))}
+ </div>
+ ))}
+ </div>
+ );
+}
+
+function Tile({ name, sizes: imageSizes }: { name: TileName; sizes: string }) {
+ const { width, height } = sizes[name];
+
+ return (
+ <div
+ className="bg-muted ring-foreground/10 relative overflow-hidden rounded-xl ring-1"
+ style={{ aspectRatio: `${width} / ${height}` }}
+ >
+ <ThemedImage src={`/showcase/${name}`} sizes={imageSizes} />
+ </div>
+ );
+}
+
+const MAIN_SIZES = "(min-width: 1280px) 27rem, (min-width: 768px) 50vw, 13rem";
+
+const RAIL_OFFSETS = [3, 6];
+
+const MAIN: TileName[][] = [
+ ["analytics-map", "route-alternatives", "heatmap", "analytics-card"],
+ ["logistics-network", "choropleth", "clusters", "route-alternatives"],
+ ["delivery-tracker", "globe", "uptime-monitor", "choropleth"],
+];
+
+// Ordered left to right, so the outer column of the left rail comes first.
+const LEFT_RAIL: TileName[][] = [
+ ["popup", "custom-layer", "route", "geojson-overlay", "arcs"],
+ ["marker-popup", "geojson-overlay", "arcs", "route-progress", "popup"],
+];
+
+const RIGHT_RAIL: TileName[][] = [
+ ["route", "arcs", "popup", "marker-popup", "custom-layer"],
+ [
+ "geojson-overlay",
+ "route-progress",
+ "custom-layer",
+ "route",
+ "marker-popup",
+ ],
+];
+
+type TileName = keyof typeof sizes;
diff --git a/src/app/(main)/(home)/_components/showcase-sizes.json b/src/app/(main)/(home)/_components/showcase-sizes.json
new file mode 100644
index 0000000..062cf04
--- /dev/null
+++ b/src/app/(main)/(home)/_components/showcase-sizes.json
@@ -0,0 +1,70 @@
+{
+ "analytics-card": {
+ "width": 446,
+ "height": 278
+ },
+ "analytics-map": {
+ "width": 1280,
+ "height": 608
+ },
+ "arcs": {
+ "width": 734,
+ "height": 420
+ },
+ "choropleth": {
+ "width": 960,
+ "height": 640
+ },
+ "clusters": {
+ "width": 734,
+ "height": 420
+ },
+ "custom-layer": {
+ "width": 734,
+ "height": 420
+ },
+ "delivery-tracker": {
+ "width": 584,
+ "height": 380
+ },
+ "geojson-overlay": {
+ "width": 734,
+ "height": 420
+ },
+ "globe": {
+ "width": 734,
+ "height": 420
+ },
+ "heatmap": {
+ "width": 960,
+ "height": 640
+ },
+ "logistics-network": {
+ "width": 844,
+ "height": 530
+ },
+ "marker-popup": {
+ "width": 734,
+ "height": 500
+ },
+ "popup": {
+ "width": 734,
+ "height": 420
+ },
+ "route": {
+ "width": 734,
+ "height": 420
+ },
+ "route-alternatives": {
+ "width": 734,
+ "height": 500
+ },
+ "route-progress": {
+ "width": 734,
+ "height": 420
+ },
+ "uptime-monitor": {
+ "width": 670,
+ "height": 408
+ }
+}
diff --git a/src/app/(main)/(home)/page.tsx b/src/app/(main)/(home)/page.tsx
index 5071001..532ef21 100644
--- a/src/app/(main)/(home)/page.tsx
+++ b/src/app/(main)/(home)/page.tsx
@@ -1,8 +1,7 @@
import Link from "next/link";
import { CSSProperties } from "react";
-import { AgentPrompt } from "./_components/agent-prompt";
-import { ExamplesGrid } from "./_components/examples-grid";
+import { MapWall } from "./_components/map-wall";
import { Footer } from "@/components/footer";
import {
PageHeader,
@@ -15,15 +14,15 @@ import { Button } from "@/components/ui/button";
export default function Page() {
return (
<>
- <PageHeader>
- <PageHeaderHeading>Beautiful maps, made simple</PageHeaderHeading>
- <PageHeaderDescription>
- Ready to use, customizable map components for React.
- <br className="hidden sm:block" />
- Built on MapLibre. Styled with Tailwind.
- </PageHeaderDescription>
- <PageActions className="mt-5 flex-col gap-4">
- <div className="flex flex-wrap items-center justify-center gap-3">
+ <div className="flex-1">
+ <PageHeader animated>
+ <PageHeaderHeading>Beautiful maps, made simple</PageHeaderHeading>
+ <PageHeaderDescription>
+ Ready to use, customizable map components for React.{" "}
+ <br className="hidden sm:block" />
+ Built on MapLibre. Styled with Tailwind.
+ </PageHeaderDescription>
+ <PageActions className="mt-5">
<Button asChild className="min-w-36 justify-center">
<Link href="/docs">Get Started</Link>
</Button>
@@ -34,23 +33,46 @@ export default function Page() {
>
<Link href="/docs/basic-map">View Components</Link>
</Button>
+ </PageActions>
+ </PageHeader>
+
+ <section
+ className="animate-fade-up animate-stagger relative"
+ style={
+ {
+ "--stagger": 5,
+ } as CSSProperties
+ }
+ >
+ <div className="relative h-[34rem] overflow-hidden mask-b-from-65% max-md:mask-r-from-85% max-md:mask-l-from-85% md:h-[44rem] lg:h-[clamp(52rem,calc(100svh-28.3125rem),90rem)]">
+ <div className="absolute inset-0 [background-image:radial-gradient(var(--color-border)_1px,transparent_0)] mask-t-from-0% [background-size:24px_24px]" />
+ <MapWall className="pt-6" />
</div>
- <AgentPrompt />
- </PageActions>
- </PageHeader>
- <section
- className="animate-fade-up animate-stagger container-wide"
- style={
- {
- "--stagger": 4.5,
- } as CSSProperties
- }
- >
- <ExamplesGrid />
- </section>
+ <p className="text-muted-foreground absolute inset-x-0 bottom-4 container text-right text-xs">
+ Map data ©{" "}
+ <a
+ href="https://www.openstreetmap.org/copyright"
+ target="_blank"
+ rel="noopener noreferrer"
+ className="hover:text-foreground transition-colors"
+ >
+ OpenStreetMap
+ </a>{" "}
+ contributors · ©{" "}
+ <a
+ href="https://carto.com/attributions"
+ target="_blank"
+ rel="noopener noreferrer"
+ className="hover:text-foreground transition-colors"
+ >
+ CARTO
+ </a>
+ </p>
+ </section>
+ </div>
- <Footer />
+ <Footer className="mt-0!" />
</>
);
}
diff --git a/src/app/(main)/blocks/[name]/page.tsx b/src/app/(main)/blocks/[name]/page.tsx
new file mode 100644
index 0000000..9298305
--- /dev/null
+++ b/src/app/(main)/blocks/[name]/page.tsx
@@ -0,0 +1,118 @@
+import Link from "next/link";
+import { notFound } from "next/navigation";
+import type { Metadata } from "next";
+import { ChevronLeft } from "lucide-react";
+import { Footer } from "@/components/footer";
+import {
+ PageHeader,
+ PageHeaderDescription,
+ PageHeaderHeading,
+} from "@/components/page-header";
+import { Button } from "@/components/ui/button";
+import { getBlocksInGridOrder } from "@/lib/blocks";
+import { BlockCard } from "../_components/block-card";
+import { BlockDisplay } from "../_components/block-display";
+
+interface BlockPageProps {
+ params: Promise<{ name: string }>;
+}
+
+export function generateStaticParams() {
+ return getBlocksInGridOrder().map(({ name }) => ({ name }));
+}
+
+export async function generateMetadata({
+ params,
+}: BlockPageProps): Promise<Metadata> {
+ const { name } = await params;
+ const block = getBlocksInGridOrder().find((block) => block.name === name);
+ if (!block) notFound();
+
+ const title = `${block.title} - mapcn`;
+ const image = {
+ url: `/blocks/${block.name}-dark.jpg`,
+ width: 1280,
+ height: 800,
+ alt: block.title,
+ };
+
+ return {
+ title: block.title,
+ description: block.description,
+ openGraph: {
+ type: "website",
+ siteName: "mapcn",
+ url: "./",
+ title,
+ description: block.description,
+ images: [image],
+ },
+ twitter: {
+ card: "summary_large_image",
+ title,
+ description: block.description,
+ images: [image.url],
+ },
+ };
+}
+
+export default async function BlockPage({ params }: BlockPageProps) {
+ const { name } = await params;
+ const blocks = getBlocksInGridOrder();
+ const index = blocks.findIndex((block) => block.name === name);
+ if (index === -1) notFound();
+
+ const block = blocks[index];
+
+ const neighbours = [
+ ...new Set([blocks.at(index - 1)!, blocks[(index + 1) % blocks.length]]),
+ ].filter((other) => other !== block);
+
+ return (
+ <>
+ <div className="flex-1">
+ <PageHeader align="left" size="sm" className="pb-8 md:pb-10">
+ <Button
+ variant="ghost"
+ size="sm"
+ asChild
+ className="text-muted-foreground hover:text-foreground -ml-4 w-fit hover:bg-transparent!"
+ >
+ <Link href="/blocks">
+ <ChevronLeft />
+ Blocks
+ </Link>
+ </Button>
+ <PageHeaderHeading>{block.title}</PageHeaderHeading>
+ {block.description && (
+ <PageHeaderDescription className="max-w-4xl">
+ {block.description}
+ </PageHeaderDescription>
+ )}
+ </PageHeader>
+
+ <section className="container space-y-20 pb-24">
+ <BlockDisplay block={block} />
+
+ {neighbours.length > 0 && (
+ <section aria-labelledby="more-blocks" className="space-y-6">
+ <h2
+ id="more-blocks"
+ className="text-foreground text-lg font-medium tracking-tight"
+ >
+ More blocks
+ </h2>
+ <div className="grid grid-cols-1 gap-6 md:grid-cols-2">
+ {neighbours.map((other) => (
+ <BlockCard key={other.name} block={other} />
+ ))}
+ </div>
+ </section>
+ )}
+ </section>
+ </div>
+
+ <Footer />
+ </>
+ );
+}
diff --git a/src/app/(main)/blocks/_components/block-card.tsx b/src/app/(main)/blocks/_components/block-card.tsx
index f3b214e..5c86b7a 100644
--- a/src/app/(main)/blocks/_components/block-card.tsx
+++ b/src/app/(main)/blocks/_components/block-card.tsx
@@ -1,6 +1,6 @@
-import Image from "next/image";
+import { ThemedImage } from "@/components/themed-image";
import type { RegistryBlockItem } from "@/lib/blocks";
-import { OpenBlockLink } from "./blocks-view";
+import Link from "next/link";
interface BlockCardProps {
block: RegistryBlockItem;
@@ -10,25 +10,12 @@ export function BlockCard({ block }: BlockCardProps) {
const title = block.title ?? block.name;
return (
- <OpenBlockLink
- name={block.name}
+ <Link
+ href={`/blocks/${block.name}`}
className="bg-muted/50 hover:bg-muted ring-foreground/5 focus-visible:ring-ring/50 dark:bg-muted/30 dark:hover:bg-muted/50 block rounded-2xl p-2 ring-1 transition-[background-color,box-shadow] outline-none focus-visible:ring-[3px]"
>
<div className="bg-background ring-foreground/5 relative aspect-[16/10] overflow-hidden rounded-lg shadow-xs ring-1">
- <Image
- src={`/blocks/${block.name}-light.jpg`}
- alt=""
- fill
- sizes={THUMBNAIL_SIZES}
- className="object-cover dark:hidden"
- />
- <Image
- src={`/blocks/${block.name}-dark.jpg`}
- alt=""
- fill
- sizes={THUMBNAIL_SIZES}
- className="hidden object-cover dark:block"
- />
+ <ThemedImage src={`/blocks/${block.name}`} sizes={THUMBNAIL_SIZES} />
</div>
<div className="min-w-0 px-2 pt-3.5 pb-2">
@@ -39,7 +26,7 @@ export function BlockCard({ block }: BlockCardProps) {
</p>
)}
</div>
- </OpenBlockLink>
+ </Link>
);
}
diff --git a/src/app/(main)/blocks/_components/block-hash-redirect.tsx b/src/app/(main)/blocks/_components/block-hash-redirect.tsx
new file mode 100644
index 0000000..4f130ac
--- /dev/null
+++ b/src/app/(main)/blocks/_components/block-hash-redirect.tsx
@@ -0,0 +1,22 @@
+"use client";
+
+import { useEffect } from "react";
+import { useRouter } from "next/navigation";
+
+// Redirects old /blocks#name links to /blocks/name.
+export function BlockHashRedirect({ blockNames }: { blockNames: string[] }) {
+ const router = useRouter();
+
+ useEffect(() => {
+ function redirect() {
+ const name = window.location.hash.slice(1);
+ if (blockNames.includes(name)) router.replace(`/blocks/${name}`);
+ }
+
+ redirect();
+ window.addEventListener("hashchange", redirect);
+ return () => window.removeEventListener("hashchange", redirect);
+ }, [blockNames, router]);
+
+ return null;
+}
diff --git a/src/app/(main)/blocks/_components/block-install-button.tsx b/src/app/(main)/blocks/_components/block-install-button.tsx
new file mode 100644
index 0000000..334a3a6
--- /dev/null
+++ b/src/app/(main)/blocks/_components/block-install-button.tsx
@@ -0,0 +1,37 @@
+"use client";
+
+import { Check, Terminal } from "lucide-react";
+import { Button } from "@/components/ui/button";
+import { useCopy } from "@/hooks/use-copy";
+import { trackEvent } from "@/lib/events";
+
+export function BlockInstallButton({ name }: { name: string }) {
+ const { status, copy } = useCopy();
+
+ async function copyCommand() {
+ if (await copy(`npx shadcn@latest add @mapcn/${name}`)) {
+ trackEvent({ name: "copy_block_cli", properties: { block: name } });
+ }
+ }
+
+ return (
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={copyCommand}
+ className="min-w-0 shrink font-mono text-xs"
+ >
+ {status === "copied" ? <Check /> : <Terminal />}
+ <span className="truncate">npx shadcn add @mapcn/{name}</span>
+ <span aria-live="polite" className="sr-only">
+ {STATUS_MESSAGES[status]}
+ </span>
+ </Button>
+ );
+}
+
+const STATUS_MESSAGES = {
+ idle: "",
+ copied: "Copied",
+ failed: "Couldn't copy",
+};
diff --git a/src/app/(main)/blocks/_components/block-preview.tsx b/src/app/(main)/blocks/_components/block-preview.tsx
index 09df9f3..89cc37a 100644
--- a/src/app/(main)/blocks/_components/block-preview.tsx
+++ b/src/app/(main)/blocks/_components/block-preview.tsx
@@ -1,14 +1,12 @@
"use client";
-import { useState } from "react";
-import { Check, Maximize, Terminal } from "lucide-react";
-import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
+import Link from "next/link";
+import { Maximize } from "lucide-react";
import { Button } from "@/components/ui/button";
+import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { type FileTree, type RegistryBlockItem } from "@/lib/blocks";
-import { trackEvent } from "@/lib/events";
+import { BlockInstallButton } from "./block-install-button";
import { BlockViewerCode, type HighlightedFile } from "./block-viewer-code";
-import { Separator } from "@/components/ui/separator";
-import Link from "next/link";
interface BlockPreviewProps {
block: RegistryBlockItem;
@@ -23,73 +21,42 @@ export function BlockPreview({
tree,
highlightedFiles,
}: BlockPreviewProps) {
- const { name, title, description, meta } = block;
- const [copiedType, setCopiedType] = useState<"code" | "cli" | null>(null);
-
- async function copyCli() {
- await navigator.clipboard.writeText(`npx shadcn@latest add @mapcn/${name}`);
- setCopiedType("cli");
- setTimeout(() => setCopiedType(null), 2000);
- trackEvent({ name: "copy_block_cli", properties: { block: name } });
- }
-
return (
- <div
- id={name}
- className="scroll-mt-24"
+ <Tabs
+ defaultValue="preview"
+ className="w-full gap-4"
style={
{
- "--block-preview-height": meta?.iframeHeight ?? "930px",
+ "--block-preview-height": block.meta?.iframeHeight ?? "930px",
} as React.CSSProperties
}
>
- <Tabs defaultValue="preview" className="w-full gap-4">
- <div className="flex flex-col gap-4 xl:flex-row xl:items-end xl:justify-between xl:gap-6">
- <div className="min-w-0">
- <h3 className="text-lg font-semibold tracking-tight">{title}</h3>
- {description && (
- <p className="text-muted-foreground mt-0.5 text-sm">
- {description}
- </p>
- )}
- </div>
-
- <div className="flex shrink-0 items-center gap-3">
- <TabsList className="bg-background dark:border-input dark:bg-input/30 h-8! gap-0.5 rounded-md border p-0.5 shadow-xs">
- <TabsTrigger value="preview" className={tabTriggerClassName}>
- Preview
- </TabsTrigger>
- <TabsTrigger value="code" className={tabTriggerClassName}>
- Code
- </TabsTrigger>
- </TabsList>
+ <div className="flex flex-wrap items-center justify-between gap-3">
+ <TabsList className="bg-background dark:border-input dark:bg-input/30 h-8! gap-0.5 rounded-md border p-0.5 shadow-xs">
+ <TabsTrigger value="preview" className={tabTriggerClassName}>
+ Preview
+ </TabsTrigger>
+ <TabsTrigger value="code" className={tabTriggerClassName}>
+ Code
+ </TabsTrigger>
+ </TabsList>
- <div className="hidden items-center gap-2 md:flex">
- <Separator orientation="vertical" className="mr-1 h-5!" />
- <Button
- onClick={copyCli}
- variant="outline"
- aria-label="Copy CLI command"
- size="sm"
- className="font-mono text-xs"
- >
- {copiedType === "cli" ? <Check /> : <Terminal />}
- npx shadcn add @mapcn/{name}
- </Button>
- <Button
- variant="outline"
- size="icon-sm"
- asChild
- aria-label="Open in new tab"
- >
- <Link href={`/view/${name}`} target="_blank">
- <Maximize />
- </Link>
- </Button>
- </div>
- </div>
+ <div className="flex min-w-0 items-center gap-2">
+ <BlockInstallButton name={block.name} />
+ <Button
+ variant="outline"
+ size="icon-sm"
+ asChild
+ aria-label="Open in new tab"
+ >
+ <Link href={`/view/${block.name}`} target="_blank">
+ <Maximize />
+ </Link>
+ </Button>
</div>
+ </div>
+ <div className="bg-muted/50 ring-foreground/5 dark:bg-muted/30 rounded-2xl p-2 ring-1">
<TabsContent
value="preview"
forceMount
@@ -101,8 +68,8 @@ export function BlockPreview({
<TabsContent value="code">
<BlockViewerCode tree={tree} highlightedFiles={highlightedFiles} />
</TabsContent>
- </Tabs>
- </div>
+ </div>
+ </Tabs>
);
}
diff --git a/src/app/(main)/blocks/_components/block-viewer-code.tsx b/src/app/(main)/blocks/_components/block-viewer-code.tsx
index 4d31bb9..a62de59 100644
--- a/src/app/(main)/blocks/_components/block-viewer-code.tsx
+++ b/src/app/(main)/blocks/_components/block-viewer-code.tsx
@@ -73,12 +73,12 @@ export function BlockViewerCode({
<BlockViewerCodeCtx.Provider
value={{ activeFile, setActiveFile, highlightedFiles, tree }}
>
- <div className="bg-background flex h-(--block-preview-height) overflow-hidden rounded-xl border">
+ <div className="bg-background ring-foreground/5 flex h-(--block-preview-height) overflow-hidden rounded-lg shadow-xs ring-1">
<div className="w-64 shrink-0">
<FileTreeSidebar />
</div>
<div className="flex min-w-0 flex-1 flex-col">
- <div className="bg-surface flex h-12 shrink-0 items-center gap-2 border-b px-4 text-sm">
+ <div className="bg-surface flex h-12 shrink-0 items-center gap-2 border-b px-4 pr-2 text-sm">
<span className="text-muted-foreground">{file.target}</span>
<div className="ml-auto">
<CodeCopyButton
diff --git a/src/app/(main)/blocks/_components/blocks-view.tsx b/src/app/(main)/blocks/_components/blocks-view.tsx
deleted file mode 100644
index 69e0f83..0000000
--- a/src/app/(main)/blocks/_components/blocks-view.tsx
+++ /dev/null
@@ -1,150 +0,0 @@
-"use client";
-
-import {
- createContext,
- useCallback,
- useContext,
- useEffect,
- useRef,
- useState,
-} from "react";
-import { LayoutGrid, Rows2 } from "lucide-react";
-import { cn } from "@/lib/utils";
-
-type BlocksViewMode = "grid" | "single";
-
-const BlocksViewContext = createContext<{
- view: BlocksViewMode;
- setView: (view: BlocksViewMode) => void;
- openBlock: (name: string) => void;
-} | null>(null);
-
-function useBlocksView() {
- const context = useContext(BlocksViewContext);
- if (!context) {
- throw new Error("useBlocksView must be used within BlocksViewProvider");
- }
- return context;
-}
-
-export function BlocksViewProvider({
- blockNames,
- children,
-}: {
- blockNames: string[];
- children: React.ReactNode;
-}) {
- const [view, setView] = useState<BlocksViewMode>("grid");
- const [openRequest, setOpenRequest] = useState(0);
- const targetRef = useRef<string | null>(null);
-
- const openBlock = useCallback((name: string) => {
- targetRef.current = name;
- setView("single");
- setOpenRequest((request) => request + 1);
- if (window.location.hash !== `#${name}`) {
- window.history.replaceState(null, "", `#${name}`);
- }
- }, []);
-
- useEffect(() => {
- function openFromHash() {
- const name = window.location.hash.slice(1);
- if (blockNames.includes(name)) openBlock(name);
- }
-
- openFromHash();
- window.addEventListener("hashchange", openFromHash);
- return () => window.removeEventListener("hashchange", openFromHash);
- }, [blockNames, openBlock]);
-
- useEffect(() => {
- const target = targetRef.current;
- if (view !== "single" || !target) return;
- document.getElementById(target)?.scrollIntoView({ block: "start" });
- targetRef.current = null;
- }, [view, openRequest]);
-
- return (
- <BlocksViewContext.Provider value={{ view, setView, openBlock }}>
- {children}
- </BlocksViewContext.Provider>
- );
-}
-
-export function BlocksView({
- mode,
- children,
-}: {
- mode: BlocksViewMode;
- children: React.ReactNode;
-}) {
- const { view } = useBlocksView();
- return view === mode ? children : null;
-}
-
-export function BlocksViewSwitch() {
- const { view, setView } = useBlocksView();
-
- const options = [
- { mode: "grid", label: "Grid view", icon: LayoutGrid },
- { mode: "single", label: "List view", icon: Rows2 },
- ] as const;
-
- return (
- <div
- role="group"
- aria-label="Blocks layout"
- className="bg-background dark:border-input dark:bg-input/30 flex items-center gap-0.5 rounded-lg border p-0.5 shadow-xs"
- >
- {options.map(({ mode, label, icon: Icon }) => (
- <button
- key={mode}
- type="button"
- aria-label={label}
- aria-pressed={view === mode}
- onClick={() => {
- setView(mode);
- window.history.replaceState(null, "", window.location.pathname);
- }}
- className={cn(
- "text-muted-foreground hover:text-foreground focus-visible:ring-ring/50 flex size-8 items-center justify-center rounded-md transition-colors outline-none focus-visible:ring-[3px]",
- view === mode && "bg-accent text-foreground",
- )}
- >
- <Icon className="size-4" />
- </button>
- ))}
- </div>
- );
-}
-
-export function OpenBlockLink({
- name,
- children,
- ...props
-}: Omit<React.ComponentProps<"a">, "href" | "onClick"> & { name: string }) {
- const { openBlock } = useBlocksView();
-
- return (
- <a
- href={`#${name}`}
- onClick={(event) => {
- if (
- event.button !== 0 ||
- event.metaKey ||
- event.ctrlKey ||
- event.shiftKey ||
- event.altKey
- ) {
- return;
- }
- event.preventDefault();
- openBlock(name);
- }}
- {...props}
- >
- {children}
- </a>
- );
-}
diff --git a/src/app/(main)/blocks/_components/iframe-preview.tsx b/src/app/(main)/blocks/_components/iframe-preview.tsx
index efd3441..fbc214c 100644
--- a/src/app/(main)/blocks/_components/iframe-preview.tsx
+++ b/src/app/(main)/blocks/_components/iframe-preview.tsx
@@ -5,7 +5,7 @@ interface IframePreviewProps {
export function IframePreview({ src, title }: IframePreviewProps) {
return (
- <div className="bg-background relative h-(--block-preview-height) w-full overflow-hidden rounded-xl border">
+ <div className="bg-background ring-foreground/5 relative h-(--block-preview-height) w-full overflow-hidden rounded-lg shadow-xs ring-1">
<iframe src={src} title={title} className="size-full border-0" />
</div>
);
diff --git a/src/app/(main)/blocks/page.tsx b/src/app/(main)/blocks/page.tsx
index 5deff38..3bc1538 100644
--- a/src/app/(main)/blocks/page.tsx
+++ b/src/app/(main)/blocks/page.tsx
@@ -1,5 +1,4 @@
import {
- PageActions,
PageHeader,
PageHeaderDescription,
PageHeaderHeading,
@@ -7,18 +6,12 @@ import {
import { Footer } from "@/components/footer";
import { Metadata } from "next";
import {
- getAllBlocks,
getBlockCategories,
+ getBlocksInGridOrder,
type BlockCategory,
} from "@/lib/blocks";
import { BlockCard } from "./_components/block-card";
-import { BlockDisplay } from "./_components/block-display";
-import {
- BlocksView,
- BlocksViewProvider,
- BlocksViewSwitch,
-} from "./_components/blocks-view";
-import { type CSSProperties } from "react";
+import { BlockHashRedirect } from "./_components/block-hash-redirect";
export const metadata: Metadata = {
title: "Map Blocks",
@@ -26,65 +19,39 @@ export const metadata: Metadata = {
"Pre-built, ready-to-use map blocks. Browse, preview, and copy them into your app with one command.",
};
-export default async function Page() {
- const blocks = getAllBlocks();
+export default function Page() {
const categories = getBlockCategories();
return (
- <BlocksViewProvider blockNames={blocks.map((block) => block.name)}>
- <PageHeader
- align="left"
- size="sm"
- className="md:flex-row md:items-end md:justify-between"
- >
- <div className="flex flex-col gap-3">
+ <>
+ <BlockHashRedirect
+ blockNames={getBlocksInGridOrder().map((block) => block.name)}
+ />
+
+ <div className="flex-1">
+ <PageHeader align="left" size="sm">
<PageHeaderHeading>Blocks</PageHeaderHeading>
<PageHeaderDescription className="max-w-4xl">
Ready-to-use map blocks. Browse, preview, and copy them into your
app with one command.
</PageHeaderDescription>
- </div>
- <PageActions className="mt-0">
- <BlocksViewSwitch />
- </PageActions>
- </PageHeader>
-
- <section
- className="animate-fade-up animate-stagger container scroll-mt-20 space-y-20 pb-24"
- id="blocks"
- style={
- {
- "--stagger": 4,
- } as CSSProperties
- }
- >
- <BlocksView mode="grid">
- <div className="space-y-16">
- {categories.map((category) => (
- <CategorySection key={category.slug} category={category}>
- <div className="grid grid-cols-1 gap-6 md:grid-cols-2">
- {category.blocks.map((block) => (
- <BlockCard key={block.name} block={block} />
- ))}
- </div>
- </CategorySection>
- ))}
- </div>
- </BlocksView>
+ </PageHeader>
- <BlocksView mode="single">
- <div className="space-y-20">
- {categories
- .flatMap((category) => category.blocks)
- .map((block) => (
- <BlockDisplay key={block.name} block={block} />
- ))}
- </div>
- </BlocksView>
- </section>
+ <section className="container space-y-16 pb-24">
+ {categories.map((category) => (
+ <CategorySection key={category.slug} category={category}>
+ <div className="grid grid-cols-1 gap-6 md:grid-cols-2">
+ {category.blocks.map((block) => (
+ <BlockCard key={block.name} block={block} />
+ ))}
+ </div>
+ </CategorySection>
+ ))}
+ </section>
+ </div>
<Footer />
- </BlocksViewProvider>
+ </>
);
}
diff --git a/src/app/(main)/docs/_components/agent-prompt.tsx b/src/app/(main)/docs/_components/agent-prompt.tsx
new file mode 100644
index 0000000..fdac1a3
--- /dev/null
+++ b/src/app/(main)/docs/_components/agent-prompt.tsx
@@ -0,0 +1,43 @@
+"use client";
+
+import { Check, Copy } from "lucide-react";
+
+import { mapInstallAgentPrompt } from "@/lib/llm-prompts";
+import { Button } from "@/components/ui/button";
+import { useCopy } from "@/hooks/use-copy";
+import { trackEvent } from "@/lib/events";
+
+export function AgentPrompt() {
+ const { status, copy } = useCopy(2500);
+
+ async function copyPrompt() {
+ if (await copy(mapInstallAgentPrompt)) {
+ trackEvent({ name: "copy_agent_prompt" });
+ }
+ }
+
+ return (
+ <Button
+ type="button"
+ onClick={copyPrompt}
+ aria-live="polite"
+ variant="outline"
+ size="sm"
+ title="Paste into your AI coding agent to install mapcn"
+ className="text-muted-foreground hover:text-foreground h-7 shrink-0 gap-1.5 bg-transparent px-2.5 text-[13px] font-normal shadow-none dark:bg-transparent"
+ >
+ {status === "copied" ? (
+ <Check className="size-3.5" />
+ ) : (
+ <Copy className="size-3.5" />
+ )}
+ {LABELS[status]}
+ </Button>
+ );
+}
+
+const LABELS = {
+ idle: "Copy prompt",
+ copied: "Copied",
+ failed: "Couldn't copy",
+};
diff --git a/src/app/(main)/docs/_components/docs.tsx b/src/app/(main)/docs/_components/docs.tsx
index 5416047..bdb07a4 100644
--- a/src/app/(main)/docs/_components/docs.tsx
+++ b/src/app/(main)/docs/_components/docs.tsx
@@ -29,14 +29,18 @@ interface TocItem {
interface DocsTitleProps {
title: string;
description: string;
+ action?: React.ReactNode;
}
-function DocsTitle({ title, description }: DocsTitleProps) {
+function DocsTitle({ title, description, action }: DocsTitleProps) {
return (
<div className="space-y-2">
- <h1 className="text-foreground text-3xl font-semibold tracking-tight">
- {title}
- </h1>
+ <div className="flex items-baseline justify-between gap-4">
+ <h1 className="text-foreground text-3xl font-semibold tracking-tight">
+ {title}
+ </h1>
+ {action}
+ </div>
<p className="text-muted-foreground text-base leading-relaxed">
{description}
</p>
@@ -75,6 +79,8 @@ interface DocsLayoutProps {
prev?: { title: string; href: string };
next?: { title: string; href: string };
toc?: TocItem[];
+ /** Shown at the end of the title row. */
+ action?: React.ReactNode;
}
export function DocsLayout({
@@ -84,13 +90,14 @@ export function DocsLayout({
prev,
next,
toc,
+ action,
}: DocsLayoutProps) {
const tocItems = toc ?? collectToc(children);
return (
<div className="flex min-w-0 flex-1">
<div className="mx-auto flex max-w-[52rem] min-w-0 flex-1 flex-col pt-10 pb-20 lg:px-12 lg:pt-12">
- <DocsTitle title={title} description={description} />
+ <DocsTitle title={title} description={description} action={action} />
<div className="mt-12 mb-12 space-y-14 [&>*:has(+[data-slot=docs-note])]:mb-6">
{children}
</div>
diff --git a/src/app/(main)/docs/_components/get-example-source.ts b/src/app/(main)/docs/_components/get-example-source.ts
index 29069e2..2f45e72 100644
--- a/src/app/(main)/docs/_components/get-example-source.ts
+++ b/src/app/(main)/docs/_components/get-example-source.ts
@@ -3,7 +3,7 @@ import path from "path";
const EXAMPLES_DIR = path.join(
process.cwd(),
- "src/app/(main)/docs/_components/examples"
+ "src/app/(main)/docs/_components/examples",
);
export function getExampleSource(filename: string): string {
diff --git a/src/app/(main)/docs/_components/install-command.tsx b/src/app/(main)/docs/_components/install-command.tsx
index cbd1995..9fac4f3 100644
--- a/src/app/(main)/docs/_components/install-command.tsx
+++ b/src/app/(main)/docs/_components/install-command.tsx
@@ -4,6 +4,7 @@ import { useState } from "react";
import { Check, Copy } from "lucide-react";
import { Button } from "@/components/ui/button";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
+import { useCopy } from "@/hooks/use-copy";
import { trackEvent } from "@/lib/events";
interface InstallCommandProps {
@@ -25,14 +26,11 @@ export function InstallCommand({ name }: InstallCommandProps) {
}));
const [active, setActive] = useState<string>(tabs[0].manager);
- const [copied, setCopied] = useState(false);
+ const { status, copy } = useCopy();
- const copy = async () => {
+ const copyCommand = async () => {
const current = tabs.find((tab) => tab.manager === active);
- if (!current) return;
- await navigator.clipboard.writeText(current.command);
- setCopied(true);
- setTimeout(() => setCopied(false), 2000);
+ if (!current || !(await copy(current.command))) return;
trackEvent({
name: "copy_install_command",
properties: { name, packageManager: active },
@@ -60,11 +58,11 @@ export function InstallCommand({ name }: InstallCommandProps) {
<Button
variant="ghost"
size="icon-sm"
- onClick={copy}
- aria-label={copied ? "Copied" : "Copy command"}
+ onClick={copyCommand}
+ aria-label={COPY_LABELS[status]}
className="text-muted-foreground"
>
- {copied ? <Check /> : <Copy />}
+ {status === "copied" ? <Check /> : <Copy />}
</Button>
</div>
{tabs.map((tab) => (
@@ -80,3 +78,9 @@ export function InstallCommand({ name }: InstallCommandProps) {
</div>
);
}
+
+const COPY_LABELS = {
+ idle: "Copy command",
+ copied: "Copied",
+ failed: "Couldn't copy",
+};
diff --git a/src/app/(main)/docs/installation/page.tsx b/src/app/(main)/docs/installation/page.tsx
index 83d0a38..50e2b1a 100644
--- a/src/app/(main)/docs/installation/page.tsx
+++ b/src/app/(main)/docs/installation/page.tsx
@@ -5,6 +5,7 @@ import {
DocsNote,
DocsSection,
} from "../_components/docs";
+import { AgentPrompt } from "../_components/agent-prompt";
import { CodeBlock } from "../_components/code-block";
import { InstallCommand } from "../_components/install-command";
import { Metadata } from "next";
@@ -44,6 +45,7 @@ export default function InstallationPage() {
description="How to install and set up mapcn in your project."
prev={{ title: "Introduction", href: "/docs" }}
next={{ title: "API Reference", href: "/docs/api-reference" }}
+ action={<AgentPrompt />}
>
<DocsSection title="Prerequisites">
<p>
diff --git a/src/app/(main)/layout.tsx b/src/app/(main)/layout.tsx
index 4ad5eac..196f964 100644
--- a/src/app/(main)/layout.tsx
+++ b/src/app/(main)/layout.tsx
@@ -8,7 +8,7 @@ export default function MainLayout({
return (
<div className="bg-background relative flex min-h-screen flex-col">
<Header />
- <main className="flex-1">{children}</main>
+ <main className="flex flex-1 flex-col">{children}</main>
</div>
);
}
diff --git a/src/app/layout.tsx b/src/app/layout.tsx
index 4deb734..c8bec18 100644
--- a/src/app/layout.tsx
+++ b/src/app/layout.tsx
@@ -65,7 +65,7 @@ export const metadata: Metadata = {
openGraph: {
type: "website",
locale: "en_US",
- url: siteUrl,
+ url: "./",
siteName: siteName,
title: "mapcn - Beautiful maps made simple",
description: siteDescription,
@@ -85,8 +85,9 @@ export const metadata: Metadata = {
creator: creator,
images: ["/banner.png"],
},
+ // "./" resolves to each page's own path.
alternates: {
- canonical: siteUrl,
+ canonical: "./",
},
category: "technology",
};
diff --git a/src/components/code-copy-button.tsx b/src/components/code-copy-button.tsx
index 7051b5e..af2aeef 100644
--- a/src/components/code-copy-button.tsx
+++ b/src/components/code-copy-button.tsx
@@ -1,9 +1,9 @@
"use client";
-import { useState } from "react";
import { Check, Copy } from "lucide-react";
import { cn } from "@/lib/utils";
import { Button } from "@/components/ui/button";
+import { useCopy } from "@/hooks/use-copy";
interface CodeCopyButtonProps {
text: string;
@@ -16,24 +16,27 @@ export function CodeCopyButton({
onCopy,
className,
}: CodeCopyButtonProps) {
- const [copied, setCopied] = useState(false);
+ const { status, copy } = useCopy();
- const copy = async () => {
- await navigator.clipboard.writeText(text);
- setCopied(true);
- setTimeout(() => setCopied(false), 2000);
- onCopy?.();
+ const copyText = async () => {
+ if (await copy(text)) onCopy?.();
};
return (
<Button
variant="ghost"
size="icon-sm"
- onClick={copy}
- aria-label={copied ? "Copied" : "Copy code"}
+ onClick={copyText}
+ aria-label={COPY_LABELS[status]}
className={cn("text-muted-foreground bg-code", className)}
>
- {copied ? <Check /> : <Copy />}
+ {status === "copied" ? <Check /> : <Copy />}
</Button>
);
}
+
+const COPY_LABELS = {
+ idle: "Copy code",
+ copied: "Copied",
+ failed: "Couldn't copy",
+};
diff --git a/src/components/github-button.tsx b/src/components/github-button.tsx
index 53b9757..c8b5c53 100644
--- a/src/components/github-button.tsx
+++ b/src/components/github-button.tsx
@@ -7,7 +7,12 @@ import { Skeleton } from "@/components/ui/skeleton";
export function GitHubButton({ withCount = true }: { withCount?: boolean }) {
return (
- <Button variant="ghost" size="sm" asChild>
+ <Button
+ variant="ghost"
+ size="sm"
+ asChild
+ className="text-muted-foreground hover:text-foreground font-normal"
+ >
<Link
href={githubRepoUrl}
target="_blank"
@@ -41,9 +46,7 @@ export async function StarCount() {
return (
<>
{formattedCount && (
- <span className="text-muted-foreground pt-0.5 text-xs tabular-nums">
- {formattedCount}
- </span>
+ <span className="pt-0.5 text-xs tabular-nums">{formattedCount}</span>
)}
</>
);
diff --git a/src/components/page-header.tsx b/src/components/page-header.tsx
index 740634b..b14face 100644
--- a/src/components/page-header.tsx
+++ b/src/components/page-header.tsx
@@ -9,9 +9,11 @@ type HeaderSize = "default" | "sm";
const PageHeaderContext = createContext<{
align: HeaderAlign;
size: HeaderSize;
+ animated: boolean;
}>({
align: "center",
size: "default",
+ animated: false,
});
function usePageHeaderContext() {
@@ -25,6 +27,8 @@ interface PageHeaderProps {
align?: HeaderAlign;
/** Visual scale of the header (default: "default") */
size?: HeaderSize;
+ /** Animate header content on entry (default: false) */
+ animated?: boolean;
}
function PageHeader({
@@ -32,9 +36,10 @@ function PageHeader({
className,
align = "center",
size = "default",
+ animated = false,
}: PageHeaderProps) {
return (
- <PageHeaderContext.Provider value={{ align, size }}>
+ <PageHeaderContext.Provider value={{ align, size, animated }}>
<section
className={cn(
"container mx-auto flex w-full max-w-6xl flex-col",
@@ -64,12 +69,13 @@ function PageHeaderHeading({
className,
as: Comp = "h1",
}: PageHeaderHeadingProps) {
- const { align, size } = usePageHeaderContext();
+ const { align, size, animated } = usePageHeaderContext();
return (
<Comp
className={cn(
- "animate-fade-up animate-stagger text-primary max-w-4xl font-bold tracking-tight text-balance",
+ "text-primary max-w-4xl font-bold tracking-tight text-balance",
+ animated && "animate-fade-up animate-stagger",
size === "sm"
? "text-4xl font-semibold md:text-5xl"
: "text-4xl sm:text-5xl md:text-6xl",
@@ -77,9 +83,11 @@ function PageHeaderHeading({
className,
)}
style={
- {
- "--stagger": 1,
- } as CSSProperties
+ animated
+ ? ({
+ "--stagger": 1,
+ } as CSSProperties)
+ : undefined
}
>
{children}
@@ -96,12 +104,13 @@ function PageHeaderDescription({
children,
className,
}: PageHeaderDescriptionProps) {
- const { align, size } = usePageHeaderContext();
+ const { align, size, animated } = usePageHeaderContext();
return (
<p
className={cn(
- "text-foreground/80 animate-fade-up animate-stagger max-w-2xl leading-relaxed text-pretty",
+ "text-foreground/80 max-w-2xl leading-relaxed text-pretty",
+ animated && "animate-fade-up animate-stagger",
size === "sm"
? "text-muted-foreground text-base sm:text-lg"
: "sm:text-lg md:text-xl",
@@ -109,9 +118,11 @@ function PageHeaderDescription({
className,
)}
style={
- {
- "--stagger": 2,
- } as CSSProperties
+ animated
+ ? ({
+ "--stagger": 2,
+ } as CSSProperties)
+ : undefined
}
>
{children}
@@ -125,19 +136,22 @@ interface PageActionsProps {
}
function PageActions({ children, className }: PageActionsProps) {
- const { align } = usePageHeaderContext();
+ const { align, animated } = usePageHeaderContext();
return (
<div
className={cn(
- "animate-fade-up animate-stagger mt-3 flex flex-wrap items-center gap-3",
+ "mt-3 flex flex-wrap items-center gap-3",
+ animated && "animate-fade-up animate-stagger",
align === "center" ? "justify-center" : "justify-start",
className,
)}
style={
- {
- "--stagger": 3,
- } as CSSProperties
+ animated
+ ? ({
+ "--stagger": 3,
+ } as CSSProperties)
+ : undefined
}
>
{children}
diff --git a/src/components/theme-toggle.tsx b/src/components/theme-toggle.tsx
index c7ff7cb..ef02fc2 100644
--- a/src/components/theme-toggle.tsx
+++ b/src/components/theme-toggle.tsx
@@ -1,16 +1,16 @@
"use client";
-import { useCallback, useEffect, useState } from "react";
+import { useCallback } from "react";
import { useTheme } from "next-themes";
import { Button } from "@/components/ui/button";
import { Moon, Sun } from "lucide-react";
-import { Skeleton } from "./ui/skeleton";
import { THEME_HOTKEY } from "./theme-provider";
export function useThemeToggle() {
const { resolvedTheme, setTheme } = useTheme();
const toggleTheme = useCallback(() => {
+ if (!resolvedTheme) return;
setTheme(resolvedTheme === "dark" ? "light" : "dark");
}, [resolvedTheme, setTheme]);
@@ -18,17 +18,7 @@ export function useThemeToggle() {
}
export function ThemeToggle() {
- const { resolvedTheme, toggleTheme } = useThemeToggle();
- const [mounted, setMounted] = useState(false);
-
- useEffect(() => {
- // eslint-disable-next-line react-hooks/set-state-in-effect
- setMounted(true);
- }, []);
-
- if (!mounted) {
- return <Skeleton className="size-8" />;
- }
+ const { toggleTheme } = useThemeToggle();
return (
<Button
@@ -37,8 +27,11 @@ export function ThemeToggle() {
aria-label="Toggle theme"
aria-keyshortcuts={THEME_HOTKEY.toUpperCase()}
size="icon-sm"
+ className="text-muted-foreground hover:text-foreground"
>
- {resolvedTheme === "dark" ? <Moon /> : <Sun />}
+ <Moon className="hidden dark:block" />
+
+ <Sun className="block dark:hidden" />
</Button>
);
}
diff --git a/src/components/themed-image.tsx b/src/components/themed-image.tsx
new file mode 100644
index 0000000..edc544d
--- /dev/null
+++ b/src/components/themed-image.tsx
@@ -0,0 +1,32 @@
+import Image from "next/image";
+import { cn } from "@/lib/utils";
+
+interface ThemedImageProps {
+ /** Path without the `-light.jpg` / `-dark.jpg` suffix. */
+ src: string;
+ sizes: string;
+ className?: string;
+}
+
+export function ThemedImage({ src, sizes, className }: ThemedImageProps) {
+ return (
+ <>
+ <Image
+ src={`${src}-light.jpg`}
+ alt=""
+ fill
+ sizes={sizes}
+ draggable={false}
+ className={cn("object-cover select-none dark:hidden", className)}
+ />
+ <Image
+ src={`${src}-dark.jpg`}
+ alt=""
+ fill
+ sizes={sizes}
+ draggable={false}
+ className={cn("hidden object-cover select-none dark:block", className)}
+ />
+ </>
+ );
+}
diff --git a/src/hooks/use-copy.ts b/src/hooks/use-copy.ts
new file mode 100644
index 0000000..211ffb5
--- /dev/null
+++ b/src/hooks/use-copy.ts
@@ -0,0 +1,28 @@
+"use client";
+
+import { useCallback, useEffect, useRef, useState } from "react";
+
+type CopyStatus = "idle" | "copied" | "failed";
+
+export function useCopy(resetAfter = 2000) {
+ const [status, setStatus] = useState<CopyStatus>("idle");
+ const timer = useRef<number | undefined>(undefined);
+
+ useEffect(() => () => window.clearTimeout(timer.current), []);
+
+ const copy = useCallback(
+ async (text: string) => {
+ window.clearTimeout(timer.current);
+ const copied = await navigator.clipboard.writeText(text).then(
+ () => true,
+ () => false,
+ );
+ setStatus(copied ? "copied" : "failed");
+ timer.current = window.setTimeout(() => setStatus("idle"), resetAfter);
+ return copied;
+ },
+ [resetAfter],
+ );
+
+ return { status, copy };
+}
diff --git a/src/lib/blocks.ts b/src/lib/blocks.ts
index a590113..10de631 100644
--- a/src/lib/blocks.ts
+++ b/src/lib/blocks.ts
@@ -125,3 +125,7 @@ export function getBlockCategories(): BlockCategory[] {
blocks,
}));
}
+
+export function getBlocksInGridOrder(): RegistryBlockItem[] {
+ return getBlockCategories().flatMap((category) => category.blocks);
+}