feat(journey): complete sharing, photo drafts and Studio maps

Connect the Journey backend to the web and mobile UI, including public access and subscriptions, day recordings, photo drafts and per-map framing. Preserve legacy recording responses and cover the new behavior in every locale.
This commit is contained in:
Maurice
2026-11-30 16:55:22 +01:00
parent 458227f489
commit ede109dce8
90 changed files with 5306 additions and 292 deletions
+13 -3
View File
@@ -32,6 +32,7 @@ import { AddTripDialog } from '../components/Journey/JourneyDetailPageAddTripDia
import { JourneySettingsDialog } from '../components/Journey/JourneyDetailPageSettingsDialog'
import HelpAnchor from '../components/Help/HelpAnchor'
import JourneyDayJump from '../components/Journey/JourneyDayJump'
import { MemberEntryComments } from '../components/Journey/JourneyEntryComments'
export default function JourneyDetailPage() {
// ViewportRoute in App.tsx picks the branch now, so the phone screen is a
@@ -53,7 +54,7 @@ export function JourneyDetailPageDesktop({ journeyId, embedded = false }: Journe
// Page = wiring container: load + live sync, view state, dialogs, the
// scroll-synced map and the map/trip-date derivations live in the hook.
const {
id, navigate, toast, t, locale,
id, navigate, toast, t, locale, comments,
openStudio, prefetchStudio,
current, loading,
canEditEntries, canEditJourney, myRole,
@@ -69,7 +70,7 @@ export function JourneyDetailPageDesktop({ journeyId, embedded = false }: Journe
galleryUploadProgress, setGalleryUploadProgress,
activeLocationId, handleMarkerClick, handleLocationClick,
mapEntries, sidebarMapItems, tripDates, isMobile, tracks, mapPhotos, openMapPhotos, mapLayers, entryTitleOf,
recordings, canTakeOverRecording, recordingNeedsConnection, dayImport, recordingPrep,
recordings, canTakeOverRecording, recordingNeedsConnection, dayImport, recordingPrep, gpxImport, canImportGpx,
feedEdge, scrollFeedTo,
loadJourney, updateEntry, deleteEntry, reorderEntries, uploadPhotos, deletePhoto,
addPickedProviderPhotos, addEntryProviderPhotos, writeAboutPlace,
@@ -211,6 +212,7 @@ export function JourneyDetailPageDesktop({ journeyId, embedded = false }: Journe
<MobileEntryView
entry={viewingEntry}
readOnly={!canEditEntries}
comments={<MemberEntryComments entryId={viewingEntry.id} thread={comments} />}
onClose={() => setViewingEntry(null)}
onEdit={() => { setViewingEntry(null); setEditingEntry(viewingEntry); }}
onDelete={() => { setViewingEntry(null); setDeleteTarget(viewingEntry); }}
@@ -508,11 +510,18 @@ export function JourneyDetailPageDesktop({ journeyId, embedded = false }: Journe
<div className="flex items-center gap-2">
<span className="inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[10px] font-bold uppercase tracking-[0.07em]" style={{ background: 'var(--vg-surf2)', color: 'var(--vg-ink3)' }}><MapPin size={12} /> {entries.length} {t('journey.synced.places', { count: entries.length })}</span>
<JourneyDayRecordingButton
day={recordings.byDate.get(date)}
day={recordings.bySource.dawarich.get(date)}
canEdit={canEditEntries}
canTakeOver={canTakeOverRecording}
needsConnection={recordingNeedsConnection}
onOpen={() => recordings.open(date)}
gpx={{
day: recordings.bySource.gpx.get(date),
canImport: canImportGpx,
busy: gpxImport.busy,
onImport: file => void gpxImport.importDayFile(file, date),
onRemove: () => void gpxImport.removeDay(date),
}}
/>
<JourneyDayImportButton
pending={stays.length}
@@ -601,6 +610,7 @@ export function JourneyDetailPageDesktop({ journeyId, embedded = false }: Journe
<EntryCard
entry={entry}
readOnly={!canEditEntries}
comments={<MemberEntryComments entryId={entry.id} thread={comments} />}
onEdit={() => setEditingEntry(entry)}
onDelete={() => setDeleteTarget(entry)}
onPhotoClick={(photos, idx) => setLightbox({ photos: photos.map(p => ({ id: p.id, src: photoUrl(p, 'original'), thumbSrc: photoUrl(p, 'thumbnail'), caption: p.caption, provider: p.provider, asset_id: p.asset_id, owner_id: p.owner_id, mediaType: p.media_type })), index: idx })}
+50
View File
@@ -0,0 +1,50 @@
import { BellOff, BellRing, CircleAlert, Loader2 } from 'lucide-react';
import { Link } from 'react-router-dom';
import { useTranslation } from '../i18n';
import { useJourneyFollowPage } from './journeyFollow/useJourneyFollowPage';
/**
* Where a follower's mail links land (#1669): the page confirms the address or
* ends the subscription, then says so in one card.
*/
export default function JourneyFollowPage() {
const { t } = useTranslation();
const { state } = useJourneyFollowPage();
let icon = <Loader2 size={20} className="animate-spin" />;
let title = t('common.loading');
let text = '';
if (state.status === 'confirmed') {
icon = <BellRing size={20} />;
title = t('journey.follow.confirmedTitle');
text = t('journey.follow.confirmedText', { title: state.title });
} else if (state.status === 'unsubscribed') {
icon = <BellOff size={20} />;
title = t('journey.follow.unsubscribedTitle');
text = t('journey.follow.unsubscribedText');
} else if (state.status === 'invalid' || state.status === 'failed') {
icon = <CircleAlert size={20} />;
title = t(state.status === 'invalid' ? 'journey.follow.invalidTitle' : 'common.errorTitle');
text = t(state.status === 'invalid' ? 'journey.follow.invalidText' : 'journey.follow.failed');
}
return (
<div className="flex min-h-screen items-center justify-center bg-surface-secondary px-4">
<div className="w-full max-w-sm rounded-[28px] border border-edge-faint bg-surface-card p-7 text-center shadow-sm">
<div className="mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-2xl bg-surface-secondary text-content-muted">
{icon}
</div>
<h1 className="text-subtitle font-bold text-content">{title}</h1>
{text && <p className="mt-1.5 text-body text-content-muted">{text}</p>}
{state.status === 'confirmed' && (
<Link
to={`/public/journey/${state.link}`}
className="mt-5 inline-flex w-full items-center justify-center rounded-xl bg-accent py-2.5 text-body font-semibold text-accent-text transition-colors hover:bg-accent-hover"
>
{t('common.open')}
</Link>
)}
</div>
</div>
);
}
+16
View File
@@ -32,6 +32,9 @@ import { useTranslation } from '../i18n';
import { formatLocationName } from '../utils/formatters';
import { posterlessVideo } from './journeyDetail/JourneyDetailPage.helpers';
import { useJourneyPublic } from './journeyPublic/useJourneyPublic';
import { GuestEntryComments } from '../components/Journey/JourneyEntryComments';
import { JourneyPublicExpired, JourneyPublicPasswordCard } from './journeyPublic/JourneyPublicGate';
import { JourneyPublicFollow } from './journeyPublic/JourneyPublicFollow';
const MOOD_CONFIG: Record<string, { icon: typeof Smile; label: string; bg: string; text: string }> = {
amazing: {
@@ -116,6 +119,9 @@ export default function JourneyPublicPage() {
data,
loading,
error,
access,
unlock,
social,
isMobile,
locale,
view,
@@ -151,6 +157,8 @@ export default function JourneyPublicPage() {
} = useJourneyPublic();
if (loading) return <SharedLoading />;
if (access === 'locked') return <JourneyPublicPasswordCard onUnlock={unlock} />;
if (access === 'expired') return <JourneyPublicExpired />;
if (error || !data) {
return (
@@ -549,6 +557,12 @@ export default function JourneyPublicPage() {
)}
</div>
)}
{social.commentsOpen && (
<div className="mt-3 border-t border-zinc-100 pt-3 dark:border-zinc-800">
<GuestEntryComments entryId={entry.id} thread={social} />
</div>
)}
</div>
</div>
);
@@ -619,6 +633,7 @@ export default function JourneyPublicPage() {
<SharedHero
trip={{ title: journey.title, description: journey.subtitle, cover_image: journey.cover_image, start_date: firstDate, end_date: lastDate }}
stats={heroStats}
action={social.canSubscribe ? <JourneyPublicFollow onSubscribe={social.subscribe} /> : undefined}
/>
{!floatingSwitch && (
<SharedTabBar tabs={availableViews.map(v => ({ id: v.id, label: v.label, icon: v.icon }))} active={view} onChange={id => setView(id as typeof view)} />
@@ -777,6 +792,7 @@ export default function JourneyPublicPage() {
publicPhotoUrl={(photoId, size = 'original') =>
`/api/public/journey/${token}/photos/${photoId}/${size}`
}
comments={social.commentsOpen ? <GuestEntryComments entryId={viewingEntry.id} thread={social} /> : undefined}
onClose={() => setViewingEntry(null)}
onEdit={() => { }}
onDelete={() => { }}
@@ -21,6 +21,7 @@ import type { DawarichSuggestion, DawarichSuggestionTarget, JourneyMapPlace } fr
import { useDawarichJournalTrail } from '../../hooks/useDawarichJournalTrail'
import { useJourneyDetailLayers } from './useJourneyDetailLayers'
import { useProviderPhotoAdds } from './useProviderPhotoAdds'
import { useJourneyComments } from '../../components/Journey/useJourneyComments'
/**
@@ -540,7 +541,7 @@ export function useJourneyDetail({ journeyId, embedded = false }: JourneyDetailO
const {
recordingPrep, recordings, canTakeOverRecording, recordingNeedsConnection, mapTracks, mapLayers, entryTitleOf,
dayImport, dayImportDates,
dayImport, dayImportDates, gpxImport, canImportGpx,
} = useJourneyDetailLayers({
journey: current, loaded: journeyLoaded, canEditEntries, loadJourney: refreshJourney, dawarich, dawarichByDate, dawarichTrail,
tripDates, sidebarMapItems, photoCount: mapPhotos.length, showTripTracks,
@@ -574,8 +575,11 @@ export function useJourneyDetail({ journeyId, embedded = false }: JourneyDetailO
void import('../JourneyStudioPage')
}, [])
// #1702: the threads under the entries, read once the journey is here.
const comments = useJourneyComments(journeyLoaded && current ? current.id : null)
return {
id, navigate, toast, t, locale, embedded, notFound,
id, navigate, toast, t, locale, embedded, notFound, comments,
openStudio, prefetchStudio,
current, loading,
canEditEntries, canEditJourney, myRole,
@@ -592,7 +596,7 @@ export function useJourneyDetail({ journeyId, embedded = false }: JourneyDetailO
galleryUploadProgress, setGalleryUploadProgress,
activeLocationId, handleMarkerClick, handleLocationClick,
mapEntries, sidebarMapItems, tripDates, isMobile, tracks: mapTracks, dawarichTrail, mapLayers, entryTitleOf,
recordings, canTakeOverRecording, recordingNeedsConnection, dayImport, dayImportDates, recordingPrep,
recordings, canTakeOverRecording, recordingNeedsConnection, dayImport, dayImportDates, recordingPrep, gpxImport, canImportGpx,
mapPhotos, openMapPhotos,
feedEdge, scrollFeedTo,
// The views reload after their own changes; such a read never rejects.
@@ -41,7 +41,7 @@ export function useJourneyDetailRecordings({
);
const recordings = useJourneyRecordings(journey, colorOfDay);
// #3085: a GPX file is a source of its own, open to whoever may edit, with or without Dawarich.
const gpxImport = useJourneyGpxImport(journeyId, recordings.keptMany);
const gpxImport = useJourneyGpxImport(journeyId, recordings.keptMany, recordings.removed);
const mapTracks = useMemo(() => {
if (recordings.tracks.length === 0 && liveTracks.length === 0) return tripTracks;
@@ -0,0 +1,15 @@
import { useParams, useSearchParams } from 'react-router-dom';
import { useJourneyFollow } from './useJourneyFollow';
/**
* The follower page's state: which mail link was opened (`/public/journey-follow/
* confirm` or `/unsubscribe`) and what posting its token came to. An unknown
* action reads as an unknown link.
*/
export function useJourneyFollowPage() {
const { action } = useParams();
const [params] = useSearchParams();
const known = action === 'confirm' || action === 'unsubscribe' ? action : null;
const state = useJourneyFollow(known ?? 'confirm', known ? params.get('token') : null);
return { action: known, state };
}
@@ -0,0 +1,143 @@
import { BellPlus, MailCheck } from 'lucide-react';
import { useId, useState, type FormEvent } from 'react';
import {
DialogButton,
DialogFooter,
DialogHeader,
DialogShell,
DialogTile,
FooterSpacer,
NEUTRAL_TINT,
fs,
} from '../../components/shared/DialogShell';
import { useTranslation } from '../../i18n';
import { GLASS } from '../sharedTrip/SharedChrome';
import type { PublicSocialOutcome } from './journeyPublicModel';
const OUTCOME_KEYS: Record<Exclude<PublicSocialOutcome, 'ok'>, string> = {
closed: 'journey.follow.closed',
gone: 'journey.public.notFoundMessage',
locked: 'journey.comments.locked',
rate_limited: 'common.tooManyAttempts',
invalid: 'journey.follow.invalid',
failed: 'journey.follow.failed',
};
/**
* "Follow" on a shared journey (#1669): one glass pill in the hero, and a small
* dialog that takes an address. The server answers the same for an address that
* already follows, so the dialog always ends on "check your inbox".
*/
export function JourneyPublicFollow({
onSubscribe,
}: {
onSubscribe: (email: string, locale: string) => Promise<PublicSocialOutcome>;
}) {
const { t, locale } = useTranslation();
const labelId = useId();
const [open, setOpen] = useState(false);
const [email, setEmail] = useState('');
const [trap, setTrap] = useState('');
const [busy, setBusy] = useState(false);
const [sent, setSent] = useState(false);
const [error, setError] = useState<string | null>(null);
const close = () => {
setOpen(false);
setError(null);
};
const submit = async (e: FormEvent) => {
e.preventDefault();
if (busy || sent || !email.trim()) return;
// Only a bot fills the field people never see: it is told all went well.
if (trap) {
setSent(true);
return;
}
setBusy(true);
setError(null);
const outcome = await onSubscribe(email.trim(), locale || 'en');
setBusy(false);
if (outcome === 'ok') setSent(true);
else setError(t(OUTCOME_KEYS[outcome]));
};
return (
<>
<button
type="button"
onClick={() => setOpen(true)}
className={`${GLASS} hover:bg-white/25`}
style={fs(12, 'body')}
>
<BellPlus size={13} strokeWidth={2} aria-hidden />
{t('journey.follow.title')}
</button>
{open && (
<DialogShell
onClose={close}
labelledBy={labelId}
width="narrow"
onSubmit={(e) => void submit(e)}
header={
<DialogHeader
tile={<DialogTile>{sent ? <MailCheck size={18} /> : <BellPlus size={18} />}</DialogTile>}
tint={NEUTRAL_TINT}
labelId={labelId}
onClose={close}
title={sent ? t('journey.follow.sentTitle') : t('journey.follow.title')}
sub={sent ? t('journey.follow.sentText') : t('journey.follow.text')}
subWraps
/>
}
footer={
<DialogFooter>
<FooterSpacer />
{sent ? (
<DialogButton variant="primary" onClick={close}>
{t('common.close')}
</DialogButton>
) : (
<DialogButton variant="primary" type="submit" disabled={busy || !email.trim()}>
{t('journey.follow.title')}
</DialogButton>
)}
</DialogFooter>
}
>
{!sent && (
<div className="flex flex-col gap-2 px-6 py-5">
<input
type="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
autoFocus
autoComplete="email"
placeholder={t('common.email')}
aria-label={t('common.email')}
className="w-full rounded-xl border border-edge bg-surface px-3.5 py-2.5 text-body text-content outline-none placeholder:text-content-faint focus:border-content-faint"
/>
{/* Left empty by people: the field sits off screen and out of the tab order. */}
<input
value={trap}
onChange={(e) => setTrap(e.target.value)}
name="website"
tabIndex={-1}
autoComplete="off"
aria-hidden="true"
className="absolute -start-[9999px] h-px w-px opacity-0"
/>
{error && (
<p role="alert" className="text-caption text-danger">
{error}
</p>
)}
<p className="text-caption text-content-faint">{t('journey.follow.privacy')}</p>
</div>
)}
</DialogShell>
)}
</>
);
}
@@ -0,0 +1,99 @@
import { Clock, Lock } from 'lucide-react';
import { useState, type FormEvent, type ReactNode } from 'react';
import { useTranslation } from '../../i18n';
import type { PublicUnlockOutcome } from './journeyPublicModel';
const OUTCOME_KEYS: Record<Exclude<PublicUnlockOutcome, 'ok' | 'expired'>, string> = {
wrong: 'journey.public.passwordWrong',
rate_limited: 'common.tooManyAttempts',
failed: 'journey.public.passwordFailed',
};
function GateFrame({
icon,
title,
text,
children,
}: {
icon: ReactNode;
title: string;
text: string;
children?: ReactNode;
}) {
return (
<div className="flex min-h-screen items-center justify-center bg-surface-secondary px-4">
<div className="w-full max-w-sm rounded-[28px] border border-edge-faint bg-surface-card p-7 text-center shadow-sm">
<div className="mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-2xl bg-surface-secondary text-content-muted">
{icon}
</div>
<h1 className="text-subtitle font-bold text-content">{title}</h1>
<p className="mt-1.5 text-body text-content-muted">{text}</p>
{children}
</div>
</div>
);
}
/** A shared journey behind a password (#2553): one field, and why it did not open. */
export function JourneyPublicPasswordCard({
onUnlock,
}: {
onUnlock: (password: string) => Promise<PublicUnlockOutcome>;
}) {
const { t } = useTranslation();
const [password, setPassword] = useState('');
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
const submit = async (e: FormEvent) => {
e.preventDefault();
if (!password || busy) return;
setBusy(true);
setError(null);
const outcome = await onUnlock(password);
setBusy(false);
if (outcome === 'ok' || outcome === 'expired') return;
setError(t(OUTCOME_KEYS[outcome]));
};
return (
<GateFrame icon={<Lock size={20} />} title={t('journey.public.lockedTitle')} text={t('journey.public.lockedText')}>
<form onSubmit={(e) => void submit(e)} className="mt-5 flex flex-col gap-2.5">
<input
type="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
autoFocus
autoComplete="current-password"
placeholder={t('common.password')}
aria-label={t('common.password')}
className="w-full rounded-xl border border-edge bg-surface px-3.5 py-2.5 text-body text-content outline-none placeholder:text-content-faint focus:border-content-faint"
/>
<button
type="submit"
disabled={!password || busy}
className="w-full rounded-xl bg-accent py-2.5 text-body font-semibold text-accent-text transition-colors hover:bg-accent-hover disabled:opacity-50"
>
{t('journey.public.unlock')}
</button>
{error && (
<p role="alert" className="text-caption text-danger">
{error}
</p>
)}
</form>
</GateFrame>
);
}
/** A shared journey whose owner let the link run out. */
export function JourneyPublicExpired() {
const { t } = useTranslation();
return (
<GateFrame
icon={<Clock size={20} />}
title={t('journey.public.expiredTitle')}
text={t('journey.public.expiredText')}
/>
);
}
@@ -11,9 +11,16 @@ import {
groupByDate, publicLinkAccessOf, unlockOutcomeOf,
type PublicEntry, type PublicGalleryPhoto, type PublicLinkAccess, type PublicUnlockOutcome,
} from './journeyPublicModel'
import { useJourneyPublicSocial } from './useJourneyPublicSocial'
import { useJourneyMapLayers } from '../../components/Journey/useJourneyMapLayers'
import { journeyOpenAtEntryId } from '../../components/Journey/journeyOpenAt'
import { localIsoDate } from '../../utils/localDate'
import { journeySocialRepo } from '../../repo/journeySocialRepo'
type PublicJourneyRead = { token: string; revision: number } & (
| { status: 'open'; data: Awaited<ReturnType<typeof journeyApi.getPublicJourney>> }
| { status: 'locked' | 'expired' | 'error' }
)
/**
* Public-journey (read-only share) data hook — owns the token fetch, the
@@ -26,14 +33,14 @@ import { localIsoDate } from '../../utils/localDate'
*/
export function useJourneyPublic() {
const { token } = useParams()
const [data, setData] = useState<any>(null)
const [loading, setLoading] = useState(true)
const [error, setError] = useState(false)
// #2553: a link with a password answers 401 until this browser unlocked it,
// one past its date 410; the page shows a password card or a "gone" note.
const [access, setAccess] = useState<PublicLinkAccess>('open')
// Bumped by a successful unlock, so the read runs again with the new cookie.
const [response, setResponse] = useState<PublicJourneyRead | null>(null)
const [reloadKey, setReloadKey] = useState(0)
// React can keep the page mounted when the visitor follows a different link.
const current = response && response.token === token && response.revision === reloadKey ? response : null
const data = current?.status === 'open' ? current.data : null
const loading = !!token && !current
const error = !token || current?.status === 'error'
const access: PublicLinkAccess = current?.status === 'locked' || current?.status === 'expired' ? current.status : 'open'
const isMobile = useIsMobile()
const [view, setView] = useState<'timeline' | 'gallery' | 'map'>('timeline')
const [lightbox, setLightbox] = useState<{ photos: { id: string; src: string; thumbSrc?: string; caption?: string | null; mediaType?: string | null }[]; index: number } | null>(null)
@@ -58,17 +65,13 @@ export function useJourneyPublic() {
journeyApi.getPublicJourney(token)
.then(d => {
if (cancelled) return
setData(d)
setAccess('open')
setResponse({ token, revision: reloadKey, status: 'open', data: d })
void journeySocialRepo.recordPublicView(token)
})
.catch((err: unknown) => {
if (cancelled) return
const refused = publicLinkAccessOf(err)
if (refused) setAccess(refused)
else setError(true)
})
.finally(() => {
if (!cancelled) setLoading(false)
setResponse({ token, revision: reloadKey, status: refused ?? 'error' })
})
return () => {
cancelled = true
@@ -83,16 +86,18 @@ export function useJourneyPublic() {
const unlock = useCallback(async (password: string): Promise<PublicUnlockOutcome> => {
if (!token) return 'failed'
try {
await journeyApi.unlockPublicJourney(token, password)
await journeySocialRepo.unlockPublicJourney(token, password)
} catch (err) {
const outcome = unlockOutcomeOf(err)
if (outcome === 'expired') setAccess('expired')
if (outcome === 'expired') setResponse({ token, revision: reloadKey, status: 'expired' })
return outcome
}
setLoading(true)
setReloadKey(n => n + 1)
return 'ok'
}, [token])
}, [token, reloadKey])
// #1702, #1669: what a reader may do besides reading, as the owner allows it.
const social = useJourneyPublicSocial(token, data?.interaction)
const entries = (data?.entries || []) as PublicEntry[]
const gallery = (data?.gallery || []) as PublicGalleryPhoto[]
@@ -212,7 +217,7 @@ export function useJourneyPublic() {
}, [desktopTwoColumn, view])
return {
token, data, loading, error, access, unlock, isMobile, locale,
token, data, loading, error, access, unlock, social, isMobile, locale,
view, setView, lightbox, setLightbox, showLangPicker, setShowLangPicker,
mapRef, feedRef, activeEntryId, setActiveEntryId, viewingEntry, setViewingEntry, handleMarkerClick,
perms, journey, stats,
+6 -3
View File
@@ -20,7 +20,7 @@ export const PAGE_WIDTH = 'mx-auto w-full max-w-[1280px] px-4 sm:px-6'
// photo is; without a cover the same dark ground keeps the hero one piece.
const HERO_GROUND = 'linear-gradient(135deg, #0b1020 0%, #1e293b 55%, #334155 100%)' // theme-lint-disable: the hero's own ground under white type
const HERO_SCRIM = 'linear-gradient(180deg, rgba(0,0,0,0.08) 0%, rgba(0,0,0,0.28) 45%, rgba(0,0,0,0.74) 100%)' // theme-lint-disable: a scrim over a photo
const GLASS = 'inline-flex items-center gap-1.5 rounded-full border border-white/20 bg-white/15 px-3 py-1 font-semibold text-white backdrop-blur-md' // theme-lint-disable: glass over a photo
export const GLASS = 'inline-flex items-center gap-1.5 rounded-full border border-white/20 bg-white/15 px-3 py-1 font-semibold text-white backdrop-blur-md' // theme-lint-disable: glass over a photo
interface TopBarProps {
title: string
@@ -62,10 +62,12 @@ export interface HeroStat {
interface HeroProps {
trip: { title: string; description?: string | null; cover_image?: string | null; start_date?: string | null; end_date?: string | null }
stats: HeroStat[]
/** One quiet action beside the stats, such as following a shared journey (#1669). */
action?: ReactNode
}
/** The trip as a postcard: its cover, its dates, its name, what the owner wrote about it, and how big it is. */
export function SharedHero({ trip, stats }: HeroProps) {
export function SharedHero({ trip, stats, action }: HeroProps) {
const { locale } = useTranslation()
const cover = coverSrc(trip.cover_image)
const dates = formatDateRange(trip.start_date, trip.end_date, locale)
@@ -84,7 +86,7 @@ export function SharedHero({ trip, stats }: HeroProps) {
{trip.description && (
<p className="max-w-2xl whitespace-pre-line text-white/80 [overflow-wrap:anywhere]" style={fs(14.5, 'body')}>{trip.description}</p> // theme-lint-disable: white type over a photo
)}
{stats.length > 0 && (
{(stats.length > 0 || action) && (
<div className="mt-1 flex flex-wrap gap-2">
{stats.map(s => (
<span key={s.key} className={GLASS} style={fs(12, 'body')}>
@@ -92,6 +94,7 @@ export function SharedHero({ trip, stats }: HeroProps) {
<span className="font-medium text-white/80">{s.label}</span>
</span>
))}
{action}
</div>
)}
</div>