mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 23:27:31 +00:00
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:
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user