Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ yarn.lock
.tanstack
.agents
**/src/generated/
# Generated Lighthouse report kept at the repo root for reference.
lighthouse.json
2 changes: 2 additions & 0 deletions apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"react": "^19.3.0",
"react-dom": "^19.3.0",
"react-leaflet": "5.0.0-rc.2",
"react-leaflet-cluster": "^4.1.3",
"tailwindcss": "^4.3.3"
},
"devDependencies": {
Expand All @@ -39,6 +40,7 @@
"@testing-library/react": "^16.3.3",
"@testing-library/user-event": "^14.6.8",
"@types/leaflet": "^1.9.22",
"@types/leaflet.markercluster": "^1.5.6",
"@types/node": "^22.20.4",
"@types/react": "^19.3.0",
"@types/react-dom": "^19.3.0",
Expand Down
Binary file modified apps/frontend/public/favicon.ico
Binary file not shown.
Binary file added apps/frontend/src/assets/fonts/lora-latin.woff2
Binary file not shown.
Binary file not shown.
File renamed without changes
37 changes: 37 additions & 0 deletions apps/frontend/src/assets/map-placeholder.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/frontend/src/assets/map-poster.avif
Binary file not shown.
3 changes: 1 addition & 2 deletions apps/frontend/src/components/AddReviewDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import { useMutation, useQueryClient } from '@tanstack/react-query'

import { graphqlFetch } from '#/graphql/client'
import { CREATE_REVIEW } from '#/graphql/venues'
import { assetUrl } from '#/lib/asset-url'
import HARP_SRC from '#/assets/harp.svg?url'
import type { VenueReview } from '#/types/venue'

const USERNAME_STORAGE_KEY = 'g-spotter:review-username'
const BODY_MAX_LENGTH = 1000
const RATING_VALUES = [1, 2, 3, 4, 5]
const HARP_SRC = assetUrl('harp.svg')

interface ReviewInput {
venueId: string
Expand Down
76 changes: 76 additions & 0 deletions apps/frontend/src/components/ClientMap.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { lazy, Suspense, useEffect, useState } from 'react'
import type { ComponentProps } from 'react'

import mapPoster from '#/assets/map-poster.avif'
import type MapComponent from './Map'

// Leaflet touches `window` while its module is evaluated, so it may only be
// imported in the browser. Kick the import off while the rest of the page is
// still hydrating, instead of waiting for the map to mount.
const mapModulePromise = import.meta.env.SSR ? null : import('./Map')

// The dynamic import also moves Leaflet into its own chunk, keeping it out of
// the JavaScript needed for the first paint.
const LazyMap = mapModulePromise ? lazy(() => mapModulePromise) : null

type MapProps = ComponentProps<typeof MapComponent>

/**
* A picture of the map's default view (Trondheim, zoom 15) rendered on the
* server. The map is the largest thing on the first screen, so pulling that
* paint out of the JavaScript bundle lets the browser show it immediately
* instead of waiting for Leaflet and a handful of map tiles.
*
* Regenerate it by screenshotting `#map` at a 1112px viewport width (the widest
* the container gets) with no location available, then `avifenc -q 40 -s 6`.
*/
function MapPoster({ ready }: { ready: boolean }) {
return (
<>
<img
src={mapPoster}
alt=""
fetchPriority="high"
decoding="async"
className="h-full w-full object-cover"
/>
{/* The live map brings its own attribution control. */}
<span
hidden={ready}
className="absolute right-0 bottom-0 bg-white/80 px-1 text-[10px] leading-4 text-[#333]"
>
© OpenStreetMap contributors
</span>
</>
)
}

export default function ClientMap(props: MapProps) {
const [mounted, setMounted] = useState(false)

useEffect(() => {
setMounted(true)
}, [])

const ready = mounted && LazyMap != null

return (
<div className="relative h-100 w-full">
{/* The map fades in on top of the poster rather than the poster fading
out, so the poster stays painted and remains the LCP element. */}
<div
aria-hidden="true"
className="pointer-events-none absolute inset-0 overflow-hidden rounded-2xl bg-(--surface-strong)"
>
<MapPoster ready={ready} />
</div>
{ready && (
<div className="map-fade-in absolute inset-0 z-10">
<Suspense fallback={null}>
<LazyMap {...props} />
</Suspense>
</div>
)}
</div>
)
}
52 changes: 52 additions & 0 deletions apps/frontend/src/components/ClientVenueMap.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { lazy, Suspense, useEffect, useState } from 'react'
import type { ComponentProps } from 'react'

import mapPlaceholder from '#/assets/map-placeholder.svg'
import type VenueMapComponent from './VenueMap'

const venueMapModulePromise = import.meta.env.SSR ? null : import('./VenueMap')
const LazyVenueMap = venueMapModulePromise
? lazy(() => venueMapModulePromise)
: null

type VenueMapProps = ComponentProps<typeof VenueMapComponent>

/**
* A neutral map skeleton is rendered on the server so this block is painted
* immediately instead of waiting for Leaflet and a handful of tiles: the tiles
* arrive seconds later and would otherwise win the LCP race on this page. The
* live map fades in on top and the skeleton stays painted underneath, which
* keeps it a valid LCP candidate.
*/
export default function ClientVenueMap(props: VenueMapProps) {
const [mounted, setMounted] = useState(false)

useEffect(() => {
setMounted(true)
}, [])

const ready = mounted && LazyVenueMap != null

return (
<div className="relative h-64 w-full">
<div
aria-hidden="true"
className="pointer-events-none absolute inset-0 overflow-hidden rounded-xl bg-(--surface-strong)"
>
<img
src={mapPlaceholder}
alt=""
decoding="async"
className="h-full w-full object-cover"
/>
</div>
{ready && (
<div className="map-fade-in absolute inset-0 z-10">
<Suspense fallback={null}>
<LazyVenueMap {...props} />
</Suspense>
</div>
)}
</div>
)
}
26 changes: 26 additions & 0 deletions apps/frontend/src/components/Devtools.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { TanStackRouterDevtoolsPanel } from '@tanstack/react-router-devtools'
import { TanStackDevtools } from '@tanstack/react-devtools'

import TanStackQueryDevtools from '../integrations/tanstack-query/devtools'

/**
* Developer tools are loaded from a separate chunk that is only requested in
* development. Keeping them out of the production bundle saves a lot of
* JavaScript that would otherwise never run.
*/
export default function Devtools() {
return (
<TanStackDevtools
config={{
position: 'bottom-right',
}}
plugins={[
{
name: 'Tanstack Router',
render: <TanStackRouterDevtoolsPanel />,
},
TanStackQueryDevtools,
]}
/>
)
}
25 changes: 13 additions & 12 deletions apps/frontend/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ import ThemeToggle from './ThemeToggle'
export default function Header() {
return (
<header className="sticky top-0 z-1000 border-b border-(--harp-gold) bg-(--cream-head) px-4 backdrop-blur-lg">
<nav className="page-wrap flex flex-wrap items-center justify-between gap-x-3 gap-y-2 py-3 sm:py-4">
<h2 className="m-0 w-full flex-1 text-base font-semibold">
<div className="flex w-full items-center justify-between gap-3">
<a
href={import.meta.env.BASE_URL}
className="m-0 p-0 text-left tracking-[0.08em] text-(--cream-dark) font-extrabold"
>
G-SPOTTER
</a>
<ThemeToggle />
</div>
</h2>
<nav
aria-label="Main"
className="page-wrap flex flex-wrap items-center justify-between gap-x-3 gap-y-2 py-3 sm:py-4"
>
<div className="flex w-full flex-1 items-center justify-between gap-3 text-base font-semibold">
<a
href={import.meta.env.BASE_URL}
className="m-0 p-0 text-left font-display tracking-[0.08em] text-(--header-ink) no-underline font-extrabold hover:text-(--header-ink)"
>
G-SPOTTER
</a>
<ThemeToggle />
</div>
</nav>
</header>
)
Expand Down
Loading