Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

Keep the pictures as a grid, wider tiles instead of a lead image

Maurice36cdb368755e
diff --git a/client/src/components/Planner/PlaceDetailsColumn.test.tsx b/client/src/components/Planner/PlaceDetailsColumn.test.tsx
index b0d576b7b..180732589 100644
--- a/client/src/components/Planner/PlaceDetailsColumn.test.tsx
+++ b/client/src/components/Planner/PlaceDetailsColumn.test.tsx
@@ -480,11 +480,11 @@ describe('PlaceDetailsColumn — chain description', () => {
})
/**
- * FE-PDC-032..037 — the lead image and its rail.
+ * FE-PDC-032..037 — the picture grid.
*
- * The grid was three 84px squares in a 288px column, which is too small to tell
- * a facade from a foyer — the one thing the picker exists for. What must NOT
- * change: picking a picture still takes one click.
+ * A lead image plus a thumbnail rail was tried and dropped: it took too much of
+ * a column that also has to show facts, hours and a description. What must hold
+ * either way is that picking a picture stays one click.
*/
describe('PlaceDetailsColumn — picture layout', () => {
const photo = (n: number, over: Record<string, unknown> = {}) => ({
@@ -508,19 +508,16 @@ describe('PlaceDetailsColumn — picture layout', () => {
// alt="" makes an image presentational, so it carries no `img` role — these
// read the DOM directly, the way the strip cases above already do.
const shownImages = () => Array.from(document.querySelectorAll('img'))
- const leadSrc = () => shownImages()[0]?.getAttribute('src')
- it('FE-PDC-032: shows the first picture large and the rest as a rail', async () => {
+ it('FE-PDC-032: shows one tile per picture and nothing else', async () => {
withPhotos(4)
renderColumn()
await screen.findByText('places.details.pickImage')
- // One lead plus one thumbnail per picture.
- expect(shownImages()).toHaveLength(5)
- expect(leadSrc()).toBe('/api/maps/place-photo/p0/bytes')
+ expect(shownImages()).toHaveLength(4)
})
- it('FE-PDC-033: leaves the rail off when there is only one picture', async () => {
+ it('FE-PDC-033: a single picture is a single tile', async () => {
withPhotos(1)
renderColumn()
@@ -528,50 +525,45 @@ describe('PlaceDetailsColumn — picture layout', () => {
expect(shownImages()).toHaveLength(1)
})
- it('FE-PDC-034: picking a picture is still one click', async () => {
+ it('FE-PDC-034: picking a picture is one click', async () => {
withPhotos(3)
const { onPickImage } = renderColumn()
await screen.findByText('places.details.pickImage')
- // Buttons: lead first, then one per thumbnail.
- const buttons = screen.getAllByRole('button', { name: /places.details.pickImage/ })
- fireEvent.click(buttons[2])
+ const tiles = screen.getAllByRole('button', { name: /places.details.pickImage/ })
+ fireEvent.click(tiles[1])
expect(onPickImage).toHaveBeenCalledWith('/api/maps/place-photo/p1/bytes')
expect(onPickImage).toHaveBeenCalledTimes(1)
})
- it('FE-PDC-035: hovering a thumbnail previews it without picking it', async () => {
- withPhotos(3)
- const { onPickImage } = renderColumn()
+ it('FE-PDC-035: clicking the picked tile again clears the choice', async () => {
+ withPhotos(2)
+ const { onPickImage } = renderColumn({ selectedImageUrl: '/api/maps/place-photo/p1/bytes' })
await screen.findByText('places.details.pickImage')
- const buttons = screen.getAllByRole('button', { name: /places.details.pickImage/ })
- fireEvent.mouseEnter(buttons[3])
+ const tiles = screen.getAllByRole('button', { name: /places.details.pickImage/ })
+ fireEvent.click(tiles[1])
- expect(leadSrc()).toBe('/api/maps/place-photo/p2/bytes')
- expect(onPickImage).not.toHaveBeenCalled()
+ expect(onPickImage).toHaveBeenCalledWith(null)
})
- it('FE-PDC-036: clicking the lead picks the picture it is showing, and unpicks it again', async () => {
- withPhotos(2)
- const { onPickImage } = renderColumn({ selectedImageUrl: '/api/maps/place-photo/p1/bytes' })
+ it('FE-PDC-036: hovering a tile moves the credit to it without picking it', async () => {
+ withPhotos(3)
+ const { onPickImage } = renderColumn()
- await screen.findByText('places.details.pickImage')
- const lead = screen.getAllByRole('button', { name: /places.details.pickImage/ })[0]
- // The picked one is what the lead slot shows.
- expect(leadSrc()).toBe('/api/maps/place-photo/p1/bytes')
+ await screen.findByText('Author 0')
+ const tiles = screen.getAllByRole('button', { name: /places.details.pickImage/ })
+ fireEvent.mouseEnter(tiles[2])
- fireEvent.click(lead)
- expect(onPickImage).toHaveBeenCalledWith(null)
+ expect(screen.getByText('Author 2')).toBeInTheDocument()
+ expect(onPickImage).not.toHaveBeenCalled()
})
- it('FE-PDC-037: credits the picture in the lead slot, licence included', async () => {
+ it('FE-PDC-037: credits the picture in play, licence included', async () => {
withPhotos(2)
renderColumn()
- // The credit rides on the picture rather than sitting in its own line, which
- // used to change text on every hover.
expect(await screen.findByText('Author 0')).toBeInTheDocument()
expect(screen.getByText('Author 0').closest('a')).toHaveAttribute(
'href',
diff --git a/client/src/components/Planner/PlaceDetailsColumn.tsx b/client/src/components/Planner/PlaceDetailsColumn.tsx
index 90345e4b1..89924e260 100644
--- a/client/src/components/Planner/PlaceDetailsColumn.tsx
+++ b/client/src/components/Planner/PlaceDetailsColumn.tsx
@@ -283,17 +283,17 @@ function creditOf(photo: PlacePhotoCandidate): string {
}
/**
- * The pictures: one large, the rest as a thumbnail rail.
+ * The picture grid.
*
- * This was a three-column square grid, which in a 288px column worked out to
- * 84px tiles — too small to tell a facade from a foyer, and the whole reason
- * for choosing one over another. A lead image at 4:3 shows what the picture
- * actually is; the rail below it says how many others there are.
+ * A grid rather than one large image: this sits beside a form in a dialog, and
+ * a picture that takes half the column pushes the facts and the description out
+ * of sight. Three columns at 320px gives ~96px tiles, which is enough to tell
+ * the pictures apart while leaving the rest of the column visible.
*
- * The click count is unchanged: a thumbnail picks that picture, exactly as the
- * tiles did. Hovering one only previews it in the lead slot, and clicking the
- * lead toggles the picture currently shown — so nothing that worked before
- * takes an extra step now.
+ * Only the picture in play is credited in full — crediting all of them at once
+ * cost two lines each and drowned the column, and the licence obligation
+ * attaches to the one that gets used. Every tile still carries the full credit
+ * as its tooltip and links to its source page.
*/
function PhotoStrip({
photos,
@@ -309,53 +309,26 @@ function PhotoStrip({
const [hovered, setHovered] = useState<string | null>(null)
if (photos.length === 0) return null
- const lead = photos.find((p) => p.url === (hovered ?? selectedImageUrl)) ?? photos[0]
- const leadPicked = !!selectedImageUrl && lead.url === selectedImageUrl
+ const shown = photos.find((p) => p.url === (hovered ?? selectedImageUrl)) ?? photos[0]
return (
<div className="space-y-2">
<Overline>{t('places.details.pickImage')}</Overline>
- <button
- type="button"
- onClick={() => onPickImage(leadPicked ? null : lead.url)}
- aria-pressed={leadPicked}
- aria-label={`${t('places.details.pickImage')} — ${creditOf(lead)}`}
- className={`group relative block w-full aspect-[4/3] overflow-hidden rounded-lg bg-surface transition-shadow ${
- leadPicked
- ? 'ring-2 ring-accent ring-offset-2 ring-offset-surface-secondary'
- : 'ring-1 ring-edge hover:ring-content-muted'
- }`}
- >
- <img src={lead.url} alt="" className="w-full h-full object-cover" />
- {/* The credit rides on the picture it belongs to. As its own line below
- the grid it changed text on every hover, which read as flicker and
- left the licence attached to nothing in particular. */}
- <span className="absolute inset-x-0 bottom-0 bg-[var(--tooltip-bg)] px-2 py-1 backdrop-blur-[2px]">
- <span className="block truncate text-caption leading-tight text-content-secondary">
- <PhotoCredit photo={lead} />
- </span>
- </span>
- {leadPicked && (
- <span className="absolute top-1.5 right-1.5 rounded-full bg-accent p-1 shadow-card">
- <Check className="w-3 h-3 text-accent-text" />
- </span>
- )}
- </button>
- {photos.length > 1 && (
- <div className="grid grid-cols-4 gap-1.5">
- {photos.map((photo) => (
- <PhotoTile
- key={photo.key}
- photo={photo}
- selected={selectedImageUrl === photo.url}
- showing={lead.url === photo.url}
- onPick={onPickImage}
- onHover={setHovered}
- t={t}
- />
- ))}
- </div>
- )}
+ <div className="grid grid-cols-3 gap-1.5">
+ {photos.map((photo) => (
+ <PhotoTile
+ key={photo.key}
+ photo={photo}
+ selected={selectedImageUrl === photo.url}
+ onPick={onPickImage}
+ onHover={setHovered}
+ t={t}
+ />
+ ))}
+ </div>
+ <p className="text-caption leading-tight text-content-faint truncate">
+ <PhotoCredit photo={shown} />
+ </p>
</div>
)
}
@@ -363,15 +336,12 @@ function PhotoStrip({
function PhotoTile({
photo,
selected,
- showing,
onPick,
onHover,
t,
}: {
photo: PlacePhotoCandidate
selected: boolean
- /** Currently in the lead slot, whether by hover or by being the picked one. */
- showing: boolean
onPick: (url: string | null) => void
onHover: (url: string | null) => void
t: TranslationFn
@@ -389,23 +359,19 @@ function PhotoTile({
aria-pressed={selected}
aria-label={`${t('places.details.pickImage')} — ${credit}`}
title={`${credit}${photo.license ? ` · ${photo.license}` : ''}`}
- className={`group relative block w-full aspect-square overflow-hidden rounded-md transition-shadow ${
- selected
- ? 'ring-2 ring-accent'
- : showing
- ? 'ring-1 ring-content-muted'
- : 'ring-1 ring-edge hover:ring-content-muted'
+ className={`group relative block w-full aspect-square overflow-hidden rounded-lg transition-shadow ${
+ selected ? 'ring-2 ring-accent ring-offset-2 ring-offset-surface-secondary' : 'ring-1 ring-edge hover:ring-content-muted'
}`}
>
<img
src={photo.url}
alt=""
loading="lazy"
- className={`w-full h-full object-cover transition-opacity ${showing || selected ? '' : 'opacity-70 group-hover:opacity-100'}`}
+ className="w-full h-full object-cover transition-transform duration-500 group-hover:scale-[1.06]"
/>
{selected && (
- <span className="absolute bottom-0.5 right-0.5 rounded-full bg-accent p-0.5 shadow-card">
- <Check className="w-2 h-2 text-accent-text" />
+ <span className="absolute top-1 right-1 rounded-full bg-accent p-0.5 shadow-card">
+ <Check className="w-2.5 h-2.5 text-accent-on" />
</span>
)}
</button>
@@ -419,7 +385,7 @@ function sourceLabelFor(source: PlacePhotoCandidate['source']): string {
}
/**
- * Author and licence for the picture in the lead slot.
+ * Author and licence for the picture currently in play.
*
* Not decoration: Commons images are largely CC BY / CC BY-SA, and reusing one
* without naming its author does not satisfy those terms. When a source hands