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
|
|
@ -19,6 +19,8 @@ import { useHashRoute } from "./router/hashRouter.js";
|
|||
import { normalizeCalendarData, normalizeTimerData } from "./features/toolboxes/storage/toolboxStorage.js";
|
||||
import { useAutoBackup } from "./features/toolboxes/storage/useAutoBackup.js";
|
||||
import { GlobalMemosTicker } from "./features/toolboxes/GlobalMemosTicker.jsx";
|
||||
import { CARDS_TOOLBOX_TARGET_ID, getDrawerToolboxId, getRouteToolboxTargetId } from "./features/toolboxes/toolboxTargets.js";
|
||||
import { useCardsToolboxChoice } from "./features/toolboxes/useCardsToolboxChoice.js";
|
||||
import { useMediaQuery } from "./hooks/useMediaQuery.js";
|
||||
import { useCardsConfig } from "./features/cards/useCardsConfig.js";
|
||||
import { useSharesConfig } from "./features/toolboxes/sharing/useSharesConfig.js";
|
||||
|
|
@ -70,6 +72,7 @@ function App() {
|
|||
const [drawerGameId, setDrawerGameId] = useState("");
|
||||
const [drawerVisible, setDrawerVisible] = useState(false);
|
||||
const [drawerContext, setDrawerContext] = useState({ route, compactGameLayout });
|
||||
const [cardsToolboxId, setCardsToolboxId] = useCardsToolboxChoice();
|
||||
const [image, setImage] = useState(null);
|
||||
const [pendingTutorialToolboxId, setPendingTutorialToolboxId] = useState("");
|
||||
const [notifications, setNotifications] = useState([]);
|
||||
|
|
@ -100,7 +103,7 @@ function App() {
|
|||
|
||||
if (drawerContext.route !== route || drawerContext.compactGameLayout !== compactGameLayout) {
|
||||
setDrawerContext({ route, compactGameLayout });
|
||||
const activeGameId = route.match(/^\/games\/([^/]+)/)?.[1] || "";
|
||||
const activeGameId = getRouteToolboxTargetId(route);
|
||||
if (activeGameId !== drawerGameId) {
|
||||
setDrawerGameId("");
|
||||
setDrawerVisible(false);
|
||||
|
|
@ -157,6 +160,11 @@ function App() {
|
|||
return capitalize ? value.charAt(0).toUpperCase() + value.slice(1) : value;
|
||||
};
|
||||
const getGame = (gameId) => games.find((item) => item.id === gameId);
|
||||
// La page courante propose le tiroir : un jeu connu (sa toolbox liée), ou Sokko TCG quand le jeu est ouvert (une toolbox au choix).
|
||||
const routeToolboxTargetId = getRouteToolboxTargetId(route);
|
||||
const shellToolboxTargetId = routeToolboxTargetId === CARDS_TOOLBOX_TARGET_ID ? (cardsConfig.enabled ? routeToolboxTargetId : "") : getGame(routeToolboxTargetId) ? routeToolboxTargetId : "";
|
||||
const drawerToolboxId = getDrawerToolboxId(drawerGameId, store.links, cardsToolboxId, store.toolboxes);
|
||||
const cardsDrawer = drawerGameId === CARDS_TOOLBOX_TARGET_ID;
|
||||
const getToolboxGameId = (toolbox) => Object.entries(store.links).find(([, toolboxId]) => toolboxId === toolbox?.id)?.[0] || "";
|
||||
const getToolboxGame = (toolbox) => getGame(getToolboxGameId(toolbox));
|
||||
|
||||
|
|
@ -177,9 +185,8 @@ function App() {
|
|||
useToolboxAlerts({
|
||||
toolboxes: store.toolboxes,
|
||||
moduleData: store.moduleData,
|
||||
links: store.links,
|
||||
route,
|
||||
drawerGameId: drawerVisible ? drawerGameId : "",
|
||||
drawerToolboxId: drawerVisible ? drawerToolboxId : "",
|
||||
normalizeTimerData,
|
||||
normalizeCalendarData,
|
||||
textContent: siteContent?.toolboxes?.modules,
|
||||
|
|
@ -223,7 +230,7 @@ function App() {
|
|||
<Shell
|
||||
route={route}
|
||||
content={siteContent}
|
||||
games={games}
|
||||
toolboxTargetId={shellToolboxTargetId}
|
||||
drawerGameId={drawerGameId}
|
||||
drawerVisible={drawerVisible}
|
||||
compactGameLayout={compactGameLayout}
|
||||
|
|
@ -270,7 +277,9 @@ function App() {
|
|||
<Suspense fallback={null}>
|
||||
<ToolboxDrawer
|
||||
gameId={drawerGameId}
|
||||
game={getGame(drawerGameId)}
|
||||
game={cardsDrawer ? undefined : getGame(drawerGameId)}
|
||||
toolboxId={drawerToolboxId}
|
||||
chooser={cardsDrawer ? { onChoose: setCardsToolboxId, getToolboxGame } : null}
|
||||
siteContent={siteContent}
|
||||
toolboxes={store.toolboxes}
|
||||
links={store.links}
|
||||
|
|
@ -290,6 +299,7 @@ function App() {
|
|||
route={route}
|
||||
toolboxes={store.toolboxes}
|
||||
links={store.links}
|
||||
cardsToolboxId={cardsToolboxId}
|
||||
moduleData={store.moduleData}
|
||||
textContent={siteContent.toolboxes.modules.memos}
|
||||
/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue