feat: redesign Toolbox navigation and personalization

This commit is contained in:
2026-07-23 00:33:03 +02:00
parent 587aadb79b
commit 67ba5e3eca
25 changed files with 1075 additions and 427 deletions

View File

@@ -2,6 +2,7 @@ import { useEffect, useState } from 'react';
import {
PREFERENCES_KEY,
defaultPreferences,
parsePreferences,
readPreferences,
writePreferences,
type Preferences,
@@ -43,5 +44,22 @@ export function usePreferences(): [
}
}, [preferences]);
useEffect(() => {
const handleStorage = (event: StorageEvent) => {
if (event.key !== PREFERENCES_KEY) return;
if (event.newValue === null) {
setPreferences({ ...defaultPreferences });
return;
}
try {
setPreferences(parsePreferences(JSON.parse(event.newValue)));
} catch {
setPreferences({ ...defaultPreferences });
}
};
globalThis.addEventListener('storage', handleStorage);
return () => globalThis.removeEventListener('storage', handleStorage);
}, []);
return [preferences, setPreferences, initial.storageAvailable];
}