Skip to content

armgit / mapcn

Public Imported from GitHub
0

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

TypeScript

feat: add blocks showcase and restructure app

Anmoldeep Singhd7d8dbe3ab52
diff --git a/.prettierrc b/.prettierrc
new file mode 100644
index 0000000..d0b3f16
--- /dev/null
+++ b/.prettierrc
@@ -0,0 +1,3 @@
+{
+ "plugins": ["prettier-plugin-tailwindcss"]
+}
\ No newline at end of file
diff --git a/README.md b/README.md
index 2aac916..2145c4b 100644
--- a/README.md
+++ b/README.md
@@ -23,7 +23,6 @@
<img src="public/banner.png" alt="mapcn banner" />
</p>
-
## Features
- 🎨 **Theme-aware** — Automatically adapts to light/dark mode
diff --git a/components.json b/components.json
index edcaef2..b4d9660 100644
--- a/components.json
+++ b/components.json
@@ -5,7 +5,7 @@
"tsx": true,
"tailwind": {
"config": "",
- "css": "src/app/globals.css",
+ "css": "src/styles/globals.css",
"baseColor": "neutral",
"cssVariables": true,
"prefix": ""
diff --git a/package-lock.json b/package-lock.json
index 04796a8..ef754fa 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -19,6 +19,7 @@
"radix-ui": "^1.4.3",
"react": "19.2.3",
"react-dom": "19.2.3",
+ "recharts": "^2.15.4",
"shiki": "^3.20.0",
"tailwind-merge": "^2.6.0"
},
@@ -29,6 +30,7 @@
"@types/react-dom": "^19",
"eslint": "^9",
"eslint-config-next": "16.1.1",
+ "prettier-plugin-tailwindcss": "^0.7.2",
"shadcn": "^3.6.2",
"tailwindcss": "^4",
"tw-animate-css": "^1.4.0",
@@ -455,6 +457,15 @@
"@babel/core": "^7.0.0-0"
}
},
+ "node_modules/@babel/runtime": {
+ "version": "7.28.6",
+ "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.28.6.tgz",
+ "integrity": "sha512-05WQkdpL9COIMz4LjTxGpPNCdlpyimKppYNoJ5Di5EUObifl8t4tuLuUBBZEpoLYOmfvIWrsp9fCl0HoPRVTdA==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=6.9.0"
+ }
+ },
"node_modules/@babel/template": {
"version": "7.27.2",
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.27.2.tgz",
@@ -5566,6 +5577,69 @@
"tslib": "^2.4.0"
}
},
+ "node_modules/@types/d3-array": {
+ "version": "3.2.2",
+ "resolved": "https://registry.npmjs.org/@types/d3-array/-/d3-array-3.2.2.tgz",
+ "integrity": "sha512-hOLWVbm7uRza0BYXpIIW5pxfrKe0W+D5lrFiAEYR+pb6w3N2SwSMaJbXdUfSEv+dT4MfHBLtn5js0LAWaO6otw==",
+ "license": "MIT"
+ },
+ "node_modules/@types/d3-color": {
+ "version": "3.1.3",
+ "resolved": "https://registry.npmjs.org/@types/d3-color/-/d3-color-3.1.3.tgz",
+ "integrity": "sha512-iO90scth9WAbmgv7ogoq57O9YpKmFBbmoEoCHDB2xMBY0+/KVrqAaCDyCE16dUspeOvIxFFRI+0sEtqDqy2b4A==",
+ "license": "MIT"
+ },
+ "node_modules/@types/d3-ease": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/@types/d3-ease/-/d3-ease-3.0.2.tgz",
+ "integrity": "sha512-NcV1JjO5oDzoK26oMzbILE6HW7uVXOHLQvHshBUW4UMdZGfiY6v5BeQwh9a9tCzv+CeefZQHJt5SRgK154RtiA==",
+ "license": "MIT"
+ },
+ "node_modules/@types/d3-interpolate": {
+ "version": "3.0.4",
+ "resolved": "https://registry.npmjs.org/@types/d3-interpolate/-/d3-interpolate-3.0.4.tgz",
+ "integrity": "sha512-mgLPETlrpVV1YRJIglr4Ez47g7Yxjl1lj7YKsiMCb27VJH9W8NVM6Bb9d8kkpG/uAQS5AmbA48q2IAolKKo1MA==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/d3-color": "*"
+ }
+ },
+ "node_modules/@types/d3-path": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/@types/d3-path/-/d3-path-3.1.1.tgz",
+ "integrity": "sha512-VMZBYyQvbGmWyWVea0EHs/BwLgxc+MKi1zLDCONksozI4YJMcTt8ZEuIR4Sb1MMTE8MMW49v0IwI5+b7RmfWlg==",
+ "license": "MIT"
+ },
+ "node_modules/@types/d3-scale": {
+ "version": "4.0.9",
+ "resolved": "https://registry.npmjs.org/@types/d3-scale/-/d3-scale-4.0.9.tgz",
+ "integrity": "sha512-dLmtwB8zkAeO/juAMfnV+sItKjlsw2lKdZVVy6LRr0cBmegxSABiLEpGVmSJJ8O08i4+sGR6qQtb6WtuwJdvVw==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/d3-time": "*"
+ }
+ },
+ "node_modules/@types/d3-shape": {
+ "version": "3.1.8",
+ "resolved": "https://registry.npmjs.org/@types/d3-shape/-/d3-shape-3.1.8.tgz",
+ "integrity": "sha512-lae0iWfcDeR7qt7rA88BNiqdvPS5pFVPpo5OfjElwNaT2yyekbM0C9vK+yqBqEmHr6lDkRnYNoTBYlAgJa7a4w==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/d3-path": "*"
+ }
+ },
+ "node_modules/@types/d3-time": {
+ "version": "3.0.4",
+ "resolved": "https://registry.npmjs.org/@types/d3-time/-/d3-time-3.0.4.tgz",
+ "integrity": "sha512-yuzZug1nkAAaBlBBikKZTgzCeA+k1uy4ZFwWANOfKw5z5LRhV0gNA7gNkKm7HoK+HRN0wX3EkxGk0fpbWhmB7g==",
+ "license": "MIT"
+ },
+ "node_modules/@types/d3-timer": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/@types/d3-timer/-/d3-timer-3.0.2.tgz",
+ "integrity": "sha512-Ps3T8E8dZDam6fUyNiMkekK3XUsaUEik+idO9/YjPtfj2qruF8tFBXS7XhtE4iIXBLxhmLjP3SXpLhVf21I9Lw==",
+ "license": "MIT"
+ },
"node_modules/@types/estree": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz",
@@ -7222,9 +7296,129 @@
"version": "3.2.3",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
"integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==",
- "devOptional": true,
"license": "MIT"
},
+ "node_modules/d3-array": {
+ "version": "3.2.4",
+ "resolved": "https://registry.npmjs.org/d3-array/-/d3-array-3.2.4.tgz",
+ "integrity": "sha512-tdQAmyA18i4J7wprpYq8ClcxZy3SC31QMeByyCFyRt7BVHdREQZ5lpzoe5mFEYZUWe+oq8HBvk9JjpibyEV4Jg==",
+ "license": "ISC",
+ "dependencies": {
+ "internmap": "1 - 2"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-color": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/d3-color/-/d3-color-3.1.0.tgz",
+ "integrity": "sha512-zg/chbXyeBtMQ1LbD/WSoW2DpC3I0mpmPdW+ynRTj/x2DAWYrIY7qeZIHidozwV24m4iavr15lNwIwLxRmOxhA==",
+ "license": "ISC",
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-ease": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/d3-ease/-/d3-ease-3.0.1.tgz",
+ "integrity": "sha512-wR/XK3D3XcLIZwpbvQwQ5fK+8Ykds1ip7A2Txe0yxncXSdq1L9skcG7blcedkOX+ZcgxGAmLX1FrRGbADwzi0w==",
+ "license": "BSD-3-Clause",
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-format": {
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/d3-format/-/d3-format-3.1.2.tgz",
+ "integrity": "sha512-AJDdYOdnyRDV5b6ArilzCPPwc1ejkHcoyFarqlPqT7zRYjhavcT3uSrqcMvsgh2CgoPbK3RCwyHaVyxYcP2Arg==",
+ "license": "ISC",
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-interpolate": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/d3-interpolate/-/d3-interpolate-3.0.1.tgz",
+ "integrity": "sha512-3bYs1rOD33uo8aqJfKP3JWPAibgw8Zm2+L9vBKEHJ2Rg+viTR7o5Mmv5mZcieN+FRYaAOWX5SJATX6k1PWz72g==",
+ "license": "ISC",
+ "dependencies": {
+ "d3-color": "1 - 3"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-path": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/d3-path/-/d3-path-3.1.0.tgz",
+ "integrity": "sha512-p3KP5HCf/bvjBSSKuXid6Zqijx7wIfNW+J/maPs+iwR35at5JCbLUT0LzF1cnjbCHWhqzQTIN2Jpe8pRebIEFQ==",
+ "license": "ISC",
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-scale": {
+ "version": "4.0.2",
+ "resolved": "https://registry.npmjs.org/d3-scale/-/d3-scale-4.0.2.tgz",
+ "integrity": "sha512-GZW464g1SH7ag3Y7hXjf8RoUuAFIqklOAq3MRl4OaWabTFJY9PN/E1YklhXLh+OQ3fM9yS2nOkCoS+WLZ6kvxQ==",
+ "license": "ISC",
+ "dependencies": {
+ "d3-array": "2.10.0 - 3",
+ "d3-format": "1 - 3",
+ "d3-interpolate": "1.2.0 - 3",
+ "d3-time": "2.1.1 - 3",
+ "d3-time-format": "2 - 4"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-shape": {
+ "version": "3.2.0",
+ "resolved": "https://registry.npmjs.org/d3-shape/-/d3-shape-3.2.0.tgz",
+ "integrity": "sha512-SaLBuwGm3MOViRq2ABk3eLoxwZELpH6zhl3FbAoJ7Vm1gofKx6El1Ib5z23NUEhF9AsGl7y+dzLe5Cw2AArGTA==",
+ "license": "ISC",
+ "dependencies": {
+ "d3-path": "^3.1.0"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-time": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/d3-time/-/d3-time-3.1.0.tgz",
+ "integrity": "sha512-VqKjzBLejbSMT4IgbmVgDjpkYrNWUYJnbCGo874u7MMKIWsILRX+OpX/gTk8MqjpT1A/c6HY2dCA77ZN0lkQ2Q==",
+ "license": "ISC",
+ "dependencies": {
+ "d3-array": "2 - 3"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-time-format": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/d3-time-format/-/d3-time-format-4.1.0.tgz",
+ "integrity": "sha512-dJxPBlzC7NugB2PDLwo9Q8JiTR3M3e4/XANkreKSUxF8vvXKqm1Yfq4Q5dl8budlunRVlUUaDUgFt7eA8D6NLg==",
+ "license": "ISC",
+ "dependencies": {
+ "d3-time": "1 - 3"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-timer": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/d3-timer/-/d3-timer-3.0.1.tgz",
+ "integrity": "sha512-ndfJ/JxxMd3nw31uyKoY2naivF+r29V+Lc0svZxe1JvvIRmi8hUsrMvdOwgS1o6uBHmiz91geQ0ylPP0aj1VUA==",
+ "license": "ISC",
+ "engines": {
+ "node": ">=12"
+ }
+ },
"node_modules/damerau-levenshtein": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz",
@@ -7314,6 +7508,12 @@
}
}
},
+ "node_modules/decimal.js-light": {
+ "version": "2.5.1",
+ "resolved": "https://registry.npmjs.org/decimal.js-light/-/decimal.js-light-2.5.1.tgz",
+ "integrity": "sha512-qIMFpTMZmny+MMIitAB6D7iVPEorVw6YQRWkvarTkT4tBeSLLiHzcwj6q0MmYSFCiVpiqPJTJEYIrpcPzVEIvg==",
+ "license": "MIT"
+ },
"node_modules/dedent": {
"version": "1.7.1",
"resolved": "https://registry.npmjs.org/dedent/-/dedent-1.7.1.tgz",
@@ -7496,6 +7696,16 @@
"node": ">=0.10.0"
}
},
+ "node_modules/dom-helpers": {
+ "version": "5.2.1",
+ "resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-5.2.1.tgz",
+ "integrity": "sha512-nRCa7CK3VTrM2NmGkIy4cbK7IZlgBE/PYMn55rrXefr5xXDP0LdtfPnblFDoVdcAfslJ7or6iqAUnx0CCGIWQA==",
+ "license": "MIT",
+ "dependencies": {
+ "@babel/runtime": "^7.8.7",
+ "csstype": "^3.0.2"
+ }
+ },
"node_modules/dotenv": {
"version": "17.2.3",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.2.3.tgz",
@@ -8268,6 +8478,12 @@
"node": ">= 0.6"
}
},
+ "node_modules/eventemitter3": {
+ "version": "4.0.7",
+ "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz",
+ "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==",
+ "license": "MIT"
+ },
"node_modules/eventsource": {
"version": "3.0.7",
"resolved": "https://registry.npmjs.org/eventsource/-/eventsource-3.0.7.tgz",
@@ -8405,6 +8621,15 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/fast-equals": {
+ "version": "5.4.0",
+ "resolved": "https://registry.npmjs.org/fast-equals/-/fast-equals-5.4.0.tgz",
+ "integrity": "sha512-jt2DW/aNFNwke7AUd+Z+e6pz39KO5rzdbbFCg2sGafS4mk13MI7Z8O5z9cADNn5lhGODIgLwug6TZO2ctf7kcw==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=6.0.0"
+ }
+ },
"node_modules/fast-glob": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz",
@@ -9248,6 +9473,15 @@
"node": ">= 0.4"
}
},
+ "node_modules/internmap": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/internmap/-/internmap-2.0.3.tgz",
+ "integrity": "sha512-5Hh7Y1wQbvY5ooGgPbDaL5iYLAPzMTUrjMulskHLH6wnv/A+1q5rgEaiuqEjB+oxGXIVZs1FF+R/KPN3ZSQYYg==",
+ "license": "ISC",
+ "engines": {
+ "node": ">=12"
+ }
+ },
"node_modules/ip-address": {
"version": "10.0.1",
"resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.0.1.tgz",
@@ -9912,7 +10146,6 @@
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
- "dev": true,
"license": "MIT"
},
"node_modules/js-yaml": {
@@ -10368,6 +10601,12 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/lodash": {
+ "version": "4.17.23",
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.23.tgz",
+ "integrity": "sha512-LgVTMpQtIopCi79SJeDiP0TfWi5CNEc/L/aRdTh3yIvmZXTnheWpKjSZhnvMl8iXbC1tFg9gdHHDMLoV7CnG+w==",
+ "license": "MIT"
+ },
"node_modules/lodash.merge": {
"version": "4.6.2",
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
@@ -10422,7 +10661,6 @@
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
"integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
- "dev": true,
"license": "MIT",
"dependencies": {
"js-tokens": "^3.0.0 || ^4.0.0"
@@ -11049,7 +11287,6 @@
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
"integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
- "dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
@@ -11618,6 +11855,102 @@
"node": ">= 0.8.0"
}
},
+ "node_modules/prettier": {
+ "version": "3.8.1",
+ "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.8.1.tgz",
+ "integrity": "sha512-UOnG6LftzbdaHZcKoPFtOcCKztrQ57WkHDeRD9t/PTQtmT0NHSeWWepj6pS0z/N7+08BHFDQVUrfmfMRcZwbMg==",
+ "dev": true,
+ "license": "MIT",
+ "peer": true,
+ "bin": {
+ "prettier": "bin/prettier.cjs"
+ },
+ "engines": {
+ "node": ">=14"
+ },
+ "funding": {
+ "url": "https://github.com/prettier/prettier?sponsor=1"
+ }
+ },
+ "node_modules/prettier-plugin-tailwindcss": {
+ "version": "0.7.2",
+ "resolved": "https://registry.npmjs.org/prettier-plugin-tailwindcss/-/prettier-plugin-tailwindcss-0.7.2.tgz",
+ "integrity": "sha512-LkphyK3Fw+q2HdMOoiEHWf93fNtYJwfamoKPl7UwtjFQdei/iIBoX11G6j706FzN3ymX9mPVi97qIY8328vdnA==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=20.19"
+ },
+ "peerDependencies": {
+ "@ianvs/prettier-plugin-sort-imports": "*",
+ "@prettier/plugin-hermes": "*",
+ "@prettier/plugin-oxc": "*",
+ "@prettier/plugin-pug": "*",
+ "@shopify/prettier-plugin-liquid": "*",
+ "@trivago/prettier-plugin-sort-imports": "*",
+ "@zackad/prettier-plugin-twig": "*",
+ "prettier": "^3.0",
+ "prettier-plugin-astro": "*",
+ "prettier-plugin-css-order": "*",
+ "prettier-plugin-jsdoc": "*",
+ "prettier-plugin-marko": "*",
+ "prettier-plugin-multiline-arrays": "*",
+ "prettier-plugin-organize-attributes": "*",
+ "prettier-plugin-organize-imports": "*",
+ "prettier-plugin-sort-imports": "*",
+ "prettier-plugin-svelte": "*"
+ },
+ "peerDependenciesMeta": {
+ "@ianvs/prettier-plugin-sort-imports": {
+ "optional": true
+ },
+ "@prettier/plugin-hermes": {
+ "optional": true
+ },
+ "@prettier/plugin-oxc": {
+ "optional": true
+ },
+ "@prettier/plugin-pug": {
+ "optional": true
+ },
+ "@shopify/prettier-plugin-liquid": {
+ "optional": true
+ },
+ "@trivago/prettier-plugin-sort-imports": {
+ "optional": true
+ },
+ "@zackad/prettier-plugin-twig": {
+ "optional": true
+ },
+ "prettier-plugin-astro": {
+ "optional": true
+ },
+ "prettier-plugin-css-order": {
+ "optional": true
+ },
+ "prettier-plugin-jsdoc": {
+ "optional": true
+ },
+ "prettier-plugin-marko": {
+ "optional": true
+ },
+ "prettier-plugin-multiline-arrays": {
+ "optional": true
+ },
+ "prettier-plugin-organize-attributes": {
+ "optional": true
+ },
+ "prettier-plugin-organize-imports": {
+ "optional": true
+ },
+ "prettier-plugin-sort-imports": {
+ "optional": true
+ },
+ "prettier-plugin-svelte": {
+ "optional": true
+ }
+ }
+ },
"node_modules/pretty-ms": {
"version": "9.3.0",
"resolved": "https://registry.npmjs.org/pretty-ms/-/pretty-ms-9.3.0.tgz",
@@ -11662,7 +11995,6 @@
"version": "15.8.1",
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
"integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==",
- "dev": true,
"license": "MIT",
"dependencies": {
"loose-envify": "^1.4.0",
@@ -11945,7 +12277,6 @@
"version": "16.13.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==",
- "dev": true,
"license": "MIT"
},
"node_modules/react-remove-scroll": {
@@ -11995,6 +12326,21 @@
}
}
},
+ "node_modules/react-smooth": {
+ "version": "4.0.4",
+ "resolved": "https://registry.npmjs.org/react-smooth/-/react-smooth-4.0.4.tgz",
+ "integrity": "sha512-gnGKTpYwqL0Iii09gHobNolvX4Kiq4PKx6eWBCYYix+8cdw+cGo3do906l1NBPKkSWx1DghC1dlWG9L2uGd61Q==",
+ "license": "MIT",
+ "dependencies": {
+ "fast-equals": "^5.0.1",
+ "prop-types": "^15.8.1",
+ "react-transition-group": "^4.4.5"
+ },
+ "peerDependencies": {
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
+ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
+ }
+ },
"node_modules/react-style-singleton": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/react-style-singleton/-/react-style-singleton-2.2.3.tgz",
@@ -12017,6 +12363,22 @@
}
}
},
+ "node_modules/react-transition-group": {
+ "version": "4.4.5",
+ "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz",
+ "integrity": "sha512-pZcd1MCJoiKiBR2NRxeCRg13uCXbydPnmB4EOeRrY7480qNWO8IIgQG6zlDkm6uRMsURXPuKq0GWtiM59a5Q6g==",
+ "license": "BSD-3-Clause",
+ "dependencies": {
+ "@babel/runtime": "^7.5.5",
+ "dom-helpers": "^5.0.1",
+ "loose-envify": "^1.4.0",
+ "prop-types": "^15.6.2"
+ },
+ "peerDependencies": {
+ "react": ">=16.6.0",
+ "react-dom": ">=16.6.0"
+ }
+ },
"node_modules/recast": {
"version": "0.23.11",
"resolved": "https://registry.npmjs.org/recast/-/recast-0.23.11.tgz",
@@ -12034,6 +12396,44 @@
"node": ">= 4"
}
},
+ "node_modules/recharts": {
+ "version": "2.15.4",
+ "resolved": "https://registry.npmjs.org/recharts/-/recharts-2.15.4.tgz",
+ "integrity": "sha512-UT/q6fwS3c1dHbXv2uFgYJ9BMFHu3fwnd7AYZaEQhXuYQ4hgsxLvsUXzGdKeZrW5xopzDCvuA2N41WJ88I7zIw==",
+ "license": "MIT",
+ "dependencies": {
+ "clsx": "^2.0.0",
+ "eventemitter3": "^4.0.1",
+ "lodash": "^4.17.21",
+ "react-is": "^18.3.1",
+ "react-smooth": "^4.0.4",
+ "recharts-scale": "^0.4.4",
+ "tiny-invariant": "^1.3.1",
+ "victory-vendor": "^36.6.8"
+ },
+ "engines": {
+ "node": ">=14"
+ },
+ "peerDependencies": {
+ "react": "^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
+ "react-dom": "^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
+ }
+ },
+ "node_modules/recharts-scale": {
+ "version": "0.4.5",
+ "resolved": "https://registry.npmjs.org/recharts-scale/-/recharts-scale-0.4.5.tgz",
+ "integrity": "sha512-kivNFO+0OcUNu7jQquLXAxz1FIwZj8nrj+YkOKc5694NbjCvcT6aSZiIzNzd2Kul4o4rTto8QVR9lMNtxD4G1w==",
+ "license": "MIT",
+ "dependencies": {
+ "decimal.js-light": "^2.4.1"
+ }
+ },
+ "node_modules/recharts/node_modules/react-is": {
+ "version": "18.3.1",
+ "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz",
+ "integrity": "sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==",
+ "license": "MIT"
+ },
"node_modules/reflect.getprototypeof": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.10.tgz",
@@ -13179,7 +13579,6 @@
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.3.tgz",
"integrity": "sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg==",
- "dev": true,
"license": "MIT"
},
"node_modules/tinyexec": {
@@ -13848,6 +14247,28 @@
"url": "https://opencollective.com/unified"
}
},
+ "node_modules/victory-vendor": {
+ "version": "36.9.2",
+ "resolved": "https://registry.npmjs.org/victory-vendor/-/victory-vendor-36.9.2.tgz",
+ "integrity": "sha512-PnpQQMuxlwYdocC8fIJqVXvkeViHYzotI+NJrCuav0ZYFoq912ZHBk3mCeuj+5/VpodOjPe1z0Fk2ihgzlXqjQ==",
+ "license": "MIT AND ISC",
+ "dependencies": {
+ "@types/d3-array": "^3.0.3",
+ "@types/d3-ease": "^3.0.0",
+ "@types/d3-interpolate": "^3.0.1",
+ "@types/d3-scale": "^4.0.2",
+ "@types/d3-shape": "^3.1.0",
+ "@types/d3-time": "^3.0.0",
+ "@types/d3-timer": "^3.0.0",
+ "d3-array": "^3.1.6",
+ "d3-ease": "^3.0.1",
+ "d3-interpolate": "^3.0.1",
+ "d3-scale": "^4.0.2",
+ "d3-shape": "^3.1.0",
+ "d3-time": "^3.0.0",
+ "d3-timer": "^3.0.1"
+ }
+ },
"node_modules/web-streams-polyfill": {
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz",
diff --git a/package.json b/package.json
index 541a41d..2f49190 100644
--- a/package.json
+++ b/package.json
@@ -21,6 +21,7 @@
"radix-ui": "^1.4.3",
"react": "19.2.3",
"react-dom": "19.2.3",
+ "recharts": "^2.15.4",
"shiki": "^3.20.0",
"tailwind-merge": "^2.6.0"
},
@@ -31,6 +32,7 @@
"@types/react-dom": "^19",
"eslint": "^9",
"eslint-config-next": "16.1.1",
+ "prettier-plugin-tailwindcss": "^0.7.2",
"shadcn": "^3.6.2",
"tailwindcss": "^4",
"tw-animate-css": "^1.4.0",
diff --git a/public/r/analytics-map.json b/public/r/analytics-map.json
new file mode 100644
index 0000000..82681d3
--- /dev/null
+++ b/public/r/analytics-map.json
@@ -0,0 +1,49 @@
+{
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
+ "name": "analytics-map",
+ "title": "Analytics Map",
+ "description": "Real-time analytics overview with a world map, breakdown cards, and device stats.",
+ "dependencies": [
+ "recharts",
+ "lucide-react"
+ ],
+ "registryDependencies": [
+ "map",
+ "card",
+ "chart"
+ ],
+ "files": [
+ {
+ "path": "src/registry/blocks/analytics-map/page.tsx",
+ "content": "\"use client\";\n\nimport {\n Map,\n MapControls,\n MapMarker,\n MarkerContent,\n MarkerTooltip,\n} from \"@/registry/map\";\nimport { OverviewCard } from \"./components/overview-card\";\nimport { BreakdownCard } from \"./components/breakdown-card\";\nimport {\n locations,\n visitedPagesRows,\n countriesRows,\n referrersRows,\n browsersRows,\n} from \"./data\";\n\nconst MAP_HEIGHT = \"38rem\";\n\nexport function AnalyticsMapBlock() {\n return (\n <div\n className=\"bg-background relative min-h-screen\"\n style={{ \"--map-height\": MAP_HEIGHT } as React.CSSProperties}\n >\n <div className=\"relative h-(--map-height)\">\n <Map\n center={[-2, 16]}\n zoom={1.5}\n scrollZoom={false}\n renderWorldCopies={true}\n >\n <MapControls showFullscreen />\n {locations.map((location) => (\n <MapMarker\n key={location.city}\n longitude={location.lng}\n latitude={location.lat}\n >\n <MarkerContent>\n <div\n className=\"rounded-full bg-blue-500/70\"\n style={{\n width: location.size * 3,\n height: location.size * 3,\n }}\n />\n </MarkerContent>\n <MarkerTooltip\n offset={20}\n className=\"bg-background text-foreground border\"\n >\n <p className=\"text-muted-foreground font-medium\">\n {location.city}\n </p>\n <p className=\"mt-1\">\n <span className=\"font-medium tabular-nums\">\n {location.size}\n </span>{\" \"}\n active users\n </p>\n </MarkerTooltip>\n </MapMarker>\n ))}\n </Map>\n <div\n className=\"via-background/30 to-background pointer-events-none absolute inset-x-0 bottom-0 h-40 bg-linear-to-b from-transparent\"\n aria-hidden\n />\n <OverviewCard />\n </div>\n\n <div className=\"grid gap-4 p-4 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4\">\n <BreakdownCard title=\"Visited pages\" rows={visitedPagesRows} />\n <BreakdownCard title=\"Referrers\" rows={referrersRows} />\n <BreakdownCard title=\"Countries\" rows={countriesRows} />\n <BreakdownCard title=\"Browsers\" rows={browsersRows} />\n </div>\n </div>\n );\n}\n",
+ "type": "registry:page",
+ "target": "app/analytics/page.tsx"
+ },
+ {
+ "path": "src/registry/blocks/analytics-map/data.ts",
+ "content": "import { type ChartConfig } from \"@/components/ui/chart\";\n\nexport interface LocationPoint {\n city: string;\n lng: number;\n lat: number;\n size: number;\n}\n\nexport interface BreakdownRow {\n label: string;\n value: number;\n}\n\nexport const locations: LocationPoint[] = [\n { city: \"San Francisco\", lng: -122.4194, lat: 37.7749, size: 16 },\n { city: \"New York\", lng: -74.006, lat: 40.7128, size: 15 },\n { city: \"Toronto\", lng: -79.3832, lat: 43.6532, size: 11 },\n { city: \"Mexico City\", lng: -99.1332, lat: 19.4326, size: 10 },\n { city: \"Sao Paulo\", lng: -46.6333, lat: -23.5505, size: 12 },\n { city: \"Buenos Aires\", lng: -58.3816, lat: -34.6037, size: 9 },\n { city: \"London\", lng: -0.1276, lat: 51.5074, size: 14 },\n { city: \"Berlin\", lng: 13.405, lat: 52.52, size: 11 },\n { city: \"Paris\", lng: 2.3522, lat: 48.8566, size: 13 },\n { city: \"Madrid\", lng: -3.7038, lat: 40.4168, size: 10 },\n { city: \"Cairo\", lng: 31.2357, lat: 30.0444, size: 9 },\n { city: \"Lagos\", lng: 3.3792, lat: 6.5244, size: 10 },\n { city: \"Mumbai\", lng: 72.8777, lat: 19.076, size: 13 },\n { city: \"Dubai\", lng: 55.2708, lat: 25.2048, size: 11 },\n { city: \"Seoul\", lng: 126.978, lat: 37.5665, size: 12 },\n { city: \"Singapore\", lng: 103.8198, lat: 1.3521, size: 10 },\n { city: \"Tokyo\", lng: 139.6917, lat: 35.6895, size: 12 },\n { city: \"Sydney\", lng: 151.2093, lat: -33.8688, size: 9 },\n { city: \"Auckland\", lng: 174.7633, lat: -36.8485, size: 8 },\n];\n\nexport const usersPerDay = [\n { day: \"Mon\", users: 320 },\n { day: \"Tue\", users: 410 },\n { day: \"Wed\", users: 560 },\n { day: \"Thu\", users: 640 },\n { day: \"Fri\", users: 780 },\n { day: \"Sat\", users: 690 },\n { day: \"Sun\", users: 720 },\n];\n\nexport const usersPerDayChartConfig = {\n users: {\n label: \"Users\",\n color: \"var(--color-blue-500)\",\n },\n} satisfies ChartConfig;\n\nexport const deviceCategoryData = [\n { name: \"Desktop\", value: 73.3, fill: \"var(--color-blue-500)\" },\n { name: \"Mobile\", value: 25.0, fill: \"var(--color-blue-400)\" },\n { name: \"Tablet\", value: 1.7, fill: \"var(--color-blue-300)\" },\n];\n\nexport const deviceCategoryChartConfig = {\n desktop: { label: \"Desktop\", color: \"var(--color-blue-500)\" },\n mobile: { label: \"Mobile\", color: \"var(--color-blue-400)\" },\n tablet: { label: \"Tablet\", color: \"var(--color-blue-300)\" },\n} satisfies ChartConfig;\n\nexport const visitedPagesRows: BreakdownRow[] = [\n { label: \"Home\", value: 31 },\n { label: \"Pricing\", value: 23 },\n { label: \"Docs / Basic Map\", value: 18 },\n { label: \"Installation\", value: 12 },\n { label: \"Components\", value: 9 },\n { label: \"Blog\", value: 6 },\n];\n\nexport const countriesRows: BreakdownRow[] = [\n { label: \"United States\", value: 27 },\n { label: \"India\", value: 14 },\n { label: \"United Kingdom\", value: 8 },\n { label: \"Germany\", value: 6 },\n { label: \"Japan\", value: 4 },\n { label: \"Australia\", value: 2 },\n];\n\nexport const referrersRows: BreakdownRow[] = [\n { label: \"google\", value: 38 },\n { label: \"direct\", value: 26 },\n { label: \"github.com\", value: 19 },\n { label: \"x.com\", value: 11 },\n { label: \"ui.shadcn.com\", value: 8 },\n { label: \"other\", value: 5 },\n];\n\nexport const browsersRows: BreakdownRow[] = [\n { label: \"Chrome\", value: 52 },\n { label: \"Safari\", value: 21 },\n { label: \"Firefox\", value: 14 },\n { label: \"Edge\", value: 8 },\n { label: \"Other\", value: 5 },\n];\n",
+ "type": "registry:component",
+ "target": "app/analytics/data.ts"
+ },
+ {
+ "path": "src/registry/blocks/analytics-map/components/overview-card.tsx",
+ "content": "\"use client\";\n\nimport { Card, CardContent, CardHeader } from \"@/components/ui/card\";\nimport { ChartContainer } from \"@/components/ui/chart\";\nimport { TrendingUp } from \"lucide-react\";\nimport { Area, AreaChart, Cell, Pie, PieChart } from \"recharts\";\nimport {\n deviceCategoryChartConfig,\n deviceCategoryData,\n usersPerDay,\n usersPerDayChartConfig,\n} from \"../data\";\n\nfunction MetricChart() {\n return (\n <ChartContainer\n config={usersPerDayChartConfig}\n className=\"aspect-auto h-8 w-full\"\n >\n <AreaChart data={usersPerDay} margin={{ left: 4, right: 4, top: 4 }}>\n <defs>\n <linearGradient id=\"usersGradient\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n <stop\n offset=\"0%\"\n stopColor=\"var(--color-users)\"\n stopOpacity={0.4}\n />\n <stop\n offset=\"100%\"\n stopColor=\"var(--color-users)\"\n stopOpacity={0}\n />\n </linearGradient>\n </defs>\n\n <Area\n type=\"natural\"\n dataKey=\"users\"\n stroke=\"var(--color-users)\"\n strokeWidth={1.5}\n fill=\"url(#usersGradient)\"\n />\n </AreaChart>\n </ChartContainer>\n );\n}\n\nexport function OverviewCard() {\n return (\n <Card className=\"bg-card/70 absolute top-4 left-4 z-10 w-60 backdrop-blur-sm\">\n <CardHeader>\n <div>\n <p className=\"text-muted-foreground pb-2 text-[10px] tracking-wider uppercase\">\n Users in last 7 days\n </p>\n <p className=\"text-3xl leading-none font-semibold\">3,803</p>\n </div>\n </CardHeader>\n\n <CardContent>\n <MetricChart />\n <div className=\"mt-4 flex items-center gap-1.5 text-xs\">\n <TrendingUp className=\"size-3 text-emerald-500\" />\n <span className=\"font-medium text-emerald-500\">+12.5%</span>\n <span className=\"text-muted-foreground\">vs previous 7 days</span>\n </div>\n\n <div className=\"border-border/60 mt-4 border-t pt-4\">\n <p className=\"text-muted-foreground text-[10px] tracking-wider uppercase\">\n Device category in last 7 days\n </p>\n\n <ChartContainer\n config={deviceCategoryChartConfig}\n className=\"mx-auto mt-3 aspect-square h-32 w-32\"\n >\n <PieChart>\n <Pie\n data={deviceCategoryData}\n dataKey=\"value\"\n nameKey=\"name\"\n innerRadius={32}\n outerRadius={52}\n strokeWidth={2}\n >\n {deviceCategoryData.map((entry) => (\n <Cell key={entry.name} fill={entry.fill} />\n ))}\n </Pie>\n </PieChart>\n </ChartContainer>\n\n <div className=\"mt-3 grid grid-cols-3 gap-2\">\n {deviceCategoryData.map((device) => (\n <div key={device.name} className=\"text-center\">\n <p className=\"text-muted-foreground flex items-center justify-center gap-1.5 text-[10px] tracking-wide uppercase\">\n <span\n className=\"size-2 rounded-full\"\n style={{ backgroundColor: device.fill }}\n />\n {device.name}\n </p>\n <p className=\"text-foreground mt-1 leading-none font-medium tabular-nums\">\n {device.value}%\n </p>\n </div>\n ))}\n </div>\n </div>\n </CardContent>\n </Card>\n );\n}\n",
+ "type": "registry:component",
+ "target": "app/analytics/components/overview-card.tsx"
+ },
+ {
+ "path": "src/registry/blocks/analytics-map/components/breakdown-card.tsx",
+ "content": "\"use client\";\n\nimport { Card, CardContent, CardHeader, CardTitle } from \"@/components/ui/card\";\nimport { type BreakdownRow } from \"../data\";\n\ninterface BreakdownCardProps {\n title: string;\n rows: BreakdownRow[];\n}\n\nexport function BreakdownCard({ title, rows }: BreakdownCardProps) {\n const maxRowValue =\n rows.length > 0 ? Math.max(...rows.map((row) => row.value)) : 0;\n\n return (\n <Card>\n <CardHeader>\n <CardTitle className=\"text-sm font-medium\">{title}</CardTitle>\n </CardHeader>\n\n <CardContent>\n <div className=\"text-muted-foreground mb-2 flex items-center justify-between text-[11px] tracking-wider uppercase\">\n <span>{title}</span>\n <span>Visitors</span>\n </div>\n <div className=\"space-y-3\">\n {rows.map((row) => (\n <div key={row.label} className=\"space-y-1.5\">\n <div className=\"flex items-center justify-between text-xs\">\n <span className=\"text-foreground/90 truncate\">{row.label}</span>\n <span className=\"text-foreground font-medium\">{row.value}</span>\n </div>\n <div className=\"bg-muted h-1 rounded-full\">\n <div\n className=\"h-full rounded-full bg-blue-500/85\"\n style={{ width: `${(row.value / maxRowValue) * 100}%` }}\n />\n </div>\n </div>\n ))}\n </div>\n </CardContent>\n </Card>\n );\n}\n",
+ "type": "registry:component",
+ "target": "app/analytics/components/breakdown-card.tsx"
+ }
+ ],
+ "meta": {
+ "iframeHeight": "970px"
+ },
+ "categories": [
+ "analytics",
+ "dashboard"
+ ],
+ "type": "registry:block"
+}
\ No newline at end of file
diff --git a/public/r/delivery-tracker.json b/public/r/delivery-tracker.json
new file mode 100644
index 0000000..bde6de3
--- /dev/null
+++ b/public/r/delivery-tracker.json
@@ -0,0 +1,31 @@
+{
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
+ "name": "delivery-tracker",
+ "title": "Delivery Tracker",
+ "description": "Live order tracking with route progress, courier position, and order details.",
+ "dependencies": [
+ "lucide-react"
+ ],
+ "registryDependencies": [
+ "map",
+ "card",
+ "badge",
+ "button"
+ ],
+ "files": [
+ {
+ "path": "src/registry/blocks/delivery-tracker/page.tsx",
+ "content": "\"use client\";\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport { Clock3, Utensils, Truck, UserRound } from \"lucide-react\";\n\nimport {\n Map,\n MapMarker,\n MapRoute,\n MarkerContent,\n MarkerTooltip,\n} from \"@/registry/map\";\nimport { Badge } from \"@/components/ui/badge\";\nimport { Button } from \"@/components/ui/button\";\nimport { Card, CardContent, CardHeader, CardTitle } from \"@/components/ui/card\";\n\ninterface DeliveryMeal {\n name: string;\n price: string;\n quantity: number;\n}\n\ninterface OsrmRouteData {\n coordinates: [number, number][];\n duration: number;\n distance: number;\n}\n\nconst deliveryMeals: DeliveryMeal[] = [\n {\n name: \"Spicy Tofu Grain Bowl\",\n price: \"$44.00\",\n quantity: 1,\n },\n {\n name: \"Herb Chicken Rice Box\",\n price: \"$58.00\",\n quantity: 2,\n },\n {\n name: \"Roasted Veggie Wrap\",\n price: \"$29.00\",\n quantity: 1,\n },\n];\n\nconst pickup = { lng: -122.466, lat: 37.716 };\nconst dropoff = { lng: -122.399, lat: 37.683 };\n\nfunction formatDistance(meters?: number) {\n if (!meters) return \"--\";\n if (meters < 1000) return `${Math.round(meters)} m`;\n return `${(meters / 1000).toFixed(1)} km`;\n}\n\nfunction formatDuration(seconds?: number) {\n if (!seconds) return \"--\";\n const minutes = Math.round(seconds / 60);\n if (minutes < 60) return `${minutes} min`;\n const hours = Math.floor(minutes / 60);\n const remainingMinutes = minutes % 60;\n return `${hours}h ${remainingMinutes}m`;\n}\n\nexport function DeliveryBlock() {\n const [routeData, setRouteData] = useState<OsrmRouteData | null>(null);\n const [loading, setLoading] = useState(true);\n\n useEffect(() => {\n async function fetchRoute() {\n setLoading(true);\n try {\n const response = await fetch(\n `https://router.project-osrm.org/route/v1/driving/${pickup.lng},${pickup.lat};${dropoff.lng},${dropoff.lat}?overview=full&geometries=geojson`\n );\n const data = await response.json();\n const route = data?.routes?.[0];\n if (!route?.geometry?.coordinates) return;\n\n setRouteData({\n coordinates: route.geometry.coordinates as [number, number][],\n duration: route.duration as number,\n distance: route.distance as number,\n });\n } catch (error) {\n console.error(\"Failed to fetch route:\", error);\n } finally {\n setLoading(false);\n }\n }\n\n fetchRoute();\n }, []);\n\n const progressCoordinates = useMemo(() => {\n const progressCount = Math.max(\n 2,\n Math.floor(\n (routeData?.coordinates?.length ?? 0) * (routeData ? 0.62 : 0.66)\n )\n );\n return routeData?.coordinates?.slice(0, progressCount) ?? [];\n }, [routeData]);\n\n const courierPosition = progressCoordinates[progressCoordinates.length - 1];\n\n return (\n <div className=\"p-8\">\n <div className=\"grid md:grid-cols-[1.05fr_1fr] bg-sidebar rounded-lg border md:h-[600px] max-w-7xl mx-auto\">\n <div className=\"p-5 md:p-6 flex flex-col\">\n <div className=\"space-y-1\">\n <h3 className=\"text-2xl font-semibold tracking-tight\">\n Track Delivery\n </h3>\n <p className=\"text-sm text-muted-foreground\">Mon Feb 10 - 2-3 PM</p>\n </div>\n\n <Card className=\"mt-5\">\n <CardHeader>\n <CardTitle className=\"font-medium\">\n Order items ({deliveryMeals.length})\n </CardTitle>\n </CardHeader>\n <CardContent className=\"space-y-5\">\n {deliveryMeals.map((meal) => (\n <div key={meal.name} className=\"flex items-center gap-3\">\n <div className=\"grid size-8 place-items-center rounded-full bg-muted text-xs font-medium\">\n <Utensils className=\"size-4 text-muted-foreground\" />\n </div>\n <div className=\"min-w-4 flex-1\">\n <p className=\"truncate text-sm font-medium pb-1\">\n {meal.name}\n </p>\n <p className=\"text-xs text-muted-foreground\">\n {meal.price}\n </p>\n </div>\n <Badge\n variant=\"secondary\"\n className=\"h-6 rounded-full px-2.5\"\n >\n x{meal.quantity}\n </Badge>\n </div>\n ))}\n <div className=\"flex items-center justify-between border-t border-border/60 pt-3 text-sm\">\n <span className=\"text-muted-foreground\">Bundle total</span>\n <span className=\"font-medium\">$189.00</span>\n </div>\n </CardContent>\n </Card>\n\n <div className=\"mt-4 grid gap-3 sm:grid-cols-2\">\n <Card>\n <CardContent className=\"space-y-2\">\n <p className=\"text-sm font-medium text-muted-foreground\">\n Pickup confirmed\n </p>\n <p className=\"text-sm font-medium\">Mon, Feb 10 at 1:48 PM</p>\n </CardContent>\n </Card>\n <Card>\n <CardContent className=\"space-y-2\">\n <p className=\"text-sm font-medium text-muted-foreground\">\n Remaining travel\n </p>\n <p className=\"text-sm font-medium\">\n {formatDuration(routeData?.duration)}\n </p>\n </CardContent>\n </Card>\n </div>\n\n <div className=\"mt-6 flex flex-wrap items-center gap-2\">\n <Button size=\"sm\" className=\"gap-1.5\">\n <Clock3 className=\"size-4\" />\n View timeline\n </Button>\n <Button variant=\"outline\" size=\"sm\" className=\"gap-1.5\">\n <UserRound className=\"size-4\" />\n Contact courier\n </Button>\n </div>\n </div>\n\n <div className=\"relative h-[400px] overflow-hidden rounded-xl md:h-full shadow-sm\">\n <Map\n loading={loading}\n center={[-122.435, 37.696]}\n zoom={12}\n minZoom={10}\n maxZoom={16}\n styles={{\n light: \"https://tiles.openfreemap.org/styles/bright\",\n dark: \"https://tiles.openfreemap.org/styles/dark\",\n }}\n >\n <MapRoute\n id=\"delivery-full-route\"\n coordinates={routeData?.coordinates ?? []}\n color=\"#5b6572\"\n width={5.2}\n opacity={0.3}\n interactive={false}\n />\n <MapRoute\n id=\"delivery-progress-route\"\n coordinates={progressCoordinates}\n color=\"#3b82f6\"\n width={6}\n opacity={0.95}\n interactive={false}\n />\n\n {courierPosition && (\n <MapMarker\n longitude={courierPosition[0]}\n latitude={courierPosition[1]}\n offset={[0, 10]}\n >\n <MarkerContent>\n <div className=\"relative grid size-9 place-items-center rounded-full bg-emerald-500 dark:bg-emerald-600\">\n <Truck className=\"size-4 text-white\" />\n </div>\n </MarkerContent>\n <MarkerTooltip>\n <div className=\"space-y-0.5 text-xs\">\n <p className=\"font-medium\">\n Order {formatDuration(routeData?.duration)} away\n </p>\n <p className=\"text-muted-foreground\">\n Route {formatDistance(routeData?.distance)}\n </p>\n </div>\n </MarkerTooltip>\n </MapMarker>\n )}\n\n <MapMarker longitude={pickup.lng} latitude={pickup.lat}>\n <MarkerContent>\n <div className=\"size-4 rounded-full border-2 border-white bg-emerald-500 shadow-sm\" />\n </MarkerContent>\n <MarkerTooltip>\n <p className=\"text-xs font-medium\">Origin</p>\n </MarkerTooltip>\n </MapMarker>\n\n <MapMarker longitude={dropoff.lng} latitude={dropoff.lat}>\n <MarkerContent>\n <div className=\"size-4 rounded-full border-2 border-white bg-rose-500 shadow-sm\" />\n </MarkerContent>\n <MarkerTooltip>\n <p className=\"text-xs font-medium\">Destination</p>\n </MarkerTooltip>\n </MapMarker>\n </Map>\n </div>\n </div>\n </div>\n );\n}\n",
+ "type": "registry:page",
+ "target": "app/delivery/page.tsx"
+ }
+ ],
+ "meta": {
+ "iframeHeight": "680px"
+ },
+ "categories": [
+ "tracking",
+ "delivery"
+ ],
+ "type": "registry:block"
+}
\ No newline at end of file
diff --git a/public/r/heatmap.json b/public/r/heatmap.json
new file mode 100644
index 0000000..3855ebe
--- /dev/null
+++ b/public/r/heatmap.json
@@ -0,0 +1,24 @@
+{
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
+ "name": "heatmap",
+ "title": "Heatmap",
+ "description": "Globe-projected heatmap visualizing earthquake density with zoom-dependent styling.",
+ "dependencies": [],
+ "registryDependencies": [
+ "map",
+ "card"
+ ],
+ "files": [
+ {
+ "path": "src/registry/blocks/heatmap/page.tsx",
+ "content": "\"use client\";\n\nimport { useEffect, useId } from \"react\";\n\nimport { Map, useMap } from \"@/registry/map\";\nimport { Card, CardContent, CardHeader, CardTitle } from \"@/components/ui/card\";\n\nconst EARTHQUAKE_GEOJSON_URL =\n \"https://maplibre.org/maplibre-gl-js/docs/assets/earthquakes.geojson\";\n\nconst HEATMAP_GRADIENT_COLORS = [\n \"#fff7bc\",\n \"#fee391\",\n \"#fec44f\",\n \"#fe9929\",\n \"#d7301f\",\n];\n\nconst HEATMAP_COLOR_STOPS: [number, string][] = [\n [0.15, HEATMAP_GRADIENT_COLORS[0]],\n [0.35, HEATMAP_GRADIENT_COLORS[1]],\n [0.55, HEATMAP_GRADIENT_COLORS[2]],\n [0.75, HEATMAP_GRADIENT_COLORS[3]],\n [1, HEATMAP_GRADIENT_COLORS[4]],\n];\n\nfunction GlobeHeatmapLayers() {\n const { map, isLoaded } = useMap();\n const id = useId();\n const sourceId = `heatmap-source-${id}`;\n const heatLayerId = `heatmap-layer-${id}`;\n const pointLayerId = `heatmap-point-layer-${id}`;\n\n useEffect(() => {\n if (!map || !isLoaded) return;\n\n if (!map.getSource(sourceId)) {\n map.addSource(sourceId, {\n type: \"geojson\",\n data: EARTHQUAKE_GEOJSON_URL,\n });\n }\n\n if (!map.getLayer(heatLayerId)) {\n map.addLayer({\n id: heatLayerId,\n type: \"heatmap\",\n source: sourceId,\n maxzoom: 6,\n paint: {\n \"heatmap-weight\": [\n \"interpolate\",\n [\"linear\"],\n [\"get\", \"mag\"],\n 0,\n 0,\n 6,\n 0.8,\n ],\n \"heatmap-intensity\": [\n \"interpolate\",\n [\"linear\"],\n [\"zoom\"],\n 0,\n 0.55,\n 6,\n 1.25,\n ],\n \"heatmap-color\": [\n \"interpolate\",\n [\"linear\"],\n [\"heatmap-density\"],\n 0,\n \"rgba(59, 130, 246, 0)\",\n ...HEATMAP_COLOR_STOPS.flat(),\n ],\n \"heatmap-radius\": [\"interpolate\", [\"linear\"], [\"zoom\"], 0, 8, 6, 34],\n \"heatmap-opacity\": [\n \"interpolate\",\n [\"linear\"],\n [\"zoom\"],\n 4.5,\n 0.75,\n 6.5,\n 0.08,\n ],\n },\n });\n }\n\n if (!map.getLayer(pointLayerId)) {\n map.addLayer({\n id: pointLayerId,\n type: \"circle\",\n source: sourceId,\n minzoom: 4.5,\n paint: {\n \"circle-radius\": [\n \"interpolate\",\n [\"linear\"],\n [\"get\", \"mag\"],\n 1,\n 3,\n 6,\n 10,\n ],\n \"circle-color\": [\n \"interpolate\",\n [\"linear\"],\n [\"get\", \"mag\"],\n 1,\n HEATMAP_GRADIENT_COLORS[1],\n 2.5,\n HEATMAP_GRADIENT_COLORS[2],\n 4,\n HEATMAP_GRADIENT_COLORS[3],\n 6,\n HEATMAP_GRADIENT_COLORS[4],\n ],\n \"circle-stroke-width\": 1,\n \"circle-stroke-color\": \"rgba(255,255,255,0.8)\",\n \"circle-opacity\": [\n \"interpolate\",\n [\"linear\"],\n [\"zoom\"],\n 4.5,\n 0,\n 6.5,\n 0.7,\n ],\n },\n });\n }\n\n return () => {\n try {\n if (map.getLayer(pointLayerId)) map.removeLayer(pointLayerId);\n if (map.getLayer(heatLayerId)) map.removeLayer(heatLayerId);\n if (map.getSource(sourceId)) map.removeSource(sourceId);\n } catch {\n // ignore\n }\n };\n }, [map, isLoaded, sourceId, heatLayerId, pointLayerId]);\n\n return null;\n}\n\nexport function HeatmapBlock() {\n return (\n <div className=\"bg-muted/50 relative h-screen\">\n <div className=\"relative h-full\">\n <Map\n center={[-113, 43]}\n zoom={3.2}\n projection={{ type: \"globe\" }}\n pitch={24}\n minZoom={1.2}\n maxZoom={8}\n >\n <GlobeHeatmapLayers />\n </Map>\n </div>\n\n <Card className=\"absolute top-4 left-4 z-10 w-72\">\n <CardHeader>\n <CardTitle>Global Earthquakes Heatmap</CardTitle>\n </CardHeader>\n <CardContent>\n <div className=\"grid grid-cols-5 gap-1.5\">\n {HEATMAP_GRADIENT_COLORS.map((color) => (\n <span\n key={color}\n className=\"h-2.5 rounded-full\"\n style={{ backgroundColor: color }}\n />\n ))}\n </div>\n <div className=\"text-muted-foreground flex items-center justify-between pt-3 text-xs\">\n <span>Low</span>\n <span>High</span>\n </div>\n <p className=\"text-muted-foreground pt-2 text-xs\">\n Data source:{\" \"}\n <a\n href={EARTHQUAKE_GEOJSON_URL}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"hover:text-foreground underline underline-offset-4 transition-colors\"\n >\n MapLibre earthquakes.geojson\n </a>\n </p>\n </CardContent>\n </Card>\n </div>\n );\n}\n",
+ "type": "registry:page",
+ "target": "app/heatmap/page.tsx"
+ }
+ ],
+ "categories": [
+ "visualization",
+ "heatmap"
+ ],
+ "type": "registry:block"
+}
\ No newline at end of file
diff --git a/public/r/logistics-network.json b/public/r/logistics-network.json
new file mode 100644
index 0000000..086e32c
--- /dev/null
+++ b/public/r/logistics-network.json
@@ -0,0 +1,55 @@
+{
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
+ "name": "logistics-network",
+ "title": "Logistics Network",
+ "description": "Domestic logistics map with a sidebar of stats.",
+ "dependencies": [
+ "lucide-react"
+ ],
+ "registryDependencies": [
+ "map",
+ "card",
+ "badge",
+ "button"
+ ],
+ "files": [
+ {
+ "path": "src/registry/blocks/logistics-network/page.tsx",
+ "content": "\"use client\";\n\nimport { SidebarInset, SidebarProvider } from \"@/components/ui/sidebar\";\nimport { hubs, routes } from \"./data\";\nimport { FilterSidebar } from \"./components/filter-sidebar\";\nimport { NetworkMap } from \"./components/network-map\";\n\nexport function LogisticsNetworkBlock() {\n return (\n <SidebarProvider>\n <FilterSidebar hubs={hubs} routes={routes} />\n <SidebarInset>\n <NetworkMap hubs={hubs} routes={routes} />\n </SidebarInset>\n </SidebarProvider>\n );\n}\n",
+ "type": "registry:page",
+ "target": "app/logistics/page.tsx"
+ },
+ {
+ "path": "src/registry/blocks/logistics-network/data.ts",
+ "content": "export interface Hub {\n id: string;\n city: string;\n lng: number;\n lat: number;\n type: \"primary\" | \"secondary\";\n shipments: number;\n region: \"west\" | \"midwest\" | \"south\" | \"northeast\";\n}\n\nexport interface Route {\n from: string;\n to: string;\n mode: \"air\" | \"ground\";\n shipments: number;\n status: \"active\" | \"delayed\";\n}\n\nexport const hubs: Hub[] = [\n {\n id: \"ord\",\n city: \"Chicago\",\n lng: -87.6298,\n lat: 41.8781,\n type: \"primary\",\n shipments: 1247,\n region: \"midwest\",\n },\n {\n id: \"lax\",\n city: \"Los Angeles\",\n lng: -118.2437,\n lat: 34.0522,\n type: \"primary\",\n shipments: 1102,\n region: \"west\",\n },\n {\n id: \"jfk\",\n city: \"New York\",\n lng: -73.9352,\n lat: 40.6413,\n type: \"primary\",\n shipments: 983,\n region: \"northeast\",\n },\n {\n id: \"dfw\",\n city: \"Dallas\",\n lng: -96.797,\n lat: 32.8968,\n type: \"primary\",\n shipments: 856,\n region: \"south\",\n },\n {\n id: \"atl\",\n city: \"Atlanta\",\n lng: -84.4281,\n lat: 33.6407,\n type: \"primary\",\n shipments: 914,\n region: \"south\",\n },\n {\n id: \"den\",\n city: \"Denver\",\n lng: -104.6731,\n lat: 39.8617,\n type: \"secondary\",\n shipments: 634,\n region: \"west\",\n },\n {\n id: \"sea\",\n city: \"Seattle\",\n lng: -122.3321,\n lat: 47.6062,\n type: \"secondary\",\n shipments: 723,\n region: \"west\",\n },\n {\n id: \"mia\",\n city: \"Miami\",\n lng: -80.1918,\n lat: 25.7617,\n type: \"secondary\",\n shipments: 478,\n region: \"south\",\n },\n {\n id: \"phx\",\n city: \"Phoenix\",\n lng: -112.074,\n lat: 33.4484,\n type: \"secondary\",\n shipments: 512,\n region: \"west\",\n },\n {\n id: \"iah\",\n city: \"Houston\",\n lng: -95.3698,\n lat: 29.9844,\n type: \"secondary\",\n shipments: 698,\n region: \"south\",\n },\n {\n id: \"bos\",\n city: \"Boston\",\n lng: -71.0054,\n lat: 42.3643,\n type: \"secondary\",\n shipments: 534,\n region: \"northeast\",\n },\n {\n id: \"sfo\",\n city: \"San Francisco\",\n lng: -122.4194,\n lat: 37.7749,\n type: \"secondary\",\n shipments: 789,\n region: \"west\",\n },\n {\n id: \"msp\",\n city: \"Minneapolis\",\n lng: -93.2219,\n lat: 44.8848,\n type: \"secondary\",\n shipments: 423,\n region: \"midwest\",\n },\n {\n id: \"dtw\",\n city: \"Detroit\",\n lng: -83.0458,\n lat: 42.2162,\n type: \"secondary\",\n shipments: 456,\n region: \"midwest\",\n },\n {\n id: \"slc\",\n city: \"Salt Lake City\",\n lng: -111.978,\n lat: 40.758,\n type: \"secondary\",\n shipments: 342,\n region: \"west\",\n },\n];\n\nexport const routes: Route[] = [\n { from: \"ord\", to: \"lax\", mode: \"air\", shipments: 234, status: \"active\" },\n { from: \"ord\", to: \"jfk\", mode: \"ground\", shipments: 312, status: \"active\" },\n { from: \"ord\", to: \"dfw\", mode: \"air\", shipments: 189, status: \"active\" },\n { from: \"ord\", to: \"atl\", mode: \"air\", shipments: 213, status: \"active\" },\n { from: \"ord\", to: \"den\", mode: \"ground\", shipments: 156, status: \"active\" },\n { from: \"ord\", to: \"msp\", mode: \"ground\", shipments: 198, status: \"active\" },\n { from: \"ord\", to: \"dtw\", mode: \"ground\", shipments: 167, status: \"delayed\" },\n { from: \"lax\", to: \"sfo\", mode: \"ground\", shipments: 245, status: \"active\" },\n { from: \"lax\", to: \"sea\", mode: \"air\", shipments: 178, status: \"active\" },\n { from: \"lax\", to: \"den\", mode: \"air\", shipments: 198, status: \"active\" },\n { from: \"lax\", to: \"phx\", mode: \"ground\", shipments: 212, status: \"active\" },\n { from: \"lax\", to: \"dfw\", mode: \"air\", shipments: 223, status: \"active\" },\n { from: \"jfk\", to: \"atl\", mode: \"air\", shipments: 267, status: \"active\" },\n { from: \"jfk\", to: \"mia\", mode: \"air\", shipments: 234, status: \"active\" },\n { from: \"jfk\", to: \"bos\", mode: \"ground\", shipments: 189, status: \"active\" },\n { from: \"jfk\", to: \"ord\", mode: \"air\", shipments: 278, status: \"active\" },\n { from: \"dfw\", to: \"atl\", mode: \"air\", shipments: 198, status: \"active\" },\n { from: \"dfw\", to: \"iah\", mode: \"ground\", shipments: 245, status: \"active\" },\n { from: \"dfw\", to: \"den\", mode: \"air\", shipments: 167, status: \"active\" },\n { from: \"dfw\", to: \"phx\", mode: \"ground\", shipments: 156, status: \"delayed\" },\n { from: \"atl\", to: \"mia\", mode: \"ground\", shipments: 234, status: \"active\" },\n { from: \"atl\", to: \"iah\", mode: \"air\", shipments: 189, status: \"active\" },\n { from: \"den\", to: \"sea\", mode: \"air\", shipments: 178, status: \"active\" },\n { from: \"den\", to: \"slc\", mode: \"ground\", shipments: 198, status: \"active\" },\n { from: \"den\", to: \"phx\", mode: \"air\", shipments: 167, status: \"active\" },\n { from: \"sea\", to: \"sfo\", mode: \"air\", shipments: 212, status: \"active\" },\n { from: \"sfo\", to: \"phx\", mode: \"air\", shipments: 156, status: \"active\" },\n { from: \"mia\", to: \"iah\", mode: \"air\", shipments: 198, status: \"active\" },\n { from: \"msp\", to: \"ord\", mode: \"ground\", shipments: 189, status: \"active\" },\n { from: \"msp\", to: \"den\", mode: \"air\", shipments: 145, status: \"active\" },\n { from: \"dtw\", to: \"ord\", mode: \"ground\", shipments: 167, status: \"active\" },\n { from: \"dtw\", to: \"jfk\", mode: \"air\", shipments: 178, status: \"active\" },\n { from: \"bos\", to: \"jfk\", mode: \"ground\", shipments: 156, status: \"active\" },\n { from: \"slc\", to: \"den\", mode: \"ground\", shipments: 134, status: \"active\" },\n { from: \"slc\", to: \"phx\", mode: \"air\", shipments: 123, status: \"delayed\" },\n { from: \"ord\", to: \"sfo\", mode: \"air\", shipments: 198, status: \"active\" },\n { from: \"ord\", to: \"mia\", mode: \"air\", shipments: 245, status: \"active\" },\n { from: \"lax\", to: \"atl\", mode: \"air\", shipments: 289, status: \"active\" },\n { from: \"jfk\", to: \"dfw\", mode: \"air\", shipments: 234, status: \"active\" },\n { from: \"atl\", to: \"ord\", mode: \"air\", shipments: 267, status: \"active\" },\n { from: \"sfo\", to: \"den\", mode: \"air\", shipments: 189, status: \"active\" },\n];\n\nexport const modeConfig = {\n air: { color: \"#3b82f6\", label: \"Air\" },\n ground: { color: \"#22c55e\", label: \"Ground\" },\n} as const;\n\nexport const statusConfig = {\n active: { color: \"#10b981\", label: \"Active\" },\n delayed: { color: \"#f59e0b\", label: \"Delayed\" },\n} as const;\n\nexport const regionLabels: Record<Hub[\"region\"], string> = {\n west: \"West\",\n midwest: \"Midwest\",\n south: \"South\",\n northeast: \"Northeast\",\n};\n",
+ "type": "registry:component",
+ "target": "app/logistics/data.ts"
+ },
+ {
+ "path": "src/registry/blocks/logistics-network/components/map-arcs.tsx",
+ "content": "\"use client\";\n\nimport { useCallback, useEffect, useMemo } from \"react\";\nimport { useMap } from \"@/registry/map\";\nimport type MapLibreGL from \"maplibre-gl\";\nimport { hubs, modeConfig, statusConfig, type Route } from \"../data\";\n\nconst SOURCE_ID = \"logistics-arcs-source\";\nconst LAYER_ID = \"logistics-arcs-layer\";\n\nfunction generateArc(\n start: [number, number],\n end: [number, number],\n segments = 50,\n): number[][] {\n const [x1, y1] = start;\n const [x2, y2] = end;\n\n const mx = (x1 + x2) / 2;\n const my = (y1 + y2) / 2;\n\n const dx = x2 - x1;\n const dy = y2 - y1;\n const dist = Math.sqrt(dx * dx + dy * dy);\n\n const nx = -dy / dist;\n const ny = dx / dist;\n const height = dist * 0.3;\n\n const cx = mx + nx * height;\n const cy = my + ny * height;\n\n const coords: number[][] = [];\n for (let i = 0; i <= segments; i++) {\n const t = i / segments;\n const px = (1 - t) * (1 - t) * x1 + 2 * (1 - t) * t * cx + t * t * x2;\n const py = (1 - t) * (1 - t) * y1 + 2 * (1 - t) * t * cy + t * t * y2;\n coords.push([px, py]);\n }\n return coords;\n}\n\nfunction getHubById(id: string) {\n return hubs.find((h) => h.id === id)!;\n}\n\ninterface MapArcsProps {\n routes: Route[];\n}\n\nexport function MapArcs({ routes: arcRoutes }: MapArcsProps) {\n const { map, isLoaded } = useMap();\n\n const geoJSON = useMemo<GeoJSON.FeatureCollection>(() => {\n const features: GeoJSON.Feature[] = arcRoutes.map((route) => {\n const fromHub = getHubById(route.from);\n const toHub = getHubById(route.to);\n const coordinates = generateArc(\n [fromHub.lng, fromHub.lat],\n [toHub.lng, toHub.lat],\n );\n return {\n type: \"Feature\" as const,\n properties: {\n id: `${route.from}-${route.to}`,\n mode: route.mode,\n status: route.status,\n color:\n route.status === \"delayed\"\n ? statusConfig.delayed.color\n : modeConfig[route.mode].color,\n },\n geometry: {\n type: \"LineString\" as const,\n coordinates,\n },\n };\n });\n return { type: \"FeatureCollection\", features };\n }, [arcRoutes]);\n\n const addLayer = useCallback(() => {\n if (!map) return;\n\n if (!map.getSource(SOURCE_ID)) {\n map.addSource(SOURCE_ID, { type: \"geojson\", data: geoJSON });\n map.addLayer({\n id: LAYER_ID,\n type: \"line\",\n source: SOURCE_ID,\n layout: { \"line-join\": \"round\", \"line-cap\": \"round\" },\n paint: {\n \"line-color\": [\"get\", \"color\"],\n \"line-width\": 2,\n \"line-opacity\": 0.65,\n },\n });\n } else {\n (map.getSource(SOURCE_ID) as MapLibreGL.GeoJSONSource).setData(geoJSON);\n }\n }, [map, geoJSON]);\n\n useEffect(() => {\n if (!map || !isLoaded) return;\n\n addLayer();\n\n return () => {\n try {\n if (map.getLayer(LAYER_ID)) map.removeLayer(LAYER_ID);\n if (map.getSource(SOURCE_ID)) map.removeSource(SOURCE_ID);\n } catch {\n // ignore\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [map, isLoaded]);\n\n useEffect(() => {\n if (!map || !isLoaded) return;\n const source = map.getSource(SOURCE_ID) as MapLibreGL.GeoJSONSource;\n if (source) source.setData(geoJSON);\n }, [map, isLoaded, geoJSON]);\n\n return null;\n}\n",
+ "type": "registry:component",
+ "target": "app/logistics/components/map-arcs.tsx"
+ },
+ {
+ "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",
+ "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 {\n Map,\n MapControls,\n MapMarker,\n MarkerContent,\n MarkerTooltip,\n} from \"@/registry/map\";\nimport { SidebarTrigger } from \"@/components/ui/sidebar\";\nimport {\n modeConfig,\n regionLabels,\n statusConfig,\n type Hub,\n type Route,\n} from \"../data\";\nimport { MapArcs } from \"./map-arcs\";\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 return (\n <div className=\"relative h-full\">\n <MapControlsCard />\n\n <Map center={[-98, 39]} zoom={4} projection={{ type: \"globe\" }}>\n <MapControls />\n <MapArcs routes={routes} />\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.5\">·</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"
+ }
+ ],
+ "meta": {
+ "iframeHeight": "800px"
+ },
+ "categories": [
+ "logistics",
+ "network"
+ ],
+ "type": "registry:block"
+}
\ No newline at end of file
diff --git a/public/r/map.json b/public/r/map.json
index 76884c9..9e3daaf 100644
--- a/public/r/map.json
+++ b/public/r/map.json
@@ -11,7 +11,7 @@
"files": [
{
"path": "src/registry/map.tsx",
- "content": "\"use client\";\n\nimport MapLibreGL, { type PopupOptions, type MarkerOptions } from \"maplibre-gl\";\nimport \"maplibre-gl/dist/maplibre-gl.css\";\nimport {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useId,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { X, Minus, Plus, Locate, Maximize, Loader2 } from \"lucide-react\";\n\nimport { cn } from \"@/lib/utils\";\n\nconst defaultStyles = {\n dark: \"https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json\",\n light: \"https://basemaps.cartocdn.com/gl/positron-gl-style/style.json\",\n};\n\ntype Theme = \"light\" | \"dark\";\n\n// Check document class for theme (works with next-themes, etc.)\nfunction getDocumentTheme(): Theme | null {\n if (typeof document === \"undefined\") return null;\n if (document.documentElement.classList.contains(\"dark\")) return \"dark\";\n if (document.documentElement.classList.contains(\"light\")) return \"light\";\n return null;\n}\n\n// Get system preference\nfunction getSystemTheme(): Theme {\n if (typeof window === \"undefined\") return \"light\";\n return window.matchMedia(\"(prefers-color-scheme: dark)\").matches\n ? \"dark\"\n : \"light\";\n}\n\nfunction useResolvedTheme(themeProp?: \"light\" | \"dark\"): Theme {\n const [detectedTheme, setDetectedTheme] = useState<Theme>(\n () => getDocumentTheme() ?? getSystemTheme()\n );\n\n useEffect(() => {\n if (themeProp) return; // Skip detection if theme is provided via prop\n\n // Watch for document class changes (e.g., next-themes toggling dark class)\n const observer = new MutationObserver(() => {\n const docTheme = getDocumentTheme();\n if (docTheme) {\n setDetectedTheme(docTheme);\n }\n });\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: [\"class\"],\n });\n\n // Also watch for system preference changes\n const mediaQuery = window.matchMedia(\"(prefers-color-scheme: dark)\");\n const handleSystemChange = (e: MediaQueryListEvent) => {\n // Only use system preference if no document class is set\n if (!getDocumentTheme()) {\n setDetectedTheme(e.matches ? \"dark\" : \"light\");\n }\n };\n mediaQuery.addEventListener(\"change\", handleSystemChange);\n\n return () => {\n observer.disconnect();\n mediaQuery.removeEventListener(\"change\", handleSystemChange);\n };\n }, [themeProp]);\n\n return themeProp ?? detectedTheme;\n}\n\ntype MapContextValue = {\n map: MapLibreGL.Map | null;\n isLoaded: boolean;\n};\n\nconst MapContext = createContext<MapContextValue | null>(null);\n\nfunction useMap() {\n const context = useContext(MapContext);\n if (!context) {\n throw new Error(\"useMap must be used within a Map component\");\n }\n return context;\n}\n\n/** Map viewport state */\ntype MapViewport = {\n /** Center coordinates [longitude, latitude] */\n center: [number, number];\n /** Zoom level */\n zoom: number;\n /** Bearing (rotation) in degrees */\n bearing: number;\n /** Pitch (tilt) in degrees */\n pitch: number;\n};\n\ntype MapStyleOption = string | MapLibreGL.StyleSpecification;\n\ntype MapRef = MapLibreGL.Map;\n\ntype MapProps = {\n children?: ReactNode;\n /** Additional CSS classes for the map container */\n className?: string;\n /**\n * Theme for the map. If not provided, automatically detects system preference.\n * Pass your theme value here.\n */\n theme?: Theme;\n /** Custom map styles for light and dark themes. Overrides the default Carto styles. */\n styles?: {\n light?: MapStyleOption;\n dark?: MapStyleOption;\n };\n /** Map projection type. Use `{ type: \"globe\" }` for 3D globe view. */\n projection?: MapLibreGL.ProjectionSpecification;\n /**\n * Controlled viewport. When provided with onViewportChange,\n * the map becomes controlled and viewport is driven by this prop.\n */\n viewport?: Partial<MapViewport>;\n /**\n * Callback fired continuously as the viewport changes (pan, zoom, rotate, pitch).\n * Can be used standalone to observe changes, or with `viewport` prop\n * to enable controlled mode where the map viewport is driven by your state.\n */\n onViewportChange?: (viewport: MapViewport) => void;\n} & Omit<MapLibreGL.MapOptions, \"container\" | \"style\">;\n\nfunction DefaultLoader() {\n return (\n <div className=\"absolute inset-0 flex items-center justify-center\">\n <div className=\"flex gap-1\">\n <span className=\"size-1.5 rounded-full bg-muted-foreground/60 animate-pulse\" />\n <span className=\"size-1.5 rounded-full bg-muted-foreground/60 animate-pulse [animation-delay:150ms]\" />\n <span className=\"size-1.5 rounded-full bg-muted-foreground/60 animate-pulse [animation-delay:300ms]\" />\n </div>\n </div>\n );\n}\n\nfunction getViewport(map: MapLibreGL.Map): MapViewport {\n const center = map.getCenter();\n return {\n center: [center.lng, center.lat],\n zoom: map.getZoom(),\n bearing: map.getBearing(),\n pitch: map.getPitch(),\n };\n}\n\nconst Map = forwardRef<MapRef, MapProps>(function Map(\n {\n children,\n className,\n theme: themeProp,\n styles,\n projection,\n viewport,\n onViewportChange,\n ...props\n },\n ref\n) {\n const containerRef = useRef<HTMLDivElement>(null);\n const [mapInstance, setMapInstance] = useState<MapLibreGL.Map | null>(null);\n const [isLoaded, setIsLoaded] = useState(false);\n const [isStyleLoaded, setIsStyleLoaded] = useState(false);\n const currentStyleRef = useRef<MapStyleOption | null>(null);\n const styleTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const internalUpdateRef = useRef(false);\n const resolvedTheme = useResolvedTheme(themeProp);\n\n const isControlled = viewport !== undefined && onViewportChange !== undefined;\n\n const onViewportChangeRef = useRef(onViewportChange);\n onViewportChangeRef.current = onViewportChange;\n\n const mapStyles = useMemo(\n () => ({\n dark: styles?.dark ?? defaultStyles.dark,\n light: styles?.light ?? defaultStyles.light,\n }),\n [styles]\n );\n\n // Expose the map instance to the parent component\n useImperativeHandle(ref, () => mapInstance as MapLibreGL.Map, [mapInstance]);\n\n const clearStyleTimeout = useCallback(() => {\n if (styleTimeoutRef.current) {\n clearTimeout(styleTimeoutRef.current);\n styleTimeoutRef.current = null;\n }\n }, []);\n\n // Initialize the map\n useEffect(() => {\n if (!containerRef.current) return;\n\n const initialStyle =\n resolvedTheme === \"dark\" ? mapStyles.dark : mapStyles.light;\n currentStyleRef.current = initialStyle;\n\n const map = new MapLibreGL.Map({\n container: containerRef.current,\n style: initialStyle,\n renderWorldCopies: false,\n attributionControl: {\n compact: true,\n },\n ...props,\n ...viewport,\n });\n\n const styleDataHandler = () => {\n clearStyleTimeout();\n // Delay to ensure style is fully processed before allowing layer operations\n // This is a workaround to avoid race conditions with the style loading\n // else we have to force update every layer on setStyle change\n styleTimeoutRef.current = setTimeout(() => {\n setIsStyleLoaded(true);\n if (projection) {\n map.setProjection(projection);\n }\n }, 100);\n };\n const loadHandler = () => setIsLoaded(true);\n\n // Viewport change handler - skip if triggered by internal update\n const handleMove = () => {\n if (internalUpdateRef.current) return;\n onViewportChangeRef.current?.(getViewport(map));\n };\n\n map.on(\"load\", loadHandler);\n map.on(\"styledata\", styleDataHandler);\n map.on(\"move\", handleMove);\n setMapInstance(map);\n\n return () => {\n clearStyleTimeout();\n map.off(\"load\", loadHandler);\n map.off(\"styledata\", styleDataHandler);\n map.off(\"move\", handleMove);\n map.remove();\n setIsLoaded(false);\n setIsStyleLoaded(false);\n setMapInstance(null);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // Sync controlled viewport to map\n useEffect(() => {\n if (!mapInstance || !isControlled || !viewport) return;\n if (mapInstance.isMoving()) return;\n\n const current = getViewport(mapInstance);\n const next = {\n center: viewport.center ?? current.center,\n zoom: viewport.zoom ?? current.zoom,\n bearing: viewport.bearing ?? current.bearing,\n pitch: viewport.pitch ?? current.pitch,\n };\n\n if (\n next.center[0] === current.center[0] &&\n next.center[1] === current.center[1] &&\n next.zoom === current.zoom &&\n next.bearing === current.bearing &&\n next.pitch === current.pitch\n ) {\n return;\n }\n\n internalUpdateRef.current = true;\n mapInstance.jumpTo(next);\n internalUpdateRef.current = false;\n }, [mapInstance, isControlled, viewport]);\n\n // Handle style change\n useEffect(() => {\n if (!mapInstance || !resolvedTheme) return;\n\n const newStyle =\n resolvedTheme === \"dark\" ? mapStyles.dark : mapStyles.light;\n\n if (currentStyleRef.current === newStyle) return;\n\n clearStyleTimeout();\n currentStyleRef.current = newStyle;\n setIsStyleLoaded(false);\n\n mapInstance.setStyle(newStyle, { diff: true });\n }, [mapInstance, resolvedTheme, mapStyles, clearStyleTimeout]);\n\n const contextValue = useMemo(\n () => ({\n map: mapInstance,\n isLoaded: isLoaded && isStyleLoaded,\n }),\n [mapInstance, isLoaded, isStyleLoaded]\n );\n\n return (\n <MapContext.Provider value={contextValue}>\n <div\n ref={containerRef}\n className={cn(\"relative w-full h-full\", className)}\n >\n {!isLoaded && <DefaultLoader />}\n {/* SSR-safe: children render only when map is loaded on client */}\n {mapInstance && children}\n </div>\n </MapContext.Provider>\n );\n});\n\ntype MarkerContextValue = {\n marker: MapLibreGL.Marker;\n map: MapLibreGL.Map | null;\n};\n\nconst MarkerContext = createContext<MarkerContextValue | null>(null);\n\nfunction useMarkerContext() {\n const context = useContext(MarkerContext);\n if (!context) {\n throw new Error(\"Marker components must be used within MapMarker\");\n }\n return context;\n}\n\ntype MapMarkerProps = {\n /** Longitude coordinate for marker position */\n longitude: number;\n /** Latitude coordinate for marker position */\n latitude: number;\n /** Marker subcomponents (MarkerContent, MarkerPopup, MarkerTooltip, MarkerLabel) */\n children: ReactNode;\n /** Callback when marker is clicked */\n onClick?: (e: MouseEvent) => void;\n /** Callback when mouse enters marker */\n onMouseEnter?: (e: MouseEvent) => void;\n /** Callback when mouse leaves marker */\n onMouseLeave?: (e: MouseEvent) => void;\n /** Callback when marker drag starts (requires draggable: true) */\n onDragStart?: (lngLat: { lng: number; lat: number }) => void;\n /** Callback during marker drag (requires draggable: true) */\n onDrag?: (lngLat: { lng: number; lat: number }) => void;\n /** Callback when marker drag ends (requires draggable: true) */\n onDragEnd?: (lngLat: { lng: number; lat: number }) => void;\n} & Omit<MarkerOptions, \"element\">;\n\nfunction MapMarker({\n longitude,\n latitude,\n children,\n onClick,\n onMouseEnter,\n onMouseLeave,\n onDragStart,\n onDrag,\n onDragEnd,\n draggable = false,\n ...markerOptions\n}: MapMarkerProps) {\n const { map } = useMap();\n\n const callbacksRef = useRef({\n onClick,\n onMouseEnter,\n onMouseLeave,\n onDragStart,\n onDrag,\n onDragEnd,\n });\n callbacksRef.current = {\n onClick,\n onMouseEnter,\n onMouseLeave,\n onDragStart,\n onDrag,\n onDragEnd,\n };\n\n const marker = useMemo(() => {\n const markerInstance = new MapLibreGL.Marker({\n ...markerOptions,\n element: document.createElement(\"div\"),\n draggable,\n }).setLngLat([longitude, latitude]);\n\n const handleClick = (e: MouseEvent) => callbacksRef.current.onClick?.(e);\n const handleMouseEnter = (e: MouseEvent) =>\n callbacksRef.current.onMouseEnter?.(e);\n const handleMouseLeave = (e: MouseEvent) =>\n callbacksRef.current.onMouseLeave?.(e);\n\n markerInstance.getElement()?.addEventListener(\"click\", handleClick);\n markerInstance\n .getElement()\n ?.addEventListener(\"mouseenter\", handleMouseEnter);\n markerInstance\n .getElement()\n ?.addEventListener(\"mouseleave\", handleMouseLeave);\n\n const handleDragStart = () => {\n const lngLat = markerInstance.getLngLat();\n callbacksRef.current.onDragStart?.({ lng: lngLat.lng, lat: lngLat.lat });\n };\n const handleDrag = () => {\n const lngLat = markerInstance.getLngLat();\n callbacksRef.current.onDrag?.({ lng: lngLat.lng, lat: lngLat.lat });\n };\n const handleDragEnd = () => {\n const lngLat = markerInstance.getLngLat();\n callbacksRef.current.onDragEnd?.({ lng: lngLat.lng, lat: lngLat.lat });\n };\n\n markerInstance.on(\"dragstart\", handleDragStart);\n markerInstance.on(\"drag\", handleDrag);\n markerInstance.on(\"dragend\", handleDragEnd);\n\n return markerInstance;\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n if (!map) return;\n\n marker.addTo(map);\n\n return () => {\n marker.remove();\n };\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [map]);\n\n if (\n marker.getLngLat().lng !== longitude ||\n marker.getLngLat().lat !== latitude\n ) {\n marker.setLngLat([longitude, latitude]);\n }\n if (marker.isDraggable() !== draggable) {\n marker.setDraggable(draggable);\n }\n\n const currentOffset = marker.getOffset();\n const newOffset = markerOptions.offset ?? [0, 0];\n const [newOffsetX, newOffsetY] = Array.isArray(newOffset)\n ? newOffset\n : [newOffset.x, newOffset.y];\n if (currentOffset.x !== newOffsetX || currentOffset.y !== newOffsetY) {\n marker.setOffset(newOffset);\n }\n\n if (marker.getRotation() !== markerOptions.rotation) {\n marker.setRotation(markerOptions.rotation ?? 0);\n }\n if (marker.getRotationAlignment() !== markerOptions.rotationAlignment) {\n marker.setRotationAlignment(markerOptions.rotationAlignment ?? \"auto\");\n }\n if (marker.getPitchAlignment() !== markerOptions.pitchAlignment) {\n marker.setPitchAlignment(markerOptions.pitchAlignment ?? \"auto\");\n }\n\n return (\n <MarkerContext.Provider value={{ marker, map }}>\n {children}\n </MarkerContext.Provider>\n );\n}\n\ntype MarkerContentProps = {\n /** Custom marker content. Defaults to a blue dot if not provided */\n children?: ReactNode;\n /** Additional CSS classes for the marker container */\n className?: string;\n};\n\nfunction MarkerContent({ children, className }: MarkerContentProps) {\n const { marker } = useMarkerContext();\n\n return createPortal(\n <div className={cn(\"relative cursor-pointer\", className)}>\n {children || <DefaultMarkerIcon />}\n </div>,\n marker.getElement()\n );\n}\n\nfunction DefaultMarkerIcon() {\n return (\n <div className=\"relative h-4 w-4 rounded-full border-2 border-white bg-blue-500 shadow-lg\" />\n );\n}\n\ntype MarkerPopupProps = {\n /** Popup content */\n children: ReactNode;\n /** Additional CSS classes for the popup container */\n className?: string;\n /** Show a close button in the popup (default: false) */\n closeButton?: boolean;\n} & Omit<PopupOptions, \"className\" | \"closeButton\">;\n\nfunction MarkerPopup({\n children,\n className,\n closeButton = false,\n ...popupOptions\n}: MarkerPopupProps) {\n const { marker, map } = useMarkerContext();\n const container = useMemo(() => document.createElement(\"div\"), []);\n const prevPopupOptions = useRef(popupOptions);\n\n const popup = useMemo(() => {\n const popupInstance = new MapLibreGL.Popup({\n offset: 16,\n ...popupOptions,\n closeButton: false,\n })\n .setMaxWidth(\"none\")\n .setDOMContent(container);\n\n return popupInstance;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n if (!map) return;\n\n popup.setDOMContent(container);\n marker.setPopup(popup);\n\n return () => {\n marker.setPopup(null);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [map]);\n\n if (popup.isOpen()) {\n const prev = prevPopupOptions.current;\n\n if (prev.offset !== popupOptions.offset) {\n popup.setOffset(popupOptions.offset ?? 16);\n }\n if (prev.maxWidth !== popupOptions.maxWidth && popupOptions.maxWidth) {\n popup.setMaxWidth(popupOptions.maxWidth ?? \"none\");\n }\n\n prevPopupOptions.current = popupOptions;\n }\n\n const handleClose = () => popup.remove();\n\n return createPortal(\n <div\n className={cn(\n \"relative rounded-md border bg-popover p-3 text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95\",\n className\n )}\n >\n {closeButton && (\n <button\n type=\"button\"\n onClick={handleClose}\n className=\"absolute top-1 right-1 z-10 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2\"\n aria-label=\"Close popup\"\n >\n <X className=\"h-4 w-4\" />\n <span className=\"sr-only\">Close</span>\n </button>\n )}\n {children}\n </div>,\n container\n );\n}\n\ntype MarkerTooltipProps = {\n /** Tooltip content */\n children: ReactNode;\n /** Additional CSS classes for the tooltip container */\n className?: string;\n} & Omit<PopupOptions, \"className\" | \"closeButton\" | \"closeOnClick\">;\n\nfunction MarkerTooltip({\n children,\n className,\n ...popupOptions\n}: MarkerTooltipProps) {\n const { marker, map } = useMarkerContext();\n const container = useMemo(() => document.createElement(\"div\"), []);\n const prevTooltipOptions = useRef(popupOptions);\n\n const tooltip = useMemo(() => {\n const tooltipInstance = new MapLibreGL.Popup({\n offset: 16,\n ...popupOptions,\n closeOnClick: true,\n closeButton: false,\n }).setMaxWidth(\"none\");\n\n return tooltipInstance;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n if (!map) return;\n\n tooltip.setDOMContent(container);\n\n const handleMouseEnter = () => {\n tooltip.setLngLat(marker.getLngLat()).addTo(map);\n };\n const handleMouseLeave = () => tooltip.remove();\n\n marker.getElement()?.addEventListener(\"mouseenter\", handleMouseEnter);\n marker.getElement()?.addEventListener(\"mouseleave\", handleMouseLeave);\n\n return () => {\n marker.getElement()?.removeEventListener(\"mouseenter\", handleMouseEnter);\n marker.getElement()?.removeEventListener(\"mouseleave\", handleMouseLeave);\n tooltip.remove();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [map]);\n\n if (tooltip.isOpen()) {\n const prev = prevTooltipOptions.current;\n\n if (prev.offset !== popupOptions.offset) {\n tooltip.setOffset(popupOptions.offset ?? 16);\n }\n if (prev.maxWidth !== popupOptions.maxWidth && popupOptions.maxWidth) {\n tooltip.setMaxWidth(popupOptions.maxWidth ?? \"none\");\n }\n\n prevTooltipOptions.current = popupOptions;\n }\n\n return createPortal(\n <div\n className={cn(\n \"rounded-md bg-foreground px-2 py-1 text-xs text-background shadow-md animate-in fade-in-0 zoom-in-95\",\n className\n )}\n >\n {children}\n </div>,\n container\n );\n}\n\ntype MarkerLabelProps = {\n /** Label text content */\n children: ReactNode;\n /** Additional CSS classes for the label */\n className?: string;\n /** Position of the label relative to the marker (default: \"top\") */\n position?: \"top\" | \"bottom\";\n};\n\nfunction MarkerLabel({\n children,\n className,\n position = \"top\",\n}: MarkerLabelProps) {\n const positionClasses = {\n top: \"bottom-full mb-1\",\n bottom: \"top-full mt-1\",\n };\n\n return (\n <div\n className={cn(\n \"absolute left-1/2 -translate-x-1/2 whitespace-nowrap\",\n \"text-[10px] font-medium text-foreground\",\n positionClasses[position],\n className\n )}\n >\n {children}\n </div>\n );\n}\n\ntype MapControlsProps = {\n /** Position of the controls on the map (default: \"bottom-right\") */\n position?: \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\";\n /** Show zoom in/out buttons (default: true) */\n showZoom?: boolean;\n /** Show compass button to reset bearing (default: false) */\n showCompass?: boolean;\n /** Show locate button to find user's location (default: false) */\n showLocate?: boolean;\n /** Show fullscreen toggle button (default: false) */\n showFullscreen?: boolean;\n /** Additional CSS classes for the controls container */\n className?: string;\n /** Callback with user coordinates when located */\n onLocate?: (coords: { longitude: number; latitude: number }) => void;\n};\n\nconst positionClasses = {\n \"top-left\": \"top-2 left-2\",\n \"top-right\": \"top-2 right-2\",\n \"bottom-left\": \"bottom-2 left-2\",\n \"bottom-right\": \"bottom-10 right-2\",\n};\n\nfunction ControlGroup({ children }: { children: React.ReactNode }) {\n return (\n <div className=\"flex flex-col rounded-md border border-border bg-background shadow-sm overflow-hidden [&>button:not(:last-child)]:border-b [&>button:not(:last-child)]:border-border\">\n {children}\n </div>\n );\n}\n\nfunction ControlButton({\n onClick,\n label,\n children,\n disabled = false,\n}: {\n onClick: () => void;\n label: string;\n children: React.ReactNode;\n disabled?: boolean;\n}) {\n return (\n <button\n onClick={onClick}\n aria-label={label}\n type=\"button\"\n className={cn(\n \"flex items-center justify-center size-8 hover:bg-accent dark:hover:bg-accent/40 transition-colors\",\n disabled && \"opacity-50 pointer-events-none cursor-not-allowed\"\n )}\n disabled={disabled}\n >\n {children}\n </button>\n );\n}\n\nfunction MapControls({\n position = \"bottom-right\",\n showZoom = true,\n showCompass = false,\n showLocate = false,\n showFullscreen = false,\n className,\n onLocate,\n}: MapControlsProps) {\n const { map } = useMap();\n const [waitingForLocation, setWaitingForLocation] = useState(false);\n\n const handleZoomIn = useCallback(() => {\n map?.zoomTo(map.getZoom() + 1, { duration: 300 });\n }, [map]);\n\n const handleZoomOut = useCallback(() => {\n map?.zoomTo(map.getZoom() - 1, { duration: 300 });\n }, [map]);\n\n const handleResetBearing = useCallback(() => {\n map?.resetNorthPitch({ duration: 300 });\n }, [map]);\n\n const handleLocate = useCallback(() => {\n setWaitingForLocation(true);\n if (\"geolocation\" in navigator) {\n navigator.geolocation.getCurrentPosition(\n (pos) => {\n const coords = {\n longitude: pos.coords.longitude,\n latitude: pos.coords.latitude,\n };\n map?.flyTo({\n center: [coords.longitude, coords.latitude],\n zoom: 14,\n duration: 1500,\n });\n onLocate?.(coords);\n setWaitingForLocation(false);\n },\n (error) => {\n console.error(\"Error getting location:\", error);\n setWaitingForLocation(false);\n }\n );\n }\n }, [map, onLocate]);\n\n const handleFullscreen = useCallback(() => {\n const container = map?.getContainer();\n if (!container) return;\n if (document.fullscreenElement) {\n document.exitFullscreen();\n } else {\n container.requestFullscreen();\n }\n }, [map]);\n\n return (\n <div\n className={cn(\n \"absolute z-10 flex flex-col gap-1.5\",\n positionClasses[position],\n className\n )}\n >\n {showZoom && (\n <ControlGroup>\n <ControlButton onClick={handleZoomIn} label=\"Zoom in\">\n <Plus className=\"size-4\" />\n </ControlButton>\n <ControlButton onClick={handleZoomOut} label=\"Zoom out\">\n <Minus className=\"size-4\" />\n </ControlButton>\n </ControlGroup>\n )}\n {showCompass && (\n <ControlGroup>\n <CompassButton onClick={handleResetBearing} />\n </ControlGroup>\n )}\n {showLocate && (\n <ControlGroup>\n <ControlButton\n onClick={handleLocate}\n label=\"Find my location\"\n disabled={waitingForLocation}\n >\n {waitingForLocation ? (\n <Loader2 className=\"size-4 animate-spin\" />\n ) : (\n <Locate className=\"size-4\" />\n )}\n </ControlButton>\n </ControlGroup>\n )}\n {showFullscreen && (\n <ControlGroup>\n <ControlButton onClick={handleFullscreen} label=\"Toggle fullscreen\">\n <Maximize className=\"size-4\" />\n </ControlButton>\n </ControlGroup>\n )}\n </div>\n );\n}\n\nfunction CompassButton({ onClick }: { onClick: () => void }) {\n const { map } = useMap();\n const compassRef = useRef<SVGSVGElement>(null);\n\n useEffect(() => {\n if (!map || !compassRef.current) return;\n\n const compass = compassRef.current;\n\n const updateRotation = () => {\n const bearing = map.getBearing();\n const pitch = map.getPitch();\n compass.style.transform = `rotateX(${pitch}deg) rotateZ(${-bearing}deg)`;\n };\n\n map.on(\"rotate\", updateRotation);\n map.on(\"pitch\", updateRotation);\n updateRotation();\n\n return () => {\n map.off(\"rotate\", updateRotation);\n map.off(\"pitch\", updateRotation);\n };\n }, [map]);\n\n return (\n <ControlButton onClick={onClick} label=\"Reset bearing to north\">\n <svg\n ref={compassRef}\n viewBox=\"0 0 24 24\"\n className=\"size-5 transition-transform duration-200\"\n style={{ transformStyle: \"preserve-3d\" }}\n >\n <path d=\"M12 2L16 12H12V2Z\" className=\"fill-red-500\" />\n <path d=\"M12 2L8 12H12V2Z\" className=\"fill-red-300\" />\n <path d=\"M12 22L16 12H12V22Z\" className=\"fill-muted-foreground/60\" />\n <path d=\"M12 22L8 12H12V22Z\" className=\"fill-muted-foreground/30\" />\n </svg>\n </ControlButton>\n );\n}\n\ntype MapPopupProps = {\n /** Longitude coordinate for popup position */\n longitude: number;\n /** Latitude coordinate for popup position */\n latitude: number;\n /** Callback when popup is closed */\n onClose?: () => void;\n /** Popup content */\n children: ReactNode;\n /** Additional CSS classes for the popup container */\n className?: string;\n /** Show a close button in the popup (default: false) */\n closeButton?: boolean;\n} & Omit<PopupOptions, \"className\" | \"closeButton\">;\n\nfunction MapPopup({\n longitude,\n latitude,\n onClose,\n children,\n className,\n closeButton = false,\n ...popupOptions\n}: MapPopupProps) {\n const { map } = useMap();\n const popupOptionsRef = useRef(popupOptions);\n const onCloseRef = useRef(onClose);\n onCloseRef.current = onClose;\n const container = useMemo(() => document.createElement(\"div\"), []);\n\n const popup = useMemo(() => {\n const popupInstance = new MapLibreGL.Popup({\n offset: 16,\n ...popupOptions,\n closeButton: false,\n })\n .setMaxWidth(\"none\")\n .setLngLat([longitude, latitude]);\n\n return popupInstance;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n if (!map) return;\n\n const onCloseProp = () => onCloseRef.current?.();\n\n popup.on(\"close\", onCloseProp);\n\n popup.setDOMContent(container);\n popup.addTo(map);\n\n return () => {\n popup.off(\"close\", onCloseProp);\n if (popup.isOpen()) {\n popup.remove();\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [map]);\n\n if (popup.isOpen()) {\n const prev = popupOptionsRef.current;\n\n if (\n popup.getLngLat().lng !== longitude ||\n popup.getLngLat().lat !== latitude\n ) {\n popup.setLngLat([longitude, latitude]);\n }\n\n if (prev.offset !== popupOptions.offset) {\n popup.setOffset(popupOptions.offset ?? 16);\n }\n if (prev.maxWidth !== popupOptions.maxWidth && popupOptions.maxWidth) {\n popup.setMaxWidth(popupOptions.maxWidth ?? \"none\");\n }\n popupOptionsRef.current = popupOptions;\n }\n\n const handleClose = () => {\n popup.remove();\n };\n\n return createPortal(\n <div\n className={cn(\n \"relative rounded-md border bg-popover p-3 text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95\",\n className\n )}\n >\n {closeButton && (\n <button\n type=\"button\"\n onClick={handleClose}\n className=\"absolute top-1 right-1 z-10 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2\"\n aria-label=\"Close popup\"\n >\n <X className=\"h-4 w-4\" />\n <span className=\"sr-only\">Close</span>\n </button>\n )}\n {children}\n </div>,\n container\n );\n}\n\ntype MapRouteProps = {\n /** Optional unique identifier for the route layer */\n id?: string;\n /** Array of [longitude, latitude] coordinate pairs defining the route */\n coordinates: [number, number][];\n /** Line color as CSS color value (default: \"#4285F4\") */\n color?: string;\n /** Line width in pixels (default: 3) */\n width?: number;\n /** Line opacity from 0 to 1 (default: 0.8) */\n opacity?: number;\n /** Dash pattern [dash length, gap length] for dashed lines */\n dashArray?: [number, number];\n /** Callback when the route line is clicked */\n onClick?: () => void;\n /** Callback when mouse enters the route line */\n onMouseEnter?: () => void;\n /** Callback when mouse leaves the route line */\n onMouseLeave?: () => void;\n /** Whether the route is interactive - shows pointer cursor on hover (default: true) */\n interactive?: boolean;\n};\n\nfunction MapRoute({\n id: propId,\n coordinates,\n color = \"#4285F4\",\n width = 3,\n opacity = 0.8,\n dashArray,\n onClick,\n onMouseEnter,\n onMouseLeave,\n interactive = true,\n}: MapRouteProps) {\n const { map, isLoaded } = useMap();\n const autoId = useId();\n const id = propId ?? autoId;\n const sourceId = `route-source-${id}`;\n const layerId = `route-layer-${id}`;\n\n // Add source and layer on mount\n useEffect(() => {\n if (!isLoaded || !map) return;\n\n map.addSource(sourceId, {\n type: \"geojson\",\n data: {\n type: \"Feature\",\n properties: {},\n geometry: { type: \"LineString\", coordinates: [] },\n },\n });\n\n map.addLayer({\n id: layerId,\n type: \"line\",\n source: sourceId,\n layout: { \"line-join\": \"round\", \"line-cap\": \"round\" },\n paint: {\n \"line-color\": color,\n \"line-width\": width,\n \"line-opacity\": opacity,\n ...(dashArray && { \"line-dasharray\": dashArray }),\n },\n });\n\n return () => {\n try {\n if (map.getLayer(layerId)) map.removeLayer(layerId);\n if (map.getSource(sourceId)) map.removeSource(sourceId);\n } catch {\n // ignore\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isLoaded, map]);\n\n // When coordinates change, update the source data\n useEffect(() => {\n if (!isLoaded || !map || coordinates.length < 2) return;\n\n const source = map.getSource(sourceId) as MapLibreGL.GeoJSONSource;\n if (source) {\n source.setData({\n type: \"Feature\",\n properties: {},\n geometry: { type: \"LineString\", coordinates },\n });\n }\n }, [isLoaded, map, coordinates, sourceId]);\n\n useEffect(() => {\n if (!isLoaded || !map || !map.getLayer(layerId)) return;\n\n map.setPaintProperty(layerId, \"line-color\", color);\n map.setPaintProperty(layerId, \"line-width\", width);\n map.setPaintProperty(layerId, \"line-opacity\", opacity);\n if (dashArray) {\n map.setPaintProperty(layerId, \"line-dasharray\", dashArray);\n }\n }, [isLoaded, map, layerId, color, width, opacity, dashArray]);\n\n // Handle click and hover events\n useEffect(() => {\n if (!isLoaded || !map || !interactive) return;\n\n const handleClick = () => {\n onClick?.();\n };\n const handleMouseEnter = () => {\n map.getCanvas().style.cursor = \"pointer\";\n onMouseEnter?.();\n };\n const handleMouseLeave = () => {\n map.getCanvas().style.cursor = \"\";\n onMouseLeave?.();\n };\n\n map.on(\"click\", layerId, handleClick);\n map.on(\"mouseenter\", layerId, handleMouseEnter);\n map.on(\"mouseleave\", layerId, handleMouseLeave);\n\n return () => {\n map.off(\"click\", layerId, handleClick);\n map.off(\"mouseenter\", layerId, handleMouseEnter);\n map.off(\"mouseleave\", layerId, handleMouseLeave);\n };\n }, [\n isLoaded,\n map,\n layerId,\n onClick,\n onMouseEnter,\n onMouseLeave,\n interactive,\n ]);\n\n return null;\n}\n\ntype MapClusterLayerProps<\n P extends GeoJSON.GeoJsonProperties = GeoJSON.GeoJsonProperties\n> = {\n /** GeoJSON FeatureCollection data or URL to fetch GeoJSON from */\n data: string | GeoJSON.FeatureCollection<GeoJSON.Point, P>;\n /** Maximum zoom level to cluster points on (default: 14) */\n clusterMaxZoom?: number;\n /** Radius of each cluster when clustering points in pixels (default: 50) */\n clusterRadius?: number;\n /** Colors for cluster circles: [small, medium, large] based on point count (default: [\"#22c55e\", \"#eab308\", \"#ef4444\"]) */\n clusterColors?: [string, string, string];\n /** Point count thresholds for color/size steps: [medium, large] (default: [100, 750]) */\n clusterThresholds?: [number, number];\n /** Color for unclustered individual points (default: \"#3b82f6\") */\n pointColor?: string;\n /** Callback when an unclustered point is clicked */\n onPointClick?: (\n feature: GeoJSON.Feature<GeoJSON.Point, P>,\n coordinates: [number, number]\n ) => void;\n /** Callback when a cluster is clicked. If not provided, zooms into the cluster */\n onClusterClick?: (\n clusterId: number,\n coordinates: [number, number],\n pointCount: number\n ) => void;\n};\n\nfunction MapClusterLayer<\n P extends GeoJSON.GeoJsonProperties = GeoJSON.GeoJsonProperties\n>({\n data,\n clusterMaxZoom = 14,\n clusterRadius = 50,\n clusterColors = [\"#22c55e\", \"#eab308\", \"#ef4444\"],\n clusterThresholds = [100, 750],\n pointColor = \"#3b82f6\",\n onPointClick,\n onClusterClick,\n}: MapClusterLayerProps<P>) {\n const { map, isLoaded } = useMap();\n const id = useId();\n const sourceId = `cluster-source-${id}`;\n const clusterLayerId = `clusters-${id}`;\n const clusterCountLayerId = `cluster-count-${id}`;\n const unclusteredLayerId = `unclustered-point-${id}`;\n\n const stylePropsRef = useRef({\n clusterColors,\n clusterThresholds,\n pointColor,\n });\n\n // Add source and layers on mount\n useEffect(() => {\n if (!isLoaded || !map) return;\n\n // Add clustered GeoJSON source\n map.addSource(sourceId, {\n type: \"geojson\",\n data,\n cluster: true,\n clusterMaxZoom,\n clusterRadius,\n });\n\n // Add cluster circles layer\n map.addLayer({\n id: clusterLayerId,\n type: \"circle\",\n source: sourceId,\n filter: [\"has\", \"point_count\"],\n paint: {\n \"circle-color\": [\n \"step\",\n [\"get\", \"point_count\"],\n clusterColors[0],\n clusterThresholds[0],\n clusterColors[1],\n clusterThresholds[1],\n clusterColors[2],\n ],\n \"circle-radius\": [\n \"step\",\n [\"get\", \"point_count\"],\n 20,\n clusterThresholds[0],\n 30,\n clusterThresholds[1],\n 40,\n ],\n \"circle-stroke-width\": 1,\n \"circle-stroke-color\": \"#fff\",\n \"circle-opacity\": 0.85,\n },\n });\n\n // Add cluster count text layer\n map.addLayer({\n id: clusterCountLayerId,\n type: \"symbol\",\n source: sourceId,\n filter: [\"has\", \"point_count\"],\n layout: {\n \"text-field\": \"{point_count_abbreviated}\",\n \"text-font\": [\"Open Sans\"],\n \"text-size\": 12,\n },\n paint: {\n \"text-color\": \"#fff\",\n },\n });\n\n // Add unclustered point layer\n map.addLayer({\n id: unclusteredLayerId,\n type: \"circle\",\n source: sourceId,\n filter: [\"!\", [\"has\", \"point_count\"]],\n paint: {\n \"circle-color\": pointColor,\n \"circle-radius\": 5,\n \"circle-stroke-width\": 2,\n \"circle-stroke-color\": \"#fff\",\n },\n });\n\n return () => {\n try {\n if (map.getLayer(clusterCountLayerId))\n map.removeLayer(clusterCountLayerId);\n if (map.getLayer(unclusteredLayerId))\n map.removeLayer(unclusteredLayerId);\n if (map.getLayer(clusterLayerId)) map.removeLayer(clusterLayerId);\n if (map.getSource(sourceId)) map.removeSource(sourceId);\n } catch {\n // ignore\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isLoaded, map, sourceId]);\n\n // Update source data when data prop changes (only for non-URL data)\n useEffect(() => {\n if (!isLoaded || !map || typeof data === \"string\") return;\n\n const source = map.getSource(sourceId) as MapLibreGL.GeoJSONSource;\n if (source) {\n source.setData(data);\n }\n }, [isLoaded, map, data, sourceId]);\n\n // Update layer styles when props change\n useEffect(() => {\n if (!isLoaded || !map) return;\n\n const prev = stylePropsRef.current;\n const colorsChanged =\n prev.clusterColors !== clusterColors ||\n prev.clusterThresholds !== clusterThresholds;\n\n // Update cluster layer colors and sizes\n if (map.getLayer(clusterLayerId) && colorsChanged) {\n map.setPaintProperty(clusterLayerId, \"circle-color\", [\n \"step\",\n [\"get\", \"point_count\"],\n clusterColors[0],\n clusterThresholds[0],\n clusterColors[1],\n clusterThresholds[1],\n clusterColors[2],\n ]);\n map.setPaintProperty(clusterLayerId, \"circle-radius\", [\n \"step\",\n [\"get\", \"point_count\"],\n 20,\n clusterThresholds[0],\n 30,\n clusterThresholds[1],\n 40,\n ]);\n }\n\n // Update unclustered point layer color\n if (map.getLayer(unclusteredLayerId) && prev.pointColor !== pointColor) {\n map.setPaintProperty(unclusteredLayerId, \"circle-color\", pointColor);\n }\n\n stylePropsRef.current = { clusterColors, clusterThresholds, pointColor };\n }, [\n isLoaded,\n map,\n clusterLayerId,\n unclusteredLayerId,\n clusterColors,\n clusterThresholds,\n pointColor,\n ]);\n\n // Handle click events\n useEffect(() => {\n if (!isLoaded || !map) return;\n\n // Cluster click handler - zoom into cluster\n const handleClusterClick = async (\n e: MapLibreGL.MapMouseEvent & {\n features?: MapLibreGL.MapGeoJSONFeature[];\n }\n ) => {\n const features = map.queryRenderedFeatures(e.point, {\n layers: [clusterLayerId],\n });\n if (!features.length) return;\n\n const feature = features[0];\n const clusterId = feature.properties?.cluster_id as number;\n const pointCount = feature.properties?.point_count as number;\n const coordinates = (feature.geometry as GeoJSON.Point).coordinates as [\n number,\n number\n ];\n\n if (onClusterClick) {\n onClusterClick(clusterId, coordinates, pointCount);\n } else {\n // Default behavior: zoom to cluster expansion zoom\n const source = map.getSource(sourceId) as MapLibreGL.GeoJSONSource;\n const zoom = await source.getClusterExpansionZoom(clusterId);\n map.easeTo({\n center: coordinates,\n zoom,\n });\n }\n };\n\n // Unclustered point click handler\n const handlePointClick = (\n e: MapLibreGL.MapMouseEvent & {\n features?: MapLibreGL.MapGeoJSONFeature[];\n }\n ) => {\n if (!onPointClick || !e.features?.length) return;\n\n const feature = e.features[0];\n const coordinates = (\n feature.geometry as GeoJSON.Point\n ).coordinates.slice() as [number, number];\n\n // Handle world copies\n while (Math.abs(e.lngLat.lng - coordinates[0]) > 180) {\n coordinates[0] += e.lngLat.lng > coordinates[0] ? 360 : -360;\n }\n\n onPointClick(\n feature as unknown as GeoJSON.Feature<GeoJSON.Point, P>,\n coordinates\n );\n };\n\n // Cursor style handlers\n const handleMouseEnterCluster = () => {\n map.getCanvas().style.cursor = \"pointer\";\n };\n const handleMouseLeaveCluster = () => {\n map.getCanvas().style.cursor = \"\";\n };\n const handleMouseEnterPoint = () => {\n if (onPointClick) {\n map.getCanvas().style.cursor = \"pointer\";\n }\n };\n const handleMouseLeavePoint = () => {\n map.getCanvas().style.cursor = \"\";\n };\n\n map.on(\"click\", clusterLayerId, handleClusterClick);\n map.on(\"click\", unclusteredLayerId, handlePointClick);\n map.on(\"mouseenter\", clusterLayerId, handleMouseEnterCluster);\n map.on(\"mouseleave\", clusterLayerId, handleMouseLeaveCluster);\n map.on(\"mouseenter\", unclusteredLayerId, handleMouseEnterPoint);\n map.on(\"mouseleave\", unclusteredLayerId, handleMouseLeavePoint);\n\n return () => {\n map.off(\"click\", clusterLayerId, handleClusterClick);\n map.off(\"click\", unclusteredLayerId, handlePointClick);\n map.off(\"mouseenter\", clusterLayerId, handleMouseEnterCluster);\n map.off(\"mouseleave\", clusterLayerId, handleMouseLeaveCluster);\n map.off(\"mouseenter\", unclusteredLayerId, handleMouseEnterPoint);\n map.off(\"mouseleave\", unclusteredLayerId, handleMouseLeavePoint);\n };\n }, [\n isLoaded,\n map,\n clusterLayerId,\n unclusteredLayerId,\n sourceId,\n onClusterClick,\n onPointClick,\n ]);\n\n return null;\n}\n\nexport {\n Map,\n useMap,\n MapMarker,\n MarkerContent,\n MarkerPopup,\n MarkerTooltip,\n MarkerLabel,\n MapPopup,\n MapControls,\n MapRoute,\n MapClusterLayer,\n};\n\nexport type { MapRef, MapViewport };\n",
+ "content": "\"use client\";\n\nimport MapLibreGL, { type PopupOptions, type MarkerOptions } from \"maplibre-gl\";\nimport \"maplibre-gl/dist/maplibre-gl.css\";\nimport {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useId,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { X, Minus, Plus, Locate, Maximize, Loader2 } from \"lucide-react\";\n\nimport { cn } from \"@/lib/utils\";\n\nconst defaultStyles = {\n dark: \"https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json\",\n light: \"https://basemaps.cartocdn.com/gl/positron-gl-style/style.json\",\n};\n\ntype Theme = \"light\" | \"dark\";\n\n// Check document class for theme (works with next-themes, etc.)\nfunction getDocumentTheme(): Theme | null {\n if (typeof document === \"undefined\") return null;\n if (document.documentElement.classList.contains(\"dark\")) return \"dark\";\n if (document.documentElement.classList.contains(\"light\")) return \"light\";\n return null;\n}\n\n// Get system preference\nfunction getSystemTheme(): Theme {\n if (typeof window === \"undefined\") return \"light\";\n return window.matchMedia(\"(prefers-color-scheme: dark)\").matches\n ? \"dark\"\n : \"light\";\n}\n\nfunction useResolvedTheme(themeProp?: \"light\" | \"dark\"): Theme {\n const [detectedTheme, setDetectedTheme] = useState<Theme>(\n () => getDocumentTheme() ?? getSystemTheme()\n );\n\n useEffect(() => {\n if (themeProp) return; // Skip detection if theme is provided via prop\n\n // Watch for document class changes (e.g., next-themes toggling dark class)\n const observer = new MutationObserver(() => {\n const docTheme = getDocumentTheme();\n if (docTheme) {\n setDetectedTheme(docTheme);\n }\n });\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: [\"class\"],\n });\n\n // Also watch for system preference changes\n const mediaQuery = window.matchMedia(\"(prefers-color-scheme: dark)\");\n const handleSystemChange = (e: MediaQueryListEvent) => {\n // Only use system preference if no document class is set\n if (!getDocumentTheme()) {\n setDetectedTheme(e.matches ? \"dark\" : \"light\");\n }\n };\n mediaQuery.addEventListener(\"change\", handleSystemChange);\n\n return () => {\n observer.disconnect();\n mediaQuery.removeEventListener(\"change\", handleSystemChange);\n };\n }, [themeProp]);\n\n return themeProp ?? detectedTheme;\n}\n\ntype MapContextValue = {\n map: MapLibreGL.Map | null;\n isLoaded: boolean;\n};\n\nconst MapContext = createContext<MapContextValue | null>(null);\n\nfunction useMap() {\n const context = useContext(MapContext);\n if (!context) {\n throw new Error(\"useMap must be used within a Map component\");\n }\n return context;\n}\n\n/** Map viewport state */\ntype MapViewport = {\n /** Center coordinates [longitude, latitude] */\n center: [number, number];\n /** Zoom level */\n zoom: number;\n /** Bearing (rotation) in degrees */\n bearing: number;\n /** Pitch (tilt) in degrees */\n pitch: number;\n};\n\ntype MapStyleOption = string | MapLibreGL.StyleSpecification;\n\ntype MapRef = MapLibreGL.Map;\n\ntype MapProps = {\n children?: ReactNode;\n /** Additional CSS classes for the map container */\n className?: string;\n /**\n * Theme for the map. If not provided, automatically detects system preference.\n * Pass your theme value here.\n */\n theme?: Theme;\n /** Custom map styles for light and dark themes. Overrides the default Carto styles. */\n styles?: {\n light?: MapStyleOption;\n dark?: MapStyleOption;\n };\n /** Map projection type. Use `{ type: \"globe\" }` for 3D globe view. */\n projection?: MapLibreGL.ProjectionSpecification;\n /**\n * Controlled viewport. When provided with onViewportChange,\n * the map becomes controlled and viewport is driven by this prop.\n */\n viewport?: Partial<MapViewport>;\n /**\n * Callback fired continuously as the viewport changes (pan, zoom, rotate, pitch).\n * Can be used standalone to observe changes, or with `viewport` prop\n * to enable controlled mode where the map viewport is driven by your state.\n */\n onViewportChange?: (viewport: MapViewport) => void;\n /** Show a loading indicator on the map */\n loading?: boolean;\n} & Omit<MapLibreGL.MapOptions, \"container\" | \"style\">;\n\nfunction DefaultLoader() {\n return (\n <div className=\"absolute inset-0 z-10 flex items-center justify-center bg-background/50 backdrop-blur-xs\">\n <div className=\"flex gap-1\">\n <span className=\"size-1.5 rounded-full bg-muted-foreground/60 animate-pulse\" />\n <span className=\"size-1.5 rounded-full bg-muted-foreground/60 animate-pulse [animation-delay:150ms]\" />\n <span className=\"size-1.5 rounded-full bg-muted-foreground/60 animate-pulse [animation-delay:300ms]\" />\n </div>\n </div>\n );\n}\n\nfunction getViewport(map: MapLibreGL.Map): MapViewport {\n const center = map.getCenter();\n return {\n center: [center.lng, center.lat],\n zoom: map.getZoom(),\n bearing: map.getBearing(),\n pitch: map.getPitch(),\n };\n}\n\nconst Map = forwardRef<MapRef, MapProps>(function Map(\n {\n children,\n className,\n theme: themeProp,\n styles,\n projection,\n viewport,\n onViewportChange,\n loading = false,\n ...props\n },\n ref\n) {\n const containerRef = useRef<HTMLDivElement>(null);\n const [mapInstance, setMapInstance] = useState<MapLibreGL.Map | null>(null);\n const [isLoaded, setIsLoaded] = useState(false);\n const [isStyleLoaded, setIsStyleLoaded] = useState(false);\n const currentStyleRef = useRef<MapStyleOption | null>(null);\n const styleTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const internalUpdateRef = useRef(false);\n const resolvedTheme = useResolvedTheme(themeProp);\n\n const isControlled = viewport !== undefined && onViewportChange !== undefined;\n\n const onViewportChangeRef = useRef(onViewportChange);\n onViewportChangeRef.current = onViewportChange;\n\n const mapStyles = useMemo(\n () => ({\n dark: styles?.dark ?? defaultStyles.dark,\n light: styles?.light ?? defaultStyles.light,\n }),\n [styles]\n );\n\n // Expose the map instance to the parent component\n useImperativeHandle(ref, () => mapInstance as MapLibreGL.Map, [mapInstance]);\n\n const clearStyleTimeout = useCallback(() => {\n if (styleTimeoutRef.current) {\n clearTimeout(styleTimeoutRef.current);\n styleTimeoutRef.current = null;\n }\n }, []);\n\n // Initialize the map\n useEffect(() => {\n if (!containerRef.current) return;\n\n const initialStyle =\n resolvedTheme === \"dark\" ? mapStyles.dark : mapStyles.light;\n currentStyleRef.current = initialStyle;\n\n const map = new MapLibreGL.Map({\n container: containerRef.current,\n style: initialStyle,\n renderWorldCopies: false,\n attributionControl: {\n compact: true,\n },\n ...props,\n ...viewport,\n });\n\n const styleDataHandler = () => {\n clearStyleTimeout();\n // Delay to ensure style is fully processed before allowing layer operations\n // This is a workaround to avoid race conditions with the style loading\n // else we have to force update every layer on setStyle change\n styleTimeoutRef.current = setTimeout(() => {\n setIsStyleLoaded(true);\n if (projection) {\n map.setProjection(projection);\n }\n }, 100);\n };\n const loadHandler = () => setIsLoaded(true);\n\n // Viewport change handler - skip if triggered by internal update\n const handleMove = () => {\n if (internalUpdateRef.current) return;\n onViewportChangeRef.current?.(getViewport(map));\n };\n\n map.on(\"load\", loadHandler);\n map.on(\"styledata\", styleDataHandler);\n map.on(\"move\", handleMove);\n setMapInstance(map);\n\n return () => {\n clearStyleTimeout();\n map.off(\"load\", loadHandler);\n map.off(\"styledata\", styleDataHandler);\n map.off(\"move\", handleMove);\n map.remove();\n setIsLoaded(false);\n setIsStyleLoaded(false);\n setMapInstance(null);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // Sync controlled viewport to map\n useEffect(() => {\n if (!mapInstance || !isControlled || !viewport) return;\n if (mapInstance.isMoving()) return;\n\n const current = getViewport(mapInstance);\n const next = {\n center: viewport.center ?? current.center,\n zoom: viewport.zoom ?? current.zoom,\n bearing: viewport.bearing ?? current.bearing,\n pitch: viewport.pitch ?? current.pitch,\n };\n\n if (\n next.center[0] === current.center[0] &&\n next.center[1] === current.center[1] &&\n next.zoom === current.zoom &&\n next.bearing === current.bearing &&\n next.pitch === current.pitch\n ) {\n return;\n }\n\n internalUpdateRef.current = true;\n mapInstance.jumpTo(next);\n internalUpdateRef.current = false;\n }, [mapInstance, isControlled, viewport]);\n\n // Handle style change\n useEffect(() => {\n if (!mapInstance || !resolvedTheme) return;\n\n const newStyle =\n resolvedTheme === \"dark\" ? mapStyles.dark : mapStyles.light;\n\n if (currentStyleRef.current === newStyle) return;\n\n clearStyleTimeout();\n currentStyleRef.current = newStyle;\n setIsStyleLoaded(false);\n\n mapInstance.setStyle(newStyle, { diff: true });\n }, [mapInstance, resolvedTheme, mapStyles, clearStyleTimeout]);\n\n const contextValue = useMemo(\n () => ({\n map: mapInstance,\n isLoaded: isLoaded && isStyleLoaded,\n }),\n [mapInstance, isLoaded, isStyleLoaded]\n );\n\n return (\n <MapContext.Provider value={contextValue}>\n <div\n ref={containerRef}\n className={cn(\"relative w-full h-full\", className)}\n >\n {(!isLoaded || loading) && <DefaultLoader />}\n {/* SSR-safe: children render only when map is loaded on client */}\n {mapInstance && children}\n </div>\n </MapContext.Provider>\n );\n});\n\ntype MarkerContextValue = {\n marker: MapLibreGL.Marker;\n map: MapLibreGL.Map | null;\n};\n\nconst MarkerContext = createContext<MarkerContextValue | null>(null);\n\nfunction useMarkerContext() {\n const context = useContext(MarkerContext);\n if (!context) {\n throw new Error(\"Marker components must be used within MapMarker\");\n }\n return context;\n}\n\ntype MapMarkerProps = {\n /** Longitude coordinate for marker position */\n longitude: number;\n /** Latitude coordinate for marker position */\n latitude: number;\n /** Marker subcomponents (MarkerContent, MarkerPopup, MarkerTooltip, MarkerLabel) */\n children: ReactNode;\n /** Callback when marker is clicked */\n onClick?: (e: MouseEvent) => void;\n /** Callback when mouse enters marker */\n onMouseEnter?: (e: MouseEvent) => void;\n /** Callback when mouse leaves marker */\n onMouseLeave?: (e: MouseEvent) => void;\n /** Callback when marker drag starts (requires draggable: true) */\n onDragStart?: (lngLat: { lng: number; lat: number }) => void;\n /** Callback during marker drag (requires draggable: true) */\n onDrag?: (lngLat: { lng: number; lat: number }) => void;\n /** Callback when marker drag ends (requires draggable: true) */\n onDragEnd?: (lngLat: { lng: number; lat: number }) => void;\n} & Omit<MarkerOptions, \"element\">;\n\nfunction MapMarker({\n longitude,\n latitude,\n children,\n onClick,\n onMouseEnter,\n onMouseLeave,\n onDragStart,\n onDrag,\n onDragEnd,\n draggable = false,\n ...markerOptions\n}: MapMarkerProps) {\n const { map } = useMap();\n\n const callbacksRef = useRef({\n onClick,\n onMouseEnter,\n onMouseLeave,\n onDragStart,\n onDrag,\n onDragEnd,\n });\n callbacksRef.current = {\n onClick,\n onMouseEnter,\n onMouseLeave,\n onDragStart,\n onDrag,\n onDragEnd,\n };\n\n const marker = useMemo(() => {\n const markerInstance = new MapLibreGL.Marker({\n ...markerOptions,\n element: document.createElement(\"div\"),\n draggable,\n }).setLngLat([longitude, latitude]);\n\n const handleClick = (e: MouseEvent) => callbacksRef.current.onClick?.(e);\n const handleMouseEnter = (e: MouseEvent) =>\n callbacksRef.current.onMouseEnter?.(e);\n const handleMouseLeave = (e: MouseEvent) =>\n callbacksRef.current.onMouseLeave?.(e);\n\n markerInstance.getElement()?.addEventListener(\"click\", handleClick);\n markerInstance\n .getElement()\n ?.addEventListener(\"mouseenter\", handleMouseEnter);\n markerInstance\n .getElement()\n ?.addEventListener(\"mouseleave\", handleMouseLeave);\n\n const handleDragStart = () => {\n const lngLat = markerInstance.getLngLat();\n callbacksRef.current.onDragStart?.({ lng: lngLat.lng, lat: lngLat.lat });\n };\n const handleDrag = () => {\n const lngLat = markerInstance.getLngLat();\n callbacksRef.current.onDrag?.({ lng: lngLat.lng, lat: lngLat.lat });\n };\n const handleDragEnd = () => {\n const lngLat = markerInstance.getLngLat();\n callbacksRef.current.onDragEnd?.({ lng: lngLat.lng, lat: lngLat.lat });\n };\n\n markerInstance.on(\"dragstart\", handleDragStart);\n markerInstance.on(\"drag\", handleDrag);\n markerInstance.on(\"dragend\", handleDragEnd);\n\n return markerInstance;\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n if (!map) return;\n\n marker.addTo(map);\n\n return () => {\n marker.remove();\n };\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [map]);\n\n if (\n marker.getLngLat().lng !== longitude ||\n marker.getLngLat().lat !== latitude\n ) {\n marker.setLngLat([longitude, latitude]);\n }\n if (marker.isDraggable() !== draggable) {\n marker.setDraggable(draggable);\n }\n\n const currentOffset = marker.getOffset();\n const newOffset = markerOptions.offset ?? [0, 0];\n const [newOffsetX, newOffsetY] = Array.isArray(newOffset)\n ? newOffset\n : [newOffset.x, newOffset.y];\n if (currentOffset.x !== newOffsetX || currentOffset.y !== newOffsetY) {\n marker.setOffset(newOffset);\n }\n\n if (marker.getRotation() !== markerOptions.rotation) {\n marker.setRotation(markerOptions.rotation ?? 0);\n }\n if (marker.getRotationAlignment() !== markerOptions.rotationAlignment) {\n marker.setRotationAlignment(markerOptions.rotationAlignment ?? \"auto\");\n }\n if (marker.getPitchAlignment() !== markerOptions.pitchAlignment) {\n marker.setPitchAlignment(markerOptions.pitchAlignment ?? \"auto\");\n }\n\n return (\n <MarkerContext.Provider value={{ marker, map }}>\n {children}\n </MarkerContext.Provider>\n );\n}\n\ntype MarkerContentProps = {\n /** Custom marker content. Defaults to a blue dot if not provided */\n children?: ReactNode;\n /** Additional CSS classes for the marker container */\n className?: string;\n};\n\nfunction MarkerContent({ children, className }: MarkerContentProps) {\n const { marker } = useMarkerContext();\n\n return createPortal(\n <div className={cn(\"relative cursor-pointer\", className)}>\n {children || <DefaultMarkerIcon />}\n </div>,\n marker.getElement()\n );\n}\n\nfunction DefaultMarkerIcon() {\n return (\n <div className=\"relative h-4 w-4 rounded-full border-2 border-white bg-blue-500 shadow-lg\" />\n );\n}\n\ntype MarkerPopupProps = {\n /** Popup content */\n children: ReactNode;\n /** Additional CSS classes for the popup container */\n className?: string;\n /** Show a close button in the popup (default: false) */\n closeButton?: boolean;\n} & Omit<PopupOptions, \"className\" | \"closeButton\">;\n\nfunction MarkerPopup({\n children,\n className,\n closeButton = false,\n ...popupOptions\n}: MarkerPopupProps) {\n const { marker, map } = useMarkerContext();\n const container = useMemo(() => document.createElement(\"div\"), []);\n const prevPopupOptions = useRef(popupOptions);\n\n const popup = useMemo(() => {\n const popupInstance = new MapLibreGL.Popup({\n offset: 16,\n ...popupOptions,\n closeButton: false,\n })\n .setMaxWidth(\"none\")\n .setDOMContent(container);\n\n return popupInstance;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n if (!map) return;\n\n popup.setDOMContent(container);\n marker.setPopup(popup);\n\n return () => {\n marker.setPopup(null);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [map]);\n\n if (popup.isOpen()) {\n const prev = prevPopupOptions.current;\n\n if (prev.offset !== popupOptions.offset) {\n popup.setOffset(popupOptions.offset ?? 16);\n }\n if (prev.maxWidth !== popupOptions.maxWidth && popupOptions.maxWidth) {\n popup.setMaxWidth(popupOptions.maxWidth ?? \"none\");\n }\n\n prevPopupOptions.current = popupOptions;\n }\n\n const handleClose = () => popup.remove();\n\n return createPortal(\n <div\n className={cn(\n \"relative rounded-md border bg-popover p-3 text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95\",\n className\n )}\n >\n {closeButton && (\n <button\n type=\"button\"\n onClick={handleClose}\n className=\"absolute top-1 right-1 z-10 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2\"\n aria-label=\"Close popup\"\n >\n <X className=\"h-4 w-4\" />\n <span className=\"sr-only\">Close</span>\n </button>\n )}\n {children}\n </div>,\n container\n );\n}\n\ntype MarkerTooltipProps = {\n /** Tooltip content */\n children: ReactNode;\n /** Additional CSS classes for the tooltip container */\n className?: string;\n} & Omit<PopupOptions, \"className\" | \"closeButton\" | \"closeOnClick\">;\n\nfunction MarkerTooltip({\n children,\n className,\n ...popupOptions\n}: MarkerTooltipProps) {\n const { marker, map } = useMarkerContext();\n const container = useMemo(() => document.createElement(\"div\"), []);\n const prevTooltipOptions = useRef(popupOptions);\n\n const tooltip = useMemo(() => {\n const tooltipInstance = new MapLibreGL.Popup({\n offset: 16,\n ...popupOptions,\n closeOnClick: true,\n closeButton: false,\n }).setMaxWidth(\"none\");\n\n return tooltipInstance;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n if (!map) return;\n\n tooltip.setDOMContent(container);\n\n const handleMouseEnter = () => {\n tooltip.setLngLat(marker.getLngLat()).addTo(map);\n };\n const handleMouseLeave = () => tooltip.remove();\n\n marker.getElement()?.addEventListener(\"mouseenter\", handleMouseEnter);\n marker.getElement()?.addEventListener(\"mouseleave\", handleMouseLeave);\n\n return () => {\n marker.getElement()?.removeEventListener(\"mouseenter\", handleMouseEnter);\n marker.getElement()?.removeEventListener(\"mouseleave\", handleMouseLeave);\n tooltip.remove();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [map]);\n\n if (tooltip.isOpen()) {\n const prev = prevTooltipOptions.current;\n\n if (prev.offset !== popupOptions.offset) {\n tooltip.setOffset(popupOptions.offset ?? 16);\n }\n if (prev.maxWidth !== popupOptions.maxWidth && popupOptions.maxWidth) {\n tooltip.setMaxWidth(popupOptions.maxWidth ?? \"none\");\n }\n\n prevTooltipOptions.current = popupOptions;\n }\n\n return createPortal(\n <div\n className={cn(\n \"rounded-md bg-foreground px-2 py-1 text-xs text-background shadow-md animate-in fade-in-0 zoom-in-95\",\n className\n )}\n >\n {children}\n </div>,\n container\n );\n}\n\ntype MarkerLabelProps = {\n /** Label text content */\n children: ReactNode;\n /** Additional CSS classes for the label */\n className?: string;\n /** Position of the label relative to the marker (default: \"top\") */\n position?: \"top\" | \"bottom\";\n};\n\nfunction MarkerLabel({\n children,\n className,\n position = \"top\",\n}: MarkerLabelProps) {\n const positionClasses = {\n top: \"bottom-full mb-1\",\n bottom: \"top-full mt-1\",\n };\n\n return (\n <div\n className={cn(\n \"absolute left-1/2 -translate-x-1/2 whitespace-nowrap\",\n \"text-[10px] font-medium text-foreground\",\n positionClasses[position],\n className\n )}\n >\n {children}\n </div>\n );\n}\n\ntype MapControlsProps = {\n /** Position of the controls on the map (default: \"bottom-right\") */\n position?: \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\";\n /** Show zoom in/out buttons (default: true) */\n showZoom?: boolean;\n /** Show compass button to reset bearing (default: false) */\n showCompass?: boolean;\n /** Show locate button to find user's location (default: false) */\n showLocate?: boolean;\n /** Show fullscreen toggle button (default: false) */\n showFullscreen?: boolean;\n /** Additional CSS classes for the controls container */\n className?: string;\n /** Callback with user coordinates when located */\n onLocate?: (coords: { longitude: number; latitude: number }) => void;\n};\n\nconst positionClasses = {\n \"top-left\": \"top-2 left-2\",\n \"top-right\": \"top-2 right-2\",\n \"bottom-left\": \"bottom-2 left-2\",\n \"bottom-right\": \"bottom-10 right-2\",\n};\n\nfunction ControlGroup({ children }: { children: React.ReactNode }) {\n return (\n <div className=\"flex flex-col rounded-md border border-border bg-background shadow-sm overflow-hidden [&>button:not(:last-child)]:border-b [&>button:not(:last-child)]:border-border\">\n {children}\n </div>\n );\n}\n\nfunction ControlButton({\n onClick,\n label,\n children,\n disabled = false,\n}: {\n onClick: () => void;\n label: string;\n children: React.ReactNode;\n disabled?: boolean;\n}) {\n return (\n <button\n onClick={onClick}\n aria-label={label}\n type=\"button\"\n className={cn(\n \"flex items-center justify-center size-8 hover:bg-accent dark:hover:bg-accent/40 transition-colors\",\n disabled && \"opacity-50 pointer-events-none cursor-not-allowed\"\n )}\n disabled={disabled}\n >\n {children}\n </button>\n );\n}\n\nfunction MapControls({\n position = \"bottom-right\",\n showZoom = true,\n showCompass = false,\n showLocate = false,\n showFullscreen = false,\n className,\n onLocate,\n}: MapControlsProps) {\n const { map } = useMap();\n const [waitingForLocation, setWaitingForLocation] = useState(false);\n\n const handleZoomIn = useCallback(() => {\n map?.zoomTo(map.getZoom() + 1, { duration: 300 });\n }, [map]);\n\n const handleZoomOut = useCallback(() => {\n map?.zoomTo(map.getZoom() - 1, { duration: 300 });\n }, [map]);\n\n const handleResetBearing = useCallback(() => {\n map?.resetNorthPitch({ duration: 300 });\n }, [map]);\n\n const handleLocate = useCallback(() => {\n setWaitingForLocation(true);\n if (\"geolocation\" in navigator) {\n navigator.geolocation.getCurrentPosition(\n (pos) => {\n const coords = {\n longitude: pos.coords.longitude,\n latitude: pos.coords.latitude,\n };\n map?.flyTo({\n center: [coords.longitude, coords.latitude],\n zoom: 14,\n duration: 1500,\n });\n onLocate?.(coords);\n setWaitingForLocation(false);\n },\n (error) => {\n console.error(\"Error getting location:\", error);\n setWaitingForLocation(false);\n }\n );\n }\n }, [map, onLocate]);\n\n const handleFullscreen = useCallback(() => {\n const container = map?.getContainer();\n if (!container) return;\n if (document.fullscreenElement) {\n document.exitFullscreen();\n } else {\n container.requestFullscreen();\n }\n }, [map]);\n\n return (\n <div\n className={cn(\n \"absolute z-10 flex flex-col gap-1.5\",\n positionClasses[position],\n className\n )}\n >\n {showZoom && (\n <ControlGroup>\n <ControlButton onClick={handleZoomIn} label=\"Zoom in\">\n <Plus className=\"size-4\" />\n </ControlButton>\n <ControlButton onClick={handleZoomOut} label=\"Zoom out\">\n <Minus className=\"size-4\" />\n </ControlButton>\n </ControlGroup>\n )}\n {showCompass && (\n <ControlGroup>\n <CompassButton onClick={handleResetBearing} />\n </ControlGroup>\n )}\n {showLocate && (\n <ControlGroup>\n <ControlButton\n onClick={handleLocate}\n label=\"Find my location\"\n disabled={waitingForLocation}\n >\n {waitingForLocation ? (\n <Loader2 className=\"size-4 animate-spin\" />\n ) : (\n <Locate className=\"size-4\" />\n )}\n </ControlButton>\n </ControlGroup>\n )}\n {showFullscreen && (\n <ControlGroup>\n <ControlButton onClick={handleFullscreen} label=\"Toggle fullscreen\">\n <Maximize className=\"size-4\" />\n </ControlButton>\n </ControlGroup>\n )}\n </div>\n );\n}\n\nfunction CompassButton({ onClick }: { onClick: () => void }) {\n const { map } = useMap();\n const compassRef = useRef<SVGSVGElement>(null);\n\n useEffect(() => {\n if (!map || !compassRef.current) return;\n\n const compass = compassRef.current;\n\n const updateRotation = () => {\n const bearing = map.getBearing();\n const pitch = map.getPitch();\n compass.style.transform = `rotateX(${pitch}deg) rotateZ(${-bearing}deg)`;\n };\n\n map.on(\"rotate\", updateRotation);\n map.on(\"pitch\", updateRotation);\n updateRotation();\n\n return () => {\n map.off(\"rotate\", updateRotation);\n map.off(\"pitch\", updateRotation);\n };\n }, [map]);\n\n return (\n <ControlButton onClick={onClick} label=\"Reset bearing to north\">\n <svg\n ref={compassRef}\n viewBox=\"0 0 24 24\"\n className=\"size-5 transition-transform duration-200\"\n style={{ transformStyle: \"preserve-3d\" }}\n >\n <path d=\"M12 2L16 12H12V2Z\" className=\"fill-red-500\" />\n <path d=\"M12 2L8 12H12V2Z\" className=\"fill-red-300\" />\n <path d=\"M12 22L16 12H12V22Z\" className=\"fill-muted-foreground/60\" />\n <path d=\"M12 22L8 12H12V22Z\" className=\"fill-muted-foreground/30\" />\n </svg>\n </ControlButton>\n );\n}\n\ntype MapPopupProps = {\n /** Longitude coordinate for popup position */\n longitude: number;\n /** Latitude coordinate for popup position */\n latitude: number;\n /** Callback when popup is closed */\n onClose?: () => void;\n /** Popup content */\n children: ReactNode;\n /** Additional CSS classes for the popup container */\n className?: string;\n /** Show a close button in the popup (default: false) */\n closeButton?: boolean;\n} & Omit<PopupOptions, \"className\" | \"closeButton\">;\n\nfunction MapPopup({\n longitude,\n latitude,\n onClose,\n children,\n className,\n closeButton = false,\n ...popupOptions\n}: MapPopupProps) {\n const { map } = useMap();\n const popupOptionsRef = useRef(popupOptions);\n const onCloseRef = useRef(onClose);\n onCloseRef.current = onClose;\n const container = useMemo(() => document.createElement(\"div\"), []);\n\n const popup = useMemo(() => {\n const popupInstance = new MapLibreGL.Popup({\n offset: 16,\n ...popupOptions,\n closeButton: false,\n })\n .setMaxWidth(\"none\")\n .setLngLat([longitude, latitude]);\n\n return popupInstance;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n if (!map) return;\n\n const onCloseProp = () => onCloseRef.current?.();\n\n popup.on(\"close\", onCloseProp);\n\n popup.setDOMContent(container);\n popup.addTo(map);\n\n return () => {\n popup.off(\"close\", onCloseProp);\n if (popup.isOpen()) {\n popup.remove();\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [map]);\n\n if (popup.isOpen()) {\n const prev = popupOptionsRef.current;\n\n if (\n popup.getLngLat().lng !== longitude ||\n popup.getLngLat().lat !== latitude\n ) {\n popup.setLngLat([longitude, latitude]);\n }\n\n if (prev.offset !== popupOptions.offset) {\n popup.setOffset(popupOptions.offset ?? 16);\n }\n if (prev.maxWidth !== popupOptions.maxWidth && popupOptions.maxWidth) {\n popup.setMaxWidth(popupOptions.maxWidth ?? \"none\");\n }\n popupOptionsRef.current = popupOptions;\n }\n\n const handleClose = () => {\n popup.remove();\n };\n\n return createPortal(\n <div\n className={cn(\n \"relative rounded-md border bg-popover p-3 text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95\",\n className\n )}\n >\n {closeButton && (\n <button\n type=\"button\"\n onClick={handleClose}\n className=\"absolute top-1 right-1 z-10 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2\"\n aria-label=\"Close popup\"\n >\n <X className=\"h-4 w-4\" />\n <span className=\"sr-only\">Close</span>\n </button>\n )}\n {children}\n </div>,\n container\n );\n}\n\ntype MapRouteProps = {\n /** Optional unique identifier for the route layer */\n id?: string;\n /** Array of [longitude, latitude] coordinate pairs defining the route */\n coordinates: [number, number][];\n /** Line color as CSS color value (default: \"#4285F4\") */\n color?: string;\n /** Line width in pixels (default: 3) */\n width?: number;\n /** Line opacity from 0 to 1 (default: 0.8) */\n opacity?: number;\n /** Dash pattern [dash length, gap length] for dashed lines */\n dashArray?: [number, number];\n /** Callback when the route line is clicked */\n onClick?: () => void;\n /** Callback when mouse enters the route line */\n onMouseEnter?: () => void;\n /** Callback when mouse leaves the route line */\n onMouseLeave?: () => void;\n /** Whether the route is interactive - shows pointer cursor on hover (default: true) */\n interactive?: boolean;\n};\n\nfunction MapRoute({\n id: propId,\n coordinates,\n color = \"#4285F4\",\n width = 3,\n opacity = 0.8,\n dashArray,\n onClick,\n onMouseEnter,\n onMouseLeave,\n interactive = true,\n}: MapRouteProps) {\n const { map, isLoaded } = useMap();\n const autoId = useId();\n const id = propId ?? autoId;\n const sourceId = `route-source-${id}`;\n const layerId = `route-layer-${id}`;\n\n // Add source and layer on mount\n useEffect(() => {\n if (!isLoaded || !map) return;\n\n map.addSource(sourceId, {\n type: \"geojson\",\n data: {\n type: \"Feature\",\n properties: {},\n geometry: { type: \"LineString\", coordinates: [] },\n },\n });\n\n map.addLayer({\n id: layerId,\n type: \"line\",\n source: sourceId,\n layout: { \"line-join\": \"round\", \"line-cap\": \"round\" },\n paint: {\n \"line-color\": color,\n \"line-width\": width,\n \"line-opacity\": opacity,\n ...(dashArray && { \"line-dasharray\": dashArray }),\n },\n });\n\n return () => {\n try {\n if (map.getLayer(layerId)) map.removeLayer(layerId);\n if (map.getSource(sourceId)) map.removeSource(sourceId);\n } catch {\n // ignore\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isLoaded, map]);\n\n // When coordinates change, update the source data\n useEffect(() => {\n if (!isLoaded || !map || coordinates.length < 2) return;\n\n const source = map.getSource(sourceId) as MapLibreGL.GeoJSONSource;\n if (source) {\n source.setData({\n type: \"Feature\",\n properties: {},\n geometry: { type: \"LineString\", coordinates },\n });\n }\n }, [isLoaded, map, coordinates, sourceId]);\n\n useEffect(() => {\n if (!isLoaded || !map || !map.getLayer(layerId)) return;\n\n map.setPaintProperty(layerId, \"line-color\", color);\n map.setPaintProperty(layerId, \"line-width\", width);\n map.setPaintProperty(layerId, \"line-opacity\", opacity);\n if (dashArray) {\n map.setPaintProperty(layerId, \"line-dasharray\", dashArray);\n }\n }, [isLoaded, map, layerId, color, width, opacity, dashArray]);\n\n // Handle click and hover events\n useEffect(() => {\n if (!isLoaded || !map || !interactive) return;\n\n const handleClick = () => {\n onClick?.();\n };\n const handleMouseEnter = () => {\n map.getCanvas().style.cursor = \"pointer\";\n onMouseEnter?.();\n };\n const handleMouseLeave = () => {\n map.getCanvas().style.cursor = \"\";\n onMouseLeave?.();\n };\n\n map.on(\"click\", layerId, handleClick);\n map.on(\"mouseenter\", layerId, handleMouseEnter);\n map.on(\"mouseleave\", layerId, handleMouseLeave);\n\n return () => {\n map.off(\"click\", layerId, handleClick);\n map.off(\"mouseenter\", layerId, handleMouseEnter);\n map.off(\"mouseleave\", layerId, handleMouseLeave);\n };\n }, [\n isLoaded,\n map,\n layerId,\n onClick,\n onMouseEnter,\n onMouseLeave,\n interactive,\n ]);\n\n return null;\n}\n\ntype MapClusterLayerProps<\n P extends GeoJSON.GeoJsonProperties = GeoJSON.GeoJsonProperties\n> = {\n /** GeoJSON FeatureCollection data or URL to fetch GeoJSON from */\n data: string | GeoJSON.FeatureCollection<GeoJSON.Point, P>;\n /** Maximum zoom level to cluster points on (default: 14) */\n clusterMaxZoom?: number;\n /** Radius of each cluster when clustering points in pixels (default: 50) */\n clusterRadius?: number;\n /** Colors for cluster circles: [small, medium, large] based on point count (default: [\"#22c55e\", \"#eab308\", \"#ef4444\"]) */\n clusterColors?: [string, string, string];\n /** Point count thresholds for color/size steps: [medium, large] (default: [100, 750]) */\n clusterThresholds?: [number, number];\n /** Color for unclustered individual points (default: \"#3b82f6\") */\n pointColor?: string;\n /** Callback when an unclustered point is clicked */\n onPointClick?: (\n feature: GeoJSON.Feature<GeoJSON.Point, P>,\n coordinates: [number, number]\n ) => void;\n /** Callback when a cluster is clicked. If not provided, zooms into the cluster */\n onClusterClick?: (\n clusterId: number,\n coordinates: [number, number],\n pointCount: number\n ) => void;\n};\n\nfunction MapClusterLayer<\n P extends GeoJSON.GeoJsonProperties = GeoJSON.GeoJsonProperties\n>({\n data,\n clusterMaxZoom = 14,\n clusterRadius = 50,\n clusterColors = [\"#22c55e\", \"#eab308\", \"#ef4444\"],\n clusterThresholds = [100, 750],\n pointColor = \"#3b82f6\",\n onPointClick,\n onClusterClick,\n}: MapClusterLayerProps<P>) {\n const { map, isLoaded } = useMap();\n const id = useId();\n const sourceId = `cluster-source-${id}`;\n const clusterLayerId = `clusters-${id}`;\n const clusterCountLayerId = `cluster-count-${id}`;\n const unclusteredLayerId = `unclustered-point-${id}`;\n\n const stylePropsRef = useRef({\n clusterColors,\n clusterThresholds,\n pointColor,\n });\n\n // Add source and layers on mount\n useEffect(() => {\n if (!isLoaded || !map) return;\n\n // Add clustered GeoJSON source\n map.addSource(sourceId, {\n type: \"geojson\",\n data,\n cluster: true,\n clusterMaxZoom,\n clusterRadius,\n });\n\n // Add cluster circles layer\n map.addLayer({\n id: clusterLayerId,\n type: \"circle\",\n source: sourceId,\n filter: [\"has\", \"point_count\"],\n paint: {\n \"circle-color\": [\n \"step\",\n [\"get\", \"point_count\"],\n clusterColors[0],\n clusterThresholds[0],\n clusterColors[1],\n clusterThresholds[1],\n clusterColors[2],\n ],\n \"circle-radius\": [\n \"step\",\n [\"get\", \"point_count\"],\n 20,\n clusterThresholds[0],\n 30,\n clusterThresholds[1],\n 40,\n ],\n \"circle-stroke-width\": 1,\n \"circle-stroke-color\": \"#fff\",\n \"circle-opacity\": 0.85,\n },\n });\n\n // Add cluster count text layer\n map.addLayer({\n id: clusterCountLayerId,\n type: \"symbol\",\n source: sourceId,\n filter: [\"has\", \"point_count\"],\n layout: {\n \"text-field\": \"{point_count_abbreviated}\",\n \"text-font\": [\"Open Sans\"],\n \"text-size\": 12,\n },\n paint: {\n \"text-color\": \"#fff\",\n },\n });\n\n // Add unclustered point layer\n map.addLayer({\n id: unclusteredLayerId,\n type: \"circle\",\n source: sourceId,\n filter: [\"!\", [\"has\", \"point_count\"]],\n paint: {\n \"circle-color\": pointColor,\n \"circle-radius\": 5,\n \"circle-stroke-width\": 2,\n \"circle-stroke-color\": \"#fff\",\n },\n });\n\n return () => {\n try {\n if (map.getLayer(clusterCountLayerId))\n map.removeLayer(clusterCountLayerId);\n if (map.getLayer(unclusteredLayerId))\n map.removeLayer(unclusteredLayerId);\n if (map.getLayer(clusterLayerId)) map.removeLayer(clusterLayerId);\n if (map.getSource(sourceId)) map.removeSource(sourceId);\n } catch {\n // ignore\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isLoaded, map, sourceId]);\n\n // Update source data when data prop changes (only for non-URL data)\n useEffect(() => {\n if (!isLoaded || !map || typeof data === \"string\") return;\n\n const source = map.getSource(sourceId) as MapLibreGL.GeoJSONSource;\n if (source) {\n source.setData(data);\n }\n }, [isLoaded, map, data, sourceId]);\n\n // Update layer styles when props change\n useEffect(() => {\n if (!isLoaded || !map) return;\n\n const prev = stylePropsRef.current;\n const colorsChanged =\n prev.clusterColors !== clusterColors ||\n prev.clusterThresholds !== clusterThresholds;\n\n // Update cluster layer colors and sizes\n if (map.getLayer(clusterLayerId) && colorsChanged) {\n map.setPaintProperty(clusterLayerId, \"circle-color\", [\n \"step\",\n [\"get\", \"point_count\"],\n clusterColors[0],\n clusterThresholds[0],\n clusterColors[1],\n clusterThresholds[1],\n clusterColors[2],\n ]);\n map.setPaintProperty(clusterLayerId, \"circle-radius\", [\n \"step\",\n [\"get\", \"point_count\"],\n 20,\n clusterThresholds[0],\n 30,\n clusterThresholds[1],\n 40,\n ]);\n }\n\n // Update unclustered point layer color\n if (map.getLayer(unclusteredLayerId) && prev.pointColor !== pointColor) {\n map.setPaintProperty(unclusteredLayerId, \"circle-color\", pointColor);\n }\n\n stylePropsRef.current = { clusterColors, clusterThresholds, pointColor };\n }, [\n isLoaded,\n map,\n clusterLayerId,\n unclusteredLayerId,\n clusterColors,\n clusterThresholds,\n pointColor,\n ]);\n\n // Handle click events\n useEffect(() => {\n if (!isLoaded || !map) return;\n\n // Cluster click handler - zoom into cluster\n const handleClusterClick = async (\n e: MapLibreGL.MapMouseEvent & {\n features?: MapLibreGL.MapGeoJSONFeature[];\n }\n ) => {\n const features = map.queryRenderedFeatures(e.point, {\n layers: [clusterLayerId],\n });\n if (!features.length) return;\n\n const feature = features[0];\n const clusterId = feature.properties?.cluster_id as number;\n const pointCount = feature.properties?.point_count as number;\n const coordinates = (feature.geometry as GeoJSON.Point).coordinates as [\n number,\n number\n ];\n\n if (onClusterClick) {\n onClusterClick(clusterId, coordinates, pointCount);\n } else {\n // Default behavior: zoom to cluster expansion zoom\n const source = map.getSource(sourceId) as MapLibreGL.GeoJSONSource;\n const zoom = await source.getClusterExpansionZoom(clusterId);\n map.easeTo({\n center: coordinates,\n zoom,\n });\n }\n };\n\n // Unclustered point click handler\n const handlePointClick = (\n e: MapLibreGL.MapMouseEvent & {\n features?: MapLibreGL.MapGeoJSONFeature[];\n }\n ) => {\n if (!onPointClick || !e.features?.length) return;\n\n const feature = e.features[0];\n const coordinates = (\n feature.geometry as GeoJSON.Point\n ).coordinates.slice() as [number, number];\n\n // Handle world copies\n while (Math.abs(e.lngLat.lng - coordinates[0]) > 180) {\n coordinates[0] += e.lngLat.lng > coordinates[0] ? 360 : -360;\n }\n\n onPointClick(\n feature as unknown as GeoJSON.Feature<GeoJSON.Point, P>,\n coordinates\n );\n };\n\n // Cursor style handlers\n const handleMouseEnterCluster = () => {\n map.getCanvas().style.cursor = \"pointer\";\n };\n const handleMouseLeaveCluster = () => {\n map.getCanvas().style.cursor = \"\";\n };\n const handleMouseEnterPoint = () => {\n if (onPointClick) {\n map.getCanvas().style.cursor = \"pointer\";\n }\n };\n const handleMouseLeavePoint = () => {\n map.getCanvas().style.cursor = \"\";\n };\n\n map.on(\"click\", clusterLayerId, handleClusterClick);\n map.on(\"click\", unclusteredLayerId, handlePointClick);\n map.on(\"mouseenter\", clusterLayerId, handleMouseEnterCluster);\n map.on(\"mouseleave\", clusterLayerId, handleMouseLeaveCluster);\n map.on(\"mouseenter\", unclusteredLayerId, handleMouseEnterPoint);\n map.on(\"mouseleave\", unclusteredLayerId, handleMouseLeavePoint);\n\n return () => {\n map.off(\"click\", clusterLayerId, handleClusterClick);\n map.off(\"click\", unclusteredLayerId, handlePointClick);\n map.off(\"mouseenter\", clusterLayerId, handleMouseEnterCluster);\n map.off(\"mouseleave\", clusterLayerId, handleMouseLeaveCluster);\n map.off(\"mouseenter\", unclusteredLayerId, handleMouseEnterPoint);\n map.off(\"mouseleave\", unclusteredLayerId, handleMouseLeavePoint);\n };\n }, [\n isLoaded,\n map,\n clusterLayerId,\n unclusteredLayerId,\n sourceId,\n onClusterClick,\n onPointClick,\n ]);\n\n return null;\n}\n\nexport {\n Map,\n useMap,\n MapMarker,\n MarkerContent,\n MarkerPopup,\n MarkerTooltip,\n MarkerLabel,\n MapPopup,\n MapControls,\n MapRoute,\n MapClusterLayer,\n};\n\nexport type { MapRef, MapViewport };\n",
"type": "registry:ui",
"target": "components/ui/map.tsx"
}
diff --git a/public/r/registry.json b/public/r/registry.json
index 7579221..af7d423 100644
--- a/public/r/registry.json
+++ b/public/r/registry.json
@@ -27,6 +27,114 @@
}
}
}
+ },
+ {
+ "name": "analytics-map",
+ "type": "registry:block",
+ "title": "Analytics Map",
+ "description": "Real-time analytics overview with a world map, breakdown cards, and device stats.",
+ "dependencies": ["recharts", "lucide-react"],
+ "registryDependencies": ["map", "card", "chart"],
+ "files": [
+ {
+ "path": "src/registry/blocks/analytics-map/page.tsx",
+ "type": "registry:page",
+ "target": "app/analytics/page.tsx"
+ },
+ {
+ "path": "src/registry/blocks/analytics-map/data.ts",
+ "type": "registry:component",
+ "target": "app/analytics/data.ts"
+ },
+ {
+ "path": "src/registry/blocks/analytics-map/components/overview-card.tsx",
+ "type": "registry:component",
+ "target": "app/analytics/components/overview-card.tsx"
+ },
+ {
+ "path": "src/registry/blocks/analytics-map/components/breakdown-card.tsx",
+ "type": "registry:component",
+ "target": "app/analytics/components/breakdown-card.tsx"
+ }
+ ],
+ "categories": ["analytics", "dashboard"],
+ "meta": {
+ "iframeHeight": "970px"
+ }
+ },
+ {
+ "name": "logistics-network",
+ "type": "registry:block",
+ "title": "Logistics Network",
+ "description": "Domestic logistics map with a sidebar of stats.",
+ "dependencies": ["lucide-react"],
+ "registryDependencies": ["map", "card", "badge", "button"],
+ "files": [
+ {
+ "path": "src/registry/blocks/logistics-network/page.tsx",
+ "type": "registry:page",
+ "target": "app/logistics/page.tsx"
+ },
+ {
+ "path": "src/registry/blocks/logistics-network/data.ts",
+ "type": "registry:component",
+ "target": "app/logistics/data.ts"
+ },
+ {
+ "path": "src/registry/blocks/logistics-network/components/map-arcs.tsx",
+ "type": "registry:component",
+ "target": "app/logistics/components/map-arcs.tsx"
+ },
+ {
+ "path": "src/registry/blocks/logistics-network/components/filter-sidebar.tsx",
+ "type": "registry:component",
+ "target": "app/logistics/components/filter-sidebar.tsx"
+ },
+ {
+ "path": "src/registry/blocks/logistics-network/components/network-map.tsx",
+ "type": "registry:component",
+ "target": "app/logistics/components/network-map.tsx"
+ }
+ ],
+ "categories": ["logistics", "network"],
+ "meta": {
+ "iframeHeight": "800px"
+ }
+ },
+ {
+ "name": "heatmap",
+ "type": "registry:block",
+ "title": "Heatmap",
+ "description": "Globe-projected heatmap visualizing earthquake density with zoom-dependent styling.",
+ "dependencies": [],
+ "registryDependencies": ["map", "card"],
+ "files": [
+ {
+ "path": "src/registry/blocks/heatmap/page.tsx",
+ "type": "registry:page",
+ "target": "app/heatmap/page.tsx"
+ }
+ ],
+ "categories": ["visualization", "heatmap"]
+ },
+ {
+ "name": "delivery-tracker",
+ "type": "registry:block",
+ "title": "Delivery Tracker",
+ "description": "Live order tracking with route progress, courier position, and order details.",
+ "dependencies": ["lucide-react"],
+ "registryDependencies": ["map", "card", "badge", "button"],
+ "files": [
+ {
+ "path": "src/registry/blocks/delivery-tracker/page.tsx",
+ "type": "registry:page",
+ "target": "app/delivery/page.tsx"
+ }
+ ],
+ "categories": ["tracking", "delivery"],
+ "meta": {
+ "iframeHeight": "680px"
+ }
}
]
}
diff --git a/registry.json b/registry.json
index 7579221..af7d423 100644
--- a/registry.json
+++ b/registry.json
@@ -27,6 +27,114 @@
}
}
}
+ },
+ {
+ "name": "analytics-map",
+ "type": "registry:block",
+ "title": "Analytics Map",
+ "description": "Real-time analytics overview with a world map, breakdown cards, and device stats.",
+ "dependencies": ["recharts", "lucide-react"],
+ "registryDependencies": ["map", "card", "chart"],
+ "files": [
+ {
+ "path": "src/registry/blocks/analytics-map/page.tsx",
+ "type": "registry:page",
+ "target": "app/analytics/page.tsx"
+ },
+ {
+ "path": "src/registry/blocks/analytics-map/data.ts",
+ "type": "registry:component",
+ "target": "app/analytics/data.ts"
+ },
+ {
+ "path": "src/registry/blocks/analytics-map/components/overview-card.tsx",
+ "type": "registry:component",
+ "target": "app/analytics/components/overview-card.tsx"
+ },
+ {
+ "path": "src/registry/blocks/analytics-map/components/breakdown-card.tsx",
+ "type": "registry:component",
+ "target": "app/analytics/components/breakdown-card.tsx"
+ }
+ ],
+ "categories": ["analytics", "dashboard"],
+ "meta": {
+ "iframeHeight": "970px"
+ }
+ },
+ {
+ "name": "logistics-network",
+ "type": "registry:block",
+ "title": "Logistics Network",
+ "description": "Domestic logistics map with a sidebar of stats.",
+ "dependencies": ["lucide-react"],
+ "registryDependencies": ["map", "card", "badge", "button"],
+ "files": [
+ {
+ "path": "src/registry/blocks/logistics-network/page.tsx",
+ "type": "registry:page",
+ "target": "app/logistics/page.tsx"
+ },
+ {
+ "path": "src/registry/blocks/logistics-network/data.ts",
+ "type": "registry:component",
+ "target": "app/logistics/data.ts"
+ },
+ {
+ "path": "src/registry/blocks/logistics-network/components/map-arcs.tsx",
+ "type": "registry:component",
+ "target": "app/logistics/components/map-arcs.tsx"
+ },
+ {
+ "path": "src/registry/blocks/logistics-network/components/filter-sidebar.tsx",
+ "type": "registry:component",
+ "target": "app/logistics/components/filter-sidebar.tsx"
+ },
+ {
+ "path": "src/registry/blocks/logistics-network/components/network-map.tsx",
+ "type": "registry:component",
+ "target": "app/logistics/components/network-map.tsx"
+ }
+ ],
+ "categories": ["logistics", "network"],
+ "meta": {
+ "iframeHeight": "800px"
+ }
+ },
+ {
+ "name": "heatmap",
+ "type": "registry:block",
+ "title": "Heatmap",
+ "description": "Globe-projected heatmap visualizing earthquake density with zoom-dependent styling.",
+ "dependencies": [],
+ "registryDependencies": ["map", "card"],
+ "files": [
+ {
+ "path": "src/registry/blocks/heatmap/page.tsx",
+ "type": "registry:page",
+ "target": "app/heatmap/page.tsx"
+ }
+ ],
+ "categories": ["visualization", "heatmap"]
+ },
+ {
+ "name": "delivery-tracker",
+ "type": "registry:block",
+ "title": "Delivery Tracker",
+ "description": "Live order tracking with route progress, courier position, and order details.",
+ "dependencies": ["lucide-react"],
+ "registryDependencies": ["map", "card", "badge", "button"],
+ "files": [
+ {
+ "path": "src/registry/blocks/delivery-tracker/page.tsx",
+ "type": "registry:page",
+ "target": "app/delivery/page.tsx"
+ }
+ ],
+ "categories": ["tracking", "delivery"],
+ "meta": {
+ "iframeHeight": "680px"
+ }
}
]
}
diff --git a/src/app/(home)/_components/examples/ev-charging-example.tsx b/src/app/(home)/_components/examples/ev-charging-example.tsx
deleted file mode 100644
index 528498e..0000000
--- a/src/app/(home)/_components/examples/ev-charging-example.tsx
+++ /dev/null
@@ -1,88 +0,0 @@
-"use client";
-
-import { Map, MapMarker, MarkerContent, MarkerTooltip } from "@/registry/map";
-import { Zap } from "lucide-react";
-import { ExampleCard } from "./example-card";
-
-export function EVChargingExample() {
- return (
- <ExampleCard
- label="EV Charging"
- className="aspect-square"
- delay="delay-700"
- >
- <Map center={[-122.425, 37.777]} zoom={11.5}>
- <MapMarker longitude={-122.4194} latitude={37.7749}>
- <MarkerContent>
- <div className="bg-emerald-500 rounded-full p-1.5 shadow-lg shadow-emerald-500/30">
- <Zap className="size-3 text-white fill-white" />
- </div>
- </MarkerContent>
- <MarkerTooltip>
- <div className="text-xs space-y-0.5">
- <div className="font-medium">Market St Station</div>
- <div className="flex items-center gap-1">
- <span className="size-1.5 rounded-full bg-emerald-500" />
- <span className="text-emerald-500">Available</span>
- </div>
- <div className="text-muted-foreground">150 kW • $0.35/kWh</div>
- </div>
- </MarkerTooltip>
- </MapMarker>
-
- <MapMarker longitude={-122.4094} latitude={37.7849}>
- <MarkerContent>
- <div className="bg-emerald-500 rounded-full p-1.5 shadow-lg shadow-emerald-500/30">
- <Zap className="size-3 text-white fill-white" />
- </div>
- </MarkerContent>
- <MarkerTooltip>
- <div className="text-xs space-y-0.5">
- <div className="font-medium">Union Square</div>
- <div className="flex items-center gap-1">
- <span className="size-1.5 rounded-full bg-emerald-500" />
- <span className="text-emerald-500">2 Available</span>
- </div>
- <div className="text-muted-foreground">50 kW • $0.28/kWh</div>
- </div>
- </MarkerTooltip>
- </MapMarker>
-
- <MapMarker longitude={-122.4294} latitude={37.7689}>
- <MarkerContent>
- <div className="bg-amber-500 rounded-full p-1.5 shadow-lg shadow-amber-500/30">
- <Zap className="size-3 text-white fill-white" />
- </div>
- </MarkerContent>
- <MarkerTooltip>
- <div className="text-xs space-y-0.5">
- <div className="font-medium">Castro Station</div>
- <div className="flex items-center gap-1">
- <span className="size-1.5 rounded-full bg-amber-500" />
- <span className="text-amber-500">In Use</span>
- </div>
- <div className="text-muted-foreground">~15 min remaining</div>
- </div>
- </MarkerTooltip>
- </MapMarker>
-
- <MapMarker longitude={-122.4394} latitude={37.7809}>
- <MarkerContent>
- <div className="bg-zinc-400 rounded-full p-1.5 shadow-lg">
- <Zap className="size-3 text-white fill-white" />
- </div>
- </MarkerContent>
- <MarkerTooltip>
- <div className="text-xs space-y-0.5">
- <div className="font-medium">Hayes Valley</div>
- <div className="flex items-center gap-1">
- <span className="size-1.5 rounded-full bg-zinc-400" />
- <span className="text-muted-foreground">Offline</span>
- </div>
- </div>
- </MarkerTooltip>
- </MapMarker>
- </Map>
- </ExampleCard>
- );
-}
diff --git a/src/app/(home)/_components/footer.tsx b/src/app/(home)/_components/footer.tsx
deleted file mode 100644
index 39530ee..0000000
--- a/src/app/(home)/_components/footer.tsx
+++ /dev/null
@@ -1,42 +0,0 @@
-import { Button } from "@/components/ui/button";
-import Link from "next/link";
-
-export function Footer() {
- return (
- <footer className="w-full py-5 border-t">
- <div className="w-full container flex flex-col sm:flex-row items-center justify-between gap-2 text-sm text-muted-foreground">
- <div className="flex items-center gap-2">
- <span className="font-medium text-foreground">mapcn</span>
- <span className="text-muted-foreground/80">•</span>
- <span>
- Built by
- <Button variant="link" size="sm" className="px-1" asChild>
- <Link
- href="https://github.com/AnmolSaini16"
- target="_blank"
- rel="noopener noreferrer"
- >
- Anmol
- </Link>
- </Button>
- </span>
- </div>
- <div className="flex items-center">
- <Button variant="ghost" size="sm" asChild>
- <Link href="/docs">Documentation</Link>
- </Button>
-
- <Button variant="ghost" size="sm" asChild>
- <Link
- href="https://github.com/AnmolSaini16/mapcn"
- target="_blank"
- rel="noopener noreferrer"
- >
- GitHub
- </Link>
- </Button>
- </div>
- </div>
- </footer>
- );
-}
diff --git a/src/app/(home)/_components/hero.tsx b/src/app/(home)/_components/hero.tsx
deleted file mode 100644
index 1b44627..0000000
--- a/src/app/(home)/_components/hero.tsx
+++ /dev/null
@@ -1,92 +0,0 @@
-"use client";
-
-import { Button } from "@/components/ui/button";
-import { Copy, Check, ArrowRight } from "lucide-react";
-import Link from "next/link";
-import { useState } from "react";
-
-const installCommand = "npx shadcn@latest add @mapcn/map";
-
-function CopyButton({ text }: { text: string }) {
- const [copied, setCopied] = useState(false);
-
- const copy = () => {
- navigator.clipboard.writeText(text);
- setCopied(true);
- setTimeout(() => setCopied(false), 2000);
- };
-
- return (
- <button
- onClick={copy}
- className="text-muted-foreground hover:text-foreground transition-colors"
- >
- {copied ? (
- <Check className="size-4 text-emerald-500" />
- ) : (
- <Copy className="size-4" />
- )}
- </button>
- );
-}
-
-export function Hero() {
- return (
- <div className="relative">
- <div className="absolute inset-x-0 -inset-y-32 -z-10 overflow-hidden">
- <div
- className="absolute inset-0 opacity-[0.3] dark:opacity-[0.15]"
- style={{
- backgroundImage: `radial-gradient(circle, currentColor 1px, transparent 1px)`,
- backgroundSize: "24px 24px",
- }}
- />
- <div className="absolute inset-0 bg-linear-to-b from-background via-transparent to-background" />
- </div>
-
- <div className="container flex flex-col items-center text-center">
- <h1 className="text-4xl sm:text-5xl md:text-6xl font-semibold tracking-tight animate-fade-up delay-100">
- <span className="bg-linear-to-b from-foreground to-foreground/60 bg-clip-text text-transparent">
- Beautiful maps, made simple.
- </span>
- </h1>
-
- <p className="mt-6 text-foreground/80 text-lg md:text-xl leading-relaxed animate-fade-up delay-200 max-w-lg">
- Ready to use, customizable map components for React.
- <br className="hidden sm:block" />
- Built on MapLibre. Styled with Tailwind.
- </p>
-
- <div className="mt-8 animate-fade-up delay-300 w-full max-w-lg">
- <div className="bg-card border border-border rounded-lg shadow-xs overflow-hidden">
- <div className="flex items-center gap-1.5 px-3 py-2 border-b border-border/50">
- <span className="size-2 rounded-full bg-foreground/20" />
- <span className="size-2 rounded-full bg-foreground/20" />
- <span className="size-2 rounded-full bg-foreground/20" />
- </div>
-
- <div className="flex items-center gap-3 px-4 py-3 font-mono text-sm">
- <span className="text-emerald-500 shrink-0">$</span>
- <code className="text-foreground/80 truncate flex-1 text-left">
- {installCommand}
- </code>
- <CopyButton text={installCommand} />
- </div>
- </div>
- </div>
-
- <div className="mt-8 flex flex-wrap justify-center items-center gap-3 animate-fade-up delay-400">
- <Button size="lg" asChild>
- <Link href="/docs">
- Get Started
- <ArrowRight className="size-4" />
- </Link>
- </Button>
- <Button variant="ghost" size="lg" asChild>
- <Link href="/docs/basic-map">View Components</Link>
- </Button>
- </div>
- </div>
- </div>
- );
-}
diff --git a/src/app/(home)/page.tsx b/src/app/(home)/page.tsx
deleted file mode 100644
index 18f28c6..0000000
--- a/src/app/(home)/page.tsx
+++ /dev/null
@@ -1,24 +0,0 @@
-import { Hero } from "./_components/hero";
-import { ExamplesGrid } from "./_components/examples-grid";
-import { Footer } from "./_components/footer";
-import { Header } from "./_components/header";
-
-export default function Page() {
- return (
- <div className="flex flex-col">
- <Header />
-
- <main className="flex-1 pb-32">
- <section className="relative w-full py-24">
- <Hero />
- </section>
-
- <section className="container">
- <ExamplesGrid />
- </section>
- </main>
-
- <Footer />
- </div>
- );
-}
diff --git a/src/app/(home)/_components/examples-grid.tsx b/src/app/(main)/(home)/_components/examples-grid.tsx
similarity index 80%
rename from src/app/(home)/_components/examples-grid.tsx
rename to src/app/(main)/(home)/_components/examples-grid.tsx
index e9939ef..f4f8f46 100644
--- a/src/app/(home)/_components/examples-grid.tsx
+++ b/src/app/(main)/(home)/_components/examples-grid.tsx
@@ -9,7 +9,7 @@ import { FlyToExample } from "./examples/flyto-example";
export function ExamplesGrid() {
return (
- <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-5 animate-fade-in delay-400">
+ <div className="animate-fade-in grid grid-cols-1 gap-5 delay-400 sm:grid-cols-2 lg:grid-cols-4">
<AnalyticsExample />
<TrailExample />
<FlyToExample />
diff --git a/src/app/(home)/_components/examples/analytics-example.tsx b/src/app/(main)/(home)/_components/examples/analytics-example.tsx
similarity index 100%
rename from src/app/(home)/_components/examples/analytics-example.tsx
rename to src/app/(main)/(home)/_components/examples/analytics-example.tsx
diff --git a/src/app/(home)/_components/examples/delivery-example.tsx b/src/app/(main)/(home)/_components/examples/delivery-example.tsx
similarity index 96%
rename from src/app/(home)/_components/examples/delivery-example.tsx
rename to src/app/(main)/(home)/_components/examples/delivery-example.tsx
index bff24c4..0056752 100644
--- a/src/app/(home)/_components/examples/delivery-example.tsx
+++ b/src/app/(main)/(home)/_components/examples/delivery-example.tsx
@@ -56,7 +56,7 @@ export function DeliveryExample() {
)}
<MapMarker longitude={store.lng} latitude={store.lat}>
<MarkerContent>
- <div className="size-3.5 rounded-full bg-blue-500 border-2 border-white shadow-lg" />
+ <div className="size-3.5 rounded-full bg-emerald-500 border-2 border-white shadow-lg" />
<MarkerLabel>Store</MarkerLabel>
</MarkerContent>
</MapMarker>
diff --git a/src/app/(main)/(home)/_components/examples/ev-charging-example.tsx b/src/app/(main)/(home)/_components/examples/ev-charging-example.tsx
new file mode 100644
index 0000000..c614647
--- /dev/null
+++ b/src/app/(main)/(home)/_components/examples/ev-charging-example.tsx
@@ -0,0 +1,165 @@
+"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
+ label="EV Charging"
+ className="aspect-square"
+ delay="delay-700"
+ >
+ <Map center={[-122.434, 37.776]} zoom={11}>
+ {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 ${
+ station.status !== "offline"
+ ? `shadow-${config.bg.replace("bg-", "")}/30`
+ : ""
+ }`}
+ >
+ <Zap className="size-3 text-white fill-white" />
+ </div>
+ </MarkerContent>
+ <MarkerTooltip>
+ <div className="text-xs space-y-0.5">
+ <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">
+ {station.detail}
+ </div>
+ )}
+ </div>
+ </MarkerTooltip>
+ </MapMarker>
+ );
+ })}
+ </Map>
+ </ExampleCard>
+ );
+}
diff --git a/src/app/(home)/_components/examples/example-card.tsx b/src/app/(main)/(home)/_components/examples/example-card.tsx
similarity index 60%
rename from src/app/(home)/_components/examples/example-card.tsx
rename to src/app/(main)/(home)/_components/examples/example-card.tsx
index 1c95dd7..7fc3481 100644
--- a/src/app/(home)/_components/examples/example-card.tsx
+++ b/src/app/(main)/(home)/_components/examples/example-card.tsx
@@ -18,13 +18,13 @@ export function ExampleCard({
return (
<div
className={cn(
- "rounded-xl overflow-hidden shadow-sm bg-card border border-border/50 relative animate-scale-in",
+ "bg-card border-border/50 animate-scale-in relative overflow-hidden rounded-xl border shadow-sm",
delay,
- className
+ className,
)}
>
{label && (
- <div className="uppercase absolute top-2 left-2 z-10 tracking-wider text-[10px] text-muted-foreground bg-background/90 backdrop-blur-sm rounded px-2 py-1">
+ <div className="text-muted-foreground bg-background/90 absolute top-2 left-2 z-10 rounded px-2 py-1 text-[10px] tracking-wider uppercase backdrop-blur-sm">
{label}
</div>
)}
diff --git a/src/app/(home)/_components/examples/flyto-example.tsx b/src/app/(main)/(home)/_components/examples/flyto-example.tsx
similarity index 100%
rename from src/app/(home)/_components/examples/flyto-example.tsx
rename to src/app/(main)/(home)/_components/examples/flyto-example.tsx
diff --git a/src/app/(home)/_components/examples/index.tsx b/src/app/(main)/(home)/_components/examples/index.tsx
similarity index 100%
rename from src/app/(home)/_components/examples/index.tsx
rename to src/app/(main)/(home)/_components/examples/index.tsx
diff --git a/src/app/(home)/_components/examples/trail-example.tsx b/src/app/(main)/(home)/_components/examples/trail-example.tsx
similarity index 100%
rename from src/app/(home)/_components/examples/trail-example.tsx
rename to src/app/(main)/(home)/_components/examples/trail-example.tsx
diff --git a/src/app/(home)/_components/examples/trending-example.tsx b/src/app/(main)/(home)/_components/examples/trending-example.tsx
similarity index 100%
rename from src/app/(home)/_components/examples/trending-example.tsx
rename to src/app/(main)/(home)/_components/examples/trending-example.tsx
diff --git a/src/app/(main)/(home)/page.tsx b/src/app/(main)/(home)/page.tsx
new file mode 100644
index 0000000..fbb7e94
--- /dev/null
+++ b/src/app/(main)/(home)/page.tsx
@@ -0,0 +1,40 @@
+import { ExamplesGrid } from "./_components/examples-grid";
+import { Footer } from "@/components/footer";
+import {
+ PageHeader,
+ PageHeaderHeading,
+ PageHeaderDescription,
+ PageActions,
+} from "@/components/page-header";
+import { Button } from "@/components/ui/button";
+import Link from "next/link";
+
+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>
+ <Button size="lg" asChild>
+ <Link href="/docs">Get Started</Link>
+ </Button>
+ <Button size="lg" variant="outline" asChild>
+ <Link href="/docs/basic-map">View Components</Link>
+ </Button>
+ </PageActions>
+ </PageHeader>
+
+ <section className="container-wide">
+ <ExamplesGrid />
+ </section>
+
+ <Footer />
+ </>
+ );
+}
diff --git a/src/app/(main)/blocks/_components/block-display.tsx b/src/app/(main)/blocks/_components/block-display.tsx
new file mode 100644
index 0000000..b619dfe
--- /dev/null
+++ b/src/app/(main)/blocks/_components/block-display.tsx
@@ -0,0 +1,40 @@
+import { getAllBlocks, createFileTreeForRegistryItemFiles } from "@/lib/blocks";
+import { getBlockFileSource } from "@/lib/get-block-file-source";
+import { highlightCode } from "@/lib/highlight";
+import { BlockPreview } from "./block-preview";
+import { IframePreview } from "./iframe-preview";
+
+interface BlockDisplayProps {
+ name: string;
+}
+
+export async function BlockDisplay({ name }: BlockDisplayProps) {
+ const blocks = getAllBlocks();
+ const block = blocks.find((b) => b.name === name);
+
+ if (!block || !block.files?.length) {
+ return null;
+ }
+
+ const tree = createFileTreeForRegistryItemFiles(block.files);
+
+ const highlightedFiles = await Promise.all(
+ block.files.map(async (file) => {
+ const content = getBlockFileSource(file.path);
+ const lang = file.path.split(".").pop() ?? "tsx";
+ const highlightedContent = await highlightCode(content, lang);
+ return {
+ path: file.path,
+ target: file.target ?? file.path,
+ content,
+ highlightedContent,
+ };
+ })
+ );
+
+ return (
+ <BlockPreview block={block} tree={tree} highlightedFiles={highlightedFiles}>
+ <IframePreview src={`/view/${block.name}`} title={block.title ?? block.name} />
+ </BlockPreview>
+ );
+}
diff --git a/src/app/(main)/blocks/_components/block-preview.tsx b/src/app/(main)/blocks/_components/block-preview.tsx
new file mode 100644
index 0000000..057b214
--- /dev/null
+++ b/src/app/(main)/blocks/_components/block-preview.tsx
@@ -0,0 +1,97 @@
+"use client";
+
+import { useState } from "react";
+import { Check, Code, Eye, Fullscreen, Terminal } from "lucide-react";
+import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
+import { Button } from "@/components/ui/button";
+import { RegistryBlockItem, type FileTree } from "@/lib/blocks";
+import { BlockViewerCode, type HighlightedFile } from "./block-viewer-code";
+import { Separator } from "@/components/ui/separator";
+import Link from "next/link";
+
+interface BlockPreviewProps {
+ block: RegistryBlockItem;
+ children: React.ReactNode;
+ tree: FileTree[];
+ highlightedFiles: HighlightedFile[];
+}
+
+export function BlockPreview({
+ block,
+ children,
+ 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);
+ }
+
+ return (
+ <div
+ className="space-y-4"
+ style={
+ {
+ "--block-preview-height": meta?.iframeHeight ?? "930px",
+ } as React.CSSProperties
+ }
+ >
+ <div>
+ <h2 className="text-xl font-semibold tracking-tight">{title}</h2>
+ {description && (
+ <p className="text-muted-foreground mt-1 text-sm">{description}</p>
+ )}
+ </div>
+
+ <Tabs defaultValue="preview" className="w-full">
+ <div className="flex items-center justify-between">
+ <TabsList className="h-8!">
+ <TabsTrigger value="preview" className="text-xs">
+ <Eye className="size-3.5" />
+ Preview
+ </TabsTrigger>
+ <TabsTrigger value="code" className="text-xs">
+ <Code className="size-3.5" />
+ Code
+ </TabsTrigger>
+ </TabsList>
+
+ <div className="hidden items-center gap-3 md:flex">
+ <Button
+ variant="outline"
+ size="icon-sm"
+ asChild
+ aria-label="Open in new tab"
+ >
+ <Link href={`/view/${name}`} target="_blank">
+ <Fullscreen />
+ </Link>
+ </Button>
+ <Separator orientation="vertical" className="h-4!" />
+ <Button
+ onClick={copyCli}
+ variant="outline"
+ aria-label="Copy CLI command"
+ size="sm"
+ >
+ {copiedType === "cli" ? <Check /> : <Terminal />}
+ npx shadcn add @mapcn/{name}
+ </Button>
+ </div>
+ </div>
+
+ <TabsContent value="preview" className="mt-2">
+ {children}
+ </TabsContent>
+
+ <TabsContent value="code" className="mt-2">
+ <BlockViewerCode tree={tree} highlightedFiles={highlightedFiles} />
+ </TabsContent>
+ </Tabs>
+ </div>
+ );
+}
diff --git a/src/app/(main)/blocks/_components/block-viewer-code.tsx b/src/app/(main)/blocks/_components/block-viewer-code.tsx
new file mode 100644
index 0000000..87dd6c9
--- /dev/null
+++ b/src/app/(main)/blocks/_components/block-viewer-code.tsx
@@ -0,0 +1,201 @@
+"use client";
+
+import * as React from "react";
+import { Check, ChevronRight, Copy, File, Folder } from "lucide-react";
+import {
+ Collapsible,
+ CollapsibleContent,
+ CollapsibleTrigger,
+} from "@/components/ui/collapsible";
+import { Button } from "@/components/ui/button";
+import {
+ Sidebar,
+ SidebarGroup,
+ SidebarGroupContent,
+ SidebarGroupLabel,
+ SidebarMenu,
+ SidebarMenuButton,
+ SidebarMenuItem,
+ SidebarMenuSub,
+ SidebarProvider,
+} from "@/components/ui/sidebar";
+import { type FileTree } from "@/lib/blocks";
+
+export interface HighlightedFile {
+ path: string;
+ target: string;
+ content: string;
+ highlightedContent: string;
+}
+
+interface BlockViewerCodeContext {
+ activeFile: string;
+ setActiveFile: (file: string) => void;
+ highlightedFiles: HighlightedFile[];
+ tree: FileTree[];
+}
+
+const BlockViewerCodeCtx = React.createContext<BlockViewerCodeContext | null>(
+ null
+);
+
+function useBlockViewerCode() {
+ const ctx = React.useContext(BlockViewerCodeCtx);
+ if (!ctx) {
+ throw new Error("useBlockViewerCode must be used within BlockViewerCode");
+ }
+ return ctx;
+}
+
+interface BlockViewerCodeProps {
+ tree: FileTree[];
+ highlightedFiles: HighlightedFile[];
+}
+
+export function BlockViewerCode({
+ tree,
+ highlightedFiles,
+}: BlockViewerCodeProps) {
+ const [activeFile, setActiveFile] = React.useState<string>(
+ highlightedFiles[0]?.target ?? ""
+ );
+
+ const file = React.useMemo(
+ () => highlightedFiles.find((f) => f.target === activeFile),
+ [highlightedFiles, activeFile]
+ );
+
+ if (!file) return null;
+
+ return (
+ <BlockViewerCodeCtx.Provider
+ value={{ activeFile, setActiveFile, highlightedFiles, tree }}
+ >
+ <div className="flex overflow-hidden rounded-xl border h-(--block-preview-height)">
+ <div className="w-64 shrink-0">
+ <FileTreeSidebar />
+ </div>
+ <div className="min-w-0 flex-1 flex flex-col">
+ <div className="flex h-12 shrink-0 items-center gap-2 border-b px-4 text-sm">
+ <span className="text-muted-foreground">{file.target}</span>
+ <div className="ml-auto">
+ <CopyCodeButton />
+ </div>
+ </div>
+ <div
+ key={file.path}
+ dangerouslySetInnerHTML={{ __html: file.highlightedContent }}
+ className="flex-1 overflow-y-auto p-4 text-sm [&_pre]:bg-transparent! [&_code]:bg-transparent!"
+ />
+ </div>
+ </div>
+ </BlockViewerCodeCtx.Provider>
+ );
+}
+
+function FileTreeSidebar() {
+ const { tree } = useBlockViewerCode();
+
+ return (
+ <SidebarProvider className="flex min-h-full! flex-col border-r">
+ <Sidebar collapsible="none" className="w-full flex-1 bg-card">
+ <SidebarGroupLabel className="h-12 rounded-none border-b px-4 text-sm">
+ Files
+ </SidebarGroupLabel>
+ <SidebarGroup className="p-0">
+ <SidebarGroupContent>
+ <SidebarMenu className="translate-x-0 gap-1.5">
+ {tree.map((file, index) => (
+ <TreeNode key={index} item={file} index={1} />
+ ))}
+ </SidebarMenu>
+ </SidebarGroupContent>
+ </SidebarGroup>
+ </Sidebar>
+ </SidebarProvider>
+ );
+}
+
+function TreeNode({ item, index }: { item: FileTree; index: number }) {
+ const { activeFile, setActiveFile } = useBlockViewerCode();
+
+ if (!item.children) {
+ return (
+ <SidebarMenuItem>
+ <SidebarMenuButton
+ isActive={item.path === activeFile}
+ onClick={() => item.path && setActiveFile(item.path)}
+ className="hover:bg-muted-foreground/15 focus:bg-muted-foreground/15 focus-visible:bg-muted-foreground/15 active:bg-muted-foreground/15 data-[active=true]:bg-muted-foreground/15 rounded-none whitespace-nowrap pl-(--index)"
+ data-index={index}
+ style={
+ {
+ "--index": `${index * (index === 2 ? 1.2 : 1.3)}rem`,
+ } as React.CSSProperties
+ }
+ >
+ <ChevronRight className="invisible" />
+ <File className="size-4" />
+ {item.name}
+ </SidebarMenuButton>
+ </SidebarMenuItem>
+ );
+ }
+
+ return (
+ <SidebarMenuItem>
+ <Collapsible
+ className="group/collapsible [&[data-state=open]>button>svg:first-child]:rotate-90"
+ defaultOpen
+ >
+ <CollapsibleTrigger asChild>
+ <SidebarMenuButton
+ className="hover:bg-muted-foreground/15 focus:bg-muted-foreground/15 focus-visible:bg-muted-foreground/15 active:bg-muted-foreground/15 data-[active=true]:bg-muted-foreground/15 rounded-none whitespace-nowrap pl-(--index)"
+ style={
+ {
+ "--index": `${index * (index === 1 ? 1 : 1.2)}rem`,
+ } as React.CSSProperties
+ }
+ >
+ <ChevronRight className="transition-transform" />
+ <Folder />
+ {item.name}
+ </SidebarMenuButton>
+ </CollapsibleTrigger>
+ <CollapsibleContent>
+ <SidebarMenuSub className="m-0 w-full translate-x-0 border-none p-0">
+ {item.children.map((subItem, key) => (
+ <TreeNode key={key} item={subItem} index={index + 1} />
+ ))}
+ </SidebarMenuSub>
+ </CollapsibleContent>
+ </Collapsible>
+ </SidebarMenuItem>
+ );
+}
+
+function CopyCodeButton() {
+ const { activeFile, highlightedFiles } = useBlockViewerCode();
+ const [copied, setCopied] = React.useState(false);
+
+ const file = React.useMemo(
+ () => highlightedFiles.find((f) => f.target === activeFile),
+ [highlightedFiles, activeFile]
+ );
+
+ if (!file) return null;
+
+ return (
+ <Button
+ variant="ghost"
+ size="icon"
+ className="size-7"
+ onClick={async () => {
+ await navigator.clipboard.writeText(file.content);
+ setCopied(true);
+ setTimeout(() => setCopied(false), 2000);
+ }}
+ >
+ {copied ? <Check /> : <Copy />}
+ </Button>
+ );
+}
diff --git a/src/app/(main)/blocks/_components/iframe-preview.tsx b/src/app/(main)/blocks/_components/iframe-preview.tsx
new file mode 100644
index 0000000..567e84c
--- /dev/null
+++ b/src/app/(main)/blocks/_components/iframe-preview.tsx
@@ -0,0 +1,14 @@
+"use client";
+
+interface IframePreviewProps {
+ src: string;
+ title: string;
+}
+
+export function IframePreview({ src, title }: IframePreviewProps) {
+ return (
+ <div className="relative w-full overflow-hidden rounded-xl border h-(--block-preview-height)">
+ <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
new file mode 100644
index 0000000..042aba3
--- /dev/null
+++ b/src/app/(main)/blocks/page.tsx
@@ -0,0 +1,55 @@
+import {
+ PageActions,
+ PageHeader,
+ PageHeaderDescription,
+ PageHeaderHeading,
+} from "@/components/page-header";
+import { Button } from "@/components/ui/button";
+import Link from "next/link";
+import { Footer } from "@/components/footer";
+import { Metadata } from "next";
+import { getAllBlocks } from "@/lib/blocks";
+import { BlockDisplay } from "./_components/block-display";
+
+export const metadata: Metadata = {
+ title: "Map blocks for your application",
+ description:
+ "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();
+
+ return (
+ <>
+ <PageHeader align="left">
+ <PageHeaderHeading className="md:text-5xl">
+ Map blocks for your application
+ </PageHeaderHeading>
+ <PageHeaderDescription className="md:text-lg">
+ Pre-built, ready-to-use map blocks. Browse, preview, and copy them
+ into your app with one command.
+ </PageHeaderDescription>
+ <PageActions className="delay-300">
+ <Button asChild>
+ <a href="#blocks">Browse Blocks</a>
+ </Button>
+ <Button variant="outline" asChild>
+ <Link href="/docs">View Documentation</Link>
+ </Button>
+ </PageActions>
+ </PageHeader>
+
+ <section
+ className="animate-fade-up container scroll-mt-20 space-y-20 delay-400"
+ id="blocks"
+ >
+ {blocks.map((block) => (
+ <BlockDisplay key={block.name} name={block.name} />
+ ))}
+ </section>
+
+ <Footer />
+ </>
+ );
+}
diff --git a/src/app/docs/_components/code-block.tsx b/src/app/(main)/docs/_components/code-block.tsx
similarity index 100%
rename from src/app/docs/_components/code-block.tsx
rename to src/app/(main)/docs/_components/code-block.tsx
diff --git a/src/app/docs/_components/component-preview-client.tsx b/src/app/(main)/docs/_components/component-preview-client.tsx
similarity index 100%
rename from src/app/docs/_components/component-preview-client.tsx
rename to src/app/(main)/docs/_components/component-preview-client.tsx
diff --git a/src/app/docs/_components/component-preview.tsx b/src/app/(main)/docs/_components/component-preview.tsx
similarity index 100%
rename from src/app/docs/_components/component-preview.tsx
rename to src/app/(main)/docs/_components/component-preview.tsx
diff --git a/src/app/docs/_components/copy-button.tsx b/src/app/(main)/docs/_components/copy-button.tsx
similarity index 100%
rename from src/app/docs/_components/copy-button.tsx
rename to src/app/(main)/docs/_components/copy-button.tsx
diff --git a/src/app/docs/_components/docs-sidebar.tsx b/src/app/(main)/docs/_components/docs-sidebar.tsx
similarity index 57%
rename from src/app/docs/_components/docs-sidebar.tsx
rename to src/app/(main)/docs/_components/docs-sidebar.tsx
index d001ce8..dcae248 100644
--- a/src/app/docs/_components/docs-sidebar.tsx
+++ b/src/app/(main)/docs/_components/docs-sidebar.tsx
@@ -6,37 +6,31 @@ import { usePathname } from "next/navigation";
import {
Sidebar,
SidebarContent,
- SidebarFooter,
SidebarGroup,
SidebarGroupContent,
SidebarGroupLabel,
- SidebarHeader,
SidebarMenu,
SidebarMenuButton,
SidebarMenuItem,
useSidebar,
} from "@/components/ui/sidebar";
-import { docsNavigation } from "@/lib/docs-navigation";
-import { Logo } from "@/components/logo";
-import { CommandSearch } from "@/components/command-search";
-import { ThemeToggle } from "@/components/theme-toggle";
-import { GitHubButton } from "@/components/github-button";
+import { docsNavigation } from "@/lib/site-navigation";
export function DocsSidebar() {
const pathname = usePathname();
const { setOpenMobile } = useSidebar();
return (
- <Sidebar>
- <SidebarHeader className="p-4 gap-4 pb-2">
- <Logo />
- <CommandSearch className="w-full flex" />
- </SidebarHeader>
-
- <SidebarContent>
+ <Sidebar
+ className="sticky top-16 z-30 hidden h-[calc(100svh-4rem)] overscroll-none bg-transparent lg:flex"
+ collapsible="none"
+ >
+ <SidebarContent className="pt-6">
{docsNavigation.map((group) => (
<SidebarGroup key={group.title}>
- <SidebarGroupLabel>{group.title}</SidebarGroupLabel>
+ <SidebarGroupLabel className="text-foreground">
+ {group.title}
+ </SidebarGroupLabel>
<SidebarGroupContent>
<SidebarMenu>
{group.items.map((item) => (
@@ -44,14 +38,13 @@ export function DocsSidebar() {
<SidebarMenuButton
asChild
isActive={pathname === item.href}
- className="font-medium text-muted-foreground"
+ className="text-muted-foreground font-medium"
>
<Link
href={item.href}
onClick={() => setOpenMobile(false)}
>
- <item.icon className="size-4" />
- <span>{item.title}</span>
+ {item.title}
</Link>
</SidebarMenuButton>
</SidebarMenuItem>
@@ -61,14 +54,6 @@ export function DocsSidebar() {
</SidebarGroup>
))}
</SidebarContent>
-
- <SidebarFooter className="border-t">
- <div className="flex justify-between">
- <GitHubButton withCount={false} />
-
- <ThemeToggle />
- </div>
- </SidebarFooter>
</Sidebar>
);
}
diff --git a/src/app/docs/_components/docs-toc.tsx b/src/app/(main)/docs/_components/docs-toc.tsx
similarity index 83%
rename from src/app/docs/_components/docs-toc.tsx
rename to src/app/(main)/docs/_components/docs-toc.tsx
index 37ec5ee..a5929e8 100644
--- a/src/app/docs/_components/docs-toc.tsx
+++ b/src/app/(main)/docs/_components/docs-toc.tsx
@@ -15,7 +15,7 @@ function useActiveItem(itemIds: string[]) {
}
}
},
- { rootMargin: "0% 0% -80% 0%" }
+ { rootMargin: "0% 0% -80% 0%" },
);
for (const id of itemIds ?? []) {
@@ -58,11 +58,11 @@ export function DocsToc({ items, className }: DocsTocProps) {
return (
<div className={cn("flex flex-col gap-1", className)}>
- <p className="text-foreground text-[13px] font-medium mb-2">
+ <p className="text-muted-foreground mb-2 flex items-center gap-1.5 text-xs font-medium">
On This Page
</p>
<div className="relative">
- <div className="absolute left-0 top-1 bottom-1 w-px bg-border" />
+ <div className="bg-border absolute top-1 bottom-1 left-0 w-px" />
<div className="flex flex-col gap-1">
{items.map((item) => {
const isActive = item.slug === activeHeading;
@@ -71,14 +71,14 @@ export function DocsToc({ items, className }: DocsTocProps) {
key={item.slug}
href={`#${item.slug}`}
className={cn(
- "relative pl-3 py-1 text-[13px] no-underline transition-colors",
+ "relative py-1 pl-3 text-[0.8rem] no-underline transition-colors",
isActive
? "text-foreground"
- : "text-muted-foreground hover:text-foreground"
+ : "text-muted-foreground hover:text-foreground",
)}
>
{isActive && (
- <div className="absolute left-0 top-1 bottom-1 w-px bg-foreground rounded-full" />
+ <div className="bg-foreground absolute top-1 bottom-1 left-0 w-px rounded-full" />
)}
{item.title}
</a>
diff --git a/src/app/docs/_components/docs.tsx b/src/app/(main)/docs/_components/docs.tsx
similarity index 97%
rename from src/app/docs/_components/docs.tsx
rename to src/app/(main)/docs/_components/docs.tsx
index 7cfa3d9..ff9e235 100644
--- a/src/app/docs/_components/docs.tsx
+++ b/src/app/(main)/docs/_components/docs.tsx
@@ -62,12 +62,10 @@ export function DocsLayout({
toc = [],
}: DocsLayoutProps) {
return (
- <div className="flex gap-8">
- <div className="flex-1 min-w-0 max-w-3xl mx-auto pt-10 pb-20">
+ <div className="flex">
+ <div className="flex-1 min-w-0 max-w-[800px] lg:px-4 mx-auto pb-20 pt-12">
<DocsTitle title={title} description={description} />
-
<div className="mt-12 space-y-12">{children}</div>
-
{(prev || next) && (
<div className="flex items-center justify-between gap-4 mt-16">
{prev ? (
@@ -118,7 +116,7 @@ interface DocsSectionProps {
export function DocsSection({ title, children }: DocsSectionProps) {
const id = title ? slugify(title) : undefined;
return (
- <section className="space-y-5 scroll-mt-24" id={id}>
+ <section className="space-y-5 scroll-m-24" id={id}>
{title && (
<h2 className="text-xl font-semibold tracking-tight text-foreground">
{title}
diff --git a/src/app/docs/_components/examples/advanced-usage-example.tsx b/src/app/(main)/docs/_components/examples/advanced-usage-example.tsx
similarity index 100%
rename from src/app/docs/_components/examples/advanced-usage-example.tsx
rename to src/app/(main)/docs/_components/examples/advanced-usage-example.tsx
diff --git a/src/app/docs/_components/examples/basic-map-example.tsx b/src/app/(main)/docs/_components/examples/basic-map-example.tsx
similarity index 100%
rename from src/app/docs/_components/examples/basic-map-example.tsx
rename to src/app/(main)/docs/_components/examples/basic-map-example.tsx
diff --git a/src/app/docs/_components/examples/cluster-example.tsx b/src/app/(main)/docs/_components/examples/cluster-example.tsx
similarity index 100%
rename from src/app/docs/_components/examples/cluster-example.tsx
rename to src/app/(main)/docs/_components/examples/cluster-example.tsx
diff --git a/src/app/docs/_components/examples/controlled-map-example.tsx b/src/app/(main)/docs/_components/examples/controlled-map-example.tsx
similarity index 100%
rename from src/app/docs/_components/examples/controlled-map-example.tsx
rename to src/app/(main)/docs/_components/examples/controlled-map-example.tsx
diff --git a/src/app/docs/_components/examples/custom-layer-example.tsx b/src/app/(main)/docs/_components/examples/custom-layer-example.tsx
similarity index 100%
rename from src/app/docs/_components/examples/custom-layer-example.tsx
rename to src/app/(main)/docs/_components/examples/custom-layer-example.tsx
diff --git a/src/app/docs/_components/examples/custom-style-example.tsx b/src/app/(main)/docs/_components/examples/custom-style-example.tsx
similarity index 100%
rename from src/app/docs/_components/examples/custom-style-example.tsx
rename to src/app/(main)/docs/_components/examples/custom-style-example.tsx
diff --git a/src/app/docs/_components/examples/draggable-marker-example.tsx b/src/app/(main)/docs/_components/examples/draggable-marker-example.tsx
similarity index 100%
rename from src/app/docs/_components/examples/draggable-marker-example.tsx
rename to src/app/(main)/docs/_components/examples/draggable-marker-example.tsx
diff --git a/src/app/docs/_components/examples/layer-markers-example.tsx b/src/app/(main)/docs/_components/examples/layer-markers-example.tsx
similarity index 100%
rename from src/app/docs/_components/examples/layer-markers-example.tsx
rename to src/app/(main)/docs/_components/examples/layer-markers-example.tsx
diff --git a/src/app/docs/_components/examples/map-controls-example.tsx b/src/app/(main)/docs/_components/examples/map-controls-example.tsx
similarity index 100%
rename from src/app/docs/_components/examples/map-controls-example.tsx
rename to src/app/(main)/docs/_components/examples/map-controls-example.tsx
diff --git a/src/app/docs/_components/examples/markers-example.tsx b/src/app/(main)/docs/_components/examples/markers-example.tsx
similarity index 100%
rename from src/app/docs/_components/examples/markers-example.tsx
rename to src/app/(main)/docs/_components/examples/markers-example.tsx
diff --git a/src/app/docs/_components/examples/osrm-route-example.tsx b/src/app/(main)/docs/_components/examples/osrm-route-example.tsx
similarity index 100%
rename from src/app/docs/_components/examples/osrm-route-example.tsx
rename to src/app/(main)/docs/_components/examples/osrm-route-example.tsx
diff --git a/src/app/docs/_components/examples/popup-example.tsx b/src/app/(main)/docs/_components/examples/popup-example.tsx
similarity index 100%
rename from src/app/docs/_components/examples/popup-example.tsx
rename to src/app/(main)/docs/_components/examples/popup-example.tsx
diff --git a/src/app/docs/_components/examples/route-example.tsx b/src/app/(main)/docs/_components/examples/route-example.tsx
similarity index 100%
rename from src/app/docs/_components/examples/route-example.tsx
rename to src/app/(main)/docs/_components/examples/route-example.tsx
diff --git a/src/app/docs/_components/examples/standalone-popup-example.tsx b/src/app/(main)/docs/_components/examples/standalone-popup-example.tsx
similarity index 100%
rename from src/app/docs/_components/examples/standalone-popup-example.tsx
rename to src/app/(main)/docs/_components/examples/standalone-popup-example.tsx
diff --git a/src/lib/get-example-source.ts b/src/app/(main)/docs/_components/get-example-source.ts
similarity index 81%
rename from src/lib/get-example-source.ts
rename to src/app/(main)/docs/_components/get-example-source.ts
index 405e912..29069e2 100644
--- a/src/lib/get-example-source.ts
+++ b/src/app/(main)/docs/_components/get-example-source.ts
@@ -3,13 +3,12 @@ import path from "path";
const EXAMPLES_DIR = path.join(
process.cwd(),
- "src/app/docs/_components/examples"
+ "src/app/(main)/docs/_components/examples"
);
export function getExampleSource(filename: string): string {
const filePath = path.join(EXAMPLES_DIR, filename);
const source = fs.readFileSync(filePath, "utf-8");
- // Clean up the source for display:
return source.replace(/@\/registry\/map/g, "@/components/ui/map");
}
diff --git a/src/app/docs/advanced-usage/page.tsx b/src/app/(main)/docs/advanced-usage/page.tsx
similarity index 98%
rename from src/app/docs/advanced-usage/page.tsx
rename to src/app/(main)/docs/advanced-usage/page.tsx
index 007b2b0..a094110 100644
--- a/src/app/docs/advanced-usage/page.tsx
+++ b/src/app/(main)/docs/advanced-usage/page.tsx
@@ -10,7 +10,7 @@ import { AdvancedUsageExample } from "../_components/examples/advanced-usage-exa
import { CustomLayerExample } from "../_components/examples/custom-layer-example";
import { LayerMarkersExample } from "../_components/examples/layer-markers-example";
import { CodeBlock } from "../_components/code-block";
-import { getExampleSource } from "@/lib/get-example-source";
+import { getExampleSource } from "../_components/get-example-source";
import { Metadata } from "next";
export const metadata: Metadata = {
diff --git a/src/app/docs/api-reference/page.tsx b/src/app/(main)/docs/api-reference/page.tsx
similarity index 99%
rename from src/app/docs/api-reference/page.tsx
rename to src/app/(main)/docs/api-reference/page.tsx
index 058ba70..eaa9304 100644
--- a/src/app/docs/api-reference/page.tsx
+++ b/src/app/(main)/docs/api-reference/page.tsx
@@ -136,6 +136,12 @@ export default function ApiReferencePage() {
description:
"Callback fired continuously as the viewport changes (during pan, zoom, rotate). Can be used alone to observe changes, or with viewport prop to enable controlled mode.",
},
+ {
+ name: "loading",
+ type: "boolean",
+ default: "false",
+ description: "Show a loading indicator on the map.",
+ },
]}
/>
</DocsSection>
diff --git a/src/app/docs/basic-map/page.tsx b/src/app/(main)/docs/basic-map/page.tsx
similarity index 97%
rename from src/app/docs/basic-map/page.tsx
rename to src/app/(main)/docs/basic-map/page.tsx
index e566ab0..cb7778f 100644
--- a/src/app/docs/basic-map/page.tsx
+++ b/src/app/(main)/docs/basic-map/page.tsx
@@ -8,7 +8,7 @@ import { ComponentPreview } from "../_components/component-preview";
import { BasicMapExample } from "../_components/examples/basic-map-example";
import { ControlledMapExample } from "../_components/examples/controlled-map-example";
import { CustomStyleExample } from "../_components/examples/custom-style-example";
-import { getExampleSource } from "@/lib/get-example-source";
+import { getExampleSource } from "../_components/get-example-source";
import { Metadata } from "next";
export const metadata: Metadata = {
diff --git a/src/app/docs/clusters/page.tsx b/src/app/(main)/docs/clusters/page.tsx
similarity index 94%
rename from src/app/docs/clusters/page.tsx
rename to src/app/(main)/docs/clusters/page.tsx
index ad8a7c8..59b2221 100644
--- a/src/app/docs/clusters/page.tsx
+++ b/src/app/(main)/docs/clusters/page.tsx
@@ -1,7 +1,7 @@
import { DocsLayout, DocsSection, DocsCode } from "../_components/docs";
import { ComponentPreview } from "../_components/component-preview";
import ClusterExample from "../_components/examples/cluster-example";
-import { getExampleSource } from "@/lib/get-example-source";
+import { getExampleSource } from "../_components/get-example-source";
import { Metadata } from "next";
export const metadata: Metadata = {
diff --git a/src/app/docs/controls/page.tsx b/src/app/(main)/docs/controls/page.tsx
similarity index 93%
rename from src/app/docs/controls/page.tsx
rename to src/app/(main)/docs/controls/page.tsx
index b91673f..4c739ee 100644
--- a/src/app/docs/controls/page.tsx
+++ b/src/app/(main)/docs/controls/page.tsx
@@ -1,7 +1,7 @@
import { DocsLayout, DocsSection, DocsCode } from "../_components/docs";
import { ComponentPreview } from "../_components/component-preview";
import { MapControlsExample } from "../_components/examples/map-controls-example";
-import { getExampleSource } from "@/lib/get-example-source";
+import { getExampleSource } from "../_components/get-example-source";
import { Metadata } from "next";
export const metadata: Metadata = {
diff --git a/src/app/docs/installation/page.tsx b/src/app/(main)/docs/installation/page.tsx
similarity index 100%
rename from src/app/docs/installation/page.tsx
rename to src/app/(main)/docs/installation/page.tsx
diff --git a/src/app/(main)/docs/layout.tsx b/src/app/(main)/docs/layout.tsx
new file mode 100644
index 0000000..1e8e8d5
--- /dev/null
+++ b/src/app/(main)/docs/layout.tsx
@@ -0,0 +1,17 @@
+import { SidebarProvider } from "@/components/ui/sidebar";
+import { DocsSidebar } from "./_components/docs-sidebar";
+
+export default function DocsLayout({
+ children,
+}: {
+ children: React.ReactNode;
+}) {
+ return (
+ <div className="container flex flex-col flex-1">
+ <SidebarProvider>
+ <DocsSidebar />
+ <main className="size-full">{children}</main>
+ </SidebarProvider>
+ </div>
+ );
+}
diff --git a/src/app/docs/markers/page.tsx b/src/app/(main)/docs/markers/page.tsx
similarity index 97%
rename from src/app/docs/markers/page.tsx
rename to src/app/(main)/docs/markers/page.tsx
index dc1bde6..7e11d17 100644
--- a/src/app/docs/markers/page.tsx
+++ b/src/app/(main)/docs/markers/page.tsx
@@ -9,7 +9,7 @@ import { ComponentPreview } from "../_components/component-preview";
import { MarkersExample } from "../_components/examples/markers-example";
import { PopupExample } from "../_components/examples/popup-example";
import { DraggableMarkerExample } from "../_components/examples/draggable-marker-example";
-import { getExampleSource } from "@/lib/get-example-source";
+import { getExampleSource } from "../_components/get-example-source";
import { Metadata } from "next";
export const metadata: Metadata = {
diff --git a/src/app/docs/page.tsx b/src/app/(main)/docs/page.tsx
similarity index 100%
rename from src/app/docs/page.tsx
rename to src/app/(main)/docs/page.tsx
diff --git a/src/app/docs/popups/page.tsx b/src/app/(main)/docs/popups/page.tsx
similarity index 94%
rename from src/app/docs/popups/page.tsx
rename to src/app/(main)/docs/popups/page.tsx
index d9bbab1..25380f6 100644
--- a/src/app/docs/popups/page.tsx
+++ b/src/app/(main)/docs/popups/page.tsx
@@ -1,7 +1,7 @@
import { DocsLayout, DocsSection, DocsCode } from "../_components/docs";
import { ComponentPreview } from "../_components/component-preview";
import { StandalonePopupExample } from "../_components/examples/standalone-popup-example";
-import { getExampleSource } from "@/lib/get-example-source";
+import { getExampleSource } from "../_components/get-example-source";
import { Metadata } from "next";
export const metadata: Metadata = {
diff --git a/src/app/docs/routes/page.tsx b/src/app/(main)/docs/routes/page.tsx
similarity index 96%
rename from src/app/docs/routes/page.tsx
rename to src/app/(main)/docs/routes/page.tsx
index e7ca24c..eb98c0c 100644
--- a/src/app/docs/routes/page.tsx
+++ b/src/app/(main)/docs/routes/page.tsx
@@ -7,7 +7,7 @@ import {
import { ComponentPreview } from "../_components/component-preview";
import { RouteExample } from "../_components/examples/route-example";
import { OsrmRouteExample } from "../_components/examples/osrm-route-example";
-import { getExampleSource } from "@/lib/get-example-source";
+import { getExampleSource } from "../_components/get-example-source";
import { Metadata } from "next";
export const metadata: Metadata = {
diff --git a/src/app/(main)/layout.tsx b/src/app/(main)/layout.tsx
new file mode 100644
index 0000000..4ad5eac
--- /dev/null
+++ b/src/app/(main)/layout.tsx
@@ -0,0 +1,14 @@
+import { Header } from "@/components/header";
+
+export default function MainLayout({
+ children,
+}: {
+ children: React.ReactNode;
+}) {
+ return (
+ <div className="bg-background relative flex min-h-screen flex-col">
+ <Header />
+ <main className="flex-1">{children}</main>
+ </div>
+ );
+}
diff --git a/src/app/(view)/view/[name]/page.tsx b/src/app/(view)/view/[name]/page.tsx
new file mode 100644
index 0000000..92a7a2d
--- /dev/null
+++ b/src/app/(view)/view/[name]/page.tsx
@@ -0,0 +1,38 @@
+import { slugToTitle } from "@/lib/utils";
+import { blockComponents } from "@/registry/blocks/__index__";
+import { notFound } from "next/navigation";
+
+interface BlockViewPageProps {
+ params: Promise<{ name: string }>;
+}
+
+export const generateMetadata = async ({ params }: BlockViewPageProps) => {
+ const { name } = await params;
+ const Component = blockComponents[name];
+
+ if (!Component) {
+ return notFound();
+ }
+
+ const title = slugToTitle(name);
+
+ return {
+ title,
+ description: `View the ${title} block`,
+ };
+};
+
+export default async function BlockViewPage({ params }: BlockViewPageProps) {
+ const { name } = await params;
+ const Component = blockComponents[name];
+
+ if (!Component) {
+ notFound();
+ }
+
+ return (
+ <div className="bg-background min-h-screen">
+ <Component />
+ </div>
+ );
+}
diff --git a/src/app/docs/_components/docs-header.tsx b/src/app/docs/_components/docs-header.tsx
deleted file mode 100644
index 629cdbb..0000000
--- a/src/app/docs/_components/docs-header.tsx
+++ /dev/null
@@ -1,72 +0,0 @@
-"use client";
-
-import Link from "next/link";
-import { usePathname } from "next/navigation";
-
-import {
- Breadcrumb,
- BreadcrumbItem,
- BreadcrumbLink,
- BreadcrumbList,
- BreadcrumbPage,
- BreadcrumbSeparator,
-} from "@/components/ui/breadcrumb";
-import { SidebarTrigger } from "@/components/ui/sidebar";
-import { docsNavigation, type NavItem } from "@/lib/docs-navigation";
-import { cn } from "@/lib/utils";
-
-export function DocsHeader({ className }: { className?: string }) {
- const pathname = usePathname();
-
- let activeItem: (NavItem & { groupTitle: string }) | null = null;
- let groupHref = "/docs";
- for (const group of docsNavigation) {
- const item = group.items.find((navItem) => navItem.href === pathname);
- if (item) {
- activeItem = { ...item, groupTitle: group.title };
- groupHref = group.items[0]?.href ?? "/docs";
- break;
- }
- }
-
- return (
- <header
- className={cn(
- "w-full p-4 px-6 sticky top-0 z-50 bg-background/95 backdrop-blur supports-backdrop-filter:bg-background/70",
- className
- )}
- >
- <nav className="flex items-center gap-3">
- <SidebarTrigger />
- <div className="h-4 w-px shrink-0 bg-border" />
- <Breadcrumb>
- <BreadcrumbList>
- <BreadcrumbItem>
- <BreadcrumbLink asChild>
- <Link href="/docs">Docs</Link>
- </BreadcrumbLink>
- </BreadcrumbItem>
- <BreadcrumbSeparator />
- <BreadcrumbItem>
- <BreadcrumbLink asChild>
- <Link href={groupHref}>
- {activeItem?.groupTitle ?? "Overview"}
- </Link>
- </BreadcrumbLink>
- </BreadcrumbItem>
- {pathname !== "/docs" && pathname !== "/docs/basic-map" && (
- <>
- <BreadcrumbSeparator />
- <BreadcrumbItem className="min-w-0 truncate">
- <BreadcrumbPage>
- {activeItem?.title ?? "Documentation"}
- </BreadcrumbPage>
- </BreadcrumbItem>
- </>
- )}
- </BreadcrumbList>
- </Breadcrumb>
- </nav>
- </header>
- );
-}
diff --git a/src/app/docs/layout.tsx b/src/app/docs/layout.tsx
deleted file mode 100644
index b0f7b8e..0000000
--- a/src/app/docs/layout.tsx
+++ /dev/null
@@ -1,19 +0,0 @@
-import { SidebarInset, SidebarProvider } from "@/components/ui/sidebar";
-import { DocsSidebar } from "./_components/docs-sidebar";
-import { DocsHeader } from "./_components/docs-header";
-
-export default function DocsLayout({
- children,
-}: {
- children: React.ReactNode;
-}) {
- return (
- <SidebarProvider>
- <DocsSidebar />
- <SidebarInset>
- <DocsHeader />
- <main className="container">{children}</main>
- </SidebarInset>
- </SidebarProvider>
- );
-}
diff --git a/src/app/layout.tsx b/src/app/layout.tsx
index 37abc33..039477e 100644
--- a/src/app/layout.tsx
+++ b/src/app/layout.tsx
@@ -2,8 +2,10 @@ import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import { Analytics } from "@vercel/analytics/next";
+import "@/styles/globals.css";
+
import { ThemeProvider } from "@/components/theme-provider";
-import "./globals.css";
+import { TooltipProvider } from "@/components/ui/tooltip";
const geist = Geist({
subsets: ["latin"],
@@ -100,9 +102,9 @@ export default function RootLayout({
className={`${geist.variable} ${geistMono.variable}`}
suppressHydrationWarning
>
- <body className="font-sans antialiased min-h-screen flex flex-col">
+ <body className="font-sans antialiased">
<ThemeProvider>
- <div className="flex-1">{children}</div>
+ <TooltipProvider>{children}</TooltipProvider>
<Analytics />
</ThemeProvider>
</body>
diff --git a/src/app/not-found.tsx b/src/app/not-found.tsx
index 92608de..3e76689 100644
--- a/src/app/not-found.tsx
+++ b/src/app/not-found.tsx
@@ -4,7 +4,7 @@ import { Button } from "@/components/ui/button";
export default function NotFound() {
return (
- <div className="min-h-screen bg-background flex flex-col items-center justify-center px-6">
+ <div className="min-h-[80vh] bg-background flex flex-col items-center justify-center px-6">
<div className="text-center space-y-6 max-w-md">
<div className="flex justify-center">
<div className="relative">
diff --git a/src/components/command-search.tsx b/src/components/command-search.tsx
index 43649b9..e4d9758 100644
--- a/src/components/command-search.tsx
+++ b/src/components/command-search.tsx
@@ -19,7 +19,7 @@ import {
CommandList,
} from "@/components/ui/command";
import { Kbd, KbdGroup } from "@/components/ui/kbd";
-import { docsNavigation } from "@/lib/docs-navigation";
+import { siteNavigation } from "@/lib/site-navigation";
import { Button } from "./ui/button";
import { cn } from "@/lib/utils";
@@ -47,17 +47,17 @@ export function CommandSearch({ className }: { className?: string }) {
return (
<>
<Button
- variant="outline"
+ variant="ghost"
size="sm"
onClick={() => setOpen(true)}
aria-label="Search documentation"
className={cn(
- "hidden group md:flex items-center w-[200px] dark:border-border/60 border-border/80 text-muted-foreground",
+ "hidden md:flex h-8 w-48 items-center gap-2 rounded-md border border-border/50 bg-muted/40 px-2.5 text-muted-foreground hover:bg-muted/70 hover:text-foreground",
className
)}
>
- <SearchIcon className="size-3.5 shrink-0" />
- <span>Search docs...</span>
+ <SearchIcon className="size-3.5" />
+ <span>Search...</span>
<KbdGroup className="ml-auto">
<Kbd>⌘</Kbd>
<Kbd>K</Kbd>
@@ -66,12 +66,12 @@ export function CommandSearch({ className }: { className?: string }) {
<CommandDialog
open={open}
onOpenChange={setOpen}
- title="Search Documentation"
- description="Search for documentation pages and components"
+ title="Search..."
+ description="Jump to pages, components, and docs"
showCloseButton={false}
>
<CommandInput
- placeholder="Search documentation..."
+ placeholder="Search..."
className="border-none text-sm h-10"
/>
<CommandList>
@@ -81,7 +81,7 @@ export function CommandSearch({ className }: { className?: string }) {
<span>No results found.</span>
</div>
</CommandEmpty>
- {docsNavigation.map((group) => (
+ {siteNavigation.map((group) => (
<CommandGroup key={group.title} heading={group.title}>
{group.items.map((item) => (
<CommandItem
diff --git a/src/components/footer.tsx b/src/components/footer.tsx
new file mode 100644
index 0000000..c8122e8
--- /dev/null
+++ b/src/components/footer.tsx
@@ -0,0 +1,117 @@
+import Link from "next/link";
+import { MapPin } from "lucide-react";
+
+const footerLinks = {
+ product: [
+ { label: "Documentation", href: "/docs" },
+ { label: "Components", href: "/docs/basic-map" },
+ { label: "Blocks", href: "/blocks" },
+ ],
+ community: [
+ {
+ label: "GitHub",
+ href: "https://github.com/AnmolSaini16/mapcn",
+ external: true,
+ },
+ {
+ label: "Sponsor",
+ href: "https://github.com/sponsors/AnmolSaini16",
+ external: true,
+ },
+ ],
+ resources: [
+ { label: "MapLibre GL", href: "https://maplibre.org/", external: true },
+ { label: "shadcn/ui", href: "https://ui.shadcn.com/", external: true },
+ {
+ label: "Tailwind CSS",
+ href: "https://tailwindcss.com/",
+ external: true,
+ },
+ ],
+};
+
+export function Footer() {
+ return (
+ <footer className="mt-24 border-t md:mt-32">
+ <div className="container py-12 md:py-16">
+ <div className="grid grid-cols-2 gap-8 md:grid-cols-4">
+ <div className="col-span-2 md:col-span-1">
+ <Link href="/" className="flex w-fit items-center gap-1.5">
+ <MapPin className="size-4 shrink-0" />
+ <span className="text-lg font-semibold tracking-tight">
+ mapcn
+ </span>
+ </Link>
+ <p className="text-muted-foreground mt-3 max-w-xs text-sm leading-relaxed">
+ Free & open-source, ready-to-use, customizable map components for
+ React.
+ </p>
+ <p className="text-muted-foreground mt-3 text-sm">
+ Built by{" "}
+ <Link
+ href="https://x.com/anmol16_"
+ target="_blank"
+ rel="noopener noreferrer"
+ className="text-muted-foreground hover:text-foreground text-sm font-medium transition-colors"
+ >
+ @anmol
+ </Link>
+ </p>
+ </div>
+
+ <div>
+ <h3 className="mb-3 text-sm font-semibold">Product</h3>
+ <ul className="space-y-2.5">
+ {footerLinks.product.map((link) => (
+ <li key={link.href}>
+ <Link
+ href={link.href}
+ className="text-muted-foreground hover:text-foreground text-sm transition-colors"
+ >
+ {link.label}
+ </Link>
+ </li>
+ ))}
+ </ul>
+ </div>
+
+ <div>
+ <h3 className="mb-3 text-sm font-semibold">Community</h3>
+ <ul className="space-y-2.5">
+ {footerLinks.community.map((link) => (
+ <li key={link.href}>
+ <Link
+ href={link.href}
+ target={link.external ? "_blank" : undefined}
+ rel={link.external ? "noopener noreferrer" : undefined}
+ className="text-muted-foreground hover:text-foreground text-sm transition-colors"
+ >
+ {link.label}
+ </Link>
+ </li>
+ ))}
+ </ul>
+ </div>
+
+ <div>
+ <h3 className="mb-3 text-sm font-semibold">Resources</h3>
+ <ul className="space-y-2.5">
+ {footerLinks.resources.map((link) => (
+ <li key={link.href}>
+ <Link
+ href={link.href}
+ target={link.external ? "_blank" : undefined}
+ rel={link.external ? "noopener noreferrer" : undefined}
+ className="text-muted-foreground hover:text-foreground text-sm transition-colors"
+ >
+ {link.label}
+ </Link>
+ </li>
+ ))}
+ </ul>
+ </div>
+ </div>
+ </div>
+ </footer>
+ );
+}
diff --git a/src/app/(home)/_components/header.tsx b/src/components/header.tsx
similarity index 71%
rename from src/app/(home)/_components/header.tsx
rename to src/components/header.tsx
index 7edf09d..b3f361d 100644
--- a/src/app/(home)/_components/header.tsx
+++ b/src/components/header.tsx
@@ -1,6 +1,8 @@
import { Heart } from "lucide-react";
import { Logo } from "@/components/logo";
+import { MainNav } from "@/components/main-nav";
+import { MobileNav } from "@/components/mobile-nav";
import { Button } from "@/components/ui/button";
import { Separator } from "@/components/ui/separator";
import {
@@ -15,11 +17,15 @@ import { cn } from "@/lib/utils";
export function Header({ className }: { className?: string }) {
return (
- <header className={cn("w-full p-4 container", className)}>
- <nav className="flex size-full items-center justify-between">
- <Logo />
+ <header
+ className={cn("bg-background sticky top-0 z-50 h-14 w-full", className)}
+ >
+ <nav className="container flex size-full items-center gap-2">
+ <MobileNav />
+ <Logo className="hidden shrink-0 lg:flex" />
+ <MainNav className="hidden lg:flex" />
- <div className="flex items-center gap-2 h-4.5">
+ <div className="ml-auto flex h-4.5 items-center gap-2">
<CommandSearch />
<Separator orientation="vertical" className="hidden md:block" />
<Tooltip>
@@ -30,8 +36,8 @@ export function Header({ className }: { className?: string }) {
target="_blank"
rel="noopener noreferrer"
>
- <Heart className="size-4 text-pink-500" />
- <span className="hidden md:inline">Sponsor</span>
+ <Heart className="size-3.5 text-pink-500" />
+ Sponsor
</a>
</Button>
</TooltipTrigger>
diff --git a/src/components/logo.tsx b/src/components/logo.tsx
index 84877ef..ce24ecb 100644
--- a/src/components/logo.tsx
+++ b/src/components/logo.tsx
@@ -1,16 +1,25 @@
import Link from "next/link";
import { MapPin } from "lucide-react";
import { cn } from "@/lib/utils";
+import { Button } from "./ui/button";
interface LogoProps {
className?: string;
+ onClick?: () => void;
}
-export function Logo({ className }: LogoProps) {
+export function Logo({ className, onClick }: LogoProps) {
return (
- <Link href="/" className={cn("flex items-center gap-1.5 w-fit", className)}>
- <MapPin className="size-4 shrink-0" />
- <span className="font-semibold text-lg tracking-tight">mapcn</span>
- </Link>
+ <Button
+ asChild
+ size="sm"
+ variant="ghost"
+ className={cn("px-2.5 text-base font-semibold", className)}
+ >
+ <Link href="/" onClick={onClick}>
+ <MapPin />
+ mapcn
+ </Link>
+ </Button>
);
}
diff --git a/src/components/main-nav.tsx b/src/components/main-nav.tsx
new file mode 100644
index 0000000..af7b296
--- /dev/null
+++ b/src/components/main-nav.tsx
@@ -0,0 +1,36 @@
+"use client";
+
+import Link from "next/link";
+
+import { siteNavigation } from "@/lib/site-navigation";
+import { Button } from "@/components/ui/button";
+import { cn } from "@/lib/utils";
+
+export function MainNav({ className, ...props }: React.ComponentProps<"nav">) {
+ const navItems = siteNavigation
+ .find((group) => group.title === "Pages")
+ ?.items.filter((item) => item.title !== "Home");
+
+ if (!navItems) return null;
+
+ return (
+ <nav className={cn("items-center gap-1", className)} {...props}>
+ {navItems.map((item) => (
+ <Button
+ key={item.href}
+ variant="ghost"
+ asChild
+ size="sm"
+ className="px-2.5"
+ >
+ <Link
+ href={item.href}
+ className="relative inline-flex items-center gap-1.5"
+ >
+ <span>{item.title}</span>
+ </Link>
+ </Button>
+ ))}
+ </nav>
+ );
+}
diff --git a/src/components/mobile-nav.tsx b/src/components/mobile-nav.tsx
new file mode 100644
index 0000000..581cfba
--- /dev/null
+++ b/src/components/mobile-nav.tsx
@@ -0,0 +1,63 @@
+"use client";
+
+import { useState } from "react";
+import Link from "next/link";
+import { Menu } from "lucide-react";
+
+import { Button } from "@/components/ui/button";
+import {
+ Sheet,
+ SheetContent,
+ SheetHeader,
+ SheetTitle,
+ SheetTrigger,
+} from "@/components/ui/sheet";
+import { siteNavigation } from "@/lib/site-navigation";
+
+export function MobileNav() {
+ const [open, setOpen] = useState(false);
+
+ return (
+ <Sheet open={open} onOpenChange={setOpen}>
+ <SheetTrigger asChild>
+ <Button
+ variant="ghost"
+ size="icon"
+ aria-label="Open docs menu"
+ className="shrink-0 lg:hidden"
+ >
+ <Menu className="size-5" />
+ </Button>
+ </SheetTrigger>
+ <SheetContent side="left" className="rounded-r-xl">
+ <SheetHeader>
+ <SheetTitle className="sr-only">Sidebar</SheetTitle>
+ </SheetHeader>
+ <div className="overflow-y-auto px-2">
+ <nav className="space-y-6">
+ {siteNavigation.map((group) => (
+ <div key={group.title}>
+ <h3 className="text-muted-foreground mb-2 px-2 text-sm font-medium">
+ {group.title}
+ </h3>
+ <ul>
+ {group.items.map((item) => (
+ <li key={item.href}>
+ <Link
+ href={item.href}
+ onClick={() => setOpen(false)}
+ className="flex items-center px-3 py-2.5"
+ >
+ {item.title}
+ </Link>
+ </li>
+ ))}
+ </ul>
+ </div>
+ ))}
+ </nav>
+ </div>
+ </SheetContent>
+ </Sheet>
+ );
+}
diff --git a/src/components/page-header.tsx b/src/components/page-header.tsx
new file mode 100644
index 0000000..4f091ab
--- /dev/null
+++ b/src/components/page-header.tsx
@@ -0,0 +1,155 @@
+"use client";
+
+import { cn } from "@/lib/utils";
+import { createContext, useContext } from "react";
+
+type HeaderAlign = "center" | "left";
+
+const PageHeaderContext = createContext<{ align: HeaderAlign }>({
+ align: "center",
+});
+
+function usePageHeaderContext() {
+ return useContext(PageHeaderContext);
+}
+
+interface PageHeaderProps {
+ children: React.ReactNode;
+ className?: string;
+ /** Show the dot grid background (default: true) */
+ showBackground?: boolean;
+ /** Header content alignment (default: center) */
+ align?: HeaderAlign;
+}
+
+function PageHeader({
+ children,
+ className,
+ showBackground = true,
+ align = "center",
+}: PageHeaderProps) {
+ return (
+ <PageHeaderContext.Provider value={{ align }}>
+ <div className="relative">
+ {showBackground && (
+ <div className="pointer-events-none absolute inset-x-0 -inset-y-10 overflow-hidden">
+ <div
+ className="absolute inset-0 opacity-[0.20] dark:opacity-[0.12]"
+ style={{
+ backgroundImage: `radial-gradient(circle, currentColor 1px, transparent 1px)`,
+ backgroundSize: "24px 24px",
+ }}
+ />
+ <div className="from-background to-background absolute inset-0 bg-linear-to-b via-transparent" />
+ </div>
+ )}
+
+ <section
+ className={cn(
+ "container mx-auto flex w-full max-w-6xl flex-col gap-4 py-16 md:py-24 lg:pt-26 lg:pb-24",
+ align === "center"
+ ? "items-center text-center"
+ : "items-start text-left",
+ className,
+ )}
+ >
+ {children}
+ </section>
+ </div>
+ </PageHeaderContext.Provider>
+ );
+}
+
+interface PageHeaderHeadingProps {
+ children: React.ReactNode;
+ className?: string;
+ as?: "h1" | "h2";
+}
+
+function PageHeaderHeading({
+ children,
+ className,
+ as: Comp = "h1",
+}: PageHeaderHeadingProps) {
+ const { align } = usePageHeaderContext();
+
+ return (
+ <Comp
+ className={cn(
+ "animate-fade-up max-w-4xl text-4xl font-semibold tracking-tight delay-100 sm:text-5xl md:text-6xl",
+ align === "center" ? "text-center" : "text-left",
+ className,
+ )}
+ >
+ <span className="from-foreground via-foreground to-foreground/65 bg-linear-to-b bg-clip-text text-transparent">
+ {children}
+ </span>
+ </Comp>
+ );
+}
+
+interface PageHeaderDescriptionProps {
+ children: React.ReactNode;
+ className?: string;
+}
+
+function PageHeaderDescription({
+ children,
+ className,
+}: PageHeaderDescriptionProps) {
+ const { align } = usePageHeaderContext();
+
+ return (
+ <p
+ className={cn(
+ "text-muted-foreground animate-fade-up max-w-2xl leading-relaxed delay-200 sm:text-lg sm:leading-relaxed md:text-xl md:leading-relaxed",
+ align === "center" ? "text-center" : "text-left",
+ className,
+ )}
+ >
+ {children}
+ </p>
+ );
+}
+
+interface PageContentProps {
+ children: React.ReactNode;
+ className?: string;
+}
+
+function PageContent({ children, className }: PageContentProps) {
+ return (
+ <div className={cn("animate-fade-up w-full max-w-lg delay-300", className)}>
+ {children}
+ </div>
+ );
+}
+
+interface PageActionsProps {
+ children: React.ReactNode;
+ className?: string;
+}
+
+function PageActions({ children, className }: PageActionsProps) {
+ const { align } = usePageHeaderContext();
+
+ return (
+ <div
+ className={cn(
+ "animate-fade-up mt-3 flex flex-wrap items-center gap-3 delay-400",
+ align === "center" ? "justify-center" : "justify-start",
+ className,
+ )}
+ >
+ {children}
+ </div>
+ );
+}
+
+export {
+ PageHeader,
+ PageHeaderHeading,
+ PageHeaderDescription,
+ PageContent,
+ PageActions,
+};
diff --git a/src/components/theme-toggle.tsx b/src/components/theme-toggle.tsx
index 296071e..dc81542 100644
--- a/src/components/theme-toggle.tsx
+++ b/src/components/theme-toggle.tsx
@@ -60,7 +60,6 @@ export function ThemeToggle() {
size="icon-sm"
>
{resolvedTheme === "dark" ? <Moon /> : <Sun />}
- <span className="sr-only">Toggle theme</span>
</Button>
</TooltipTrigger>
<TooltipContent className="flex items-center gap-2 pr-1">
diff --git a/src/components/ui/badge.tsx b/src/components/ui/badge.tsx
new file mode 100644
index 0000000..6eb2a05
--- /dev/null
+++ b/src/components/ui/badge.tsx
@@ -0,0 +1,48 @@
+import * as React from "react"
+import { cva, type VariantProps } from "class-variance-authority"
+import { Slot } from "radix-ui"
+
+import { cn } from "@/lib/utils"
+
+const badgeVariants = cva(
+ "inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3",
+ {
+ variants: {
+ variant: {
+ default: "bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
+ secondary:
+ "bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
+ destructive:
+ "bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90",
+ outline:
+ "border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
+ ghost: "[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
+ link: "text-primary underline-offset-4 [a&]:hover:underline",
+ },
+ },
+ defaultVariants: {
+ variant: "default",
+ },
+ }
+)
+
+function Badge({
+ className,
+ variant = "default",
+ asChild = false,
+ ...props
+}: React.ComponentProps<"span"> &
+ VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
+ const Comp = asChild ? Slot.Root : "span"
+
+ return (
+ <Comp
+ data-slot="badge"
+ data-variant={variant}
+ className={cn(badgeVariants({ variant }), className)}
+ {...props}
+ />
+ )
+}
+
+export { Badge, badgeVariants }
diff --git a/src/components/ui/button.tsx b/src/components/ui/button.tsx
index 8d27741..4d38506 100644
--- a/src/components/ui/button.tsx
+++ b/src/components/ui/button.tsx
@@ -1,30 +1,32 @@
-import * as React from "react";
-import { Slot } from "@radix-ui/react-slot";
-import { cva, type VariantProps } from "class-variance-authority";
+import * as React from "react"
+import { cva, type VariantProps } from "class-variance-authority"
+import { Slot } from "radix-ui"
-import { cn } from "@/lib/utils";
+import { cn } from "@/lib/utils"
const buttonVariants = cva(
- "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
+ "inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
{
variants: {
variant: {
default: "bg-primary text-primary-foreground hover:bg-primary/90",
destructive:
- "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
+ "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",
outline:
- "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
+ "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
secondary:
"bg-secondary text-secondary-foreground hover:bg-secondary/80",
ghost:
- "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/60",
+ "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
link: "text-primary underline-offset-4 hover:underline",
},
size: {
default: "h-9 px-4 py-2 has-[>svg]:px-3",
- sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
+ xs: "h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",
+ sm: "h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
icon: "size-9",
+ "icon-xs": "size-6 rounded-md [&_svg:not([class*='size-'])]:size-3",
"icon-sm": "size-8",
"icon-lg": "size-10",
},
@@ -34,7 +36,7 @@ const buttonVariants = cva(
size: "default",
},
}
-);
+)
function Button({
className,
@@ -44,9 +46,9 @@ function Button({
...props
}: React.ComponentProps<"button"> &
VariantProps<typeof buttonVariants> & {
- asChild?: boolean;
+ asChild?: boolean
}) {
- const Comp = asChild ? Slot : "button";
+ const Comp = asChild ? Slot.Root : "button"
return (
<Comp
@@ -56,7 +58,7 @@ function Button({
className={cn(buttonVariants({ variant, size, className }))}
{...props}
/>
- );
+ )
}
-export { Button, buttonVariants };
+export { Button, buttonVariants }
diff --git a/src/components/ui/card.tsx b/src/components/ui/card.tsx
index 681ad98..f0e6607 100644
--- a/src/components/ui/card.tsx
+++ b/src/components/ui/card.tsx
@@ -1,18 +1,18 @@
-import * as React from "react"
+import * as React from "react";
-import { cn } from "@/lib/utils"
+import { cn } from "@/lib/utils";
function Card({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card"
className={cn(
- "bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",
+ "flex flex-col gap-4 rounded-xl border bg-card py-4 text-card-foreground shadow-sm",
className
)}
{...props}
/>
- )
+ );
}
function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
@@ -20,12 +20,12 @@ function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
<div
data-slot="card-header"
className={cn(
- "@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",
+ "@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-4 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-4",
className
)}
{...props}
/>
- )
+ );
}
function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
@@ -35,17 +35,17 @@ function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
className={cn("leading-none font-semibold", className)}
{...props}
/>
- )
+ );
}
function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-description"
- className={cn("text-muted-foreground text-sm", className)}
+ className={cn("text-sm text-muted-foreground", className)}
{...props}
/>
- )
+ );
}
function CardAction({ className, ...props }: React.ComponentProps<"div">) {
@@ -58,27 +58,27 @@ function CardAction({ className, ...props }: React.ComponentProps<"div">) {
)}
{...props}
/>
- )
+ );
}
function CardContent({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-content"
- className={cn("px-6", className)}
+ className={cn("px-4", className)}
{...props}
/>
- )
+ );
}
function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-footer"
- className={cn("flex items-center px-6 [.border-t]:pt-6", className)}
+ className={cn("flex items-center px-4 [.border-t]:pt-4", className)}
{...props}
/>
- )
+ );
}
export {
@@ -89,4 +89,4 @@ export {
CardAction,
CardDescription,
CardContent,
-}
+};
diff --git a/src/components/ui/chart.tsx b/src/components/ui/chart.tsx
new file mode 100644
index 0000000..5a7170c
--- /dev/null
+++ b/src/components/ui/chart.tsx
@@ -0,0 +1,357 @@
+"use client";
+
+import * as React from "react";
+import * as RechartsPrimitive from "recharts";
+
+import { cn } from "@/lib/utils";
+
+// Format: { THEME_NAME: CSS_SELECTOR }
+const THEMES = { light: "", dark: ".dark" } as const;
+
+export type ChartConfig = {
+ [k in string]: {
+ label?: React.ReactNode;
+ icon?: React.ComponentType;
+ } & (
+ | { color?: string; theme?: never }
+ | { color?: never; theme: Record<keyof typeof THEMES, string> }
+ );
+};
+
+type ChartContextProps = {
+ config: ChartConfig;
+};
+
+const ChartContext = React.createContext<ChartContextProps | null>(null);
+
+function useChart() {
+ const context = React.useContext(ChartContext);
+
+ if (!context) {
+ throw new Error("useChart must be used within a <ChartContainer />");
+ }
+
+ return context;
+}
+
+function ChartContainer({
+ id,
+ className,
+ children,
+ config,
+ ...props
+}: React.ComponentProps<"div"> & {
+ config: ChartConfig;
+ children: React.ComponentProps<
+ typeof RechartsPrimitive.ResponsiveContainer
+ >["children"];
+}) {
+ const uniqueId = React.useId();
+ const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
+
+ return (
+ <ChartContext.Provider value={{ config }}>
+ <div
+ data-slot="chart"
+ data-chart={chartId}
+ className={cn(
+ "flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
+ className
+ )}
+ {...props}
+ >
+ <ChartStyle id={chartId} config={config} />
+ <RechartsPrimitive.ResponsiveContainer>
+ {children}
+ </RechartsPrimitive.ResponsiveContainer>
+ </div>
+ </ChartContext.Provider>
+ );
+}
+
+const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
+ const colorConfig = Object.entries(config).filter(
+ ([, config]) => config.theme || config.color
+ );
+
+ if (!colorConfig.length) {
+ return null;
+ }
+
+ return (
+ <style
+ dangerouslySetInnerHTML={{
+ __html: Object.entries(THEMES)
+ .map(
+ ([theme, prefix]) => `
+${prefix} [data-chart=${id}] {
+${colorConfig
+ .map(([key, itemConfig]) => {
+ const color =
+ itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ||
+ itemConfig.color;
+ return color ? ` --color-${key}: ${color};` : null;
+ })
+ .join("\n")}
+}
+`
+ )
+ .join("\n"),
+ }}
+ />
+ );
+};
+
+const ChartTooltip = RechartsPrimitive.Tooltip;
+
+function ChartTooltipContent({
+ active,
+ payload,
+ className,
+ indicator = "dot",
+ hideLabel = false,
+ hideIndicator = false,
+ label,
+ labelFormatter,
+ labelClassName,
+ formatter,
+ color,
+ nameKey,
+ labelKey,
+}: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
+ React.ComponentProps<"div"> & {
+ hideLabel?: boolean;
+ hideIndicator?: boolean;
+ indicator?: "line" | "dot" | "dashed";
+ nameKey?: string;
+ labelKey?: string;
+ }) {
+ const { config } = useChart();
+
+ const tooltipLabel = React.useMemo(() => {
+ if (hideLabel || !payload?.length) {
+ return null;
+ }
+
+ const [item] = payload;
+ const key = `${labelKey || item?.dataKey || item?.name || "value"}`;
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
+ const value =
+ !labelKey && typeof label === "string"
+ ? config[label as keyof typeof config]?.label || label
+ : itemConfig?.label;
+
+ if (labelFormatter) {
+ return (
+ <div className={cn("font-medium", labelClassName)}>
+ {labelFormatter(value, payload)}
+ </div>
+ );
+ }
+
+ if (!value) {
+ return null;
+ }
+
+ return <div className={cn("font-medium", labelClassName)}>{value}</div>;
+ }, [
+ label,
+ labelFormatter,
+ payload,
+ hideLabel,
+ labelClassName,
+ config,
+ labelKey,
+ ]);
+
+ if (!active || !payload?.length) {
+ return null;
+ }
+
+ const nestLabel = payload.length === 1 && indicator !== "dot";
+
+ return (
+ <div
+ className={cn(
+ "grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",
+ className
+ )}
+ >
+ {!nestLabel ? tooltipLabel : null}
+ <div className="grid gap-1.5">
+ {payload
+ .filter((item) => item.type !== "none")
+ .map((item, index) => {
+ const key = `${nameKey || item.name || item.dataKey || "value"}`;
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
+ const indicatorColor = color || item.payload.fill || item.color;
+
+ return (
+ <div
+ key={item.dataKey}
+ className={cn(
+ "flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",
+ indicator === "dot" && "items-center"
+ )}
+ >
+ {formatter && item?.value !== undefined && item.name ? (
+ formatter(item.value, item.name, item, index, item.payload)
+ ) : (
+ <>
+ {itemConfig?.icon ? (
+ <itemConfig.icon />
+ ) : (
+ !hideIndicator && (
+ <div
+ className={cn(
+ "shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
+ {
+ "h-2.5 w-2.5": indicator === "dot",
+ "w-1": indicator === "line",
+ "w-0 border-[1.5px] border-dashed bg-transparent":
+ indicator === "dashed",
+ "my-0.5": nestLabel && indicator === "dashed",
+ }
+ )}
+ style={
+ {
+ "--color-bg": indicatorColor,
+ "--color-border": indicatorColor,
+ } as React.CSSProperties
+ }
+ />
+ )
+ )}
+ <div
+ className={cn(
+ "flex flex-1 justify-between leading-none",
+ nestLabel ? "items-end" : "items-center"
+ )}
+ >
+ <div className="grid gap-1.5">
+ {nestLabel ? tooltipLabel : null}
+ <span className="text-muted-foreground">
+ {itemConfig?.label || item.name}
+ </span>
+ </div>
+ {item.value && (
+ <span className="font-mono font-medium text-foreground tabular-nums">
+ {item.value.toLocaleString()}
+ </span>
+ )}
+ </div>
+ </>
+ )}
+ </div>
+ );
+ })}
+ </div>
+ </div>
+ );
+}
+
+const ChartLegend = RechartsPrimitive.Legend;
+
+function ChartLegendContent({
+ className,
+ hideIcon = false,
+ payload,
+ verticalAlign = "bottom",
+ nameKey,
+}: React.ComponentProps<"div"> &
+ Pick<RechartsPrimitive.LegendProps, "payload" | "verticalAlign"> & {
+ hideIcon?: boolean;
+ nameKey?: string;
+ }) {
+ const { config } = useChart();
+
+ if (!payload?.length) {
+ return null;
+ }
+
+ return (
+ <div
+ className={cn(
+ "flex items-center justify-center gap-4",
+ verticalAlign === "top" ? "pb-3" : "pt-3",
+ className
+ )}
+ >
+ {payload
+ .filter((item) => item.type !== "none")
+ .map((item) => {
+ const key = `${nameKey || item.dataKey || "value"}`;
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
+
+ return (
+ <div
+ key={item.value}
+ className={cn(
+ "flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"
+ )}
+ >
+ {itemConfig?.icon && !hideIcon ? (
+ <itemConfig.icon />
+ ) : (
+ <div
+ className="h-2 w-2 shrink-0 rounded-[2px]"
+ style={{
+ backgroundColor: item.color,
+ }}
+ />
+ )}
+ {itemConfig?.label}
+ </div>
+ );
+ })}
+ </div>
+ );
+}
+
+// Helper to extract item config from a payload.
+function getPayloadConfigFromPayload(
+ config: ChartConfig,
+ payload: unknown,
+ key: string
+) {
+ if (typeof payload !== "object" || payload === null) {
+ return undefined;
+ }
+
+ const payloadPayload =
+ "payload" in payload &&
+ typeof payload.payload === "object" &&
+ payload.payload !== null
+ ? payload.payload
+ : undefined;
+
+ let configLabelKey: string = key;
+
+ if (
+ key in payload &&
+ typeof payload[key as keyof typeof payload] === "string"
+ ) {
+ configLabelKey = payload[key as keyof typeof payload] as string;
+ } else if (
+ payloadPayload &&
+ key in payloadPayload &&
+ typeof payloadPayload[key as keyof typeof payloadPayload] === "string"
+ ) {
+ configLabelKey = payloadPayload[
+ key as keyof typeof payloadPayload
+ ] as string;
+ }
+
+ return configLabelKey in config
+ ? config[configLabelKey]
+ : config[key as keyof typeof config];
+}
+
+export {
+ ChartContainer,
+ ChartTooltip,
+ ChartTooltipContent,
+ ChartLegend,
+ ChartLegendContent,
+ ChartStyle,
+};
diff --git a/src/components/ui/collapsible.tsx b/src/components/ui/collapsible.tsx
new file mode 100644
index 0000000..2f7a4e7
--- /dev/null
+++ b/src/components/ui/collapsible.tsx
@@ -0,0 +1,33 @@
+"use client"
+
+import { Collapsible as CollapsiblePrimitive } from "radix-ui"
+
+function Collapsible({
+ ...props
+}: React.ComponentProps<typeof CollapsiblePrimitive.Root>) {
+ return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />
+}
+
+function CollapsibleTrigger({
+ ...props
+}: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>) {
+ return (
+ <CollapsiblePrimitive.CollapsibleTrigger
+ data-slot="collapsible-trigger"
+ {...props}
+ />
+ )
+}
+
+function CollapsibleContent({
+ ...props
+}: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>) {
+ return (
+ <CollapsiblePrimitive.CollapsibleContent
+ data-slot="collapsible-content"
+ {...props}
+ />
+ )
+}
+
+export { Collapsible, CollapsibleTrigger, CollapsibleContent }
diff --git a/src/components/ui/input.tsx b/src/components/ui/input.tsx
index 8916905..f1124ae 100644
--- a/src/components/ui/input.tsx
+++ b/src/components/ui/input.tsx
@@ -8,9 +8,9 @@ function Input({ className, type, ...props }: React.ComponentProps<"input">) {
type={type}
data-slot="input"
className={cn(
- "file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
- "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
- "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
+ "h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none selection:bg-primary selection:text-primary-foreground file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm dark:bg-input/30",
+ "focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50",
+ "aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40",
className
)}
{...props}
diff --git a/src/components/ui/separator.tsx b/src/components/ui/separator.tsx
index 4c24b2a..cd873e3 100644
--- a/src/components/ui/separator.tsx
+++ b/src/components/ui/separator.tsx
@@ -17,7 +17,7 @@ function Separator({
decorative={decorative}
orientation={orientation}
className={cn(
- "bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",
+ "shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",
className
)}
{...props}
diff --git a/src/components/ui/sheet.tsx b/src/components/ui/sheet.tsx
index 84649ad..cb53bb2 100644
--- a/src/components/ui/sheet.tsx
+++ b/src/components/ui/sheet.tsx
@@ -1,8 +1,8 @@
"use client"
import * as React from "react"
-import * as SheetPrimitive from "@radix-ui/react-dialog"
import { XIcon } from "lucide-react"
+import { Dialog as SheetPrimitive } from "radix-ui"
import { cn } from "@/lib/utils"
@@ -36,7 +36,7 @@ function SheetOverlay({
<SheetPrimitive.Overlay
data-slot="sheet-overlay"
className={cn(
- "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
+ "fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",
className
)}
{...props}
@@ -48,9 +48,11 @@ function SheetContent({
className,
children,
side = "right",
+ showCloseButton = true,
...props
}: React.ComponentProps<typeof SheetPrimitive.Content> & {
side?: "top" | "right" | "bottom" | "left"
+ showCloseButton?: boolean
}) {
return (
<SheetPortal>
@@ -58,24 +60,26 @@ function SheetContent({
<SheetPrimitive.Content
data-slot="sheet-content"
className={cn(
- "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500",
+ "fixed z-50 flex flex-col gap-4 bg-background shadow-lg transition ease-in-out data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:animate-in data-[state=open]:duration-500",
side === "right" &&
- "data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm",
+ "inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm",
side === "left" &&
- "data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm",
+ "inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",
side === "top" &&
- "data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",
+ "inset-x-0 top-0 h-auto border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
side === "bottom" &&
- "data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",
+ "inset-x-0 bottom-0 h-auto border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
className
)}
{...props}
>
{children}
- <SheetPrimitive.Close className="ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none">
- <XIcon className="size-4" />
- <span className="sr-only">Close</span>
- </SheetPrimitive.Close>
+ {showCloseButton && (
+ <SheetPrimitive.Close className="absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-secondary">
+ <XIcon className="size-4" />
+ <span className="sr-only">Close</span>
+ </SheetPrimitive.Close>
+ )}
</SheetPrimitive.Content>
</SheetPortal>
)
@@ -108,7 +112,7 @@ function SheetTitle({
return (
<SheetPrimitive.Title
data-slot="sheet-title"
- className={cn("text-foreground font-semibold", className)}
+ className={cn("font-semibold text-foreground", className)}
{...props}
/>
)
@@ -121,7 +125,7 @@ function SheetDescription({
return (
<SheetPrimitive.Description
data-slot="sheet-description"
- className={cn("text-muted-foreground text-sm", className)}
+ className={cn("text-sm text-muted-foreground", className)}
{...props}
/>
)
diff --git a/src/components/ui/sidebar.tsx b/src/components/ui/sidebar.tsx
index 7e0b1ce..778bf99 100644
--- a/src/components/ui/sidebar.tsx
+++ b/src/components/ui/sidebar.tsx
@@ -1,57 +1,56 @@
-"use client";
-
-import * as React from "react";
-import { cva, type VariantProps } from "class-variance-authority";
-import { PanelLeftIcon } from "lucide-react";
-import { Slot } from "@radix-ui/react-slot";
-
-import { useIsMobile } from "@/hooks/use-mobile";
-import { cn } from "@/lib/utils";
-import { Button } from "@/components/ui/button";
-import { Input } from "@/components/ui/input";
-import { Separator } from "@/components/ui/separator";
+"use client"
+
+import * as React from "react"
+import { cva, type VariantProps } from "class-variance-authority"
+import { PanelLeftIcon } from "lucide-react"
+import { Slot } from "radix-ui"
+
+import { useIsMobile } from "@/hooks/use-mobile"
+import { cn } from "@/lib/utils"
+import { Button } from "@/components/ui/button"
+import { Input } from "@/components/ui/input"
+import { Separator } from "@/components/ui/separator"
import {
Sheet,
SheetContent,
SheetDescription,
SheetHeader,
SheetTitle,
-} from "@/components/ui/sheet";
-import { Skeleton } from "@/components/ui/skeleton";
+} from "@/components/ui/sheet"
+import { Skeleton } from "@/components/ui/skeleton"
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
-} from "@/components/ui/tooltip";
-import { Kbd, KbdGroup } from "./kbd";
+} from "@/components/ui/tooltip"
-const SIDEBAR_COOKIE_NAME = "sidebar_state";
-const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
-const SIDEBAR_WIDTH = "16rem";
-const SIDEBAR_WIDTH_MOBILE = "18rem";
-const SIDEBAR_WIDTH_ICON = "3rem";
-const SIDEBAR_KEYBOARD_SHORTCUT = "b";
+const SIDEBAR_COOKIE_NAME = "sidebar_state"
+const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7
+const SIDEBAR_WIDTH = "16rem"
+const SIDEBAR_WIDTH_MOBILE = "18rem"
+const SIDEBAR_WIDTH_ICON = "3rem"
+const SIDEBAR_KEYBOARD_SHORTCUT = "b"
type SidebarContextProps = {
- state: "expanded" | "collapsed";
- open: boolean;
- setOpen: (open: boolean) => void;
- openMobile: boolean;
- setOpenMobile: (open: boolean) => void;
- isMobile: boolean;
- toggleSidebar: () => void;
-};
+ state: "expanded" | "collapsed"
+ open: boolean
+ setOpen: (open: boolean) => void
+ openMobile: boolean
+ setOpenMobile: (open: boolean) => void
+ isMobile: boolean
+ toggleSidebar: () => void
+}
-const SidebarContext = React.createContext<SidebarContextProps | null>(null);
+const SidebarContext = React.createContext<SidebarContextProps | null>(null)
function useSidebar() {
- const context = React.useContext(SidebarContext);
+ const context = React.useContext(SidebarContext)
if (!context) {
- throw new Error("useSidebar must be used within a SidebarProvider.");
+ throw new Error("useSidebar must be used within a SidebarProvider.")
}
- return context;
+ return context
}
function SidebarProvider({
@@ -63,36 +62,36 @@ function SidebarProvider({
children,
...props
}: React.ComponentProps<"div"> & {
- defaultOpen?: boolean;
- open?: boolean;
- onOpenChange?: (open: boolean) => void;
+ defaultOpen?: boolean
+ open?: boolean
+ onOpenChange?: (open: boolean) => void
}) {
- const isMobile = useIsMobile();
- const [openMobile, setOpenMobile] = React.useState(false);
+ const isMobile = useIsMobile()
+ const [openMobile, setOpenMobile] = React.useState(false)
// This is the internal state of the sidebar.
// We use openProp and setOpenProp for control from outside the component.
- const [_open, _setOpen] = React.useState(defaultOpen);
- const open = openProp ?? _open;
+ const [_open, _setOpen] = React.useState(defaultOpen)
+ const open = openProp ?? _open
const setOpen = React.useCallback(
(value: boolean | ((value: boolean) => boolean)) => {
- const openState = typeof value === "function" ? value(open) : value;
+ const openState = typeof value === "function" ? value(open) : value
if (setOpenProp) {
- setOpenProp(openState);
+ setOpenProp(openState)
} else {
- _setOpen(openState);
+ _setOpen(openState)
}
// This sets the cookie to keep the sidebar state.
- document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
+ document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`
},
[setOpenProp, open]
- );
+ )
// Helper to toggle the sidebar.
const toggleSidebar = React.useCallback(() => {
- return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open);
- }, [isMobile, setOpen, setOpenMobile]);
+ return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open)
+ }, [isMobile, setOpen, setOpenMobile])
// Adds a keyboard shortcut to toggle the sidebar.
React.useEffect(() => {
@@ -101,18 +100,18 @@ function SidebarProvider({
event.key === SIDEBAR_KEYBOARD_SHORTCUT &&
(event.metaKey || event.ctrlKey)
) {
- event.preventDefault();
- toggleSidebar();
+ event.preventDefault()
+ toggleSidebar()
}
- };
+ }
- window.addEventListener("keydown", handleKeyDown);
- return () => window.removeEventListener("keydown", handleKeyDown);
- }, [toggleSidebar]);
+ window.addEventListener("keydown", handleKeyDown)
+ return () => window.removeEventListener("keydown", handleKeyDown)
+ }, [toggleSidebar])
// We add a state so that we can do data-state="expanded" or "collapsed".
// This makes it easier to style the sidebar with Tailwind classes.
- const state = open ? "expanded" : "collapsed";
+ const state = open ? "expanded" : "collapsed"
const contextValue = React.useMemo<SidebarContextProps>(
() => ({
@@ -125,7 +124,7 @@ function SidebarProvider({
toggleSidebar,
}),
[state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]
- );
+ )
return (
<SidebarContext.Provider value={contextValue}>
@@ -140,7 +139,7 @@ function SidebarProvider({
} as React.CSSProperties
}
className={cn(
- "group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full",
+ "group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar",
className
)}
{...props}
@@ -149,7 +148,7 @@ function SidebarProvider({
</div>
</TooltipProvider>
</SidebarContext.Provider>
- );
+ )
}
function Sidebar({
@@ -160,25 +159,25 @@ function Sidebar({
children,
...props
}: React.ComponentProps<"div"> & {
- side?: "left" | "right";
- variant?: "sidebar" | "floating" | "inset";
- collapsible?: "offcanvas" | "icon" | "none";
+ side?: "left" | "right"
+ variant?: "sidebar" | "floating" | "inset"
+ collapsible?: "offcanvas" | "icon" | "none"
}) {
- const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
+ const { isMobile, state, openMobile, setOpenMobile } = useSidebar()
if (collapsible === "none") {
return (
<div
data-slot="sidebar"
className={cn(
- "bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col",
+ "flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground",
className
)}
{...props}
>
{children}
</div>
- );
+ )
}
if (isMobile) {
@@ -188,7 +187,7 @@ function Sidebar({
data-sidebar="sidebar"
data-slot="sidebar"
data-mobile="true"
- className="bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden"
+ className="w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden"
style={
{
"--sidebar-width": SIDEBAR_WIDTH_MOBILE,
@@ -203,12 +202,12 @@ function Sidebar({
<div className="flex h-full w-full flex-col">{children}</div>
</SheetContent>
</Sheet>
- );
+ )
}
return (
<div
- className="group peer text-sidebar-foreground hidden md:block"
+ className="group peer hidden text-sidebar-foreground md:block"
data-state={state}
data-collapsible={state === "collapsed" ? collapsible : ""}
data-variant={variant}
@@ -245,13 +244,13 @@ function Sidebar({
<div
data-sidebar="sidebar"
data-slot="sidebar-inner"
- className="bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow-sm"
+ className="flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow-sm"
>
{children}
</div>
</div>
</div>
- );
+ )
}
function SidebarTrigger({
@@ -259,40 +258,29 @@ function SidebarTrigger({
onClick,
...props
}: React.ComponentProps<typeof Button>) {
- const { toggleSidebar } = useSidebar();
+ const { toggleSidebar } = useSidebar()
return (
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- data-sidebar="trigger"
- data-slot="sidebar-trigger"
- variant="ghost"
- size="icon"
- className={cn("size-7", className)}
- onClick={(event) => {
- onClick?.(event);
- toggleSidebar();
- }}
- {...props}
- >
- <PanelLeftIcon />
- <span className="sr-only">Toggle Sidebar</span>
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- Toggle Sidebar{" "}
- <KbdGroup>
- <Kbd>⌘</Kbd>
- <Kbd>{SIDEBAR_KEYBOARD_SHORTCUT.toUpperCase()}</Kbd>
- </KbdGroup>
- </TooltipContent>
- </Tooltip>
- );
+ <Button
+ data-sidebar="trigger"
+ data-slot="sidebar-trigger"
+ variant="ghost"
+ size="icon"
+ className={cn("size-7", className)}
+ onClick={(event) => {
+ onClick?.(event)
+ toggleSidebar()
+ }}
+ {...props}
+ >
+ <PanelLeftIcon />
+ <span className="sr-only">Toggle Sidebar</span>
+ </Button>
+ )
}
function SidebarRail({ className, ...props }: React.ComponentProps<"button">) {
- const { toggleSidebar } = useSidebar();
+ const { toggleSidebar } = useSidebar()
return (
<button
@@ -303,17 +291,17 @@ function SidebarRail({ className, ...props }: React.ComponentProps<"button">) {
onClick={toggleSidebar}
title="Toggle Sidebar"
className={cn(
- "hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] sm:flex",
+ "absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex",
"in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize",
"[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
- "hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full",
+ "group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar",
"[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
"[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
className
)}
{...props}
/>
- );
+ )
}
function SidebarInset({ className, ...props }: React.ComponentProps<"main">) {
@@ -321,13 +309,13 @@ function SidebarInset({ className, ...props }: React.ComponentProps<"main">) {
<main
data-slot="sidebar-inset"
className={cn(
- "bg-background relative flex w-full flex-1 flex-col",
+ "relative flex w-full flex-1 flex-col bg-background",
"md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",
className
)}
{...props}
/>
- );
+ )
}
function SidebarInput({
@@ -338,10 +326,10 @@ function SidebarInput({
<Input
data-slot="sidebar-input"
data-sidebar="input"
- className={cn("bg-background h-8 w-full shadow-none", className)}
+ className={cn("h-8 w-full bg-background shadow-none", className)}
{...props}
/>
- );
+ )
}
function SidebarHeader({ className, ...props }: React.ComponentProps<"div">) {
@@ -352,7 +340,7 @@ function SidebarHeader({ className, ...props }: React.ComponentProps<"div">) {
className={cn("flex flex-col gap-2 p-2", className)}
{...props}
/>
- );
+ )
}
function SidebarFooter({ className, ...props }: React.ComponentProps<"div">) {
@@ -363,7 +351,7 @@ function SidebarFooter({ className, ...props }: React.ComponentProps<"div">) {
className={cn("flex flex-col gap-2 p-2", className)}
{...props}
/>
- );
+ )
}
function SidebarSeparator({
@@ -374,10 +362,10 @@ function SidebarSeparator({
<Separator
data-slot="sidebar-separator"
data-sidebar="separator"
- className={cn("bg-sidebar-border mx-2 w-auto", className)}
+ className={cn("mx-2 w-auto bg-sidebar-border", className)}
{...props}
/>
- );
+ )
}
function SidebarContent({ className, ...props }: React.ComponentProps<"div">) {
@@ -391,7 +379,7 @@ function SidebarContent({ className, ...props }: React.ComponentProps<"div">) {
)}
{...props}
/>
- );
+ )
}
function SidebarGroup({ className, ...props }: React.ComponentProps<"div">) {
@@ -402,7 +390,7 @@ function SidebarGroup({ className, ...props }: React.ComponentProps<"div">) {
className={cn("relative flex w-full min-w-0 flex-col p-2", className)}
{...props}
/>
- );
+ )
}
function SidebarGroupLabel({
@@ -410,20 +398,20 @@ function SidebarGroupLabel({
asChild = false,
...props
}: React.ComponentProps<"div"> & { asChild?: boolean }) {
- const Comp = asChild ? Slot : "div";
+ const Comp = asChild ? Slot.Root : "div"
return (
<Comp
data-slot="sidebar-group-label"
data-sidebar="group-label"
className={cn(
- "text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium outline-hidden transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
+ "flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
"group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",
className
)}
{...props}
/>
- );
+ )
}
function SidebarGroupAction({
@@ -431,14 +419,14 @@ function SidebarGroupAction({
asChild = false,
...props
}: React.ComponentProps<"button"> & { asChild?: boolean }) {
- const Comp = asChild ? Slot : "button";
+ const Comp = asChild ? Slot.Root : "button"
return (
<Comp
data-slot="sidebar-group-action"
data-sidebar="group-action"
className={cn(
- "text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-hidden transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
+ "absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
// Increases the hit area of the button on mobile.
"after:absolute after:-inset-2 md:after:hidden",
"group-data-[collapsible=icon]:hidden",
@@ -446,7 +434,7 @@ function SidebarGroupAction({
)}
{...props}
/>
- );
+ )
}
function SidebarGroupContent({
@@ -460,7 +448,7 @@ function SidebarGroupContent({
className={cn("w-full text-sm", className)}
{...props}
/>
- );
+ )
}
function SidebarMenu({ className, ...props }: React.ComponentProps<"ul">) {
@@ -471,7 +459,7 @@ function SidebarMenu({ className, ...props }: React.ComponentProps<"ul">) {
className={cn("flex w-full min-w-0 flex-col gap-1", className)}
{...props}
/>
- );
+ )
}
function SidebarMenuItem({ className, ...props }: React.ComponentProps<"li">) {
@@ -482,11 +470,11 @@ function SidebarMenuItem({ className, ...props }: React.ComponentProps<"li">) {
className={cn("group/menu-item relative", className)}
{...props}
/>
- );
+ )
}
const sidebarMenuButtonVariants = cva(
- "peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-hidden ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-data-[sidebar=menu-action]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
+ "peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
{
variants: {
variant: {
@@ -505,7 +493,7 @@ const sidebarMenuButtonVariants = cva(
size: "default",
},
}
-);
+)
function SidebarMenuButton({
asChild = false,
@@ -516,12 +504,12 @@ function SidebarMenuButton({
className,
...props
}: React.ComponentProps<"button"> & {
- asChild?: boolean;
- isActive?: boolean;
- tooltip?: string | React.ComponentProps<typeof TooltipContent>;
+ asChild?: boolean
+ isActive?: boolean
+ tooltip?: string | React.ComponentProps<typeof TooltipContent>
} & VariantProps<typeof sidebarMenuButtonVariants>) {
- const Comp = asChild ? Slot : "button";
- const { isMobile, state } = useSidebar();
+ const Comp = asChild ? Slot.Root : "button"
+ const { isMobile, state } = useSidebar()
const button = (
<Comp
@@ -532,16 +520,16 @@ function SidebarMenuButton({
className={cn(sidebarMenuButtonVariants({ variant, size }), className)}
{...props}
/>
- );
+ )
if (!tooltip) {
- return button;
+ return button
}
if (typeof tooltip === "string") {
tooltip = {
children: tooltip,
- };
+ }
}
return (
@@ -554,7 +542,7 @@ function SidebarMenuButton({
{...tooltip}
/>
</Tooltip>
- );
+ )
}
function SidebarMenuAction({
@@ -563,17 +551,17 @@ function SidebarMenuAction({
showOnHover = false,
...props
}: React.ComponentProps<"button"> & {
- asChild?: boolean;
- showOnHover?: boolean;
+ asChild?: boolean
+ showOnHover?: boolean
}) {
- const Comp = asChild ? Slot : "button";
+ const Comp = asChild ? Slot.Root : "button"
return (
<Comp
data-slot="sidebar-menu-action"
data-sidebar="menu-action"
className={cn(
- "text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground peer-hover/menu-button:text-sidebar-accent-foreground absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-hidden transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
+ "absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform peer-hover/menu-button:text-sidebar-accent-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
// Increases the hit area of the button on mobile.
"after:absolute after:-inset-2 md:after:hidden",
"peer-data-[size=sm]/menu-button:top-1",
@@ -581,12 +569,12 @@ function SidebarMenuAction({
"peer-data-[size=lg]/menu-button:top-2.5",
"group-data-[collapsible=icon]:hidden",
showOnHover &&
- "peer-data-[active=true]/menu-button:text-sidebar-accent-foreground group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 md:opacity-0",
+ "group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground data-[state=open]:opacity-100 md:opacity-0",
className
)}
{...props}
/>
- );
+ )
}
function SidebarMenuBadge({
@@ -598,7 +586,7 @@ function SidebarMenuBadge({
data-slot="sidebar-menu-badge"
data-sidebar="menu-badge"
className={cn(
- "text-sidebar-foreground pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums select-none",
+ "pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium text-sidebar-foreground tabular-nums select-none",
"peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground",
"peer-data-[size=sm]/menu-button:top-1",
"peer-data-[size=default]/menu-button:top-1.5",
@@ -608,7 +596,7 @@ function SidebarMenuBadge({
)}
{...props}
/>
- );
+ )
}
function SidebarMenuSkeleton({
@@ -616,12 +604,12 @@ function SidebarMenuSkeleton({
showIcon = false,
...props
}: React.ComponentProps<"div"> & {
- showIcon?: boolean;
+ showIcon?: boolean
}) {
// Random width between 50 to 90%.
const width = React.useMemo(() => {
- return `${Math.floor(Math.random() * 40) + 50}%`;
- }, []);
+ return `${Math.floor(Math.random() * 40) + 50}%`
+ }, [])
return (
<div
@@ -646,7 +634,7 @@ function SidebarMenuSkeleton({
}
/>
</div>
- );
+ )
}
function SidebarMenuSub({ className, ...props }: React.ComponentProps<"ul">) {
@@ -655,13 +643,13 @@ function SidebarMenuSub({ className, ...props }: React.ComponentProps<"ul">) {
data-slot="sidebar-menu-sub"
data-sidebar="menu-sub"
className={cn(
- "border-sidebar-border mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l px-2.5 py-0.5",
+ "mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5",
"group-data-[collapsible=icon]:hidden",
className
)}
{...props}
/>
- );
+ )
}
function SidebarMenuSubItem({
@@ -675,7 +663,7 @@ function SidebarMenuSubItem({
className={cn("group/menu-sub-item relative", className)}
{...props}
/>
- );
+ )
}
function SidebarMenuSubButton({
@@ -685,11 +673,11 @@ function SidebarMenuSubButton({
className,
...props
}: React.ComponentProps<"a"> & {
- asChild?: boolean;
- size?: "sm" | "md";
- isActive?: boolean;
+ asChild?: boolean
+ size?: "sm" | "md"
+ isActive?: boolean
}) {
- const Comp = asChild ? Slot : "a";
+ const Comp = asChild ? Slot.Root : "a"
return (
<Comp
@@ -698,7 +686,7 @@ function SidebarMenuSubButton({
data-size={size}
data-active={isActive}
className={cn(
- "text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 outline-hidden focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
+ "flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground",
"data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",
size === "sm" && "text-xs",
size === "md" && "text-sm",
@@ -707,7 +695,7 @@ function SidebarMenuSubButton({
)}
{...props}
/>
- );
+ )
}
export {
@@ -735,4 +723,4 @@ export {
SidebarSeparator,
SidebarTrigger,
useSidebar,
-};
+}
diff --git a/src/components/ui/skeleton.tsx b/src/components/ui/skeleton.tsx
index 32ea0ef..3ec6be7 100644
--- a/src/components/ui/skeleton.tsx
+++ b/src/components/ui/skeleton.tsx
@@ -4,7 +4,7 @@ function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="skeleton"
- className={cn("bg-accent animate-pulse rounded-md", className)}
+ className={cn("animate-pulse rounded-md bg-accent", className)}
{...props}
/>
)
diff --git a/src/components/ui/tabs.tsx b/src/components/ui/tabs.tsx
new file mode 100644
index 0000000..b463afd
--- /dev/null
+++ b/src/components/ui/tabs.tsx
@@ -0,0 +1,91 @@
+"use client"
+
+import * as React from "react"
+import { cva, type VariantProps } from "class-variance-authority"
+import { Tabs as TabsPrimitive } from "radix-ui"
+
+import { cn } from "@/lib/utils"
+
+function Tabs({
+ className,
+ orientation = "horizontal",
+ ...props
+}: React.ComponentProps<typeof TabsPrimitive.Root>) {
+ return (
+ <TabsPrimitive.Root
+ data-slot="tabs"
+ data-orientation={orientation}
+ orientation={orientation}
+ className={cn(
+ "group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",
+ className
+ )}
+ {...props}
+ />
+ )
+}
+
+const tabsListVariants = cva(
+ "group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-9 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none",
+ {
+ variants: {
+ variant: {
+ default: "bg-muted",
+ line: "gap-1 bg-transparent",
+ },
+ },
+ defaultVariants: {
+ variant: "default",
+ },
+ }
+)
+
+function TabsList({
+ className,
+ variant = "default",
+ ...props
+}: React.ComponentProps<typeof TabsPrimitive.List> &
+ VariantProps<typeof tabsListVariants>) {
+ return (
+ <TabsPrimitive.List
+ data-slot="tabs-list"
+ data-variant={variant}
+ className={cn(tabsListVariants({ variant }), className)}
+ {...props}
+ />
+ )
+}
+
+function TabsTrigger({
+ className,
+ ...props
+}: React.ComponentProps<typeof TabsPrimitive.Trigger>) {
+ return (
+ <TabsPrimitive.Trigger
+ data-slot="tabs-trigger"
+ className={cn(
+ "relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ "group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent",
+ "data-[state=active]:bg-background data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 dark:data-[state=active]:text-foreground",
+ "after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",
+ className
+ )}
+ {...props}
+ />
+ )
+}
+
+function TabsContent({
+ className,
+ ...props
+}: React.ComponentProps<typeof TabsPrimitive.Content>) {
+ return (
+ <TabsPrimitive.Content
+ data-slot="tabs-content"
+ className={cn("flex-1 outline-none", className)}
+ {...props}
+ />
+ )
+}
+
+export { Tabs, TabsList, TabsTrigger, TabsContent, tabsListVariants }
diff --git a/src/components/ui/tooltip.tsx b/src/components/ui/tooltip.tsx
index d4e6be9..ec65c1e 100644
--- a/src/components/ui/tooltip.tsx
+++ b/src/components/ui/tooltip.tsx
@@ -1,9 +1,9 @@
-"use client";
+"use client"
-import * as React from "react";
-import * as TooltipPrimitive from "@radix-ui/react-tooltip";
+import * as React from "react"
+import { Tooltip as TooltipPrimitive } from "radix-ui"
-import { cn } from "@/lib/utils";
+import { cn } from "@/lib/utils"
function TooltipProvider({
delayDuration = 0,
@@ -15,23 +15,19 @@ function TooltipProvider({
delayDuration={delayDuration}
{...props}
/>
- );
+ )
}
function Tooltip({
...props
}: React.ComponentProps<typeof TooltipPrimitive.Root>) {
- return (
- <TooltipProvider>
- <TooltipPrimitive.Root data-slot="tooltip" {...props} />
- </TooltipProvider>
- );
+ return <TooltipPrimitive.Root data-slot="tooltip" {...props} />
}
function TooltipTrigger({
...props
}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
- return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />;
+ return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />
}
function TooltipContent({
@@ -46,16 +42,16 @@ function TooltipContent({
data-slot="tooltip-content"
sideOffset={sideOffset}
className={cn(
- "bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",
+ "z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md bg-foreground px-3 py-1.5 text-xs text-balance text-background fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
className
)}
{...props}
>
{children}
- <TooltipPrimitive.Arrow className="bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" />
+ <TooltipPrimitive.Arrow className="z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground" />
</TooltipPrimitive.Content>
</TooltipPrimitive.Portal>
- );
+ )
}
-export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
+export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }
diff --git a/src/lib/blocks.ts b/src/lib/blocks.ts
new file mode 100644
index 0000000..ab49cfa
--- /dev/null
+++ b/src/lib/blocks.ts
@@ -0,0 +1,77 @@
+import registry from "../../registry.json";
+
+export interface RegistryBlockItem {
+ name: string;
+ type: string;
+ title?: string;
+ description?: string;
+ files?: Array<{ path: string; target?: string }>;
+ registryDependencies?: string[];
+ categories?: string[];
+ meta?: { iframeHeight?: string };
+}
+
+interface RegistrySchema {
+ items: RegistryBlockItem[];
+}
+
+export interface FileTree {
+ name: string;
+ path?: string;
+ children?: FileTree[];
+}
+
+const typedRegistry = registry as RegistrySchema;
+
+export function getAllBlocks(): RegistryBlockItem[] {
+ return typedRegistry.items
+ .filter((item) => item.type === "registry:block")
+ .map((item) => ({
+ name: item.name,
+ type: item.type,
+ title: item.title ?? item.name,
+ description: item.description,
+ files: item.files ?? [],
+ registryDependencies: item.registryDependencies ?? [],
+ categories: item.categories ?? [],
+ meta: item.meta,
+ }));
+}
+
+export function createFileTreeForRegistryItemFiles(
+ files: Array<{ path: string; target?: string }>,
+): FileTree[] {
+ const root: FileTree[] = [];
+
+ for (const file of files) {
+ const filePath = file.target ?? file.path;
+ const parts = filePath.split("/");
+ let currentLevel = root;
+
+ for (let i = 0; i < parts.length; i++) {
+ const part = parts[i];
+ const isFile = i === parts.length - 1;
+ const existingNode = currentLevel.find((node) => node.name === part);
+
+ if (existingNode) {
+ if (isFile) {
+ existingNode.path = filePath;
+ } else {
+ currentLevel = existingNode.children!;
+ }
+ } else {
+ const newNode: FileTree = isFile
+ ? { name: part, path: filePath }
+ : { name: part, children: [] };
+
+ currentLevel.push(newNode);
+
+ if (!isFile) {
+ currentLevel = newNode.children!;
+ }
+ }
+ }
+ }
+
+ return root;
+}
diff --git a/src/lib/get-block-file-source.ts b/src/lib/get-block-file-source.ts
new file mode 100644
index 0000000..4fd693d
--- /dev/null
+++ b/src/lib/get-block-file-source.ts
@@ -0,0 +1,11 @@
+import fs from "fs";
+import path from "path";
+
+const SRC_DIR = process.cwd();
+
+export function getBlockFileSource(registryPath: string): string {
+ const filePath = path.join(SRC_DIR, registryPath);
+ const source = fs.readFileSync(filePath, "utf-8");
+
+ return source.replace(/@\/registry\/map/g, "@/components/ui/map");
+}
diff --git a/src/lib/docs-navigation.ts b/src/lib/site-navigation.ts
similarity index 60%
rename from src/lib/docs-navigation.ts
rename to src/lib/site-navigation.ts
index f675877..9b59fff 100644
--- a/src/lib/docs-navigation.ts
+++ b/src/lib/site-navigation.ts
@@ -1,29 +1,37 @@
import {
- Map,
BookOpen,
- Code,
Braces,
+ Code,
+ Home,
+ Layers,
+ LayoutGrid,
+ LucideIcon,
+ Map,
MapPin,
MessageSquare,
Route,
- Wrench,
Settings,
- Layers,
- LucideIcon,
+ Wrench,
} from "lucide-react";
-export interface NavItem {
+export interface MainNavItem {
+ href: string;
+ label: string;
+}
+
+export interface SiteNavigationItem {
title: string;
href: string;
icon: LucideIcon;
+ new?: boolean;
}
-export interface NavGroup {
+export interface SiteNavigationGroup {
title: string;
- items: NavItem[];
+ items: SiteNavigationItem[];
}
-export const docsNavigation: NavGroup[] = [
+export const docsNavigation: SiteNavigationGroup[] = [
{
title: "Basics",
items: [
@@ -45,3 +53,18 @@ export const docsNavigation: NavGroup[] = [
],
},
];
+
+const navItems: SiteNavigationItem[] = [
+ { title: "Home", href: "/", icon: Home },
+ { title: "Docs", href: "/docs", icon: BookOpen },
+ { title: "Components", href: "/docs/basic-map", icon: Map },
+ { title: "Blocks", href: "/blocks", icon: LayoutGrid },
+];
+
+export const siteNavigation: SiteNavigationGroup[] = [
+ {
+ title: "Pages",
+ items: navItems,
+ },
+ ...docsNavigation,
+];
diff --git a/src/lib/utils.ts b/src/lib/utils.ts
index a5ef193..827e9ab 100644
--- a/src/lib/utils.ts
+++ b/src/lib/utils.ts
@@ -4,3 +4,7 @@ import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
+
+export function slugToTitle(name: string): string {
+ return name.replace(/-/g, " ").replace(/\b\w/g, (char) => char.toUpperCase());
+}
diff --git a/src/registry/blocks/__index__.tsx b/src/registry/blocks/__index__.tsx
new file mode 100644
index 0000000..f1f6cff
--- /dev/null
+++ b/src/registry/blocks/__index__.tsx
@@ -0,0 +1,28 @@
+import React from "react";
+import { RegistryBlockItem } from "@/lib/blocks";
+
+export const blockComponents: Record<
+ RegistryBlockItem["name"],
+ React.LazyExoticComponent<React.ComponentType<object>>
+> = {
+ "analytics-map": React.lazy(() =>
+ import("./analytics-map/page").then((mod) => ({
+ default: mod.AnalyticsMapBlock,
+ }))
+ ),
+ heatmap: React.lazy(() =>
+ import("./heatmap/page").then((mod) => ({
+ default: mod.HeatmapBlock,
+ }))
+ ),
+ "delivery-tracker": React.lazy(() =>
+ import("./delivery-tracker/page").then((mod) => ({
+ default: mod.DeliveryBlock,
+ }))
+ ),
+ "logistics-network": React.lazy(() =>
+ import("./logistics-network/page").then((mod) => ({
+ default: mod.LogisticsNetworkBlock,
+ }))
+ ),
+};
diff --git a/src/registry/blocks/analytics-map/components/breakdown-card.tsx b/src/registry/blocks/analytics-map/components/breakdown-card.tsx
new file mode 100644
index 0000000..d9580b2
--- /dev/null
+++ b/src/registry/blocks/analytics-map/components/breakdown-card.tsx
@@ -0,0 +1,45 @@
+"use client";
+
+import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
+import { type BreakdownRow } from "../data";
+
+interface BreakdownCardProps {
+ title: string;
+ rows: BreakdownRow[];
+}
+
+export function BreakdownCard({ title, rows }: BreakdownCardProps) {
+ const maxRowValue =
+ rows.length > 0 ? Math.max(...rows.map((row) => row.value)) : 0;
+
+ return (
+ <Card>
+ <CardHeader>
+ <CardTitle className="text-sm font-medium">{title}</CardTitle>
+ </CardHeader>
+
+ <CardContent>
+ <div className="text-muted-foreground mb-2 flex items-center justify-between text-[11px] tracking-wider uppercase">
+ <span>{title}</span>
+ <span>Visitors</span>
+ </div>
+ <div className="space-y-3">
+ {rows.map((row) => (
+ <div key={row.label} className="space-y-1.5">
+ <div className="flex items-center justify-between text-xs">
+ <span className="text-foreground/90 truncate">{row.label}</span>
+ <span className="text-foreground font-medium">{row.value}</span>
+ </div>
+ <div className="bg-muted h-1 rounded-full">
+ <div
+ className="h-full rounded-full bg-blue-500/85"
+ style={{ width: `${(row.value / maxRowValue) * 100}%` }}
+ />
+ </div>
+ </div>
+ ))}
+ </div>
+ </CardContent>
+ </Card>
+ );
+}
diff --git a/src/registry/blocks/analytics-map/components/overview-card.tsx b/src/registry/blocks/analytics-map/components/overview-card.tsx
new file mode 100644
index 0000000..b49919d
--- /dev/null
+++ b/src/registry/blocks/analytics-map/components/overview-card.tsx
@@ -0,0 +1,113 @@
+"use client";
+
+import { Card, CardContent, CardHeader } from "@/components/ui/card";
+import { ChartContainer } from "@/components/ui/chart";
+import { TrendingUp } from "lucide-react";
+import { Area, AreaChart, Cell, Pie, PieChart } from "recharts";
+import {
+ deviceCategoryChartConfig,
+ deviceCategoryData,
+ usersPerDay,
+ usersPerDayChartConfig,
+} from "../data";
+
+function MetricChart() {
+ return (
+ <ChartContainer
+ config={usersPerDayChartConfig}
+ className="aspect-auto h-8 w-full"
+ >
+ <AreaChart data={usersPerDay} margin={{ left: 4, right: 4, top: 4 }}>
+ <defs>
+ <linearGradient id="usersGradient" x1="0" y1="0" x2="0" y2="1">
+ <stop
+ offset="0%"
+ stopColor="var(--color-users)"
+ stopOpacity={0.4}
+ />
+ <stop
+ offset="100%"
+ stopColor="var(--color-users)"
+ stopOpacity={0}
+ />
+ </linearGradient>
+ </defs>
+
+ <Area
+ type="natural"
+ dataKey="users"
+ stroke="var(--color-users)"
+ strokeWidth={1.5}
+ fill="url(#usersGradient)"
+ />
+ </AreaChart>
+ </ChartContainer>
+ );
+}
+
+export function OverviewCard() {
+ return (
+ <Card className="bg-card/70 absolute top-4 left-4 z-10 w-60 backdrop-blur-sm">
+ <CardHeader>
+ <div>
+ <p className="text-muted-foreground pb-2 text-[10px] tracking-wider uppercase">
+ Users in last 7 days
+ </p>
+ <p className="text-3xl leading-none font-semibold">3,803</p>
+ </div>
+ </CardHeader>
+
+ <CardContent>
+ <MetricChart />
+ <div className="mt-4 flex items-center gap-1.5 text-xs">
+ <TrendingUp className="size-3 text-emerald-500" />
+ <span className="font-medium text-emerald-500">+12.5%</span>
+ <span className="text-muted-foreground">vs previous 7 days</span>
+ </div>
+
+ <div className="border-border/60 mt-4 border-t pt-4">
+ <p className="text-muted-foreground text-[10px] tracking-wider uppercase">
+ Device category in last 7 days
+ </p>
+
+ <ChartContainer
+ config={deviceCategoryChartConfig}
+ className="mx-auto mt-3 aspect-square h-32 w-32"
+ >
+ <PieChart>
+ <Pie
+ data={deviceCategoryData}
+ dataKey="value"
+ nameKey="name"
+ innerRadius={32}
+ outerRadius={52}
+ strokeWidth={2}
+ >
+ {deviceCategoryData.map((entry) => (
+ <Cell key={entry.name} fill={entry.fill} />
+ ))}
+ </Pie>
+ </PieChart>
+ </ChartContainer>
+
+ <div className="mt-3 grid grid-cols-3 gap-2">
+ {deviceCategoryData.map((device) => (
+ <div key={device.name} className="text-center">
+ <p className="text-muted-foreground flex items-center justify-center gap-1.5 text-[10px] tracking-wide uppercase">
+ <span
+ className="size-2 rounded-full"
+ style={{ backgroundColor: device.fill }}
+ />
+ {device.name}
+ </p>
+ <p className="text-foreground mt-1 leading-none font-medium tabular-nums">
+ {device.value}%
+ </p>
+ </div>
+ ))}
+ </div>
+ </div>
+ </CardContent>
+ </Card>
+ );
+}
diff --git a/src/registry/blocks/analytics-map/data.ts b/src/registry/blocks/analytics-map/data.ts
new file mode 100644
index 0000000..801f909
--- /dev/null
+++ b/src/registry/blocks/analytics-map/data.ts
@@ -0,0 +1,99 @@
+import { type ChartConfig } from "@/components/ui/chart";
+
+export interface LocationPoint {
+ city: string;
+ lng: number;
+ lat: number;
+ size: number;
+}
+
+export interface BreakdownRow {
+ label: string;
+ value: number;
+}
+
+export const locations: LocationPoint[] = [
+ { city: "San Francisco", lng: -122.4194, lat: 37.7749, size: 16 },
+ { city: "New York", lng: -74.006, lat: 40.7128, size: 15 },
+ { city: "Toronto", lng: -79.3832, lat: 43.6532, size: 11 },
+ { city: "Mexico City", lng: -99.1332, lat: 19.4326, size: 10 },
+ { city: "Sao Paulo", lng: -46.6333, lat: -23.5505, size: 12 },
+ { city: "Buenos Aires", lng: -58.3816, lat: -34.6037, size: 9 },
+ { city: "London", lng: -0.1276, lat: 51.5074, size: 14 },
+ { city: "Berlin", lng: 13.405, lat: 52.52, size: 11 },
+ { city: "Paris", lng: 2.3522, lat: 48.8566, size: 13 },
+ { city: "Madrid", lng: -3.7038, lat: 40.4168, size: 10 },
+ { city: "Cairo", lng: 31.2357, lat: 30.0444, size: 9 },
+ { city: "Lagos", lng: 3.3792, lat: 6.5244, size: 10 },
+ { city: "Mumbai", lng: 72.8777, lat: 19.076, size: 13 },
+ { city: "Dubai", lng: 55.2708, lat: 25.2048, size: 11 },
+ { city: "Seoul", lng: 126.978, lat: 37.5665, size: 12 },
+ { city: "Singapore", lng: 103.8198, lat: 1.3521, size: 10 },
+ { city: "Tokyo", lng: 139.6917, lat: 35.6895, size: 12 },
+ { city: "Sydney", lng: 151.2093, lat: -33.8688, size: 9 },
+ { city: "Auckland", lng: 174.7633, lat: -36.8485, size: 8 },
+];
+
+export const usersPerDay = [
+ { day: "Mon", users: 320 },
+ { day: "Tue", users: 410 },
+ { day: "Wed", users: 560 },
+ { day: "Thu", users: 640 },
+ { day: "Fri", users: 780 },
+ { day: "Sat", users: 690 },
+ { day: "Sun", users: 720 },
+];
+
+export const usersPerDayChartConfig = {
+ users: {
+ label: "Users",
+ color: "var(--color-blue-500)",
+ },
+} satisfies ChartConfig;
+
+export const deviceCategoryData = [
+ { name: "Desktop", value: 73.3, fill: "var(--color-blue-500)" },
+ { name: "Mobile", value: 25.0, fill: "var(--color-blue-400)" },
+ { name: "Tablet", value: 1.7, fill: "var(--color-blue-300)" },
+];
+
+export const deviceCategoryChartConfig = {
+ desktop: { label: "Desktop", color: "var(--color-blue-500)" },
+ mobile: { label: "Mobile", color: "var(--color-blue-400)" },
+ tablet: { label: "Tablet", color: "var(--color-blue-300)" },
+} satisfies ChartConfig;
+
+export const visitedPagesRows: BreakdownRow[] = [
+ { label: "Home", value: 31 },
+ { label: "Pricing", value: 23 },
+ { label: "Docs / Basic Map", value: 18 },
+ { label: "Installation", value: 12 },
+ { label: "Components", value: 9 },
+ { label: "Blog", value: 6 },
+];
+
+export const countriesRows: BreakdownRow[] = [
+ { label: "United States", value: 27 },
+ { label: "India", value: 14 },
+ { label: "United Kingdom", value: 8 },
+ { label: "Germany", value: 6 },
+ { label: "Japan", value: 4 },
+ { label: "Australia", value: 2 },
+];
+
+export const referrersRows: BreakdownRow[] = [
+ { label: "google", value: 38 },
+ { label: "direct", value: 26 },
+ { label: "github.com", value: 19 },
+ { label: "x.com", value: 11 },
+ { label: "ui.shadcn.com", value: 8 },
+ { label: "other", value: 5 },
+];
+
+export const browsersRows: BreakdownRow[] = [
+ { label: "Chrome", value: 52 },
+ { label: "Safari", value: 21 },
+ { label: "Firefox", value: 14 },
+ { label: "Edge", value: 8 },
+ { label: "Other", value: 5 },
+];
diff --git a/src/registry/blocks/analytics-map/page.tsx b/src/registry/blocks/analytics-map/page.tsx
new file mode 100644
index 0000000..5281eff
--- /dev/null
+++ b/src/registry/blocks/analytics-map/page.tsx
@@ -0,0 +1,83 @@
+"use client";
+
+import {
+ Map,
+ MapControls,
+ MapMarker,
+ MarkerContent,
+ MarkerTooltip,
+} from "@/registry/map";
+import { OverviewCard } from "./components/overview-card";
+import { BreakdownCard } from "./components/breakdown-card";
+import {
+ locations,
+ visitedPagesRows,
+ countriesRows,
+ referrersRows,
+ browsersRows,
+} from "./data";
+
+const MAP_HEIGHT = "38rem";
+
+export function AnalyticsMapBlock() {
+ return (
+ <div
+ className="bg-background relative min-h-screen"
+ style={{ "--map-height": MAP_HEIGHT } as React.CSSProperties}
+ >
+ <div className="relative h-(--map-height)">
+ <Map
+ center={[-2, 16]}
+ zoom={1.5}
+ scrollZoom={false}
+ renderWorldCopies={true}
+ >
+ <MapControls showFullscreen />
+ {locations.map((location) => (
+ <MapMarker
+ key={location.city}
+ longitude={location.lng}
+ latitude={location.lat}
+ >
+ <MarkerContent>
+ <div
+ className="rounded-full bg-blue-500/70"
+ style={{
+ width: location.size * 3,
+ height: location.size * 3,
+ }}
+ />
+ </MarkerContent>
+ <MarkerTooltip
+ offset={20}
+ className="bg-background text-foreground border"
+ >
+ <p className="text-muted-foreground font-medium">
+ {location.city}
+ </p>
+ <p className="mt-1">
+ <span className="font-medium tabular-nums">
+ {location.size}
+ </span>{" "}
+ active users
+ </p>
+ </MarkerTooltip>
+ </MapMarker>
+ ))}
+ </Map>
+ <div
+ className="via-background/30 to-background pointer-events-none absolute inset-x-0 bottom-0 h-40 bg-linear-to-b from-transparent"
+ aria-hidden
+ />
+ <OverviewCard />
+ </div>
+
+ <div className="grid gap-4 p-4 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
+ <BreakdownCard title="Visited pages" rows={visitedPagesRows} />
+ <BreakdownCard title="Referrers" rows={referrersRows} />
+ <BreakdownCard title="Countries" rows={countriesRows} />
+ <BreakdownCard title="Browsers" rows={browsersRows} />
+ </div>
+ </div>
+ );
+}
diff --git a/src/registry/blocks/delivery-tracker/page.tsx b/src/registry/blocks/delivery-tracker/page.tsx
new file mode 100644
index 0000000..1e2f084
--- /dev/null
+++ b/src/registry/blocks/delivery-tracker/page.tsx
@@ -0,0 +1,261 @@
+"use client";
+
+import { useEffect, useMemo, useState } from "react";
+import { Clock3, Utensils, Truck, UserRound } from "lucide-react";
+
+import {
+ Map,
+ MapMarker,
+ MapRoute,
+ MarkerContent,
+ MarkerTooltip,
+} from "@/registry/map";
+import { Badge } from "@/components/ui/badge";
+import { Button } from "@/components/ui/button";
+import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
+
+interface DeliveryMeal {
+ name: string;
+ price: string;
+ quantity: number;
+}
+
+interface OsrmRouteData {
+ coordinates: [number, number][];
+ duration: number;
+ distance: number;
+}
+
+const deliveryMeals: DeliveryMeal[] = [
+ {
+ name: "Spicy Tofu Grain Bowl",
+ price: "$44.00",
+ quantity: 1,
+ },
+ {
+ name: "Herb Chicken Rice Box",
+ price: "$58.00",
+ quantity: 2,
+ },
+ {
+ name: "Roasted Veggie Wrap",
+ price: "$29.00",
+ quantity: 1,
+ },
+];
+
+const pickup = { lng: -122.466, lat: 37.716 };
+const dropoff = { lng: -122.399, lat: 37.683 };
+
+function formatDistance(meters?: number) {
+ if (!meters) return "--";
+ if (meters < 1000) return `${Math.round(meters)} m`;
+ return `${(meters / 1000).toFixed(1)} km`;
+}
+
+function formatDuration(seconds?: number) {
+ if (!seconds) return "--";
+ const minutes = Math.round(seconds / 60);
+ if (minutes < 60) return `${minutes} min`;
+ const hours = Math.floor(minutes / 60);
+ const remainingMinutes = minutes % 60;
+ return `${hours}h ${remainingMinutes}m`;
+}
+
+export function DeliveryBlock() {
+ const [routeData, setRouteData] = useState<OsrmRouteData | null>(null);
+ const [loading, setLoading] = useState(true);
+
+ useEffect(() => {
+ async function fetchRoute() {
+ setLoading(true);
+ try {
+ const response = await fetch(
+ `https://router.project-osrm.org/route/v1/driving/${pickup.lng},${pickup.lat};${dropoff.lng},${dropoff.lat}?overview=full&geometries=geojson`
+ );
+ const data = await response.json();
+ const route = data?.routes?.[0];
+ if (!route?.geometry?.coordinates) return;
+
+ setRouteData({
+ coordinates: route.geometry.coordinates as [number, number][],
+ duration: route.duration as number,
+ distance: route.distance as number,
+ });
+ } catch (error) {
+ console.error("Failed to fetch route:", error);
+ } finally {
+ setLoading(false);
+ }
+ }
+
+ fetchRoute();
+ }, []);
+
+ const progressCoordinates = useMemo(() => {
+ const progressCount = Math.max(
+ 2,
+ Math.floor(
+ (routeData?.coordinates?.length ?? 0) * (routeData ? 0.62 : 0.66)
+ )
+ );
+ return routeData?.coordinates?.slice(0, progressCount) ?? [];
+ }, [routeData]);
+
+ const courierPosition = progressCoordinates[progressCoordinates.length - 1];
+
+ return (
+ <div className="p-8">
+ <div className="grid md:grid-cols-[1.05fr_1fr] bg-sidebar rounded-lg border md:h-[600px] max-w-7xl mx-auto">
+ <div className="p-5 md:p-6 flex flex-col">
+ <div className="space-y-1">
+ <h3 className="text-2xl font-semibold tracking-tight">
+ Track Delivery
+ </h3>
+ <p className="text-sm text-muted-foreground">Mon Feb 10 - 2-3 PM</p>
+ </div>
+
+ <Card className="mt-5">
+ <CardHeader>
+ <CardTitle className="font-medium">
+ Order items ({deliveryMeals.length})
+ </CardTitle>
+ </CardHeader>
+ <CardContent className="space-y-5">
+ {deliveryMeals.map((meal) => (
+ <div key={meal.name} className="flex items-center gap-3">
+ <div className="grid size-8 place-items-center rounded-full bg-muted text-xs font-medium">
+ <Utensils className="size-4 text-muted-foreground" />
+ </div>
+ <div className="min-w-4 flex-1">
+ <p className="truncate text-sm font-medium pb-1">
+ {meal.name}
+ </p>
+ <p className="text-xs text-muted-foreground">
+ {meal.price}
+ </p>
+ </div>
+ <Badge
+ variant="secondary"
+ className="h-6 rounded-full px-2.5"
+ >
+ x{meal.quantity}
+ </Badge>
+ </div>
+ ))}
+ <div className="flex items-center justify-between border-t border-border/60 pt-3 text-sm">
+ <span className="text-muted-foreground">Bundle total</span>
+ <span className="font-medium">$189.00</span>
+ </div>
+ </CardContent>
+ </Card>
+
+ <div className="mt-4 grid gap-3 sm:grid-cols-2">
+ <Card>
+ <CardContent className="space-y-2">
+ <p className="text-sm font-medium text-muted-foreground">
+ Pickup confirmed
+ </p>
+ <p className="text-sm font-medium">Mon, Feb 10 at 1:48 PM</p>
+ </CardContent>
+ </Card>
+ <Card>
+ <CardContent className="space-y-2">
+ <p className="text-sm font-medium text-muted-foreground">
+ Remaining travel
+ </p>
+ <p className="text-sm font-medium">
+ {formatDuration(routeData?.duration)}
+ </p>
+ </CardContent>
+ </Card>
+ </div>
+
+ <div className="mt-6 flex flex-wrap items-center gap-2">
+ <Button size="sm" className="gap-1.5">
+ <Clock3 className="size-4" />
+ View timeline
+ </Button>
+ <Button variant="outline" size="sm" className="gap-1.5">
+ <UserRound className="size-4" />
+ Contact courier
+ </Button>
+ </div>
+ </div>
+
+ <div className="relative h-[400px] overflow-hidden rounded-xl md:h-full shadow-sm">
+ <Map
+ loading={loading}
+ center={[-122.435, 37.696]}
+ zoom={12}
+ minZoom={10}
+ maxZoom={16}
+ styles={{
+ light: "https://tiles.openfreemap.org/styles/bright",
+ dark: "https://tiles.openfreemap.org/styles/dark",
+ }}
+ >
+ <MapRoute
+ id="delivery-full-route"
+ coordinates={routeData?.coordinates ?? []}
+ color="#5b6572"
+ width={5.2}
+ opacity={0.3}
+ interactive={false}
+ />
+ <MapRoute
+ id="delivery-progress-route"
+ coordinates={progressCoordinates}
+ color="#3b82f6"
+ width={6}
+ opacity={0.95}
+ interactive={false}
+ />
+
+ {courierPosition && (
+ <MapMarker
+ longitude={courierPosition[0]}
+ latitude={courierPosition[1]}
+ offset={[0, 10]}
+ >
+ <MarkerContent>
+ <div className="relative grid size-9 place-items-center rounded-full bg-emerald-500 dark:bg-emerald-600">
+ <Truck className="size-4 text-white" />
+ </div>
+ </MarkerContent>
+ <MarkerTooltip>
+ <div className="space-y-0.5 text-xs">
+ <p className="font-medium">
+ Order {formatDuration(routeData?.duration)} away
+ </p>
+ <p className="text-muted-foreground">
+ Route {formatDistance(routeData?.distance)}
+ </p>
+ </div>
+ </MarkerTooltip>
+ </MapMarker>
+ )}
+
+ <MapMarker longitude={pickup.lng} latitude={pickup.lat}>
+ <MarkerContent>
+ <div className="size-4 rounded-full border-2 border-white bg-emerald-500 shadow-sm" />
+ </MarkerContent>
+ <MarkerTooltip>
+ <p className="text-xs font-medium">Origin</p>
+ </MarkerTooltip>
+ </MapMarker>
+
+ <MapMarker longitude={dropoff.lng} latitude={dropoff.lat}>
+ <MarkerContent>
+ <div className="size-4 rounded-full border-2 border-white bg-rose-500 shadow-sm" />
+ </MarkerContent>
+ <MarkerTooltip>
+ <p className="text-xs font-medium">Destination</p>
+ </MarkerTooltip>
+ </MapMarker>
+ </Map>
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/src/registry/blocks/heatmap/page.tsx b/src/registry/blocks/heatmap/page.tsx
new file mode 100644
index 0000000..f2ba325
--- /dev/null
+++ b/src/registry/blocks/heatmap/page.tsx
@@ -0,0 +1,198 @@
+"use client";
+
+import { useEffect, useId } from "react";
+
+import { Map, useMap } from "@/registry/map";
+import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
+
+const EARTHQUAKE_GEOJSON_URL =
+ "https://maplibre.org/maplibre-gl-js/docs/assets/earthquakes.geojson";
+
+const HEATMAP_GRADIENT_COLORS = [
+ "#fff7bc",
+ "#fee391",
+ "#fec44f",
+ "#fe9929",
+ "#d7301f",
+];
+
+const HEATMAP_COLOR_STOPS: [number, string][] = [
+ [0.15, HEATMAP_GRADIENT_COLORS[0]],
+ [0.35, HEATMAP_GRADIENT_COLORS[1]],
+ [0.55, HEATMAP_GRADIENT_COLORS[2]],
+ [0.75, HEATMAP_GRADIENT_COLORS[3]],
+ [1, HEATMAP_GRADIENT_COLORS[4]],
+];
+
+function GlobeHeatmapLayers() {
+ const { map, isLoaded } = useMap();
+ const id = useId();
+ const sourceId = `heatmap-source-${id}`;
+ const heatLayerId = `heatmap-layer-${id}`;
+ const pointLayerId = `heatmap-point-layer-${id}`;
+
+ useEffect(() => {
+ if (!map || !isLoaded) return;
+
+ if (!map.getSource(sourceId)) {
+ map.addSource(sourceId, {
+ type: "geojson",
+ data: EARTHQUAKE_GEOJSON_URL,
+ });
+ }
+
+ if (!map.getLayer(heatLayerId)) {
+ map.addLayer({
+ id: heatLayerId,
+ type: "heatmap",
+ source: sourceId,
+ maxzoom: 6,
+ paint: {
+ "heatmap-weight": [
+ "interpolate",
+ ["linear"],
+ ["get", "mag"],
+ 0,
+ 0,
+ 6,
+ 0.8,
+ ],
+ "heatmap-intensity": [
+ "interpolate",
+ ["linear"],
+ ["zoom"],
+ 0,
+ 0.55,
+ 6,
+ 1.25,
+ ],
+ "heatmap-color": [
+ "interpolate",
+ ["linear"],
+ ["heatmap-density"],
+ 0,
+ "rgba(59, 130, 246, 0)",
+ ...HEATMAP_COLOR_STOPS.flat(),
+ ],
+ "heatmap-radius": ["interpolate", ["linear"], ["zoom"], 0, 8, 6, 34],
+ "heatmap-opacity": [
+ "interpolate",
+ ["linear"],
+ ["zoom"],
+ 4.5,
+ 0.75,
+ 6.5,
+ 0.08,
+ ],
+ },
+ });
+ }
+
+ if (!map.getLayer(pointLayerId)) {
+ map.addLayer({
+ id: pointLayerId,
+ type: "circle",
+ source: sourceId,
+ minzoom: 4.5,
+ paint: {
+ "circle-radius": [
+ "interpolate",
+ ["linear"],
+ ["get", "mag"],
+ 1,
+ 3,
+ 6,
+ 10,
+ ],
+ "circle-color": [
+ "interpolate",
+ ["linear"],
+ ["get", "mag"],
+ 1,
+ HEATMAP_GRADIENT_COLORS[1],
+ 2.5,
+ HEATMAP_GRADIENT_COLORS[2],
+ 4,
+ HEATMAP_GRADIENT_COLORS[3],
+ 6,
+ HEATMAP_GRADIENT_COLORS[4],
+ ],
+ "circle-stroke-width": 1,
+ "circle-stroke-color": "rgba(255,255,255,0.8)",
+ "circle-opacity": [
+ "interpolate",
+ ["linear"],
+ ["zoom"],
+ 4.5,
+ 0,
+ 6.5,
+ 0.7,
+ ],
+ },
+ });
+ }
+
+ return () => {
+ try {
+ if (map.getLayer(pointLayerId)) map.removeLayer(pointLayerId);
+ if (map.getLayer(heatLayerId)) map.removeLayer(heatLayerId);
+ if (map.getSource(sourceId)) map.removeSource(sourceId);
+ } catch {
+ // ignore
+ }
+ };
+ }, [map, isLoaded, sourceId, heatLayerId, pointLayerId]);
+
+ return null;
+}
+
+export function HeatmapBlock() {
+ return (
+ <div className="bg-muted/50 relative h-screen">
+ <div className="relative h-full">
+ <Map
+ center={[-113, 43]}
+ zoom={3.2}
+ projection={{ type: "globe" }}
+ pitch={24}
+ minZoom={1.2}
+ maxZoom={8}
+ >
+ <GlobeHeatmapLayers />
+ </Map>
+ </div>
+
+ <Card className="absolute top-4 left-4 z-10 w-72">
+ <CardHeader>
+ <CardTitle>Global Earthquakes Heatmap</CardTitle>
+ </CardHeader>
+ <CardContent>
+ <div className="grid grid-cols-5 gap-1.5">
+ {HEATMAP_GRADIENT_COLORS.map((color) => (
+ <span
+ key={color}
+ className="h-2.5 rounded-full"
+ style={{ backgroundColor: color }}
+ />
+ ))}
+ </div>
+ <div className="text-muted-foreground flex items-center justify-between pt-3 text-xs">
+ <span>Low</span>
+ <span>High</span>
+ </div>
+ <p className="text-muted-foreground pt-2 text-xs">
+ Data source:{" "}
+ <a
+ href={EARTHQUAKE_GEOJSON_URL}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="hover:text-foreground underline underline-offset-4 transition-colors"
+ >
+ MapLibre earthquakes.geojson
+ </a>
+ </p>
+ </CardContent>
+ </Card>
+ </div>
+ );
+}
diff --git a/src/registry/blocks/logistics-network/components/filter-sidebar.tsx b/src/registry/blocks/logistics-network/components/filter-sidebar.tsx
new file mode 100644
index 0000000..f25cb55
--- /dev/null
+++ b/src/registry/blocks/logistics-network/components/filter-sidebar.tsx
@@ -0,0 +1,193 @@
+"use client";
+
+import {
+ Sidebar,
+ SidebarContent,
+ SidebarFooter,
+ SidebarGroup,
+ SidebarGroupContent,
+ SidebarGroupLabel,
+ SidebarHeader,
+ SidebarMenu,
+ SidebarMenuBadge,
+ SidebarMenuButton,
+ SidebarMenuItem,
+ SidebarSeparator,
+} from "@/components/ui/sidebar";
+import { Network, Plane, Truck } from "lucide-react";
+import { regionLabels, statusConfig, type Hub, type Route } from "../data";
+
+const regionIcons: Record<Hub["region"], string> = {
+ west: "W",
+ midwest: "MW",
+ south: "S",
+ northeast: "NE",
+};
+
+interface FilterSidebarProps {
+ hubs: Hub[];
+ routes: Route[];
+}
+
+export function FilterSidebar({ hubs, routes }: FilterSidebarProps) {
+ const totalShipments = routes.reduce((s, r) => s + r.shipments, 0);
+ const activeCount = routes.filter((r) => r.status === "active").length;
+ const delayedCount = routes.filter((r) => r.status === "delayed").length;
+ const airRouteCount = routes.filter((r) => r.mode === "air").length;
+ const groundRouteCount = routes.filter((r) => r.mode === "ground").length;
+
+ return (
+ <Sidebar collapsible="offcanvas">
+ <SidebarHeader className="p-4">
+ <div className="flex items-center gap-2">
+ <div className="bg-sidebar-primary text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg">
+ <Network className="size-4" />
+ </div>
+ <div className="flex flex-col gap-0.5 leading-none">
+ <span className="text-sm font-medium">Logistics Network</span>
+ <span className="text-muted-foreground text-xs">
+ Domestic Routes
+ </span>
+ </div>
+ </div>
+ <div className="mt-3 grid grid-cols-3 gap-2">
+ <div className="bg-background rounded-md border px-2.5 py-2 text-center">
+ <p className="text-lg leading-none font-bold tabular-nums">
+ {hubs.length}
+ </p>
+ <p className="text-muted-foreground mt-1 text-[10px]">Hubs</p>
+ </div>
+ <div className="bg-background rounded-md border px-2.5 py-2 text-center">
+ <p className="text-lg leading-none font-bold tabular-nums">
+ {activeCount}
+ </p>
+ <p className="text-muted-foreground mt-1 text-[10px]">Active</p>
+ </div>
+ <div className="bg-background rounded-md border px-2.5 py-2 text-center">
+ <p className="text-lg leading-none font-bold tabular-nums">
+ {delayedCount}
+ </p>
+ <p className="text-muted-foreground mt-1 text-[10px]">Delayed</p>
+ </div>
+ </div>
+ </SidebarHeader>
+
+ <SidebarSeparator className="mx-0" />
+
+ <SidebarContent>
+ <SidebarGroup>
+ <SidebarGroupLabel>Transport Mode</SidebarGroupLabel>
+ <SidebarGroupContent>
+ <SidebarMenu>
+ <SidebarMenuItem>
+ <SidebarMenuButton
+ tooltip="Air"
+ className="pointer-events-none"
+ >
+ <Plane className="size-4" />
+ <span>Air Freight</span>
+ </SidebarMenuButton>
+ <SidebarMenuBadge>{airRouteCount}</SidebarMenuBadge>
+ </SidebarMenuItem>
+ <SidebarMenuItem>
+ <SidebarMenuButton
+ tooltip="Ground"
+ className="pointer-events-none"
+ >
+ <Truck className="size-4" />
+ <span>Ground</span>
+ </SidebarMenuButton>
+ <SidebarMenuBadge>{groundRouteCount}</SidebarMenuBadge>
+ </SidebarMenuItem>
+ </SidebarMenu>
+ </SidebarGroupContent>
+ </SidebarGroup>
+
+ <SidebarGroup>
+ <SidebarGroupLabel>Status</SidebarGroupLabel>
+ <SidebarGroupContent>
+ <SidebarMenu>
+ <SidebarMenuItem>
+ <SidebarMenuButton
+ tooltip={statusConfig.active.label}
+ className="pointer-events-none"
+ >
+ <span className="flex size-4 items-center justify-center">
+ <span
+ className="size-2 rounded-full"
+ style={{ backgroundColor: statusConfig.active.color }}
+ />
+ </span>
+ <span>{statusConfig.active.label}</span>
+ </SidebarMenuButton>
+ <SidebarMenuBadge>{activeCount}</SidebarMenuBadge>
+ </SidebarMenuItem>
+ <SidebarMenuItem>
+ <SidebarMenuButton
+ tooltip={statusConfig.delayed.label}
+ className="pointer-events-none"
+ >
+ <span className="flex size-4 items-center justify-center">
+ <span
+ className="size-2 rounded-full"
+ style={{ backgroundColor: statusConfig.delayed.color }}
+ />
+ </span>
+ <span>{statusConfig.delayed.label}</span>
+ </SidebarMenuButton>
+ <SidebarMenuBadge>{delayedCount}</SidebarMenuBadge>
+ </SidebarMenuItem>
+ </SidebarMenu>
+ </SidebarGroupContent>
+ </SidebarGroup>
+
+ <SidebarGroup>
+ <SidebarGroupLabel>Region</SidebarGroupLabel>
+ <SidebarGroupContent>
+ <SidebarMenu>
+ {(["west", "midwest", "south", "northeast"] as const).map(
+ (region) => {
+ const hubsInRegion = hubs.filter((h) => h.region === region);
+ return (
+ <SidebarMenuItem key={region}>
+ <SidebarMenuButton
+ tooltip={regionLabels[region]}
+ className="pointer-events-none"
+ >
+ <span className="bg-muted text-muted-foreground flex size-4 items-center justify-center rounded text-[9px] font-bold">
+ {regionIcons[region]}
+ </span>
+ <span>{regionLabels[region]}</span>
+ </SidebarMenuButton>
+ <SidebarMenuBadge>{hubsInRegion.length}</SidebarMenuBadge>
+ </SidebarMenuItem>
+ );
+ },
+ )}
+ </SidebarMenu>
+ </SidebarGroupContent>
+ </SidebarGroup>
+ </SidebarContent>
+
+ <SidebarFooter className="p-4 pt-0">
+ <p className="text-muted-foreground mb-2 text-[11px] font-medium tracking-wider uppercase">
+ Summary
+ </p>
+ <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">
+ {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>
+ </div>
+ </div>
+ </SidebarFooter>
+ </Sidebar>
+ );
+}
diff --git a/src/registry/blocks/logistics-network/components/map-arcs.tsx b/src/registry/blocks/logistics-network/components/map-arcs.tsx
new file mode 100644
index 0000000..2ec1a3f
--- /dev/null
+++ b/src/registry/blocks/logistics-network/components/map-arcs.tsx
@@ -0,0 +1,126 @@
+"use client";
+
+import { useCallback, useEffect, useMemo } from "react";
+import { useMap } from "@/registry/map";
+import type MapLibreGL from "maplibre-gl";
+import { hubs, modeConfig, statusConfig, type Route } from "../data";
+
+const SOURCE_ID = "logistics-arcs-source";
+const LAYER_ID = "logistics-arcs-layer";
+
+function generateArc(
+ start: [number, number],
+ end: [number, number],
+ segments = 50,
+): number[][] {
+ const [x1, y1] = start;
+ const [x2, y2] = end;
+
+ const mx = (x1 + x2) / 2;
+ const my = (y1 + y2) / 2;
+
+ const dx = x2 - x1;
+ const dy = y2 - y1;
+ const dist = Math.sqrt(dx * dx + dy * dy);
+
+ const nx = -dy / dist;
+ const ny = dx / dist;
+ const height = dist * 0.3;
+
+ const cx = mx + nx * height;
+ const cy = my + ny * height;
+
+ const coords: number[][] = [];
+ for (let i = 0; i <= segments; i++) {
+ const t = i / segments;
+ const px = (1 - t) * (1 - t) * x1 + 2 * (1 - t) * t * cx + t * t * x2;
+ const py = (1 - t) * (1 - t) * y1 + 2 * (1 - t) * t * cy + t * t * y2;
+ coords.push([px, py]);
+ }
+ return coords;
+}
+
+function getHubById(id: string) {
+ return hubs.find((h) => h.id === id)!;
+}
+
+interface MapArcsProps {
+ routes: Route[];
+}
+
+export function MapArcs({ routes: arcRoutes }: MapArcsProps) {
+ const { map, isLoaded } = useMap();
+
+ const geoJSON = useMemo<GeoJSON.FeatureCollection>(() => {
+ const features: GeoJSON.Feature[] = arcRoutes.map((route) => {
+ const fromHub = getHubById(route.from);
+ const toHub = getHubById(route.to);
+ const coordinates = generateArc(
+ [fromHub.lng, fromHub.lat],
+ [toHub.lng, toHub.lat],
+ );
+ return {
+ type: "Feature" as const,
+ properties: {
+ id: `${route.from}-${route.to}`,
+ mode: route.mode,
+ status: route.status,
+ color:
+ route.status === "delayed"
+ ? statusConfig.delayed.color
+ : modeConfig[route.mode].color,
+ },
+ geometry: {
+ type: "LineString" as const,
+ coordinates,
+ },
+ };
+ });
+ return { type: "FeatureCollection", features };
+ }, [arcRoutes]);
+
+ const addLayer = useCallback(() => {
+ if (!map) return;
+
+ if (!map.getSource(SOURCE_ID)) {
+ map.addSource(SOURCE_ID, { type: "geojson", data: geoJSON });
+ map.addLayer({
+ id: LAYER_ID,
+ type: "line",
+ source: SOURCE_ID,
+ layout: { "line-join": "round", "line-cap": "round" },
+ paint: {
+ "line-color": ["get", "color"],
+ "line-width": 2,
+ "line-opacity": 0.65,
+ },
+ });
+ } else {
+ (map.getSource(SOURCE_ID) as MapLibreGL.GeoJSONSource).setData(geoJSON);
+ }
+ }, [map, geoJSON]);
+
+ useEffect(() => {
+ if (!map || !isLoaded) return;
+
+ addLayer();
+
+ return () => {
+ try {
+ if (map.getLayer(LAYER_ID)) map.removeLayer(LAYER_ID);
+ if (map.getSource(SOURCE_ID)) map.removeSource(SOURCE_ID);
+ } catch {
+ // ignore
+ }
+ };
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [map, isLoaded]);
+
+ useEffect(() => {
+ if (!map || !isLoaded) return;
+ const source = map.getSource(SOURCE_ID) as MapLibreGL.GeoJSONSource;
+ if (source) source.setData(geoJSON);
+ }, [map, isLoaded, geoJSON]);
+
+ return null;
+}
diff --git a/src/registry/blocks/logistics-network/components/network-map.tsx b/src/registry/blocks/logistics-network/components/network-map.tsx
new file mode 100644
index 0000000..df1535e
--- /dev/null
+++ b/src/registry/blocks/logistics-network/components/network-map.tsx
@@ -0,0 +1,93 @@
+"use client";
+
+import {
+ Map,
+ MapControls,
+ MapMarker,
+ MarkerContent,
+ MarkerTooltip,
+} from "@/registry/map";
+import { SidebarTrigger } from "@/components/ui/sidebar";
+import {
+ modeConfig,
+ regionLabels,
+ statusConfig,
+ type Hub,
+ type Route,
+} from "../data";
+import { MapArcs } from "./map-arcs";
+import { Separator } from "@/components/ui/separator";
+
+interface NetworkMapProps {
+ hubs: Hub[];
+ routes: Route[];
+}
+
+function MapControlsCard() {
+ return (
+ <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">
+ <SidebarTrigger />
+ <Separator orientation="vertical" className="h-4!" />
+ <div className="flex items-center gap-3 text-xs">
+ <div className="flex items-center gap-1.5">
+ <span
+ className="h-0.5 w-4 shrink-0 rounded-full"
+ style={{ backgroundColor: modeConfig.air.color }}
+ />
+ <span>{modeConfig.air.label}</span>
+ </div>
+ <div className="flex items-center gap-1.5">
+ <span
+ className="h-0.5 w-4 shrink-0 rounded-full"
+ style={{ backgroundColor: modeConfig.ground.color }}
+ />
+ <span>{modeConfig.ground.label}</span>
+ </div>
+ <div className="flex items-center gap-1.5">
+ <span
+ className="h-0.5 w-4 shrink-0 rounded-full"
+ style={{ backgroundColor: statusConfig.delayed.color }}
+ />
+ <span>{statusConfig.delayed.label}</span>
+ </div>
+ <div className="bg-border h-4 w-px" />
+ <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>
+ </div>
+ </div>
+ </div>
+ );
+}
+
+export function NetworkMap({ hubs, routes }: NetworkMapProps) {
+ return (
+ <div className="relative h-full">
+ <MapControlsCard />
+
+ <Map center={[-98, 39]} zoom={4} projection={{ type: "globe" }}>
+ <MapControls />
+ <MapArcs routes={routes} />
+
+ {hubs.map((hub) => (
+ <MapMarker key={hub.id} longitude={hub.lng} latitude={hub.lat}>
+ <MarkerContent>
+ <div className="size-3 rounded-full border-2 border-white bg-blue-500 shadow-md" />
+ </MarkerContent>
+ <MarkerTooltip
+ offset={16}
+ className="bg-background text-foreground border px-2.5 py-1.5"
+ >
+ <p className="font-medium">{hub.city}</p>
+ <p className="text-muted-foreground mt-1">
+ {hub.shipments.toLocaleString()} shipments
+ <span className="mx-1.5">·</span>
+ {regionLabels[hub.region]}
+ </p>
+ </MarkerTooltip>
+ </MapMarker>
+ ))}
+ </Map>
+ </div>
+ );
+}
diff --git a/src/registry/blocks/logistics-network/data.ts b/src/registry/blocks/logistics-network/data.ts
new file mode 100644
index 0000000..35beb6d
--- /dev/null
+++ b/src/registry/blocks/logistics-network/data.ts
@@ -0,0 +1,216 @@
+export interface Hub {
+ id: string;
+ city: string;
+ lng: number;
+ lat: number;
+ type: "primary" | "secondary";
+ shipments: number;
+ region: "west" | "midwest" | "south" | "northeast";
+}
+
+export interface Route {
+ from: string;
+ to: string;
+ mode: "air" | "ground";
+ shipments: number;
+ status: "active" | "delayed";
+}
+
+export const hubs: Hub[] = [
+ {
+ id: "ord",
+ city: "Chicago",
+ lng: -87.6298,
+ lat: 41.8781,
+ type: "primary",
+ shipments: 1247,
+ region: "midwest",
+ },
+ {
+ id: "lax",
+ city: "Los Angeles",
+ lng: -118.2437,
+ lat: 34.0522,
+ type: "primary",
+ shipments: 1102,
+ region: "west",
+ },
+ {
+ id: "jfk",
+ city: "New York",
+ lng: -73.9352,
+ lat: 40.6413,
+ type: "primary",
+ shipments: 983,
+ region: "northeast",
+ },
+ {
+ id: "dfw",
+ city: "Dallas",
+ lng: -96.797,
+ lat: 32.8968,
+ type: "primary",
+ shipments: 856,
+ region: "south",
+ },
+ {
+ id: "atl",
+ city: "Atlanta",
+ lng: -84.4281,
+ lat: 33.6407,
+ type: "primary",
+ shipments: 914,
+ region: "south",
+ },
+ {
+ id: "den",
+ city: "Denver",
+ lng: -104.6731,
+ lat: 39.8617,
+ type: "secondary",
+ shipments: 634,
+ region: "west",
+ },
+ {
+ id: "sea",
+ city: "Seattle",
+ lng: -122.3321,
+ lat: 47.6062,
+ type: "secondary",
+ shipments: 723,
+ region: "west",
+ },
+ {
+ id: "mia",
+ city: "Miami",
+ lng: -80.1918,
+ lat: 25.7617,
+ type: "secondary",
+ shipments: 478,
+ region: "south",
+ },
+ {
+ id: "phx",
+ city: "Phoenix",
+ lng: -112.074,
+ lat: 33.4484,
+ type: "secondary",
+ shipments: 512,
+ region: "west",
+ },
+ {
+ id: "iah",
+ city: "Houston",
+ lng: -95.3698,
+ lat: 29.9844,
+ type: "secondary",
+ shipments: 698,
+ region: "south",
+ },
+ {
+ id: "bos",
+ city: "Boston",
+ lng: -71.0054,
+ lat: 42.3643,
+ type: "secondary",
+ shipments: 534,
+ region: "northeast",
+ },
+ {
+ id: "sfo",
+ city: "San Francisco",
+ lng: -122.4194,
+ lat: 37.7749,
+ type: "secondary",
+ shipments: 789,
+ region: "west",
+ },
+ {
+ id: "msp",
+ city: "Minneapolis",
+ lng: -93.2219,
+ lat: 44.8848,
+ type: "secondary",
+ shipments: 423,
+ region: "midwest",
+ },
+ {
+ id: "dtw",
+ city: "Detroit",
+ lng: -83.0458,
+ lat: 42.2162,
+ type: "secondary",
+ shipments: 456,
+ region: "midwest",
+ },
+ {
+ id: "slc",
+ city: "Salt Lake City",
+ lng: -111.978,
+ lat: 40.758,
+ type: "secondary",
+ shipments: 342,
+ region: "west",
+ },
+];
+
+export const routes: Route[] = [
+ { from: "ord", to: "lax", mode: "air", shipments: 234, status: "active" },
+ { from: "ord", to: "jfk", mode: "ground", shipments: 312, status: "active" },
+ { from: "ord", to: "dfw", mode: "air", shipments: 189, status: "active" },
+ { from: "ord", to: "atl", mode: "air", shipments: 213, status: "active" },
+ { from: "ord", to: "den", mode: "ground", shipments: 156, status: "active" },
+ { from: "ord", to: "msp", mode: "ground", shipments: 198, status: "active" },
+ { from: "ord", to: "dtw", mode: "ground", shipments: 167, status: "delayed" },
+ { from: "lax", to: "sfo", mode: "ground", shipments: 245, status: "active" },
+ { from: "lax", to: "sea", mode: "air", shipments: 178, status: "active" },
+ { from: "lax", to: "den", mode: "air", shipments: 198, status: "active" },
+ { from: "lax", to: "phx", mode: "ground", shipments: 212, status: "active" },
+ { from: "lax", to: "dfw", mode: "air", shipments: 223, status: "active" },
+ { from: "jfk", to: "atl", mode: "air", shipments: 267, status: "active" },
+ { from: "jfk", to: "mia", mode: "air", shipments: 234, status: "active" },
+ { from: "jfk", to: "bos", mode: "ground", shipments: 189, status: "active" },
+ { from: "jfk", to: "ord", mode: "air", shipments: 278, status: "active" },
+ { from: "dfw", to: "atl", mode: "air", shipments: 198, status: "active" },
+ { from: "dfw", to: "iah", mode: "ground", shipments: 245, status: "active" },
+ { from: "dfw", to: "den", mode: "air", shipments: 167, status: "active" },
+ { from: "dfw", to: "phx", mode: "ground", shipments: 156, status: "delayed" },
+ { from: "atl", to: "mia", mode: "ground", shipments: 234, status: "active" },
+ { from: "atl", to: "iah", mode: "air", shipments: 189, status: "active" },
+ { from: "den", to: "sea", mode: "air", shipments: 178, status: "active" },
+ { from: "den", to: "slc", mode: "ground", shipments: 198, status: "active" },
+ { from: "den", to: "phx", mode: "air", shipments: 167, status: "active" },
+ { from: "sea", to: "sfo", mode: "air", shipments: 212, status: "active" },
+ { from: "sfo", to: "phx", mode: "air", shipments: 156, status: "active" },
+ { from: "mia", to: "iah", mode: "air", shipments: 198, status: "active" },
+ { from: "msp", to: "ord", mode: "ground", shipments: 189, status: "active" },
+ { from: "msp", to: "den", mode: "air", shipments: 145, status: "active" },
+ { from: "dtw", to: "ord", mode: "ground", shipments: 167, status: "active" },
+ { from: "dtw", to: "jfk", mode: "air", shipments: 178, status: "active" },
+ { from: "bos", to: "jfk", mode: "ground", shipments: 156, status: "active" },
+ { from: "slc", to: "den", mode: "ground", shipments: 134, status: "active" },
+ { from: "slc", to: "phx", mode: "air", shipments: 123, status: "delayed" },
+ { from: "ord", to: "sfo", mode: "air", shipments: 198, status: "active" },
+ { from: "ord", to: "mia", mode: "air", shipments: 245, status: "active" },
+ { from: "lax", to: "atl", mode: "air", shipments: 289, status: "active" },
+ { from: "jfk", to: "dfw", mode: "air", shipments: 234, status: "active" },
+ { from: "atl", to: "ord", mode: "air", shipments: 267, status: "active" },
+ { from: "sfo", to: "den", mode: "air", shipments: 189, status: "active" },
+];
+
+export const modeConfig = {
+ air: { color: "#3b82f6", label: "Air" },
+ ground: { color: "#22c55e", label: "Ground" },
+} as const;
+
+export const statusConfig = {
+ active: { color: "#10b981", label: "Active" },
+ delayed: { color: "#f59e0b", label: "Delayed" },
+} as const;
+
+export const regionLabels: Record<Hub["region"], string> = {
+ west: "West",
+ midwest: "Midwest",
+ south: "South",
+ northeast: "Northeast",
+};
diff --git a/src/registry/blocks/logistics-network/page.tsx b/src/registry/blocks/logistics-network/page.tsx
new file mode 100644
index 0000000..abbcd18
--- /dev/null
+++ b/src/registry/blocks/logistics-network/page.tsx
@@ -0,0 +1,17 @@
+"use client";
+
+import { SidebarInset, SidebarProvider } from "@/components/ui/sidebar";
+import { hubs, routes } from "./data";
+import { FilterSidebar } from "./components/filter-sidebar";
+import { NetworkMap } from "./components/network-map";
+
+export function LogisticsNetworkBlock() {
+ return (
+ <SidebarProvider>
+ <FilterSidebar hubs={hubs} routes={routes} />
+ <SidebarInset>
+ <NetworkMap hubs={hubs} routes={routes} />
+ </SidebarInset>
+ </SidebarProvider>
+ );
+}
diff --git a/src/registry/map.tsx b/src/registry/map.tsx
index db2c9bc..745476d 100644
--- a/src/registry/map.tsx
+++ b/src/registry/map.tsx
@@ -140,11 +140,13 @@ type MapProps = {
* to enable controlled mode where the map viewport is driven by your state.
*/
onViewportChange?: (viewport: MapViewport) => void;
+ /** Show a loading indicator on the map */
+ loading?: boolean;
} & Omit<MapLibreGL.MapOptions, "container" | "style">;
function DefaultLoader() {
return (
- <div className="absolute inset-0 flex items-center justify-center">
+ <div className="absolute inset-0 z-10 flex items-center justify-center bg-background/50 backdrop-blur-xs">
<div className="flex gap-1">
<span className="size-1.5 rounded-full bg-muted-foreground/60 animate-pulse" />
<span className="size-1.5 rounded-full bg-muted-foreground/60 animate-pulse [animation-delay:150ms]" />
@@ -173,6 +175,7 @@ const Map = forwardRef<MapRef, MapProps>(function Map(
projection,
viewport,
onViewportChange,
+ loading = false,
...props
},
ref
@@ -324,7 +327,7 @@ const Map = forwardRef<MapRef, MapProps>(function Map(
ref={containerRef}
className={cn("relative w-full h-full", className)}
>
- {!isLoaded && <DefaultLoader />}
+ {(!isLoaded || loading) && <DefaultLoader />}
{/* SSR-safe: children render only when map is loaded on client */}
{mapInstance && children}
</div>
diff --git a/src/app/globals.css b/src/styles/globals.css
similarity index 92%
rename from src/app/globals.css
rename to src/styles/globals.css
index 2bf588e..acb437a 100644
--- a/src/app/globals.css
+++ b/src/styles/globals.css
@@ -38,6 +38,7 @@
--color-popover: var(--popover);
--color-card-foreground: var(--card-foreground);
--color-card: var(--card);
+ --color-code-number: var(--code-number);
--radius-sm: calc(var(--radius) - 4px);
--radius-md: calc(var(--radius) - 2px);
--radius-lg: var(--radius);
@@ -80,6 +81,7 @@
--sidebar-ring: oklch(0.708 0 0);
--background: oklch(1 0 0);
--foreground: oklch(0.145 0 0);
+ --code-number: oklch(0.708 0 0);
}
.dark {
@@ -114,6 +116,7 @@
--sidebar-accent-foreground: oklch(0.985 0 0);
--sidebar-border: oklch(1 0 0 / 10%);
--sidebar-ring: oklch(0.556 0 0);
+ --code-number: oklch(0.556 0 0);
}
@layer base {
@@ -136,7 +139,11 @@
}
.container {
- @apply max-w-[1480px] mx-auto px-6;
+ @apply max-w-[1440px] mx-auto px-6;
+}
+
+.container-wide {
+ @apply max-w-[1640px] mx-auto px-6;
}
/* animations for the home page */
@@ -204,4 +211,19 @@ html.dark .shiki,
html.dark .shiki span {
color: var(--shiki-dark) !important;
background-color: transparent !important;
+}
+
+code {
+ counter-reset: step;
+ counter-increment: step 0;
+}
+
+code .line::before {
+ content: counter(step);
+ counter-increment: step;
+ width: 1rem;
+ margin-right: 1.5rem;
+ display: inline-block;
+ text-align: right;
+ color: var(--code-number)
}
\ No newline at end of file