Skip to content

armgit / mapcn

Public Imported from GitHub
0

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

TypeScript

fix(blocks): choropleth legend theme flash

Anmol6d86cb75a0bb
diff --git a/AGENTS.md b/AGENTS.md
index e9bbbbb..aa44e7c 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -75,7 +75,10 @@ src/
## Design System
+- Minimal, content-first aesthetic - no visual noise, no unnecessary borders/shadows/decoration
- Color palette is monochrome (grayscale oklch)
+- Generous, consistent white space; let layouts breathe rather than packing elements tightly
+- Clear typographic hierarchy - Geist Sans for UI/prose, Geist Mono for code/labels; use size, weight, and muted-foreground (not color) to establish hierarchy
- Radius: `0.625rem` base with computed variants
- Animations: `fade-up`, `fade-in`, `scale-in` with staggered delays (85ms intervals)
- Header: sticky, backdrop-blur, gradient bottom border
diff --git a/public/r/choropleth.json b/public/r/choropleth.json
index fe87315..ff7cbf5 100644
--- a/public/r/choropleth.json
+++ b/public/r/choropleth.json
@@ -13,13 +13,13 @@
"files": [
{
"path": "src/registry/blocks/choropleth/page.tsx",
- "content": "\"use client\";\n\nimport { useMemo, useState } from \"react\";\nimport { useTheme } from \"next-themes\";\n\nimport { Map, MapControls, MapGeoJSON, MapPopup } from \"@/components/ui/map\";\nimport { useWorldData } from \"@/lib/use-world-data\";\nimport { mapConfig, visitorsByCountry, type Theme } from \"./data\";\n\n// WebGL paint can't read CSS variables, so we build a concrete value→color\n// expression per theme. The hovered country is highlighted in place via the\n// `hover` feature-state, restricted to countries that actually have data.\nfunction buildFillColor(theme: Theme): unknown[] {\n const { base, ramp, hover } = mapConfig.colors[theme];\n const [s0, s1, s2, s3, s4] = mapConfig.scaleStops;\n const ramped = [\n \"interpolate\",\n [\"linear\"],\n [\"coalesce\", [\"get\", \"visitors\"], 0],\n s0,\n base,\n s1,\n ramp[0],\n s2,\n ramp[1],\n s3,\n ramp[2],\n s4,\n ramp[3],\n ];\n return [\n \"case\",\n [\n \"all\",\n [\"boolean\", [\"feature-state\", \"hover\"], false],\n [\">\", [\"coalesce\", [\"get\", \"visitors\"], 0], 0],\n ],\n hover,\n ramped,\n ];\n}\n\ninterface HoverInfo {\n name: string;\n visitors: number;\n lng: number;\n lat: number;\n}\n\ninterface CountryProperties {\n NAME_LONG: string;\n visitors: number;\n}\n\ntype CountryFeatureCollection = GeoJSON.FeatureCollection<\n GeoJSON.Geometry,\n CountryProperties\n>;\n\nfunction Legend({ theme }: { theme: Theme }) {\n const gradient = `linear-gradient(to right, ${mapConfig.colors[theme].ramp.join(\", \")})`;\n\n return (\n <div className=\"bg-card/90 absolute bottom-4 left-4 z-10 rounded-lg border px-3 py-2.5 backdrop-blur-sm\">\n <p className=\"text-foreground text-xs font-medium\">Visitors by country</p>\n <div\n className=\"mt-2 h-2 w-40 rounded-full\"\n style={{ backgroundImage: gradient }}\n suppressHydrationWarning\n />\n <div className=\"text-muted-foreground flex items-center justify-between pt-1.5 text-[10px]\">\n <span>Low</span>\n <span>High</span>\n </div>\n </div>\n );\n}\n\nexport default function Page() {\n const { resolvedTheme } = useTheme();\n const theme: Theme = resolvedTheme === \"dark\" ? \"dark\" : \"light\";\n const [hover, setHover] = useState<HoverInfo | null>(null);\n const world = useWorldData();\n\n const countries = useMemo<CountryFeatureCollection | null>(() => {\n if (!world) return null;\n return {\n type: \"FeatureCollection\",\n features: world.features.map((f) => ({\n ...f,\n properties: {\n NAME_LONG: f.properties.NAME_LONG,\n visitors: visitorsByCountry[f.properties.NAME_LONG] ?? 0,\n },\n })),\n };\n }, [world]);\n\n // Recompute paint only when the theme changes; MapGeoJSON recolors in place.\n const fillPaint = useMemo(\n () => ({\n \"fill-color\": buildFillColor(theme) as never,\n \"fill-opacity\": 0.92,\n }),\n [theme],\n );\n return (\n <div className=\"bg-card relative h-screen overflow-hidden\">\n <Map\n blank\n center={mapConfig.view.center}\n zoom={mapConfig.view.zoom}\n minZoom={mapConfig.view.minZoom}\n maxZoom={mapConfig.view.maxZoom}\n scrollZoom={false}\n dragRotate={false}\n pitchWithRotate={false}\n loading={!countries}\n >\n {countries && (\n <MapGeoJSON<CountryProperties>\n data={countries}\n promoteId=\"NAME_LONG\"\n fillPaint={fillPaint}\n interactive\n onHover={(e) => {\n const visitors = e?.feature.properties.visitors ?? 0;\n // Only countries with data are interactive.\n if (!e || visitors <= 0) {\n setHover(null);\n return;\n }\n setHover({\n name: e.feature.properties.NAME_LONG,\n visitors,\n lng: e.longitude,\n lat: e.latitude,\n });\n }}\n />\n )}\n <MapControls className=\"bottom-2\" />\n {hover && (\n <MapPopup\n longitude={hover.lng}\n latitude={hover.lat}\n offset={12}\n closeOnClick={false}\n className=\"pointer-events-none p-2\"\n >\n <p className=\"text-xs font-medium\">{hover.name}</p>\n <div className=\"flex items-center justify-between gap-4 pt-1\">\n <span className=\"text-muted-foreground flex items-center gap-1.5 text-[11px]\">\n <span\n className=\"size-2 rounded-full\"\n style={{ backgroundColor: mapConfig.colors[theme].hover }}\n />\n Visitors\n </span>\n <span className=\"text-foreground text-xs font-semibold tabular-nums\">\n {hover.visitors.toLocaleString()}\n </span>\n </div>\n </MapPopup>\n )}\n </Map>\n\n <Legend theme={theme} />\n </div>\n );\n}\n",
+ "content": "\"use client\";\n\nimport { useMemo, useState } from \"react\";\nimport { useTheme } from \"next-themes\";\n\nimport { Map, MapControls, MapGeoJSON, MapPopup } from \"@/components/ui/map\";\nimport { useWorldData } from \"@/lib/use-world-data\";\nimport { mapConfig, visitorsByCountry, type Theme } from \"./data\";\n\n// WebGL paint can't read CSS variables, so we build a concrete value→color\n// expression per theme. The hovered country is highlighted in place via the\n// `hover` feature-state, restricted to countries that actually have data.\nfunction buildFillColor(theme: Theme): unknown[] {\n const { base, ramp, hover } = mapConfig.colors[theme];\n const [s0, s1, s2, s3, s4] = mapConfig.scaleStops;\n const ramped = [\n \"interpolate\",\n [\"linear\"],\n [\"coalesce\", [\"get\", \"visitors\"], 0],\n s0,\n base,\n s1,\n ramp[0],\n s2,\n ramp[1],\n s3,\n ramp[2],\n s4,\n ramp[3],\n ];\n return [\n \"case\",\n [\n \"all\",\n [\"boolean\", [\"feature-state\", \"hover\"], false],\n [\">\", [\"coalesce\", [\"get\", \"visitors\"], 0], 0],\n ],\n hover,\n ramped,\n ];\n}\n\nconst legendGradientStyle = {\n \"--choropleth-ramp-light\": `linear-gradient(to right, ${mapConfig.colors.light.ramp.join(\", \")})`,\n \"--choropleth-ramp-dark\": `linear-gradient(to right, ${mapConfig.colors.dark.ramp.join(\", \")})`,\n} as React.CSSProperties;\n\ninterface HoverInfo {\n name: string;\n visitors: number;\n lng: number;\n lat: number;\n}\n\ninterface CountryProperties {\n NAME_LONG: string;\n visitors: number;\n}\n\ntype CountryFeatureCollection = GeoJSON.FeatureCollection<\n GeoJSON.Geometry,\n CountryProperties\n>;\n\nexport default function Page() {\n const { resolvedTheme } = useTheme();\n const theme: Theme = resolvedTheme === \"dark\" ? \"dark\" : \"light\";\n const [hover, setHover] = useState<HoverInfo | null>(null);\n const world = useWorldData();\n\n const countries = useMemo<CountryFeatureCollection | null>(() => {\n if (!world) return null;\n return {\n type: \"FeatureCollection\",\n features: world.features.map((f) => ({\n ...f,\n properties: {\n NAME_LONG: f.properties.NAME_LONG,\n visitors: visitorsByCountry[f.properties.NAME_LONG] ?? 0,\n },\n })),\n };\n }, [world]);\n\n // Recompute paint only when the theme changes; MapGeoJSON recolors in place.\n const fillPaint = useMemo(\n () => ({\n \"fill-color\": buildFillColor(theme) as never,\n \"fill-opacity\": 0.92,\n }),\n [theme],\n );\n\n return (\n <div className=\"bg-card relative h-screen overflow-hidden\">\n <Map\n blank\n center={mapConfig.view.center}\n zoom={mapConfig.view.zoom}\n minZoom={mapConfig.view.minZoom}\n maxZoom={mapConfig.view.maxZoom}\n scrollZoom={false}\n dragRotate={false}\n pitchWithRotate={false}\n loading={!countries}\n >\n {countries && (\n <MapGeoJSON<CountryProperties>\n data={countries}\n promoteId=\"NAME_LONG\"\n fillPaint={fillPaint}\n interactive\n onHover={(e) => {\n const visitors = e?.feature.properties.visitors ?? 0;\n // Only countries with data are interactive.\n if (!e || visitors <= 0) {\n setHover(null);\n return;\n }\n setHover({\n name: e.feature.properties.NAME_LONG,\n visitors,\n lng: e.longitude,\n lat: e.latitude,\n });\n }}\n />\n )}\n <MapControls className=\"bottom-2\" />\n {hover && (\n <MapPopup\n longitude={hover.lng}\n latitude={hover.lat}\n offset={12}\n closeOnClick={false}\n className=\"pointer-events-none p-2\"\n >\n <p className=\"text-xs font-medium\">{hover.name}</p>\n <div className=\"flex items-center justify-between gap-4 pt-1\">\n <span className=\"text-muted-foreground flex items-center gap-1.5 text-[11px]\">\n <span\n className=\"size-2 rounded-full\"\n style={{ backgroundColor: mapConfig.colors[theme].hover }}\n />\n Visitors\n </span>\n <span className=\"text-foreground text-xs font-semibold tabular-nums\">\n {hover.visitors.toLocaleString()}\n </span>\n </div>\n </MapPopup>\n )}\n </Map>\n\n <div\n className=\"bg-card absolute bottom-4 left-4 z-10 rounded-lg border px-3 py-2.5 backdrop-blur-sm\"\n style={legendGradientStyle}\n >\n <p className=\"text-foreground text-xs font-medium\">\n Visitors by country\n </p>\n <div className=\"mt-2 h-2 w-40 rounded-full [background-image:var(--choropleth-ramp-light)] dark:[background-image:var(--choropleth-ramp-dark)]\" />\n <div className=\"text-muted-foreground flex items-center justify-between pt-1.5 text-[10px]\">\n <span>Low</span>\n <span>High</span>\n </div>\n </div>\n </div>\n );\n}\n",
"type": "registry:page",
"target": "app/choropleth/page.tsx"
},
{
"path": "src/registry/blocks/choropleth/data.ts",
- "content": "/** Visitor counts keyed by the feature `NAME_LONG`. */\nexport const visitorsByCountry: Record<string, number> = {\n \"United States\": 100,\n Canada: 70,\n Brazil: 65,\n \"United Kingdom\": 95,\n Germany: 80,\n France: 55,\n India: 90,\n China: 45,\n Japan: 35,\n Australia: 25,\n \"South Africa\": 20,\n Egypt: 15,\n};\nexport type Theme = \"light\" | \"dark\";\n\n/** Resolved colors for the choropleth, per theme. */\ninterface ChoroplethColors {\n /** Fill for countries with no data (value 0). */\n base: string;\n /** Sequential fill ramp from low → high, mapped to `scaleStops`. */\n ramp: [string, string, string, string];\n /** Fill for the hovered country. */\n hover: string;\n}\n\n/**\n * Central map config — colors, the value→color scale, and the initial view.\n * WebGL paint can't read CSS variables, so colors are concrete values per\n * theme. The no-data fill stays muted, while the ramp uses hex equivalents of\n * the grayscale chart tokens from globals.css. Values move toward darker chart\n * colors in light mode and toward chart-1 in dark mode.\n */\nexport const mapConfig = {\n view: {\n center: [12, 28] as [number, number],\n zoom: 1.4,\n minZoom: 1,\n maxZoom: 4,\n },\n scaleStops: [0, 25, 50, 75, 100] as const,\n colors: {\n light: {\n base: \"#f0f0f0\",\n ramp: [\"#d4d4d4\", \"#a3a3a3\", \"#737373\", \"#404040\"],\n hover: \"#0a0a0a\",\n },\n dark: {\n base: \"#2a2a2a\",\n ramp: [\"#404040\", \"#737373\", \"#a3a3a3\", \"#d4d4d4\"],\n hover: \"#ffffff\",\n },\n } satisfies Record<Theme, ChoroplethColors>,\n};\n",
+ "content": "/** Visitor counts keyed by the feature `NAME_LONG`. */\nexport const visitorsByCountry: Record<string, number> = {\n \"United States\": 100,\n Canada: 70,\n Brazil: 65,\n \"United Kingdom\": 95,\n Germany: 80,\n France: 55,\n India: 90,\n China: 45,\n Japan: 35,\n Australia: 25,\n \"South Africa\": 20,\n Egypt: 15,\n};\nexport type Theme = \"light\" | \"dark\";\n\n/** Resolved colors for the choropleth, per theme. */\ninterface ChoroplethColors {\n /** Fill for countries with no data (value 0). */\n base: string;\n /** Sequential fill ramp from low → high, mapped to `scaleStops`. */\n ramp: [string, string, string, string];\n /** Fill for the hovered country. */\n hover: string;\n}\n\n/**\n * Central map config: colors, the value→color scale, and the initial view.\n * Colors are concrete hex values (not CSS variables) since WebGL paint can't\n * read them. Update `colors.light`/`colors.dark` below for custom colors.\n */\nexport const mapConfig = {\n view: {\n center: [12, 28] as [number, number],\n zoom: 1.4,\n minZoom: 1,\n maxZoom: 4,\n },\n scaleStops: [0, 25, 50, 75, 100] as const,\n colors: {\n light: {\n base: \"#f0f0f0\",\n ramp: [\"#d4d4d4\", \"#a3a3a3\", \"#737373\", \"#404040\"],\n hover: \"#0a0a0a\",\n },\n dark: {\n base: \"#2a2a2a\",\n ramp: [\"#404040\", \"#737373\", \"#a3a3a3\", \"#d4d4d4\"],\n hover: \"#ffffff\",\n },\n } satisfies Record<Theme, ChoroplethColors>,\n};\n",
"type": "registry:component",
"target": "app/choropleth/data.ts"
},
diff --git a/public/r/logistics-network.json b/public/r/logistics-network.json
index d9a65b4..3835ccb 100644
--- a/public/r/logistics-network.json
+++ b/public/r/logistics-network.json
@@ -26,13 +26,13 @@
},
{
"path": "src/registry/blocks/logistics-network/components/filter-sidebar.tsx",
- "content": "\"use client\";\n\nimport {\n Sidebar,\n SidebarContent,\n SidebarFooter,\n SidebarGroup,\n SidebarGroupContent,\n SidebarGroupLabel,\n SidebarHeader,\n SidebarMenu,\n SidebarMenuBadge,\n SidebarMenuButton,\n SidebarMenuItem,\n SidebarSeparator,\n} from \"@/components/ui/sidebar\";\nimport { Network, Plane, Truck } from \"lucide-react\";\nimport { regionLabels, statusConfig, type Hub, type Route } from \"../data\";\n\nconst regionIcons: Record<Hub[\"region\"], string> = {\n west: \"W\",\n midwest: \"MW\",\n south: \"S\",\n northeast: \"NE\",\n};\n\ninterface FilterSidebarProps {\n hubs: Hub[];\n routes: Route[];\n}\n\nexport function FilterSidebar({ hubs, routes }: FilterSidebarProps) {\n const totalShipments = routes.reduce((s, r) => s + r.shipments, 0);\n const activeCount = routes.filter((r) => r.status === \"active\").length;\n const delayedCount = routes.filter((r) => r.status === \"delayed\").length;\n const airRouteCount = routes.filter((r) => r.mode === \"air\").length;\n const groundRouteCount = routes.filter((r) => r.mode === \"ground\").length;\n\n return (\n <Sidebar collapsible=\"offcanvas\">\n <SidebarHeader className=\"p-4\">\n <div className=\"flex items-center gap-2\">\n <div className=\"bg-sidebar-primary text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg\">\n <Network className=\"size-4\" />\n </div>\n <div className=\"flex flex-col gap-0.5 leading-none\">\n <span className=\"text-sm font-medium\">Logistics Network</span>\n <span className=\"text-muted-foreground text-xs\">\n Domestic Routes\n </span>\n </div>\n </div>\n <div className=\"mt-3 grid grid-cols-3 gap-2\">\n <div className=\"bg-background rounded-md border px-2.5 py-2 text-center\">\n <p className=\"text-lg leading-none font-bold tabular-nums\">\n {hubs.length}\n </p>\n <p className=\"text-muted-foreground mt-1 text-[10px]\">Hubs</p>\n </div>\n <div className=\"bg-background rounded-md border px-2.5 py-2 text-center\">\n <p className=\"text-lg leading-none font-bold tabular-nums\">\n {activeCount}\n </p>\n <p className=\"text-muted-foreground mt-1 text-[10px]\">Active</p>\n </div>\n <div className=\"bg-background rounded-md border px-2.5 py-2 text-center\">\n <p className=\"text-lg leading-none font-bold tabular-nums\">\n {delayedCount}\n </p>\n <p className=\"text-muted-foreground mt-1 text-[10px]\">Delayed</p>\n </div>\n </div>\n </SidebarHeader>\n\n <SidebarSeparator className=\"mx-0\" />\n\n <SidebarContent>\n <SidebarGroup>\n <SidebarGroupLabel>Transport Mode</SidebarGroupLabel>\n <SidebarGroupContent>\n <SidebarMenu>\n <SidebarMenuItem>\n <SidebarMenuButton\n tooltip=\"Air\"\n className=\"pointer-events-none\"\n >\n <Plane className=\"size-4\" />\n <span>Air Freight</span>\n </SidebarMenuButton>\n <SidebarMenuBadge>{airRouteCount}</SidebarMenuBadge>\n </SidebarMenuItem>\n <SidebarMenuItem>\n <SidebarMenuButton\n tooltip=\"Ground\"\n className=\"pointer-events-none\"\n >\n <Truck className=\"size-4\" />\n <span>Ground</span>\n </SidebarMenuButton>\n <SidebarMenuBadge>{groundRouteCount}</SidebarMenuBadge>\n </SidebarMenuItem>\n </SidebarMenu>\n </SidebarGroupContent>\n </SidebarGroup>\n\n <SidebarGroup>\n <SidebarGroupLabel>Status</SidebarGroupLabel>\n <SidebarGroupContent>\n <SidebarMenu>\n <SidebarMenuItem>\n <SidebarMenuButton\n tooltip={statusConfig.active.label}\n className=\"pointer-events-none\"\n >\n <span className=\"flex size-4 items-center justify-center\">\n <span\n className=\"size-2 rounded-full\"\n style={{ backgroundColor: statusConfig.active.color }}\n />\n </span>\n <span>{statusConfig.active.label}</span>\n </SidebarMenuButton>\n <SidebarMenuBadge>{activeCount}</SidebarMenuBadge>\n </SidebarMenuItem>\n <SidebarMenuItem>\n <SidebarMenuButton\n tooltip={statusConfig.delayed.label}\n className=\"pointer-events-none\"\n >\n <span className=\"flex size-4 items-center justify-center\">\n <span\n className=\"size-2 rounded-full\"\n style={{ backgroundColor: statusConfig.delayed.color }}\n />\n </span>\n <span>{statusConfig.delayed.label}</span>\n </SidebarMenuButton>\n <SidebarMenuBadge>{delayedCount}</SidebarMenuBadge>\n </SidebarMenuItem>\n </SidebarMenu>\n </SidebarGroupContent>\n </SidebarGroup>\n\n <SidebarGroup>\n <SidebarGroupLabel>Region</SidebarGroupLabel>\n <SidebarGroupContent>\n <SidebarMenu>\n {([\"west\", \"midwest\", \"south\", \"northeast\"] as const).map(\n (region) => {\n const hubsInRegion = hubs.filter((h) => h.region === region);\n return (\n <SidebarMenuItem key={region}>\n <SidebarMenuButton\n tooltip={regionLabels[region]}\n className=\"pointer-events-none\"\n >\n <span className=\"bg-muted text-muted-foreground flex size-4 items-center justify-center rounded text-[9px] font-bold\">\n {regionIcons[region]}\n </span>\n <span>{regionLabels[region]}</span>\n </SidebarMenuButton>\n <SidebarMenuBadge>{hubsInRegion.length}</SidebarMenuBadge>\n </SidebarMenuItem>\n );\n },\n )}\n </SidebarMenu>\n </SidebarGroupContent>\n </SidebarGroup>\n </SidebarContent>\n\n <SidebarFooter className=\"p-4 pt-0\">\n <p className=\"text-muted-foreground mb-2 text-[11px] font-medium tracking-wider uppercase\">\n Summary\n </p>\n <div className=\"bg-background space-y-1.5 rounded-md border px-3 py-2 text-xs\">\n <div className=\"flex justify-between\">\n <span className=\"text-muted-foreground\">Shipments</span>\n <span className=\"text-primary font-medium tabular-nums\">\n {totalShipments.toLocaleString()}\n </span>\n </div>\n <div className=\"flex justify-between\">\n <span className=\"text-muted-foreground\">Routes</span>\n <span className=\"text-primary font-medium tabular-nums\">\n {routes.length}\n </span>\n </div>\n </div>\n </SidebarFooter>\n </Sidebar>\n );\n}\n",
+ "content": "\"use client\";\n\nimport {\n Sidebar,\n SidebarContent,\n SidebarFooter,\n SidebarGroup,\n SidebarGroupContent,\n SidebarGroupLabel,\n SidebarHeader,\n SidebarMenu,\n SidebarMenuBadge,\n SidebarMenuButton,\n SidebarMenuItem,\n SidebarSeparator,\n} from \"@/components/ui/sidebar\";\nimport { Network, Plane, Truck } from \"lucide-react\";\nimport { regionLabels, statusConfig, type Hub, type Route } from \"../data\";\n\nconst regionIcons: Record<Hub[\"region\"], string> = {\n west: \"W\",\n midwest: \"MW\",\n south: \"S\",\n northeast: \"NE\",\n};\n\ninterface FilterSidebarProps {\n hubs: Hub[];\n routes: Route[];\n}\n\nexport function FilterSidebar({ hubs, routes }: FilterSidebarProps) {\n const totalShipments = routes.reduce((s, r) => s + r.shipments, 0);\n const activeCount = routes.filter((r) => r.status === \"active\").length;\n const delayedCount = routes.filter((r) => r.status === \"delayed\").length;\n const airRouteCount = routes.filter((r) => r.mode === \"air\").length;\n const groundRouteCount = routes.filter((r) => r.mode === \"ground\").length;\n\n return (\n <Sidebar collapsible=\"offcanvas\">\n <SidebarHeader className=\"p-4\">\n <div className=\"flex items-center gap-2\">\n <div className=\"bg-sidebar-primary text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg\">\n <Network className=\"size-4\" />\n </div>\n <div className=\"flex flex-col gap-0.5 leading-none\">\n <span className=\"text-sm font-medium\">Logistics Network</span>\n <span className=\"text-muted-foreground text-xs\">\n Domestic Routes\n </span>\n </div>\n </div>\n <div className=\"mt-3 grid grid-cols-3 gap-2\">\n <div className=\"bg-background rounded-md border px-2.5 py-2 text-center\">\n <p className=\"text-lg leading-none font-bold tabular-nums\">\n {hubs.length}\n </p>\n <p className=\"text-muted-foreground mt-1 text-[10px]\">Hubs</p>\n </div>\n <div className=\"bg-background rounded-md border px-2.5 py-2 text-center\">\n <p className=\"text-lg leading-none font-bold tabular-nums\">\n {activeCount}\n </p>\n <p className=\"text-muted-foreground mt-1 text-[10px]\">Active</p>\n </div>\n <div className=\"bg-background rounded-md border px-2.5 py-2 text-center\">\n <p className=\"text-lg leading-none font-bold tabular-nums\">\n {delayedCount}\n </p>\n <p className=\"text-muted-foreground mt-1 text-[10px]\">Delayed</p>\n </div>\n </div>\n </SidebarHeader>\n\n <SidebarSeparator className=\"mx-0\" />\n\n <SidebarContent>\n <SidebarGroup>\n <SidebarGroupLabel>Transport Mode</SidebarGroupLabel>\n <SidebarGroupContent>\n <SidebarMenu>\n <SidebarMenuItem>\n <SidebarMenuButton\n tooltip=\"Air\"\n className=\"pointer-events-none\"\n >\n <Plane className=\"size-4\" />\n <span>Air Freight</span>\n </SidebarMenuButton>\n <SidebarMenuBadge>{airRouteCount}</SidebarMenuBadge>\n </SidebarMenuItem>\n <SidebarMenuItem>\n <SidebarMenuButton\n tooltip=\"Ground\"\n className=\"pointer-events-none\"\n >\n <Truck className=\"size-4\" />\n <span>Ground</span>\n </SidebarMenuButton>\n <SidebarMenuBadge>{groundRouteCount}</SidebarMenuBadge>\n </SidebarMenuItem>\n </SidebarMenu>\n </SidebarGroupContent>\n </SidebarGroup>\n\n <SidebarGroup>\n <SidebarGroupLabel>Status</SidebarGroupLabel>\n <SidebarGroupContent>\n <SidebarMenu>\n <SidebarMenuItem>\n <SidebarMenuButton\n tooltip={statusConfig.active.label}\n className=\"pointer-events-none\"\n >\n <span className=\"flex size-4 items-center justify-center\">\n <span\n className=\"size-2 rounded-full\"\n style={{ backgroundColor: statusConfig.active.color }}\n />\n </span>\n <span>{statusConfig.active.label}</span>\n </SidebarMenuButton>\n <SidebarMenuBadge>{activeCount}</SidebarMenuBadge>\n </SidebarMenuItem>\n <SidebarMenuItem>\n <SidebarMenuButton\n tooltip={statusConfig.delayed.label}\n className=\"pointer-events-none\"\n >\n <span className=\"flex size-4 items-center justify-center\">\n <span\n className=\"size-2 rounded-full\"\n style={{ backgroundColor: statusConfig.delayed.color }}\n />\n </span>\n <span>{statusConfig.delayed.label}</span>\n </SidebarMenuButton>\n <SidebarMenuBadge>{delayedCount}</SidebarMenuBadge>\n </SidebarMenuItem>\n </SidebarMenu>\n </SidebarGroupContent>\n </SidebarGroup>\n\n <SidebarGroup>\n <SidebarGroupLabel>Region</SidebarGroupLabel>\n <SidebarGroupContent>\n <SidebarMenu>\n {([\"west\", \"midwest\", \"south\", \"northeast\"] as const).map(\n (region) => {\n const hubsInRegion = hubs.filter((h) => h.region === region);\n return (\n <SidebarMenuItem key={region}>\n <SidebarMenuButton\n tooltip={regionLabels[region]}\n className=\"pointer-events-none\"\n >\n <span className=\"bg-muted text-muted-foreground flex size-4 items-center justify-center rounded text-[9px] font-bold\">\n {regionIcons[region]}\n </span>\n <span>{regionLabels[region]}</span>\n </SidebarMenuButton>\n <SidebarMenuBadge>{hubsInRegion.length}</SidebarMenuBadge>\n </SidebarMenuItem>\n );\n },\n )}\n </SidebarMenu>\n </SidebarGroupContent>\n </SidebarGroup>\n </SidebarContent>\n\n <SidebarFooter className=\"p-4 pt-0\">\n <p className=\"text-muted-foreground mb-2 text-[11px] font-medium tracking-wider uppercase\">\n Summary\n </p>\n <div className=\"bg-background space-y-1.5 rounded-md border px-3 py-2 text-xs\">\n <div className=\"flex justify-between\">\n <span className=\"text-muted-foreground\">Shipments</span>\n <span className=\"font-medium tabular-nums\">\n {totalShipments.toLocaleString()}\n </span>\n </div>\n <div className=\"flex justify-between\">\n <span className=\"text-muted-foreground\">Routes</span>\n <span className=\"font-medium tabular-nums\">{routes.length}</span>\n </div>\n </div>\n </SidebarFooter>\n </Sidebar>\n );\n}\n",
"type": "registry:component",
"target": "app/logistics/components/filter-sidebar.tsx"
},
{
"path": "src/registry/blocks/logistics-network/components/network-map.tsx",
- "content": "\"use client\";\n\nimport { useMemo } from \"react\";\nimport {\n Map,\n MapArc,\n MapControls,\n MapMarker,\n MarkerContent,\n MarkerTooltip,\n} from \"@/components/ui/map\";\nimport { SidebarTrigger } from \"@/components/ui/sidebar\";\nimport {\n modeConfig,\n regionLabels,\n statusConfig,\n type Hub,\n type Route,\n} from \"../data\";\nimport { Separator } from \"@/components/ui/separator\";\n\ninterface NetworkMapProps {\n hubs: Hub[];\n routes: Route[];\n}\n\nfunction MapControlsCard() {\n return (\n <div className=\"border-border/40 bg-background/70 absolute top-4 left-4 z-20 flex items-center gap-3 rounded-lg border px-2.5 py-1.5 backdrop-blur-sm\">\n <SidebarTrigger />\n <Separator orientation=\"vertical\" className=\"h-4!\" />\n <div className=\"flex items-center gap-3 text-xs\">\n <div className=\"flex items-center gap-1.5\">\n <span\n className=\"h-0.5 w-4 shrink-0 rounded-full\"\n style={{ backgroundColor: modeConfig.air.color }}\n />\n <span>{modeConfig.air.label}</span>\n </div>\n <div className=\"flex items-center gap-1.5\">\n <span\n className=\"h-0.5 w-4 shrink-0 rounded-full\"\n style={{ backgroundColor: modeConfig.ground.color }}\n />\n <span>{modeConfig.ground.label}</span>\n </div>\n <div className=\"flex items-center gap-1.5\">\n <span\n className=\"h-0.5 w-4 shrink-0 rounded-full\"\n style={{ backgroundColor: statusConfig.delayed.color }}\n />\n <span>{statusConfig.delayed.label}</span>\n </div>\n <div className=\"bg-border h-4 w-px\" />\n <div className=\"flex items-center gap-1.5\">\n <div className=\"size-2.5 shrink-0 rounded-full border border-white bg-blue-500 shadow-sm\" />\n <span>Hub</span>\n </div>\n </div>\n </div>\n );\n}\n\nexport function NetworkMap({ hubs, routes }: NetworkMapProps) {\n const arcs = useMemo(() => {\n const hubById: Record<string, Hub> = Object.fromEntries(\n hubs.map((hub) => [hub.id, hub]),\n );\n return routes.flatMap((route) => {\n const fromHub = hubById[route.from];\n const toHub = hubById[route.to];\n if (!fromHub || !toHub) return [];\n return [\n {\n id: `${route.from}-${route.to}`,\n from: [fromHub.lng, fromHub.lat] as [number, number],\n to: [toHub.lng, toHub.lat] as [number, number],\n color:\n route.status === \"delayed\"\n ? statusConfig.delayed.color\n : modeConfig[route.mode].color,\n },\n ];\n });\n }, [hubs, routes]);\n\n return (\n <div className=\"relative h-full\">\n <MapControlsCard />\n\n <Map center={[-98, 39]} zoom={4} projection={{ type: \"globe\" }}>\n <MapControls />\n <MapArc\n data={arcs}\n curvature={0.3}\n paint={{\n \"line-color\": [\"get\", \"color\"],\n \"line-width\": 2,\n \"line-opacity\": 0.65,\n }}\n interactive={false}\n />\n\n {hubs.map((hub) => (\n <MapMarker key={hub.id} longitude={hub.lng} latitude={hub.lat}>\n <MarkerContent>\n <div className=\"size-3 rounded-full border-2 border-white bg-blue-500 shadow-md\" />\n </MarkerContent>\n <MarkerTooltip\n offset={16}\n className=\"bg-background text-foreground border px-2.5 py-1.5\"\n >\n <p className=\"font-medium\">{hub.city}</p>\n <p className=\"text-muted-foreground mt-1\">\n {hub.shipments.toLocaleString()} shipments\n <span className=\"mx-1\">•</span>\n {regionLabels[hub.region]}\n </p>\n </MarkerTooltip>\n </MapMarker>\n ))}\n </Map>\n </div>\n );\n}\n",
+ "content": "\"use client\";\n\nimport { useMemo } from \"react\";\nimport {\n Map,\n MapArc,\n MapControls,\n MapMarker,\n MarkerContent,\n MarkerTooltip,\n} from \"@/components/ui/map\";\nimport { SidebarTrigger } from \"@/components/ui/sidebar\";\nimport {\n modeConfig,\n regionLabels,\n statusConfig,\n type Hub,\n type Route,\n} from \"../data\";\nimport { Separator } from \"@/components/ui/separator\";\n\ninterface NetworkMapProps {\n hubs: Hub[];\n routes: Route[];\n}\n\nfunction MapControlsCard() {\n return (\n <div className=\"border-border/40 bg-background/70 absolute top-4 left-4 z-20 flex items-center gap-3 rounded-lg border px-2.5 py-1.5 backdrop-blur-sm\">\n <SidebarTrigger />\n <Separator orientation=\"vertical\" className=\"h-4!\" />\n <div className=\"flex items-center gap-3 text-xs\">\n <div className=\"flex items-center gap-1.5\">\n <span\n className=\"h-0.5 w-4 shrink-0 rounded-full\"\n style={{ backgroundColor: modeConfig.air.color }}\n />\n <span>{modeConfig.air.label}</span>\n </div>\n <div className=\"flex items-center gap-1.5\">\n <span\n className=\"h-0.5 w-4 shrink-0 rounded-full\"\n style={{ backgroundColor: modeConfig.ground.color }}\n />\n <span>{modeConfig.ground.label}</span>\n </div>\n <div className=\"flex items-center gap-1.5\">\n <span\n className=\"h-0.5 w-4 shrink-0 rounded-full\"\n style={{ backgroundColor: statusConfig.delayed.color }}\n />\n <span>{statusConfig.delayed.label}</span>\n </div>\n <Separator orientation=\"vertical\" className=\"h-4!\" />\n <div className=\"flex items-center gap-1.5\">\n <div className=\"size-2.5 shrink-0 rounded-full border border-white bg-blue-500 shadow-sm\" />\n <span>Hub</span>\n </div>\n </div>\n </div>\n );\n}\n\nexport function NetworkMap({ hubs, routes }: NetworkMapProps) {\n const arcs = useMemo(() => {\n const hubById: Record<string, Hub> = Object.fromEntries(\n hubs.map((hub) => [hub.id, hub]),\n );\n return routes.flatMap((route) => {\n const fromHub = hubById[route.from];\n const toHub = hubById[route.to];\n if (!fromHub || !toHub) return [];\n return [\n {\n id: `${route.from}-${route.to}`,\n from: [fromHub.lng, fromHub.lat] as [number, number],\n to: [toHub.lng, toHub.lat] as [number, number],\n color:\n route.status === \"delayed\"\n ? statusConfig.delayed.color\n : modeConfig[route.mode].color,\n },\n ];\n });\n }, [hubs, routes]);\n\n return (\n <div className=\"relative h-full\">\n <MapControlsCard />\n\n <Map center={[-98, 39]} zoom={4} projection={{ type: \"globe\" }}>\n <MapControls />\n <MapArc\n data={arcs}\n curvature={0.3}\n paint={{\n \"line-color\": [\"get\", \"color\"],\n \"line-width\": 2,\n \"line-opacity\": 0.65,\n }}\n interactive={false}\n />\n\n {hubs.map((hub) => (\n <MapMarker key={hub.id} longitude={hub.lng} latitude={hub.lat}>\n <MarkerContent>\n <div className=\"size-3 rounded-full border-2 border-white bg-blue-500 shadow-md\" />\n </MarkerContent>\n <MarkerTooltip\n offset={16}\n className=\"bg-background text-foreground border px-2.5 py-1.5\"\n >\n <p className=\"font-medium\">{hub.city}</p>\n <p className=\"text-muted-foreground mt-1\">\n {hub.shipments.toLocaleString()} shipments\n <span className=\"mx-1\">•</span>\n {regionLabels[hub.region]}\n </p>\n </MarkerTooltip>\n </MapMarker>\n ))}\n </Map>\n </div>\n );\n}\n",
"type": "registry:component",
"target": "app/logistics/components/network-map.tsx"
}
diff --git a/src/app/(main)/docs/_components/docs-toc.tsx b/src/app/(main)/docs/_components/docs-toc.tsx
index d1a5021..904ac26 100644
--- a/src/app/(main)/docs/_components/docs-toc.tsx
+++ b/src/app/(main)/docs/_components/docs-toc.tsx
@@ -58,11 +58,11 @@ export function DocsToc({ items, className }: DocsTocProps) {
return (
<nav aria-label="On this page" className={cn("flex flex-col", className)}>
- <p className="text-sidebar-foreground/70 mb-3 text-xs font-medium">
+ <p className="text-muted-foreground/70 mb-3 text-[11px] font-semibold tracking-wide uppercase">
On This Page
</p>
- <div className="before:bg-border relative flex flex-col gap-0.5 before:absolute before:top-1 before:bottom-1 before:left-0 before:w-0.5 before:rounded-full">
+ <div className="flex flex-col gap-1.5">
{items.map((item) => {
const isActive = item.slug === activeHeading;
return (
@@ -70,9 +70,9 @@ export function DocsToc({ items, className }: DocsTocProps) {
key={item.slug}
href={`#${item.slug}`}
className={cn(
- "relative py-1 pl-3 text-sm no-underline transition-colors",
+ "py-0.5 text-sm no-underline transition-colors",
isActive
- ? "text-foreground before:bg-foreground before:absolute before:top-1 before:bottom-1 before:left-0 before:w-0.5 before:rounded-full"
+ ? "text-foreground font-medium"
: "text-muted-foreground hover:text-foreground",
)}
>
diff --git a/src/app/(main)/docs/_components/docs.tsx b/src/app/(main)/docs/_components/docs.tsx
index d97eb1c..ffe2d6f 100644
--- a/src/app/(main)/docs/_components/docs.tsx
+++ b/src/app/(main)/docs/_components/docs.tsx
@@ -122,7 +122,7 @@ export function DocsSection({ title, children }: DocsSectionProps) {
{title}
</h2>
)}
- <div className="text-primary [&_strong]:text-foreground [&_em]:text-muted-foreground space-y-4 text-base leading-7 [&_strong]:font-medium [&>ol]:list-decimal [&>ol]:space-y-2 [&>ol]:pl-5 [&>ol>li]:leading-7 [&>p]:leading-7 [&>ul]:list-disc [&>ul]:space-y-2 [&>ul]:pl-5 [&>ul>li]:leading-7">
+ <div className="[&_em]:text-muted-foreground space-y-4 text-base leading-7 [&_strong]:font-medium [&>ol]:list-decimal [&>ol]:space-y-2 [&>ol]:pl-5 [&>ol>li]:leading-7 [&>p]:leading-7 [&>ul]:list-disc [&>ul]:space-y-2 [&>ul]:pl-5 [&>ul>li]:leading-7">
{children}
</div>
</section>
diff --git a/src/app/(main)/docs/page.tsx b/src/app/(main)/docs/page.tsx
index de06598..841e132 100644
--- a/src/app/(main)/docs/page.tsx
+++ b/src/app/(main)/docs/page.tsx
@@ -99,21 +99,20 @@ export default function IntroductionPage() {
</p>
<ul>
<li>
- <strong className="text-foreground">Own Your Code:</strong> Copy the
- components into your project and customize everything.
+ <strong>Own Your Code:</strong> Copy the components into your
+ project and customize everything.
</li>
<li>
- <strong className="text-foreground">Start Fast:</strong> Run one
- command and render your first map with production-ready defaults.
+ <strong>Start Fast:</strong> Run one command and render your first
+ map with production-ready defaults.
</li>
<li>
- <strong className="text-foreground">Scale Safely:</strong> Build on
- top of MapLibre directly, then drop to raw APIs when needed.
+ <strong>Scale Safely:</strong> Build on top of MapLibre directly,
+ then drop to raw APIs when needed.
</li>
<li>
- <strong className="text-foreground">Design-System Friendly:</strong>{" "}
- Styled with Tailwind and made to fit naturally with shadcn/ui
- patterns.
+ <strong>Design-System Friendly:</strong> Styled with Tailwind and
+ made to fit naturally with shadcn/ui patterns.
</li>
</ul>
</DocsSection>
diff --git a/src/registry/blocks/choropleth/data.ts b/src/registry/blocks/choropleth/data.ts
index 9da86fd..2056fa2 100644
--- a/src/registry/blocks/choropleth/data.ts
+++ b/src/registry/blocks/choropleth/data.ts
@@ -26,11 +26,9 @@ interface ChoroplethColors {
}
/**
- * Central map config — colors, the value→color scale, and the initial view.
- * WebGL paint can't read CSS variables, so colors are concrete values per
- * theme. The no-data fill stays muted, while the ramp uses hex equivalents of
- * the grayscale chart tokens from globals.css. Values move toward darker chart
- * colors in light mode and toward chart-1 in dark mode.
+ * Central map config: colors, the value→color scale, and the initial view.
+ * Colors are concrete hex values (not CSS variables) since WebGL paint can't
+ * read them. Update `colors.light`/`colors.dark` below for custom colors.
*/
export const mapConfig = {
view: {
diff --git a/src/registry/blocks/choropleth/page.tsx b/src/registry/blocks/choropleth/page.tsx
index 0b7353b..7d625ef 100644
--- a/src/registry/blocks/choropleth/page.tsx
+++ b/src/registry/blocks/choropleth/page.tsx
@@ -40,6 +40,11 @@ function buildFillColor(theme: Theme): unknown[] {
];
}
+const legendGradientStyle = {
+ "--choropleth-ramp-light": `linear-gradient(to right, ${mapConfig.colors.light.ramp.join(", ")})`,
+ "--choropleth-ramp-dark": `linear-gradient(to right, ${mapConfig.colors.dark.ramp.join(", ")})`,
+} as React.CSSProperties;
+
interface HoverInfo {
name: string;
visitors: number;
@@ -57,25 +62,6 @@ type CountryFeatureCollection = GeoJSON.FeatureCollection<
CountryProperties
>;
-function Legend({ theme }: { theme: Theme }) {
- const gradient = `linear-gradient(to right, ${mapConfig.colors[theme].ramp.join(", ")})`;
-
- return (
- <div className="bg-card/90 absolute bottom-4 left-4 z-10 rounded-lg border px-3 py-2.5 backdrop-blur-sm">
- <p className="text-foreground text-xs font-medium">Visitors by country</p>
- <div
- className="mt-2 h-2 w-40 rounded-full"
- style={{ backgroundImage: gradient }}
- suppressHydrationWarning
- />
- <div className="text-muted-foreground flex items-center justify-between pt-1.5 text-[10px]">
- <span>Low</span>
- <span>High</span>
- </div>
- </div>
- );
-}
-
export default function Page() {
const { resolvedTheme } = useTheme();
const theme: Theme = resolvedTheme === "dark" ? "dark" : "light";
@@ -104,6 +90,7 @@ export default function Page() {
}),
[theme],
);
+
return (
<div className="bg-card relative h-screen overflow-hidden">
<Map
@@ -165,7 +152,19 @@ export default function Page() {
)}
</Map>
- <Legend theme={theme} />
+ <div
+ className="bg-card absolute bottom-4 left-4 z-10 rounded-lg border px-3 py-2.5 backdrop-blur-sm"
+ style={legendGradientStyle}
+ >
+ <p className="text-foreground text-xs font-medium">
+ Visitors by country
+ </p>
+ <div className="mt-2 h-2 w-40 rounded-full [background-image:var(--choropleth-ramp-light)] dark:[background-image:var(--choropleth-ramp-dark)]" />
+ <div className="text-muted-foreground flex items-center justify-between pt-1.5 text-[10px]">
+ <span>Low</span>
+ <span>High</span>
+ </div>
+ </div>
</div>
);
}
diff --git a/src/registry/blocks/logistics-network/components/filter-sidebar.tsx b/src/registry/blocks/logistics-network/components/filter-sidebar.tsx
index f25cb55..867aa29 100644
--- a/src/registry/blocks/logistics-network/components/filter-sidebar.tsx
+++ b/src/registry/blocks/logistics-network/components/filter-sidebar.tsx
@@ -176,15 +176,13 @@ export function FilterSidebar({ hubs, routes }: FilterSidebarProps) {
<div className="bg-background space-y-1.5 rounded-md border px-3 py-2 text-xs">
<div className="flex justify-between">
<span className="text-muted-foreground">Shipments</span>
- <span className="text-primary font-medium tabular-nums">
+ <span className="font-medium tabular-nums">
{totalShipments.toLocaleString()}
</span>
</div>
<div className="flex justify-between">
<span className="text-muted-foreground">Routes</span>
- <span className="text-primary font-medium tabular-nums">
- {routes.length}
- </span>
+ <span className="font-medium tabular-nums">{routes.length}</span>
</div>
</div>
</SidebarFooter>
diff --git a/src/registry/blocks/logistics-network/components/network-map.tsx b/src/registry/blocks/logistics-network/components/network-map.tsx
index f057b73..344adde 100644
--- a/src/registry/blocks/logistics-network/components/network-map.tsx
+++ b/src/registry/blocks/logistics-network/components/network-map.tsx
@@ -51,7 +51,7 @@ function MapControlsCard() {
/>
<span>{statusConfig.delayed.label}</span>
</div>
- <div className="bg-border h-4 w-px" />
+ <Separator orientation="vertical" className="h-4!" />
<div className="flex items-center gap-1.5">
<div className="size-2.5 shrink-0 rounded-full border border-white bg-blue-500 shadow-sm" />
<span>Hub</span>