Skip to content

armgit / mapcn

Public Imported from GitHub
0

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

TypeScript

fix(analytics-card): derive header scrim from content instead of a fixed height

Anmol50c67608c21c
diff --git a/public/r/analytics-card.json b/public/r/analytics-card.json
index 6833932..178f106 100644
--- a/public/r/analytics-card.json
+++ b/public/r/analytics-card.json
@@ -14,7 +14,7 @@
"files": [
{
"path": "src/registry/blocks/analytics-card/page.tsx",
- "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",
+ "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 overflow-hidden py-0\">\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 <CardHeader className=\"from-card via-card/85 to-card/0 relative z-10 gap-1 rounded-t-[inherit] bg-linear-to-b pt-4 pb-10 mask-[linear-gradient(to_bottom,black_calc(100%_-_2.5rem),transparent)] backdrop-blur-[2px]\">\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"
},
diff --git a/src/registry/blocks/analytics-card/page.tsx b/src/registry/blocks/analytics-card/page.tsx
index 298ad78..8c3b2d4 100644
--- a/src/registry/blocks/analytics-card/page.tsx
+++ b/src/registry/blocks/analytics-card/page.tsx
@@ -24,7 +24,7 @@ function bubbleSize(visitors: number) {
export default function Page() {
return (
<div className="flex min-h-screen items-center justify-center p-8">
- <Card className="relative aspect-16/10 w-full max-w-md gap-0 overflow-hidden">
+ <Card className="relative aspect-16/10 w-full max-w-md overflow-hidden py-0">
<div className="absolute inset-0">
<Map
center={[1, 30]}
@@ -57,12 +57,7 @@ export default function Page() {
</Map>
</div>
- <div
- 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]"
- aria-hidden
- />
-
- <CardHeader className="relative z-20 gap-1">
+ <CardHeader className="from-card via-card/85 to-card/0 relative z-10 gap-1 rounded-t-[inherit] bg-linear-to-b pt-4 pb-10 mask-[linear-gradient(to_bottom,black_calc(100%_-_2.5rem),transparent)] backdrop-blur-[2px]">
<CardDescription>Visitors</CardDescription>
<CardTitle className="text-lg tabular-nums">
{totalVisitors}