feat(pdf): redesign the trip PDF

The trip PDF gets a new layout in the app's current look, with nothing it
printed before left out and more of each place on the page.

- Cover: the trip photo full bleed, title and dates over it, the trip's
  figures on frosted tiles.
- Overview: the route map, every day at a glance (colour, date, plan, the
  night's stay, stops, cost) and all bookings and stays with their codes.
- Days: the header in the day's map colour, a photo strip of the day's
  stops, where the night is spent, then the plan as a timeline with the
  times on the left.
- Places: photo or category tile, category, duration, price, rating, tags,
  address, coordinates, description, notes, opening hours of that day,
  phone, website, e-mail and the members going. The rating, e-mail, hours
  and reservation note come from the trip's place, since the assignment
  only carries a projection of it.
- Bookings: route first, then airline, number, seat or platform as badges,
  each leg with its own code, status and the booking's code.
- A second row of switches in the preview: overview, photos, coordinates,
  and contact and hours, next to page per day, large text and transport
  notes. Each one is a class on the document and remembered.

The document is split into modules for its helpers, icons, stylesheet,
cover and overview, and the day, so the export itself only gathers the data.
This commit is contained in:
Maurice
2026-11-22 21:34:29 +01:00
parent 1b20214a7f
commit a5de1bc52d
41 changed files with 2117 additions and 768 deletions
+54 -2
View File
@@ -1,12 +1,21 @@
/**
* FE-PDFPREVIEW-001 to FE-PDFPREVIEW-007: the trip PDF's preview and the control
* FE-PDFPREVIEW-001 to FE-PDFPREVIEW-009: the trip PDF's preview and the control
* that saves it. An iPhone or iPad ignores print() in the Home Screen app, so
* there the preview hands the export to Safari instead of offering a button that
* does nothing.
*/
import { afterEach, describe, expect, it, vi } from 'vitest';
import { LARGE_TEXT_KEY, PAGE_BREAK_KEY, openPdfPreview, type PdfPreviewOptions } from './pdfPreview';
import {
COORDINATES_KEY,
DETAILS_KEY,
LARGE_TEXT_KEY,
OVERVIEW_KEY,
PAGE_BREAK_KEY,
PHOTOS_KEY,
openPdfPreview,
type PdfPreviewOptions,
} from './pdfPreview';
const tr = (key: string) => key;
@@ -20,6 +29,10 @@ function open(overrides: Partial<PdfPreviewOptions> = {}) {
showTransportNotes: true,
hasTransportNotes: false,
largeText: false,
photos: true,
overview: true,
coordinates: true,
details: true,
...overrides,
});
}
@@ -111,4 +124,43 @@ describe('openPdfPreview', () => {
}
expect(document.getElementById('pdf-large-text-toggle')?.getAttribute('aria-checked')).toBe('true');
});
it('FE-PDFPREVIEW-008: the switches sit in a row of their own under the title and the actions', () => {
open({ hasTransportNotes: true });
const row = document.getElementById('pdf-settings-row');
const ids = [...(row?.querySelectorAll('[role="switch"]') ?? [])].map((toggle) => toggle.id);
expect(ids).toEqual([
'pdf-daybreak-toggle',
'pdf-large-text-toggle',
'pdf-overview-toggle',
'pdf-photos-toggle',
'pdf-coordinates-toggle',
'pdf-details-toggle',
'pdf-transport-notes-toggle',
]);
// The header keeps only the title and its two actions.
expect(row?.previousElementSibling?.querySelector('[role="switch"]')).toBeNull();
expect(row?.previousElementSibling?.querySelector('#pdf-print-btn')).not.toBeNull();
});
it.each([
['pdf-overview-toggle', OVERVIEW_KEY, 'pdf-no-overview'],
['pdf-photos-toggle', PHOTOS_KEY, 'pdf-no-photos'],
['pdf-coordinates-toggle', COORDINATES_KEY, 'pdf-no-coords'],
['pdf-details-toggle', DETAILS_KEY, 'pdf-no-details'],
])('FE-PDFPREVIEW-009: %s hides its part of the open document at once and is remembered', (id, key, hidden) => {
open();
const toggle = document.getElementById(id);
const body = document.querySelector<HTMLIFrameElement>('#pdf-preview-overlay iframe')?.contentDocument?.body;
expect(toggle?.getAttribute('aria-checked')).toBe('true');
toggle?.click();
expect(toggle?.getAttribute('aria-checked')).toBe('false');
expect(localStorage.getItem(key)).toBe('0');
if (body) expect(body.classList.contains(hidden)).toBe(true);
toggle?.click();
expect(localStorage.getItem(key)).toBe('1');
if (body) expect(body.classList.contains(hidden)).toBe(false);
});
});