Beautiful map components. 100% Free, Zero config, one command setup.
TypeScript
refactor(analytics-card): build on Card and Badge primitives
Anmolcf2ecad4ff42
diff --git a/.cursor/rules/rules.mdc b/.cursor/rules/rules.mdcdeleted file mode 100644index 66ba159..0000000--- a/.cursor/rules/rules.mdc+++ /dev/null@@ -1,53 +0,0 @@-----alwaysApply: true------You are an expert in TypeScript, Node.js, Next.js App Router, React, Shadcn UI, Radix UI and Tailwind.--Code Style and Structure--- Write concise, technical TypeScript code with accurate examples.-- Use functional and declarative programming patterns; avoid classes.-- Prefer iteration and modularization over code duplication.-- Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError).-- Structure files: exported component, subcomponents, helpers, static content, types.--Naming Conventions--- Use lowercase with dashes for directories (e.g., components/auth-wizard).-- Favor named exports for components.--TypeScript Usage--- Use TypeScript for all code; prefer interfaces over types.-- Avoid enums; use maps instead.-- Use functional components with TypeScript interfaces.--Syntax and Formatting--- Use the "function" keyword for pure functions.-- Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements.-- Use declarative JSX.--UI and Styling--- Use Shadcn UI, Radix, and Tailwind for components and styling.-- Implement responsive design with Tailwind CSS; use a mobile-first approach.--Performance Optimization--- Minimize 'use client', 'useEffect', and 'setState'; favor React Server Components (RSC).-- Wrap client components in Suspense with fallback.-- Use dynamic loading for non-critical components.-- Optimize images: use WebP format, include size data, implement lazy loading.--Key Conventions--- Use 'nuqs' for URL search parameter state management.-- Optimize Web Vitals (LCP, CLS, FID).-- Limit 'use client':- - Favor server components and Next.js SSR.- - Use only for Web API access in small components.- - Avoid for data fetching or state management.--Follow Next.js docs for Data Fetching, Rendering, and Routing.diff --git a/public/r/analytics-card.json b/public/r/analytics-card.jsonindex 43da197..6833932 100644--- a/public/r/analytics-card.json+++ b/public/r/analytics-card.json@@ -7,18 +7,20 @@"lucide-react"],"registryDependencies": [- "@mapcn/map"+ "@mapcn/map",+ "card",+ "badge"],"files": [{"path": "src/registry/blocks/analytics-card/page.tsx",- "content": "\"use client\";\n\nimport { TrendingUp } from \"lucide-react\";\n\nimport { Map, MapGeoJSON, MapMarker, MarkerContent } from \"@/components/ui/map\";\nimport { totalVisitors, visitorGrowth, visitorLocations } from \"./data\";\n\n// Country borders from a public CDN, or swap in your own GeoJSON.\nconst WORLD_GEOJSON =\n \"https://cdn.jsdelivr.net/gh/nvkelso/[email protected]/geojson/ne_110m_admin_0_countries.geojson\";\n\nfunction bubbleSize(visitors: number) {\n return Math.round(10 + Math.sqrt(visitors) * 2.2);\n}\n\nexport default function Page() {\n return (\n <div className=\"flex min-h-screen items-center justify-center p-8\">\n <div className=\"bg-card relative aspect-16/10 w-full max-w-md overflow-hidden rounded-xl border shadow-sm\">\n <div className=\"absolute inset-0\">\n <Map\n center={[1, 30]}\n scrollZoom={false}\n dragRotate={false}\n dragPan={false}\n doubleClickZoom={false}\n pitchWithRotate={false}\n className=\"[&_.maplibregl-canvas]:cursor-default! [&_.maplibregl-canvas-container]:cursor-default!\"\n blank\n >\n <MapGeoJSON data={WORLD_GEOJSON} linePaint={false} />\n {visitorLocations.map((location) => {\n const size = bubbleSize(location.visitors);\n return (\n <MapMarker\n key={location.city}\n longitude={location.lng}\n latitude={location.lat}\n >\n <MarkerContent className=\"cursor-default\">\n <span\n className=\"bg-chart-2/80 block rounded-full\"\n style={{ width: size, height: size }}\n />\n </MarkerContent>\n </MapMarker>\n );\n })}\n </Map>\n </div>\n\n <div\n className=\"from-card via-card/85 to-card/0 pointer-events-none absolute inset-x-0 top-0 z-10 h-24 rounded-t-xl bg-linear-to-b mask-[linear-gradient(to_bottom,black_70%,transparent)] backdrop-blur-[2px]\"\n aria-hidden\n />\n\n <div className=\"relative z-20 flex items-start justify-between gap-3 p-4\">\n <div>\n <h2 className=\"text-foreground text-lg font-medium tracking-tight\">\n Analytics\n </h2>\n <p className=\"text-muted-foreground mt-1 text-xs font-medium\">\n Last 30 days\n </p>\n </div>\n\n <div className=\"text-right\">\n <p className=\"text-foreground text-lg font-medium tracking-tight tabular-nums\">\n {totalVisitors}\n </p>\n <span className=\"text-muted-foreground mt-1 inline-flex items-center gap-0.5 text-xs font-medium\">\n <TrendingUp className=\"size-2.5\" />\n {visitorGrowth} visitors\n </span>\n </div>\n </div>\n </div>\n </div>\n );\n}\n",+ "content": "\"use client\";\n\nimport { TrendingUp } from \"lucide-react\";\n\nimport { Badge } from \"@/components/ui/badge\";\nimport {\n Card,\n CardAction,\n CardDescription,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\";\nimport { Map, MapGeoJSON, MapMarker, MarkerContent } from \"@/components/ui/map\";\nimport { totalVisitors, visitorGrowth, visitorLocations } from \"./data\";\n\n// Country borders from a public CDN, or swap in your own GeoJSON.\nconst WORLD_GEOJSON =\n \"https://cdn.jsdelivr.net/gh/nvkelso/[email protected]/geojson/ne_110m_admin_0_countries.geojson\";\n\nfunction bubbleSize(visitors: number) {\n return Math.round(10 + Math.sqrt(visitors) * 2.2);\n}\n\nexport default function Page() {\n return (\n <div className=\"flex min-h-screen items-center justify-center p-8\">\n <Card className=\"relative aspect-16/10 w-full max-w-md gap-0 overflow-hidden\">\n <div className=\"absolute inset-0\">\n <Map\n center={[1, 30]}\n scrollZoom={false}\n dragRotate={false}\n dragPan={false}\n doubleClickZoom={false}\n pitchWithRotate={false}\n className=\"[&_.maplibregl-canvas]:cursor-default! [&_.maplibregl-canvas-container]:cursor-default!\"\n blank\n >\n <MapGeoJSON data={WORLD_GEOJSON} linePaint={false} />\n {visitorLocations.map((location) => {\n const size = bubbleSize(location.visitors);\n return (\n <MapMarker\n key={location.city}\n longitude={location.lng}\n latitude={location.lat}\n >\n <MarkerContent className=\"cursor-default\">\n <span\n className=\"bg-chart-2/80 block rounded-full\"\n style={{ width: size, height: size }}\n />\n </MarkerContent>\n </MapMarker>\n );\n })}\n </Map>\n </div>\n\n <div\n className=\"from-card via-card/85 to-card/0 pointer-events-none absolute inset-x-0 top-0 z-10 h-24 rounded-t-xl bg-linear-to-b mask-[linear-gradient(to_bottom,black_70%,transparent)] backdrop-blur-[2px]\"\n aria-hidden\n />\n\n <CardHeader className=\"relative z-20 gap-1\">\n <CardDescription>Visitors</CardDescription>\n <CardTitle className=\"text-lg tabular-nums\">\n {totalVisitors}\n </CardTitle>\n\n <CardAction>\n <Badge variant=\"outline\">\n <TrendingUp />\n {visitorGrowth} growth\n </Badge>\n </CardAction>\n </CardHeader>\n </Card>\n </div>\n );\n}\n","type": "registry:page","target": "app/analytics-card/page.tsx"},{"path": "src/registry/blocks/analytics-card/data.ts",- "content": "export interface VisitorLocation {\n city: string;\n lng: number;\n lat: number;\n visitors: number;\n}\n\nexport const totalVisitors = \"418.2K\";\nexport const visitorGrowth = \"+10%\";\n\nexport const visitorLocations: VisitorLocation[] = [\n { city: \"San Francisco\", lng: -122.4194, lat: 37.7749, visitors: 62 },\n { city: \"New York\", lng: -74.006, lat: 40.7128, visitors: 58 },\n { city: \"Mexico City\", lng: -99.1332, lat: 19.4326, visitors: 22 },\n { city: \"Sao Paulo\", lng: -46.6333, lat: -23.5505, visitors: 30 },\n { city: \"London\", lng: -0.1276, lat: 51.5074, visitors: 48 },\n { city: \"Berlin\", lng: 13.405, lat: 52.52, visitors: 28 },\n { city: \"Madrid\", lng: -3.7038, lat: 40.4168, visitors: 18 },\n { city: \"Lagos\", lng: 3.3792, lat: 6.5244, visitors: 16 },\n { city: \"Dubai\", lng: 55.2708, lat: 25.2048, visitors: 24 },\n { city: \"Mumbai\", lng: 72.8777, lat: 19.076, visitors: 40 },\n { city: \"Singapore\", lng: 103.8198, lat: 1.3521, visitors: 21 },\n { city: \"Tokyo\", lng: 139.6917, lat: 35.6895, visitors: 38 },\n { city: \"Seoul\", lng: 126.978, lat: 37.5665, visitors: 26 },\n { city: \"Sydney\", lng: 151.2093, lat: -33.8688, visitors: 17 },\n];\n",+ "content": "export interface VisitorLocation {\n city: string;\n lng: number;\n lat: number;\n visitors: number;\n}\n\nexport const totalVisitors = \"418.2K\";\nexport const visitorGrowth = \"+12%\";\n\nexport const visitorLocations: VisitorLocation[] = [\n { city: \"San Francisco\", lng: -122.4194, lat: 37.7749, visitors: 62 },\n { city: \"New York\", lng: -74.006, lat: 40.7128, visitors: 58 },\n { city: \"Mexico City\", lng: -99.1332, lat: 19.4326, visitors: 22 },\n { city: \"Sao Paulo\", lng: -46.6333, lat: -23.5505, visitors: 30 },\n { city: \"London\", lng: -0.1276, lat: 51.5074, visitors: 48 },\n { city: \"Berlin\", lng: 13.405, lat: 52.52, visitors: 28 },\n { city: \"Madrid\", lng: -3.7038, lat: 40.4168, visitors: 18 },\n { city: \"Lagos\", lng: 3.3792, lat: 6.5244, visitors: 16 },\n { city: \"Dubai\", lng: 55.2708, lat: 25.2048, visitors: 24 },\n { city: \"Mumbai\", lng: 72.8777, lat: 19.076, visitors: 40 },\n { city: \"Singapore\", lng: 103.8198, lat: 1.3521, visitors: 21 },\n { city: \"Tokyo\", lng: 139.6917, lat: 35.6895, visitors: 38 },\n { city: \"Seoul\", lng: 126.978, lat: 37.5665, visitors: 26 },\n { city: \"Sydney\", lng: 151.2093, lat: -33.8688, visitors: 17 },\n];\n","type": "registry:component","target": "app/analytics-card/data.ts"}diff --git a/public/r/registry.json b/public/r/registry.jsonindex 0c30700..7e74b63 100644--- a/public/r/registry.json+++ b/public/r/registry.json@@ -180,7 +180,9 @@"lucide-react"],"registryDependencies": [- "@mapcn/map"+ "@mapcn/map",+ "card",+ "badge"],"files": [{diff --git a/registry.json b/registry.jsonindex 0c30700..7e74b63 100644--- a/registry.json+++ b/registry.json@@ -180,7 +180,9 @@"lucide-react"],"registryDependencies": [- "@mapcn/map"+ "@mapcn/map",+ "card",+ "badge"],"files": [{diff --git a/src/registry/blocks/analytics-card/data.ts b/src/registry/blocks/analytics-card/data.tsindex 0e60d11..70c28e8 100644--- a/src/registry/blocks/analytics-card/data.ts+++ b/src/registry/blocks/analytics-card/data.ts@@ -6,7 +6,7 @@ export interface VisitorLocation {}export const totalVisitors = "418.2K";-export const visitorGrowth = "+10%";+export const visitorGrowth = "+12%";export const visitorLocations: VisitorLocation[] = [{ city: "San Francisco", lng: -122.4194, lat: 37.7749, visitors: 62 },diff --git a/src/registry/blocks/analytics-card/page.tsx b/src/registry/blocks/analytics-card/page.tsxindex fb49bc6..298ad78 100644--- a/src/registry/blocks/analytics-card/page.tsx+++ b/src/registry/blocks/analytics-card/page.tsx@@ -2,6 +2,14 @@import { TrendingUp } from "lucide-react";+import { Badge } from "@/components/ui/badge";+import {+ Card,+ CardAction,+ CardDescription,+ CardHeader,+ CardTitle,+} from "@/components/ui/card";import { Map, MapGeoJSON, MapMarker, MarkerContent } from "@/registry/map";import { totalVisitors, visitorGrowth, visitorLocations } from "./data";@@ -16,7 +24,7 @@ function bubbleSize(visitors: number) {export default function Page() {return (<div className="flex min-h-screen items-center justify-center p-8">- <div className="bg-card relative aspect-16/10 w-full max-w-md overflow-hidden rounded-xl border shadow-sm">+ <Card className="relative aspect-16/10 w-full max-w-md gap-0 overflow-hidden"><div className="absolute inset-0"><Mapcenter={[1, 30]}@@ -54,27 +62,20 @@ export default function Page() {aria-hidden/>- <div className="relative z-20 flex items-start justify-between gap-3 p-4">- <div>- <h2 className="text-foreground text-lg font-medium tracking-tight">- Analytics- </h2>- <p className="text-muted-foreground mt-1 text-xs font-medium">- Last 30 days- </p>- </div>+ <CardHeader className="relative z-20 gap-1">+ <CardDescription>Visitors</CardDescription>+ <CardTitle className="text-lg tabular-nums">+ {totalVisitors}+ </CardTitle>- <div className="text-right">- <p className="text-foreground text-lg font-medium tracking-tight tabular-nums">- {totalVisitors}- </p>- <span className="text-muted-foreground mt-1 inline-flex items-center gap-0.5 text-xs font-medium">- <TrendingUp className="size-2.5" />- {visitorGrowth} visitors- </span>- </div>- </div>- </div>+ <CardAction>+ <Badge variant="outline">+ <TrendingUp />+ {visitorGrowth} growth+ </Badge>+ </CardAction>+ </CardHeader>+ </Card></div>);}diff --git a/src/styles/globals.css b/src/styles/globals.cssindex fe222c4..04f9782 100644--- a/src/styles/globals.css+++ b/src/styles/globals.css@@ -179,12 +179,12 @@}.animate-fade-up {- animation: fade-up 0.65s cubic-bezier(0.33, 1, 0.68, 1) both;+ animation: fade-up 0.6s both;}.animate-stagger {--stagger: 0;- --delay: 110ms;+ --delay: 0.12s;animation-delay: calc(var(--stagger) * var(--delay));}