import type { Lang } from './types'; export interface Settings { lang: Lang; textScale: 100 | 125 | 150; highContrast: boolean; reduceMotion: boolean; showDemoPlaces: boolean; } export const defaultSettings = (lang: Lang): Settings => ({ lang, textScale: 100, highContrast: false, reduceMotion: false, showDemoPlaces: true, }); export function isSettings(v: unknown): v is Settings { if (typeof v !== 'object' || v === null) return false; const s = v as Record; return ( (s.lang === 'pl' || s.lang === 'en') && (s.textScale === 100 || s.textScale === 125 || s.textScale === 150) && typeof s.highContrast === 'boolean' && typeof s.reduceMotion === 'boolean' && typeof s.showDemoPlaces === 'boolean' ); } /** Applies display settings to the document root. */ export function applySettings(s: Settings) { const root = document.documentElement; root.lang = s.lang; root.style.fontSize = `${s.textScale}%`; root.dataset.contrast = s.highContrast ? 'high' : 'default'; root.dataset.motion = s.reduceMotion ? 'reduce' : 'default'; }