Mediabibliotheek: tegels als standaardweergave, schakelaar tegels/lijst met onthouden keuze
Continuous Integration / config-sls (pull_request) Successful in 8s
Continuous Integration / config-asf (pull_request) Successful in 8s
Continuous Integration / changes (pull_request) Successful in 15s
Continuous Integration / backend-build (pull_request) Successful in 1m57s
Continuous Integration / compile-sites (pull_request) Successful in 1m57s
Continuous Integration / vulnerability-scan (pull_request) Successful in 1m44s
Continuous Integration / frontend-prepare (pull_request) Successful in 29s
Continuous Integration / frontend-build (pull_request) Successful in 1m18s
Continuous Integration / backend-test (pull_request) Successful in 3m41s
Continuous Integration / frontend-test (pull_request) Successful in 3m15s
Continuous Integration / frontend-lint (pull_request) Successful in 3m46s
Continuous Integration / publish-sls-test (pull_request) Skipped
Continuous Integration / publish-sls-production (pull_request) Skipped
Continuous Integration / deploy-sls-test (pull_request) Skipped
Continuous Integration / deploy-sls-production (pull_request) Skipped
Continuous Integration / publish-asf-test (pull_request) Skipped
Continuous Integration / deploy-asf-test (pull_request) Skipped
Continuous Integration / smoke-sls-test (pull_request) Skipped
Continuous Integration / smoke-asf-test (pull_request) Skipped

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 20:01:07 +01:00
co-authored by Claude Sonnet 5.5
parent e7443e6e82
commit e2d353b54d
7 changed files with 165 additions and 55 deletions
@@ -0,0 +1,28 @@
import { useCallback, useState } from 'react';
export type PhotoLayout = 'tiles' | 'list';
const KEY = 'slp.media.layout';
/** The layout this user chose last (tiles by default). Browser storage may be blocked, so every access is guarded. */
export function readLayout(): PhotoLayout {
try {
return window.localStorage.getItem(KEY) === 'list' ? 'list' : 'tiles';
} catch {
return 'tiles';
}
}
/** The layout of the photos and a setter that remembers the choice per user (per browser). */
export function useLayoutPreference(): [PhotoLayout, (layout: PhotoLayout) => void] {
const [layout, setLayoutState] = useState<PhotoLayout>(readLayout);
const setLayout = useCallback((next: PhotoLayout) => {
setLayoutState(next);
try {
window.localStorage.setItem(KEY, next);
} catch {
// Blocked or full: the choice then only lasts for this visit.
}
}, []);
return [layout, setLayout];
}