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
75 changes: 39 additions & 36 deletions apps/frontend/src/components/AddReviewDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ 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 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 Expand Up @@ -110,7 +112,7 @@ export default function AddReviewDialog({
<button
type="button"
onClick={openDialog}
className="inline-flex items-center gap-1.5 rounded-xl border border-(--lagoon-deep) bg-(--chip-bg) px-3.5 py-2 text-sm font-bold text-(--sea-ink) shadow-[0_8px_22px_rgba(30,90,72,0.08)] hover:-translate-y-0.5 hover:bg-(--link-bg-hover) focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--lagoon-deep)"
className="inline-flex items-center gap-1.5 rounded-xl bg-(--chip-bg) px-3.5 py-2 text-sm font-bold text-(--sea-ink) shadow-[0_8px_22px_rgba(0,0,0,0.28)] hover:-translate-y-0.5 hover:bg-(--link-bg-hover) focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--lagoon-deep)"
>
<span aria-hidden="true" className="text-base leading-none">
+
Expand All @@ -127,7 +129,7 @@ export default function AddReviewDialog({
closeDialog()
}
}}
className="m-auto max-h-[calc(100dvh_-_2rem)] w-[min(30rem,calc(100vw_-_2rem))] overflow-y-auto rounded-2xl border border-(--line) bg-(--surface-strong) p-0 text-(--sea-ink) shadow-2xl backdrop:bg-black/50 backdrop:backdrop-blur-sm"
className="m-auto max-h-[calc(100dvh_-_2rem)] w-[min(30rem,calc(100vw_-_2rem))] overflow-y-auto rounded-2xl bg-(--surface-strong) p-0 text-(--sea-ink) shadow-2xl backdrop:bg-black/50 backdrop:backdrop-blur-sm"
>
<div className="relative p-5">
<h2 id={titleId} className="text-xl font-extrabold">
Expand All @@ -152,46 +154,47 @@ export default function AddReviewDialog({
required
autoComplete="nickname"
placeholder="e.g. Kari"
className="w-full rounded-xl border border-(--line) bg-(--chip-bg) px-3 py-2 text-sm text-(--sea-ink) outline-none placeholder:text-(--sea-ink-soft) focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--lagoon-deep)"
className="w-full rounded-xl bg-(--chip-bg) px-3 py-2 text-sm text-(--sea-ink) outline-none placeholder:text-(--sea-ink-soft) focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--lagoon-deep)"
/>
</div>

<fieldset className="grid gap-1.5">
<legend className="text-sm font-bold">Rating</legend>
<div
className="flex flex-wrap items-center gap-1"
className="flex flex-wrap items-center"
onMouseLeave={() => setHoveredRating(0)}
>
{RATING_VALUES.map((value) => (
<label
key={value}
onMouseEnter={() => setHoveredRating(value)}
className="cursor-pointer rounded-md p-0.5 focus-within:outline-2 focus-within:outline-offset-2 focus-within:outline-(--lagoon-deep)"
>
<input
type="radio"
name="rating"
value={value}
checked={rating === value}
onChange={() => setRating(value)}
className="sr-only"
/>
<span
aria-hidden="true"
className={`text-2xl leading-none transition-colors ${
value <= visibleRating
? 'text-amber-500'
: 'text-(--line)'
}`}
>
★
</span>
<span className="sr-only">{value} out of 5 stars</span>
</label>
))}
<span className="ml-2 text-xs font-bold text-(--sea-ink-soft)">
{rating > 0 ? `${rating} / 5` : 'Select a rating'}
<span className="mr-2 w-24 shrink-0 text-right text-xs font-bold whitespace-nowrap text-(--sea-ink-soft)">
Select a rating:
</span>
<div className="flex items-center -space-x-4">
{RATING_VALUES.map((value) => (
<label
key={value}
onMouseEnter={() => setHoveredRating(value)}
className="cursor-pointer rounded-md p-0.5"
>
<input
type="radio"
name="rating"
value={value}
checked={rating === value}
onChange={() => setRating(value)}
className="peer sr-only"
/>
<img
src={HARP_SRC}
alt=""
aria-hidden="true"
draggable={false}
className={`h-5 w-auto rounded-sm select-none transition-opacity peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-(--lagoon-deep) ${
value <= visibleRating ? 'opacity-100' : 'opacity-30'
}`}
/>
<span className="sr-only">{value} out of 5 harps</span>
</label>
))}
</div>
</div>
</fieldset>

Expand All @@ -212,7 +215,7 @@ export default function AddReviewDialog({
required
rows={4}
placeholder="What was the atmosphere, selection and price like?"
className="min-h-28 w-full resize-y rounded-xl border border-(--line) bg-(--chip-bg) px-3 py-2 text-sm text-(--sea-ink) outline-none placeholder:text-(--sea-ink-soft) focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--lagoon-deep)"
className="min-h-28 w-full resize-y rounded-xl bg-(--chip-bg) px-3 py-2 text-sm text-(--sea-ink) outline-none placeholder:text-(--sea-ink-soft) focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--lagoon-deep)"
/>
</div>

Expand All @@ -230,14 +233,14 @@ export default function AddReviewDialog({
<button
type="button"
onClick={closeDialog}
className="rounded-xl border border-(--line) px-3.5 py-2 text-sm font-bold text-(--sea-ink-soft) hover:bg-(--chip-bg) hover:text-(--sea-ink) focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--lagoon-deep)"
className="rounded-xl px-3.5 py-2 text-sm font-bold text-(--sea-ink-soft) hover:bg-(--chip-bg) hover:text-(--sea-ink) focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--lagoon-deep)"
>
Cancel
</button>
<button
type="submit"
disabled={isPending}
className="rounded-xl border border-(--lagoon-deep) bg-(--chip-bg) px-3.5 py-2 text-sm font-bold text-(--sea-ink) hover:bg-(--link-bg-hover) focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--lagoon-deep) disabled:cursor-not-allowed disabled:opacity-60"
className="rounded-xl bg-(--chip-bg) px-3.5 py-2 text-sm font-bold text-(--sea-ink) hover:bg-(--link-bg-hover) focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--lagoon-deep) disabled:cursor-not-allowed disabled:opacity-60"
>
{isPending ? 'Posting…' : 'Post review'}
</button>
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function Header() {
<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 text-(--cream-dark)"
className="m-0 p-0 text-left tracking-[0.08em] text-(--) font-extrabold"
>
G-SPOTTER
</a>
Expand Down
33 changes: 23 additions & 10 deletions apps/frontend/src/components/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import {
CircleMarker,
MapContainer,
Marker,
Popup,
TileLayer,
Tooltip,
useMap,
} from 'react-leaflet'
import L from 'leaflet'
import { useNavigate } from '@tanstack/react-router'

import { formatPrice } from '../lib/format-price'
import { assetUrl } from '#/lib/asset-url'
import { MOCK_LOCATION_NAME } from '../lib/location'
import type { Coordinates } from '../lib/location'
import type { SearchResult } from '../types/search'
Expand All @@ -32,13 +34,13 @@ function FlyToResult({ coordinates }: { coordinates: number[] | undefined }) {
}

const harpIcon = new L.Icon({
iconUrl: 'harp.svg',
shadowUrl: 'harp_shadow.svg',
iconUrl: assetUrl('harp.svg'),
shadowUrl: assetUrl('harp_shadow.svg'),
iconSize: [46, 46],
shadowSize: [50, 50],
iconAnchor: [23, 23],
shadowAnchor: [25, 25],
popupAnchor: [0, -47.5],
popupAnchor: [0, -25],
})

export default function Map({
Expand All @@ -52,6 +54,7 @@ export default function Map({
flyTo?: number[]
isMockLocation?: boolean
}) {
const navigate = useNavigate()
const markers = nearby.filter(
(venue, index, all) =>
all.findIndex(
Expand Down Expand Up @@ -80,33 +83,43 @@ export default function Map({
key={`${curr.type}-${curr.name}-${curr.lat}-${curr.lon}`}
icon={harpIcon}
position={[curr.lat, curr.lon]}
eventHandlers={{
click: () => {
if (curr.cityId) {
void navigate({
to: '/$cityId/venues/$venueId',
params: { cityId: curr.cityId, venueId: curr.id },
})
}
},
}}
>
<Popup>
<Tooltip direction="top" offset={[0, -20]}>
<strong>{curr.name}</strong>
{curr.address && <span className="block">{curr.address}</span>}
{curr.latestPriceSighting && (
<span className="block">
{formatPrice(curr.latestPriceSighting)}
</span>
)}
</Popup>
</Tooltip>
</Marker>
))}
{userLocation && (
<CircleMarker
center={[userLocation.lat, userLocation.lon]}
radius={8}
pathOptions={{
color: '#328f97',
fillColor: '#4fb8b2',
color: '#d3ad57',
fillColor: '#e6c77f',
fillOpacity: 0.85,
}}
>
<Popup>
<Tooltip direction="top" offset={[0, -12]}>
{isMockLocation
? `Mock location: ${MOCK_LOCATION_NAME}`
: 'Your location'}
</Popup>
</Tooltip>
</CircleMarker>
)}
</MapContainer>
Expand Down
8 changes: 4 additions & 4 deletions apps/frontend/src/components/NearbyVenues.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface NearbyVenuesProps {
}

const rowClassName =
'block w-full border-t border-[var(--line)] px-1 py-3 text-left text-sm text-[var(--sea-ink)] transition hover:bg-[var(--chip-bg)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--lagoon-deep)'
'block w-full px-1 py-3 text-left text-sm text-[var(--sea-ink)] transition-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--lagoon-deep)'

function VenueRow({ venue }: { venue: SearchResult }) {
return (
Expand All @@ -28,7 +28,7 @@ function VenueRow({ venue }: { venue: SearchResult }) {
title={`Average rating ${venue.averageRating.toFixed(1)} out of 5 from ${
venue.reviewCount ?? 0
} ${(venue.reviewCount ?? 0) === 1 ? 'review' : 'reviews'}`}
className="inline-flex shrink-0 items-center gap-1 rounded-full border border-[var(--chip-line)] bg-[var(--chip-bg)] px-2 py-0.5 text-xs font-bold text-[var(--sea-ink)]"
className="inline-flex shrink-0 items-center gap-1 rounded-full bg-[var(--chip-bg)] px-2 py-0.5 text-xs font-bold text-[var(--sea-ink)]"
>
<span aria-hidden="true" className="text-amber-500">
★
Expand Down Expand Up @@ -82,7 +82,7 @@ export default function NearbyVenues({
type="button"
onClick={onRefresh}
disabled={locating}
className="rounded-full border border-[var(--chip-line)] bg-[var(--chip-bg)] px-3 py-1.5 text-sm font-semibold text-[var(--sea-ink)] transition hover:-translate-y-0.5 disabled:cursor-wait disabled:opacity-60 disabled:hover:translate-y-0"
className="rounded-full bg-[var(--chip-bg)] px-3 py-1.5 text-sm font-semibold text-[var(--sea-ink)] transition hover:-translate-y-0.5 disabled:cursor-wait disabled:opacity-60 disabled:hover:translate-y-0"
>
{locating ? 'Finding location…' : 'Refresh location'}
</button>
Expand Down Expand Up @@ -125,7 +125,7 @@ export default function NearbyVenues({
)}

{hasLocation && venues.length > 0 && (
<ul className="mt-3">
<ul className="mt-3 striped-list venue-list">
{venues.map((venue) => (
<li key={venue.id}>
{venue.cityId ? (
Expand Down
10 changes: 5 additions & 5 deletions apps/frontend/src/components/SearchBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,11 @@ export function SearchBox({ coordinates = null, filters }: SearchBoxProps) {
}

return (
<div className="absolute top-3 right-3 z-[1000] w-[min(22rem,calc(100%_-_1.5rem))]">
<div className="relative z-[1000] w-full max-w-[22rem]">
<form
role="search"
onSubmit={handleSubmit}
className="rounded-xl border border-[var(--line)] bg-[var(--surface-strong)] shadow-lg backdrop-blur"
className="rounded-xl bg-[var(--surface-strong)] shadow-lg backdrop-blur"
>
<div className="flex items-center gap-2 px-3 py-2">
<button
Expand Down Expand Up @@ -270,7 +270,7 @@ export function SearchBox({ coordinates = null, filters }: SearchBoxProps) {
</form>

{showPanel && (
<div className="mt-2 overflow-hidden rounded-xl border border-[var(--line)] bg-[var(--surface-strong)] shadow-lg backdrop-blur">
<div className="mt-2 overflow-hidden rounded-xl bg-[var(--surface-strong)] shadow-lg backdrop-blur">
{isError && (
<p className="px-3 py-2 text-sm text-[var(--sea-ink-soft)]">
Search is unavailable right now.
Expand Down Expand Up @@ -313,7 +313,7 @@ export function SearchBox({ coordinates = null, filters }: SearchBoxProps) {
<span className="flex items-baseline justify-between gap-2">
<span className="min-w-0">
<span className="font-semibold">{result.name}</span>
<span className="ml-2 rounded-full border border-[var(--chip-line)] px-1.5 py-0.5 text-[0.65rem] font-bold tracking-wide uppercase text-[var(--sea-ink-soft)]">
<span className="ml-2 rounded-full px-1.5 py-0.5 text-[0.65rem] font-bold tracking-wide uppercase text-[var(--sea-ink-soft)]">
{typeLabel(result)}
</span>
</span>
Expand All @@ -326,7 +326,7 @@ export function SearchBox({ coordinates = null, filters }: SearchBoxProps) {
? 'review'
: 'reviews'
}`}
className="inline-flex shrink-0 items-center gap-1 rounded-full border border-[var(--chip-line)] bg-[var(--chip-bg)] px-1.5 py-0.5 text-xs font-bold"
className="inline-flex shrink-0 items-center gap-1 rounded-full bg-[var(--chip-bg)] px-1.5 py-0.5 text-xs font-bold"
>
<span aria-hidden="true" className="text-amber-500">
★
Expand Down
7 changes: 3 additions & 4 deletions apps/frontend/src/components/SearchFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const SIZE_OPTIONS: { value: GlassSize; label: string }[] = [
]

const fieldClassName =
'mt-1 w-full rounded-lg border border-[var(--line)] bg-[var(--surface-strong)] px-2.5 py-1.5 text-sm text-[var(--sea-ink)] outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--lagoon-deep)'
'mt-1 w-full rounded-xl bg-[var(--chip-bg)] px-2.5 py-1.5 text-sm text-[var(--sea-ink)] outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--lagoon-deep)'

const labelClassName = 'block text-xs font-semibold text-[var(--sea-ink-soft)]'

Expand Down Expand Up @@ -67,10 +67,9 @@ export default function SearchFilters({
}

return (
<section className="mt-4 rounded-2xl border border-[var(--line)] bg-[var(--surface-strong)] p-4 text-[var(--sea-ink)]">
<section className="mt-4 rounded-2xl bg-[var(--surface-strong)] p-4 text-[var(--sea-ink)]">
<div className="flex flex-wrap items-start justify-between gap-3">
<div>
<p className="island-kicker">Filters</p>
<h2 className="mt-1 text-lg font-extrabold">Filter pubs</h2>
<p className="mt-0.5 text-xs text-[var(--sea-ink-soft)]">
Applies to the map, nearby pubs and search results.
Expand All @@ -80,7 +79,7 @@ export default function SearchFilters({
type="button"
onClick={() => onChange(EMPTY_SEARCH_FILTERS)}
disabled={activeCount === 0}
className="rounded-full border border-[var(--chip-line)] bg-[var(--chip-bg)] px-3 py-1.5 text-xs font-semibold text-[var(--sea-ink)] transition hover:-translate-y-0.5 disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:translate-y-0"
className="rounded-full bg-[var(--chip-bg)] px-3 py-1.5 text-xs font-semibold text-[var(--sea-ink)] transition hover:-translate-y-0.5 disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:translate-y-0"
>
Clear filters
{activeCount > 0 && ` (${activeCount})`}
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/src/components/ThemeToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function ThemeToggle() {
onClick={toggleMode}
aria-label={label}
title={label}
className="rounded-full bg-(--cream-dark) px-3 py-1.5 text-sm font-semibold text-(--stout-black) shadow-[0_8px_22px_rgba(30,90,72,0.08)] transition hover:-translate-y-0.5"
className="rounded-full bg-(--cream-dark) px-3 py-1.5 text-sm font-semibold text-(--stout-black) shadow-[0_8px_22px_rgba(0,0,0,0.28)] transition hover:-translate-y-0.5"
>
{mode === 'dark' ? 'Dark' : 'Light'}
</button>
Expand Down
15 changes: 14 additions & 1 deletion apps/frontend/src/components/VenueMap.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
import { MapContainer, Marker, TileLayer } from 'react-leaflet'
import L from 'leaflet'

import { assetUrl } from '#/lib/asset-url'

interface VenueMapProps {
lat: number
lon: number
name: string
}

const harpIcon = new L.Icon({
iconUrl: assetUrl('harp.svg'),
shadowUrl: assetUrl('harp_shadow.svg'),
iconSize: [46, 46],
shadowSize: [50, 50],
iconAnchor: [23, 23],
shadowAnchor: [25, 25],
popupAnchor: [0, -20],
})

export default function VenueMap({ lat, lon, name }: VenueMapProps) {
return (
<MapContainer
Expand All @@ -21,7 +34,7 @@ export default function VenueMap({ lat, lon, name }: VenueMapProps) {
attribution='&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
/>
<Marker position={[lat, lon]} title={name} />
<Marker position={[lat, lon]} icon={harpIcon} title={name} />
</MapContainer>
)
}
Loading