mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 08:53:13 +00:00
15aefa449e
Everything here came out of putting the first commit in front of somebody and watching them use it. **The marker card is one card now, and it carries the entry's photos.** Leaflet showed a one-line label and the GL map a two-line card, so the same marker said different things depending on a renderer setting nobody connects to journeys. Both now build from one module: a strip of up to three thumbnails bleeding to the card's edges, the name, and the place and date as chips. On the GL map the thumbnails open the entry's photos; the rest of the card still never takes the pointer, so the map drags from anywhere on it. **A pin that would not sit still.** Dragging the map left the marker trailing behind and snapping back at the end. The app's press-feedback rule puts a 180ms transition on `[role="button"]`, MapLibre and Mapbox give their marker element exactly that role, and both rewrite its `transform` on every frame of a movement. Markers are excluded now — every map in TREK, not just this one. **The phone card, after four rounds of looking at it.** The day is the card's own edge rather than a bar across its foot, and the ring is inset because the carousel clips. A card without a photo is opaque: it was a wash of the day's colour over the map. The country is a real flag rather than two letters — Windows has no flag glyphs, so the emoji drew "DE" where a flag was meant, and the image falls back to the emoji when it cannot be fetched. Mood, weather and the date share the top edge; the flag sits opposite them. **The day bar answers to a finger.** Press the date and slide sideways to run through the days. The bar is still a row of buttons underneath, because that is the only version of it a keyboard can reach, and each one is 20px tall now rather than 3. Also here: - Videos upload to an entry (issue #2341). The gallery has taken them since #823 and an entry could not: everything went through the images-only filter and came back 400, reported as "1 of 1 photos failed". Same two-part upload, same absence of transcoding, and the editor now previews a clip in a `<video>` instead of a broken-image glyph. - The search box takes the gap the toolbar already had instead of clipping its own placeholder. - Entry cards line up with the day header again: the reorder arrows moved out of a column of their own into the feed's padding and appear on hover, and the day-coloured ring on the active card is a layer over it — an outline tight enough to sit on the card's edge was painting behind it. - Map attribution is collapsed to its ⓘ. It cannot go away — the OSM licence asks for it — but it does not have to lie under the carousel. - The suggestion dismiss and the day-header plus use TREK's own tooltip rather than the browser's.
87 lines
3.5 KiB
TypeScript
87 lines
3.5 KiB
TypeScript
// FE-JRN-CARDMODEL-001 to FE-JRN-CARDMODEL-010
|
|
|
|
import { describe, it, expect } from 'vitest'
|
|
import { cardDateLabel, cardPhotoId, cardPlace, cardTitle, countryBadge, dayColorOf, journeyDays } from './journeyCard'
|
|
import { DAY_COLORS } from './dayColors'
|
|
|
|
const t = (key: string) => key
|
|
|
|
describe('countryBadge', () => {
|
|
it('FE-JRN-CARDMODEL-001: stamps the ISO code, upper case', () => {
|
|
// Letters, not the flag emoji: Windows has no flag glyphs and drew the bare
|
|
// code anyway, which read as something broken.
|
|
expect(countryBadge('DE')).toBe('DE')
|
|
expect(countryBadge('jp')).toBe('JP')
|
|
})
|
|
|
|
it('FE-JRN-CARDMODEL-002: stamps nothing when there is no country to stamp', () => {
|
|
expect(countryBadge(null)).toBe('')
|
|
expect(countryBadge(undefined)).toBe('')
|
|
expect(countryBadge('')).toBe('')
|
|
expect(countryBadge('DEU')).toBe('')
|
|
expect(countryBadge('D1')).toBe('')
|
|
})
|
|
})
|
|
|
|
describe('cardTitle', () => {
|
|
it('FE-JRN-CARDMODEL-003: uses the title when there is one', () => {
|
|
expect(cardTitle({ title: 'Mercado', type: 'entry', location_name: 'Lisbon' }, t)).toBe('Mercado')
|
|
})
|
|
|
|
it('FE-JRN-CARDMODEL-004: says what a suggestion is rather than calling it untitled', () => {
|
|
expect(cardTitle({ title: null, type: 'skeleton', location_name: 'Museum' }, t)).toBe('journey.entry.suggestion')
|
|
})
|
|
|
|
it('FE-JRN-CARDMODEL-005: falls back to the place before it falls back to a placeholder', () => {
|
|
// Where you were is at least true; "Untitled" says nothing at all.
|
|
expect(cardTitle({ title: ' ', type: 'entry', location_name: 'Porto, Portugal' }, t)).toBe('Porto, Portugal')
|
|
expect(cardTitle({ title: null, type: 'entry', location_name: null }, t)).toBe('journey.editor.titlePlaceholder')
|
|
expect(cardTitle({ title: null, type: 'checkin', location_name: null }, t)).toBe('journey.detail.journeyTab')
|
|
})
|
|
})
|
|
|
|
describe('cardPlace', () => {
|
|
it('FE-JRN-CARDMODEL-006: is left out when the title is already the place', () => {
|
|
// cardTitle promoted the place to the title, so repeating it below would be
|
|
// the same words twice on a card that has room for two lines.
|
|
expect(cardPlace({ title: null, location_name: 'Porto, Portugal' })).toBe('')
|
|
expect(cardPlace({ title: 'Mercado', location_name: 'Porto, Portugal' })).toBe('Porto, Portugal')
|
|
expect(cardPlace({ title: 'Mercado', location_name: null })).toBe('')
|
|
})
|
|
})
|
|
|
|
describe('cardPhotoId', () => {
|
|
it('FE-JRN-CARDMODEL-007: reads either shape a shell hands over', () => {
|
|
expect(cardPhotoId({ photo_id: 4, id: 9 })).toBe(4)
|
|
expect(cardPhotoId({ id: 9 })).toBe(9)
|
|
expect(cardPhotoId(undefined)).toBeUndefined()
|
|
})
|
|
})
|
|
|
|
describe('cardDateLabel', () => {
|
|
it('FE-JRN-CARDMODEL-008: is short, and in the reader locale', () => {
|
|
expect(cardDateLabel('2026-03-15', 'en-GB')).toBe('15 Mar')
|
|
})
|
|
})
|
|
|
|
describe('journeyDays', () => {
|
|
it('FE-JRN-CARDMODEL-009: one entry per day, in order, coloured by position', () => {
|
|
const days = journeyDays([
|
|
{ entry_date: '2026-03-16' },
|
|
{ entry_date: '2026-03-15' },
|
|
{ entry_date: '2026-03-16' },
|
|
])
|
|
|
|
expect(days).toEqual([
|
|
{ date: '2026-03-15', color: DAY_COLORS[0] },
|
|
{ date: '2026-03-16', color: DAY_COLORS[1] },
|
|
])
|
|
})
|
|
|
|
it('FE-JRN-CARDMODEL-010: a date nobody knows still gets a colour', () => {
|
|
const days = journeyDays([{ entry_date: '2026-03-15' }])
|
|
expect(dayColorOf(days, '2026-03-15')).toBe(DAY_COLORS[0])
|
|
expect(dayColorOf(days, '2099-01-01')).toBe(DAY_COLORS[0])
|
|
})
|
|
})
|