Desktop: wide tables keep their first column in view while scrolling; compact table density (Settings > Appearance, Ctrl+K)
This commit is contained in:
parent
364b8ec0d4
commit
c0a13b5f87
6 changed files with 23 additions and 2 deletions
|
|
@ -3,7 +3,9 @@
|
|||
export type Theme = 'system' | 'light' | 'dark';
|
||||
export type Motion = 'system' | 'reduce';
|
||||
export type Lang = 'system' | 'en' | 'tr';
|
||||
export interface Prefs { theme: Theme; motion: Motion; lang: Lang; onboarded: boolean }
|
||||
/** Tables: comfortable rows, or compact (smaller padding) for wide data on small windows. */
|
||||
export type Density = 'comfortable' | 'compact';
|
||||
export interface Prefs { theme: Theme; motion: Motion; lang: Lang; onboarded: boolean; density?: Density }
|
||||
|
||||
export const DEFAULT_PREFS: Prefs = { theme: 'system', motion: 'system', lang: 'system', onboarded: false };
|
||||
const KEY = 'storebound.prefs.v1';
|
||||
|
|
@ -16,6 +18,7 @@ export function parsePrefs(raw: string | null): Prefs {
|
|||
motion: v.motion === 'reduce' ? 'reduce' : 'system',
|
||||
lang: v.lang === 'en' || v.lang === 'tr' ? v.lang : 'system',
|
||||
onboarded: v.onboarded === true,
|
||||
...(v.density === 'compact' ? { density: 'compact' as const } : {}),
|
||||
};
|
||||
} catch { return { ...DEFAULT_PREFS }; }
|
||||
}
|
||||
|
|
@ -32,6 +35,7 @@ export function savePrefs(p: Prefs): void {
|
|||
export function applyPrefs(p: Prefs, root: { dataset: DOMStringMap; lang?: string } = document.documentElement, systemLang = 'en'): void {
|
||||
if (p.theme === 'system') delete root.dataset.theme; else root.dataset.theme = p.theme;
|
||||
if (p.motion === 'reduce') root.dataset.motion = 'reduce'; else delete root.dataset.motion;
|
||||
if (p.density === 'compact') root.dataset.density = 'compact'; else delete root.dataset.density;
|
||||
root.lang = resolveLang(p.lang, systemLang);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue