diff options
| author | Copilot <198982749+Copilot@users.noreply.github.com> | 2025-11-22 18:02:36 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-22 18:02:36 +0100 |
| commit | b96273b54a9b47c79e0afe40a918f751e82097ae (patch) | |
| tree | ae2990aac150d880df0307124807560cc4593038 /src/frontend/app/components/NavBar.tsx | |
| parent | 738cd874fa68cde13dbe6c3f12738abec8e3a8d2 (diff) | |
Link previous trip shapes for GPS positioning on circular routes (#111)
Co-authored-by: Ariel Costas Guerrero <ariel@costas.dev>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: arielcostas <94913521+arielcostas@users.noreply.github.com>
Diffstat (limited to 'src/frontend/app/components/NavBar.tsx')
| -rw-r--r-- | src/frontend/app/components/NavBar.tsx | 89 |
1 files changed, 0 insertions, 89 deletions
diff --git a/src/frontend/app/components/NavBar.tsx b/src/frontend/app/components/NavBar.tsx deleted file mode 100644 index b8c6ad6..0000000 --- a/src/frontend/app/components/NavBar.tsx +++ /dev/null @@ -1,89 +0,0 @@ -import { Link } from "react-router"; -import { Map, MapPin, Settings } from "lucide-react"; -import { useApp } from "../AppContext"; -import type { LngLatLike } from "maplibre-gl"; -import { useTranslation } from "react-i18next"; - -// Helper: check if coordinates are within Vigo bounds -function isWithinVigo(lngLat: LngLatLike): boolean { - let lng: number, lat: number; - if (Array.isArray(lngLat)) { - [lng, lat] = lngLat; - } else if ("lng" in lngLat && "lat" in lngLat) { - lng = lngLat.lng; - lat = lngLat.lat; - } else { - return false; - } - // Rough bounding box for Vigo - return lat >= 42.18 && lat <= 42.3 && lng >= -8.78 && lng <= -8.65; -} - -export default function NavBar() { - const { t } = useTranslation(); - const { mapState, updateMapState, mapPositionMode } = useApp(); - - const navItems = [ - { - name: t("navbar.stops", "Paradas"), - icon: MapPin, - path: "/", - exact: true, - }, - { - name: t("navbar.map", "Mapa"), - icon: Map, - path: "/map", - callback: () => { - if (mapPositionMode !== "gps") { - return; - } - - if (!("geolocation" in navigator)) { - return; - } - - navigator.geolocation.getCurrentPosition( - (position) => { - const { latitude, longitude } = position.coords; - const coords: LngLatLike = [latitude, longitude]; - if (isWithinVigo(coords)) { - updateMapState(coords, 16); - } - }, - () => {} - ); - }, - }, - { - name: t("navbar.settings", "Ajustes"), - icon: Settings, - path: "/settings", - }, - ]; - - return ( - <nav className="navigation-bar"> - {navItems.map((item) => { - const Icon = item.icon; - const isActive = item.exact - ? location.pathname === item.path - : location.pathname.startsWith(item.path); - - return ( - <Link - key={item.name} - to={item.path} - className={`navigation-bar__link ${isActive ? "active" : ""}`} - onClick={item.callback ? item.callback : undefined} - title={item.name} - aria-label={item.name} - > - <Icon size={24} /> - <span>{item.name}</span> - </Link> - ); - })} - </nav> - ); -} |
