From 9c61f4b8b5e379d7c99e95dfde5b06390fb4add3 Mon Sep 17 00:00:00 2001 From: Philipp Opheys Date: Mon, 28 Oct 2024 14:41:54 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20update=20landing=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/tour/tourMap.tsx | 110 +++++++--- components/ui/footer.tsx | 14 +- components/ui/navbar.tsx | 119 ++++++----- pages/index.tsx | 390 +++++++++++++++++------------------- pages/tour/[city].tsx | 2 +- 5 files changed, 351 insertions(+), 284 deletions(-) diff --git a/components/tour/tourMap.tsx b/components/tour/tourMap.tsx index afff9b3..cc75c6f 100644 --- a/components/tour/tourMap.tsx +++ b/components/tour/tourMap.tsx @@ -1,11 +1,17 @@ -import React, { useState, createRef, useMemo } from 'react' +import React, { + useState, + createRef, + useMemo, + useCallback, + useEffect, +} from 'react' import Link from 'next/link' import Image from 'next/image' import Map, { MapRef, Marker } from 'react-map-gl/maplibre' import { useMediaQuery } from 'usehooks-ts' import { ChevronsLeft, ImagePlay, MapPin, Menu } from 'lucide-react' -import { TourData } from '@/pages/tour/[city]' +import { City, TourData } from '@/pages/tour/[city]' import { Dialog, DialogContent, @@ -33,6 +39,9 @@ import { } from '@/components/ui/drawer' import { AttributionControl } from '@/components/map/attributionControl' import MapStyleControl from '@/components/map/styleControl' +import { useTheme } from 'next-themes' +import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs' +import { useRouter } from 'next/router' interface CategoryProps { fill: string @@ -78,7 +87,16 @@ interface TourMapProps { export type MapStyle = 'bright' | 'light' | 'dark' export default function TourMap({ center, data }: TourMapProps) { - const [mapStyle, setMapStyle] = useState('bright') + const router = useRouter() + + const city = useMemo(() => { + return router.query.city as string + }, [router.query.city]) + + const { resolvedTheme } = useTheme() + const [mapStyle, setMapStyle] = useState( + resolvedTheme === 'dark' ? 'dark' : 'light' + ) const [dialogOpen, showDialog] = useState(true) const [drawerOpen, setDrawer] = useState(false) const [popup, setPopup] = useState(undefined) @@ -163,6 +181,45 @@ export default function TourMap({ center, data }: TourMapProps) { ) }, [PADDING, categorizedData, mapRef]) + const selectCity = useCallback( + (city: City) => { + router.push(`/tour/${city}`) + }, + [router] + ) + + useEffect(() => { + mapRef.current?.getMap().easeTo({ + center: [center[1], center[0]], + zoom: 15, + animate: false, + }) + }, [center, mapRef]) + + const tabs = useMemo(() => { + return ( + + + selectCity('ingolstadt')} + > + Ingolstadt + + selectCity('neuburg')} + > + Neuburg + + + + ) + }, [city, selectCity]) + return ( <> + {tabs} + - - - +
+
+ + + - + +
+ + {tabs} +
diff --git a/components/ui/footer.tsx b/components/ui/footer.tsx index 1d4b41a..55ea3d1 100644 --- a/components/ui/footer.tsx +++ b/components/ui/footer.tsx @@ -1,9 +1,19 @@ import { Button } from '@/components/ui/button' +import { cn } from '@/lib/utils' import Link from 'next/link' -export default function Footer() { +interface FooterProps { + className?: string +} + +export default function Footer({ className }: FooterProps) { return ( -