Open any toolbox from a list in Sokko TCG's toolbox drawer
Every Sokko TCG section now offers the top bar's toolbox button. Instead of linking a toolbox, the drawer lists all toolboxes (linked to a game or not) as wide rows with a large cover, opens the one chosen, and remembers it on the device. Memos and alerts follow the toolbox shown. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e8fe27a90f
commit
8253f74c90
17 changed files with 359 additions and 45 deletions
27
website/src/features/toolboxes/useCardsToolboxChoice.js
Normal file
27
website/src/features/toolboxes/useCardsToolboxChoice.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// Rôle : retient, sur cet appareil, la toolbox choisie dans le tiroir de Sokko TCG, pour la rouvrir directement à la visite suivante.
|
||||
// Une préférence d'affichage, pas une donnée de toolbox : elle n'entre ni dans les liaisons ni dans les exports.
|
||||
import { useCallback, useState } from "react";
|
||||
|
||||
const CARDS_TOOLBOX_STORAGE_KEY = "sokkog:cards-toolbox";
|
||||
|
||||
function readChoice() {
|
||||
try {
|
||||
return globalThis.localStorage?.getItem(CARDS_TOOLBOX_STORAGE_KEY) || "";
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
export function useCardsToolboxChoice() {
|
||||
const [toolboxId, setToolboxId] = useState(readChoice);
|
||||
const choose = useCallback((nextId) => {
|
||||
setToolboxId(nextId || "");
|
||||
try {
|
||||
if (nextId) globalThis.localStorage?.setItem(CARDS_TOOLBOX_STORAGE_KEY, nextId);
|
||||
else globalThis.localStorage?.removeItem(CARDS_TOOLBOX_STORAGE_KEY);
|
||||
} catch {
|
||||
// Stockage refusé (navigation privée, quota) : le choix vaut pour la session.
|
||||
}
|
||||
}, []);
|
||||
return [toolboxId, choose];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue