Skip to content

Commit

Permalink
feat: add more locations for illustration (#640)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregkonush authored Dec 24, 2024
1 parent 04ef652 commit 5724d07
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 13 deletions.
8 changes: 6 additions & 2 deletions apps/findbobastore/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { MapContainer } from '@/components/map-container'

export default function Home() {
export default async function Home() {
const mapboxToken = process.env.NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN
if (!mapboxToken) {
throw new Error('Missing NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN')
}
return (
<main className="relative w-full h-screen">
<div className="absolute top-4 left-4 z-10 bg-slate-900/80 px-4 py-2 rounded-lg">
<h1 className="text-xl font-bold text-white">Find Boba Store</h1>
</div>
<MapContainer />
<MapContainer token={mapboxToken} />
</main>
)
}
4 changes: 2 additions & 2 deletions apps/findbobastore/src/components/map-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ const MapView = dynamic(() => import('./map-view'), {
),
})

export function MapContainer() {
return <MapView />
export function MapContainer({ token }: { token: string }) {
return <MapView token={token} />
}
32 changes: 23 additions & 9 deletions apps/findbobastore/src/components/map-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ import { motion, AnimatePresence } from 'framer-motion'
import { cn } from '../lib/utils'
import 'mapbox-gl/dist/mapbox-gl.css'

const MAPBOX_ACCESS_TOKEN = process.env.NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN

if (!MAPBOX_ACCESS_TOKEN) {
throw new Error('Missing NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN')
}

mapboxgl.accessToken = MAPBOX_ACCESS_TOKEN

interface BobaStore {
id: string
name: string
Expand Down Expand Up @@ -196,6 +188,27 @@ const mockBobaStores: BobaStore[] = [
rating: 4.5,
address: '677 Tasman Dr, Sunnyvale, CA 94089',
},
{
id: '26',
name: 'Pekoe',
coordinates: [-122.0317, 37.3784],
rating: 3.9,
address: '939 W El Camino Real Suite 117, Sunnyvale, CA 94087',
},
{
id: '27',
name: 'Tastea Sunnyvale',
coordinates: [-122.0327, 37.3794],
rating: 4.2,
address: '114 E El Camino Real, Sunnyvale, CA 94087',
},
{
id: '28',
name: 'Mr. Sun Tea Mountain View',
coordinates: [-122.0891, 37.3894],
rating: 4.1,
address: '801 W El Camino Real A, Mountain View, CA 94040',
},
]

function MapOverlay({ store }: { store: BobaStore | null }) {
Expand Down Expand Up @@ -224,7 +237,8 @@ function MapOverlay({ store }: { store: BobaStore | null }) {
)
}

export function MapView() {
export function MapView({ token }: { token: string }) {
mapboxgl.accessToken = token
const mapContainer = useRef<HTMLDivElement>(null)
const map = useRef<mapboxgl.Map | null>(null)
const [selectedStore, setSelectedStore] = useState<BobaStore | null>(null)
Expand Down

0 comments on commit 5724d07

Please sign in to comment.