feat(pdf): large text switch in the trip PDF preview (#2817)

A third switch next to the page break and transport notes switches scales the
day content's type by 1.35 and darkens its greys, for readers who print the
plan. Off by default and remembered per browser like the other two; the day
content's sizes and greys now come from three CSS variables on <body>.
This commit is contained in:
Maurice
2026-11-13 09:17:00 +01:00
parent 12ae32b69e
commit 12406bbbf4
37 changed files with 204 additions and 43 deletions
+10 -1
View File
@@ -1,4 +1,4 @@
// FE-UTIL-PDFSWITCH-001 to FE-UTIL-PDFSWITCH-002
// FE-UTIL-PDFSWITCH-001 to FE-UTIL-PDFSWITCH-003
import { afterEach, describe, expect, it, vi } from 'vitest';
import { pdfSwitchOn, rememberPdfSwitch } from './pdfSwitch';
@@ -28,6 +28,15 @@ describe('pdfSwitch', () => {
throw new Error('blocked');
});
expect(pdfSwitchOn(KEY)).toBe(true);
expect(pdfSwitchOn(KEY, false)).toBe(false);
expect(() => rememberPdfSwitch(KEY, false)).not.toThrow();
});
it('FE-UTIL-PDFSWITCH-003: a switch that defaults to off stays off until it is turned on', () => {
expect(pdfSwitchOn(KEY, false)).toBe(false);
rememberPdfSwitch(KEY, true);
expect(pdfSwitchOn(KEY, false)).toBe(true);
rememberPdfSwitch(KEY, false);
expect(pdfSwitchOn(KEY, false)).toBe(false);
});
});
+7 -6
View File
@@ -1,14 +1,15 @@
/*
* The two switches of the trip PDF preview (a new page for every day, and the notes
* of the transports), remembered in this browser.
* The switches of the trip PDF preview (a new page for every day, the notes of
* the transports, large text), remembered in this browser.
*/
/** A preview switch that is on unless it was turned off; both default to on. */
export function pdfSwitchOn(key: string): boolean {
/** A preview switch as it was last left; `defaultOn` until it is first touched, or when storage is blocked. */
export function pdfSwitchOn(key: string, defaultOn = true): boolean {
try {
return localStorage.getItem(key) !== '0';
const stored = localStorage.getItem(key);
return stored === null ? defaultOn : stored !== '0';
} catch {
return true;
return defaultOn;
}
}