Open any toolbox from a list in Sokko TCG's toolbox drawer
All checks were successful
Validate and deploy Sokko G / validate (push) Successful in 23m40s
Validate and deploy Sokko G / deploy (push) Successful in 16s

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:
Shinuwa 2026-11-30 14:31:53 +01:00
parent e8fe27a90f
commit 8253f74c90
17 changed files with 359 additions and 45 deletions

View file

@ -501,3 +501,4 @@
{"id":"int-c432affacccf11095a7349e6a9cf1107","kind":"field_change","created_at":"2026-11-30T10:29:14.693613904Z","actor":"Shinuwa","issue_id":"sokko-g-akg7","extra":{"field":"status","new_value":"closed","old_value":"open","reason":"Pastille ajoutée (CardsPage navigationCounts.packs), test e2e mis à jour"}}
{"id":"int-622c82c7a1fac1f9758f971874d8a80f","kind":"field_change","created_at":"2026-11-30T11:15:28.399226475Z","actor":"Shinuwa","issue_id":"sokko-g-wqfj","extra":{"field":"status","new_value":"closed","old_value":"open","reason":"bonusOffers côté serveur + BonusOffers dans le planificateur. npm run check 463/463, e2e cards 15/15."}}
{"id":"int-e75296b6fbef720fbc6ae7cf1f92fb25","kind":"field_change","created_at":"2026-11-30T12:14:21.343085085Z","actor":"Shinuwa","issue_id":"sokko-g-8qjt","extra":{"field":"status","new_value":"closed","old_value":"open","reason":"npm run check 463/463, e2e cards 15/15."}}
{"id":"int-5f9231ef4e37eb6f4a922438fd43ef78","kind":"field_change","created_at":"2026-11-30T13:00:01.89545152Z","actor":"Shinuwa","issue_id":"sokko-g-p2gx","extra":{"field":"status","new_value":"closed","old_value":"open","reason":"Tiroir de toolbox ouvert sur toutes les routes /cards via la clé sokko-tcg ; tests unitaires et e2e ajoutés."}}

View file

@ -822,6 +822,10 @@ Les associations entre pages jeux et toolboxes sont stockées dans `kv/links`.
}
```
Sokko TCG n'a pas de liaison : son tiroir liste toutes les toolboxes, liées à un jeu ou non. `localStorage["sokkog:cards-toolbox"]`
retient l'identifiant de la dernière toolbox choisie, pour la rouvrir directement ; une préférence de l'appareil, jamais exportée
ni sauvegardée. Une toolbox supprimée depuis ramène simplement à la liste.
## Outil Bloc Note
Type : `notepad`

View file

@ -4,6 +4,7 @@ import { tmpdir } from "node:os";
import { join } from "node:path";
import { DatabaseSync } from "node:sqlite";
import { expect, test } from "@playwright/test";
import { readStoredSnapshot } from "./helpers/storage.js";
// Sélecteurs à choix unique du design system (`SelectDropdown`).
const selectTrigger = (scope, label) => scope.getByRole("button", { name: new RegExp(`^${label} : `) });
@ -2705,3 +2706,58 @@ test("an administrator opens the broken mirror and a player rebuilds the easy an
await page.getByRole("dialog").getByRole("button", { name: "Fermer", exact: true }).click();
await expect(status).toContainText("Fermé aux joueurs");
});
test("the Sokko TCG drawer opens any toolbox from a list and remembers the choice", async ({ page }) => {
test.setTimeout(60_000);
await page.setViewportSize({ width: 1600, height: 900 });
await page.goto("/#/cards/guild");
await page.getByRole("button", { name: "Version développement", exact: true }).click();
await expect(page.locator(".nebula-quests")).toBeVisible();
const drawer = page.locator("#toolbox-drawer");
const openedTitle = (name) => drawer.getByRole("heading", { level: 1, name, exact: true });
const createInDrawer = async (name) => {
await drawer.getByRole("button", { name: "Nouvelle toolbox", exact: true }).click();
await page.getByRole("textbox", { name: "Nom", exact: true }).fill(name);
await page.getByRole("button", { name: "Créer", exact: true }).click();
await expect(openedTitle(name)).toBeVisible();
};
// Sans toolbox, le tiroir propose d'en créer une : elle s'y ouvre sans quitter le jeu.
await page.getByRole("button", { name: "Afficher la toolbox", exact: true }).click();
await expect(drawer).toContainText("Aucune toolbox pour l’instant.");
await createInDrawer("Notes TCG");
await expect(page).toHaveURL(/#\/cards\/guild$/);
// Passer de la Guilde aux Expéditions garde la toolbox ouverte.
await page.goto("/#/cards/expeditions");
await expect(page.getByRole("button", { name: "Masquer la toolbox", exact: true })).toHaveAttribute("aria-pressed", "true");
await expect(openedTitle("Notes TCG")).toBeVisible();
// « Changer de toolbox » ramène à la liste, d'où l'on en crée ou en ouvre une autre.
await drawer.getByRole("button", { name: "Changer de toolbox", exact: true }).click();
await expect(drawer.getByRole("heading", { name: "Quelle toolbox ouvrir ?" })).toBeVisible();
await expect(drawer.locator(".drawer-toolbox-chooser-row")).toHaveText(["Notes TCGToolbox libre"]);
await createInDrawer("Build");
// Le choix est retenu : après un rechargement, le tiroir rouvre directement « Build » (une fois la toolbox enregistrée).
await expect.poll(async () => (await readStoredSnapshot(page)).toolboxes.map((toolbox) => toolbox.name)).toContain("Build");
await page.reload();
await page.getByRole("button", { name: "Afficher la toolbox", exact: true }).click();
await expect(openedTitle("Build")).toBeVisible();
// Une toolbox liée à un jeu reste disponible dans Sokko TCG, sans perdre sa liaison. La liste suit l'ordre de la page Toolboxes.
await page.goto("/#/games/mhwilds");
await page.getByRole("button", { name: "Afficher la toolbox", exact: true }).click();
await drawer.getByLabel("Toolbox disponible").selectOption({ label: "Notes TCG" });
await drawer.getByRole("button", { name: "Associer", exact: true }).click();
await expect(openedTitle("Notes TCG")).toBeVisible();
await page.goto("/#/cards/collection");
await page.getByRole("button", { name: "Afficher la toolbox", exact: true }).click();
await drawer.getByRole("button", { name: "Changer de toolbox", exact: true }).click();
await expect(drawer.locator(".drawer-toolbox-chooser-row")).toHaveText(["BuildToolbox libre", "Notes TCGMonster Hunter Wilds"]);
await drawer.getByRole("button", { name: /^Notes TCG/ }).click();
await expect(openedTitle("Notes TCG")).toBeVisible();
await page.goto("/#/games/mhwilds");
await page.getByRole("button", { name: "Afficher la toolbox", exact: true }).click();
await expect(openedTitle("Notes TCG")).toBeVisible();
});

View file

@ -101,6 +101,7 @@ export function validateSiteContent(site) {
"topbar.cards",
"topbar.gameViewLabel",
"topbar.guideView",
"topbar.cardsView",
"topbar.toolboxView",
"gamesPage.eyebrow",
"gamesPage.title",
@ -942,6 +943,13 @@ export function validateSiteContent(site) {
"toolboxes.drawer.selectPlaceholder",
"toolboxes.drawer.noAvailable",
"toolboxes.drawer.linkLabel",
"toolboxes.drawer.chooser.eyebrow",
"toolboxes.drawer.chooser.title",
"toolboxes.drawer.chooser.actionsLabel",
"toolboxes.drawer.chooser.changeLabel",
"toolboxes.drawer.chooser.freeLabel",
"toolboxes.drawer.chooser.emptyText",
"toolboxes.drawer.chooser.createLabel",
"toolboxes.title",
"toolboxes.newButton",
"toolboxes.createShortButton",

View file

@ -4,11 +4,14 @@ import assert from "node:assert/strict";
import { getVisibleToolboxIds } from "../website/src/hooks/useToolboxAlerts.js";
test("a mounted compact drawer is visible only while its toolbox view is selected", () => {
const links = { mhwilds: "linked" };
assert.deepEqual([...getVisibleToolboxIds("/games/mhwilds/monsters", "", links)], []);
assert.deepEqual([...getVisibleToolboxIds("/games/mhwilds/monsters", "mhwilds", links)], ["linked"]);
assert.deepEqual([...getVisibleToolboxIds("/games/mhwilds/monsters", "")], []);
assert.deepEqual([...getVisibleToolboxIds("/games/mhwilds/monsters", "linked")], ["linked"]);
});
test("the toolbox chosen in the Sokko TCG drawer is visible like a linked one", () => {
assert.deepEqual([...getVisibleToolboxIds("/cards/guild", "chosen")], ["chosen"]);
});
test("a full toolbox page remains visible independently of the game drawer", () => {
assert.deepEqual([...getVisibleToolboxIds("/toolbox/personal", "", {})], ["personal"]);
assert.deepEqual([...getVisibleToolboxIds("/toolbox/personal", "")], ["personal"]);
});

View file

@ -0,0 +1,38 @@
// Rôle : vérifie quelles pages ouvrent le tiroir de toolbox et quelle toolbox il affiche : la toolbox liée d'un jeu, ou celle
// choisie dans Sokko TCG, sans liaison.
import { test } from "node:test";
import assert from "node:assert/strict";
import { CARDS_TOOLBOX_TARGET_ID, getDrawerToolboxId, getRouteToolboxTargetId } from "../website/src/features/toolboxes/toolboxTargets.js";
test("a game page targets its game", () => {
assert.equal(getRouteToolboxTargetId("/games/mhwilds"), "mhwilds");
assert.equal(getRouteToolboxTargetId("/games/mhwilds/monsters"), "mhwilds");
});
test("every Sokko TCG section shares the same target", () => {
for (const route of ["/cards", "/cards/guild", "/cards/expeditions", "/cards/expeditions/abc", "/cards/admin/catalog"]) {
assert.equal(getRouteToolboxTargetId(route), CARDS_TOOLBOX_TARGET_ID, route);
}
});
test("other pages have no target", () => {
for (const route of ["/", "/games", "/toolboxes", "/toolbox/abc", "/library", "/cardsx", "/games/sokko-tcg"]) {
assert.equal(getRouteToolboxTargetId(route), "", route);
}
});
test("a game drawer shows the toolbox linked to the game", () => {
const links = { mhwilds: "tbx1" };
assert.equal(getDrawerToolboxId("mhwilds", links, "tbx2", [{ id: "tbx1" }, { id: "tbx2" }]), "tbx1");
assert.equal(getDrawerToolboxId("diablo4", links, "tbx2", [{ id: "tbx1" }, { id: "tbx2" }]), "");
assert.equal(getDrawerToolboxId("", links, "tbx2", [{ id: "tbx1" }, { id: "tbx2" }]), "");
});
test("the Sokko TCG drawer shows the chosen toolbox, linked to a game or not, until it is deleted", () => {
const links = { mhwilds: "tbx1" };
const toolboxes = [{ id: "tbx1" }, { id: "tbx2" }];
assert.equal(getDrawerToolboxId(CARDS_TOOLBOX_TARGET_ID, links, "tbx1", toolboxes), "tbx1");
assert.equal(getDrawerToolboxId(CARDS_TOOLBOX_TARGET_ID, links, "tbx2", toolboxes), "tbx2");
assert.equal(getDrawerToolboxId(CARDS_TOOLBOX_TARGET_ID, links, "", toolboxes), "");
assert.equal(getDrawerToolboxId(CARDS_TOOLBOX_TARGET_ID, links, "deleted", toolboxes), "");
});

View file

@ -25,6 +25,7 @@
"cards": "Sokko TCG",
"gameViewLabel": "Vue de la page jeu",
"guideView": "Guide",
"cardsView": "Jeu",
"toolboxView": "Toolbox"
},
"gamesPage": {
@ -2922,7 +2923,16 @@
"selectLabel": "Toolbox disponible",
"selectPlaceholder": "Choisir une toolbox",
"noAvailable": "Aucune toolbox disponible",
"linkLabel": "Associer"
"linkLabel": "Associer",
"chooser": {
"eyebrow": "Toolbox",
"title": "Quelle toolbox ouvrir ?",
"actionsLabel": "Actions de la toolbox ouverte",
"changeLabel": "Changer de toolbox",
"freeLabel": "Toolbox libre",
"emptyText": "Aucune toolbox pour l’instant.",
"createLabel": "Nouvelle toolbox"
}
},
"storageStatus": {
"loadingTitle": "Chargement des données locales",

View file

@ -65,7 +65,9 @@ export function AppOverlays({
if (!name) return;
const toolbox = actions.createToolbox(name, gameId, { tutorial: createModal.tutorial === true });
if (toolbox && createModal.tutorial === true) setPendingTutorialToolboxId?.(toolbox.id);
if (toolbox && gameId) setDrawerGameId(gameId);
// Créée depuis le tiroir de Sokko TCG : elle s'y ouvre, sans liaison ni changement de page.
if (toolbox && createModal.onCreated) createModal.onCreated(toolbox);
else if (toolbox && gameId) setDrawerGameId(gameId);
else if (toolbox) {
navigate(`/toolbox/${toolbox.id}`);
scrollToTopAfterNavigation();

View file

@ -5,11 +5,10 @@ import { Icon } from "./Icon.jsx";
import { ImportButton } from "./ImportButton.jsx";
import { Tooltip } from "./Tooltip.jsx";
export function Shell({ route, content, games, drawerGameId = "", drawerVisible = false, compactGameLayout = false, reducedSidebar = false, cardsEnabled = false, actions, onOpenAutoBackup, children }) {
const gameId = route.split("/")[1] === "games" ? route.split("/")[2] || "" : "";
const game = games.find((item) => item.id === gameId);
// `toolboxTargetId` : le jeu (sa toolbox liée) ou Sokko TCG (une toolbox au choix) dont la page ouvre le tiroir, sinon vide.
export function Shell({ route, content, toolboxTargetId = "", drawerGameId = "", drawerVisible = false, compactGameLayout = false, reducedSidebar = false, cardsEnabled = false, actions, onOpenAutoBackup, children }) {
const topbarLabel = route === "/design-system" && import.meta.env.DEV ? "Design system" : route.startsWith("/toolbox") || route.startsWith("/receive/") ? content.topbar.toolbox : route.startsWith("/games") ? content.topbar.games : route === "/library" ? content.topbar.library : route.startsWith("/cards") ? content.topbar.cards : content.topbar.dashboard;
const toolboxOpen = Boolean(game && drawerGameId === game.id && drawerVisible);
const toolboxOpen = Boolean(toolboxTargetId && drawerGameId === toolboxTargetId && drawerVisible);
const toolboxLabel = toolboxOpen ? "Masquer la toolbox" : "Afficher la toolbox";
const compactSidebar = Boolean(reducedSidebar || (!compactGameLayout && toolboxOpen));
const compactToolboxVisible = Boolean(compactGameLayout && toolboxOpen);
@ -80,17 +79,17 @@ export function Shell({ route, content, games, drawerGameId = "", drawerVisible
<div className="content-shell">
<header className="topbar">
<div><strong>{topbarLabel}</strong></div>
{game && (
{toolboxTargetId && (
<div className="topbar-actions">
{compactGameLayout ? <div className="compact-game-view-switch nds-radio-button-group" role="tablist" aria-label={content.topbar.gameViewLabel}>
<button ref={guideTabRef} type="button" role="tab" aria-selected={!compactToolboxVisible} className={!compactToolboxVisible ? "active" : ""} onClick={() => actions.setDrawerGameId("")}>{content.topbar.guideView}</button>
<button ref={toolboxTabRef} type="button" role="tab" aria-selected={compactToolboxVisible} className={compactToolboxVisible ? "active" : ""} onClick={() => actions.setDrawerGameId(game.id)}>{content.topbar.toolboxView}</button>
<button ref={guideTabRef} type="button" role="tab" aria-selected={!compactToolboxVisible} className={!compactToolboxVisible ? "active" : ""} onClick={() => actions.setDrawerGameId("")}>{route.startsWith("/cards") ? content.topbar.cardsView : content.topbar.guideView}</button>
<button ref={toolboxTabRef} type="button" role="tab" aria-selected={compactToolboxVisible} className={compactToolboxVisible ? "active" : ""} onClick={() => actions.setDrawerGameId(toolboxTargetId)}>{content.topbar.toolboxView}</button>
</div> : <button
className={`drawer-button toolbox-button nds-button ${toolboxOpen ? "active" : ""}`}
ref={wideToolboxButtonRef}
data-size="sm"
data-variant="primary"
onClick={() => actions.setDrawerGameId(toolboxOpen ? "" : game.id)}
onClick={() => actions.setDrawerGameId(toolboxOpen ? "" : toolboxTargetId)}
aria-label={toolboxLabel}
aria-pressed={toolboxOpen}
title={toolboxLabel}

View file

@ -1,17 +1,17 @@
// Rôle : affiche en bas de page les mémos et alertes de tâches de la toolbox courante ou liée au jeu.
// Rôle : affiche en bas de page les mémos et alertes de tâches de la toolbox courante, liée au jeu, ou choisie dans Sokko TCG.
import { useEffect, useMemo, useState } from "react";
import { moduleStorageKey, normalizeMemosData } from "./storage/toolboxStorage.js";
import { MemosTicker } from "./modules/MemosTicker.jsx";
import { getPlannerTaskTickerItems, resolveMemosPlannerLink } from "./modules/memosPlannerUtils.js";
import { getDrawerToolboxId, getRouteToolboxTargetId } from "./toolboxTargets.js";
function getRouteToolboxId(route, links) {
function getRouteToolboxId(route, links, cardsToolboxId, toolboxes) {
const toolboxMatch = route.match(/^\/toolbox\/([^/]+)/);
if (toolboxMatch) return decodeURIComponent(toolboxMatch[1]);
const gameMatch = route.match(/^\/games\/([^/]+)/);
return gameMatch ? links[gameMatch[1]] || "" : "";
return getDrawerToolboxId(getRouteToolboxTargetId(route), links, cardsToolboxId, toolboxes);
}
export function GlobalMemosTicker({ route, toolboxes, links, moduleData, textContent }) {
export function GlobalMemosTicker({ route, toolboxes, links, cardsToolboxId = "", moduleData, textContent }) {
const [nowMs, setNowMs] = useState(() => Date.now());
useEffect(() => {
@ -20,7 +20,7 @@ export function GlobalMemosTicker({ route, toolboxes, links, moduleData, textCon
}, []);
const items = useMemo(() => {
const toolboxId = getRouteToolboxId(route, links);
const toolboxId = getRouteToolboxId(route, links, cardsToolboxId, toolboxes);
const toolbox = toolboxes.find((item) => item.id === toolboxId);
if (!toolbox) return [];
return toolbox.modules
@ -41,7 +41,7 @@ export function GlobalMemosTicker({ route, toolboxes, links, moduleData, textCon
...taskItems.map((item) => ({ ...item, id: `${module.id}:${item.id}` }))
];
});
}, [route, toolboxes, links, moduleData, nowMs, textContent?.taskAlertTemplate]);
}, [route, toolboxes, links, cardsToolboxId, moduleData, nowMs, textContent?.taskAlertTemplate]);
if (!items.length) return null;
return (

View file

@ -22,11 +22,23 @@ export function formatDate(value) {
return new Intl.DateTimeFormat("fr-FR", { dateStyle: "medium", timeStyle: "short" }).format(new Date(value));
}
export function ToolboxCard({ toolbox, game, actions, reorder }) {
// Couverture d'une toolbox : celle du jeu lié, sinon l'image choisie, sinon son icône. `rect` distingue une image (bandeau)
// d'une icône (à centrer sur le dégradé).
export function getToolboxCover(toolbox, game) {
const gameCoverImage = getGameCardCover(game);
const customCoverImage = !gameCoverImage && toolbox.customCover ? toolbox.customCover : "";
const coverImage = gameCoverImage || customCoverImage || toolbox.icon || DEFAULT_TOOLBOX_ICON;
const hasRectCover = Boolean(gameCoverImage || customCoverImage);
return {
src: gameCoverImage || customCoverImage || toolbox.icon || DEFAULT_TOOLBOX_ICON,
rect: Boolean(gameCoverImage || customCoverImage),
custom: Boolean(customCoverImage)
};
}
export function ToolboxCard({ toolbox, game, actions, reorder }) {
const cover = getToolboxCover(toolbox, game);
const customCoverImage = cover.custom ? cover.src : "";
const coverImage = cover.src;
const hasRectCover = cover.rect;
const className = [
"card",
"nds-card",

View file

@ -9,7 +9,7 @@ import { StorageQuota } from "../../components/StorageQuota.jsx";
import { useGroupedReorder } from "../../hooks/useGroupedReorder.js";
import { useInlineEdit } from "../../hooks/useInlineEdit.js";
import { compressImage } from "../../utils/imageCompression.js";
import { getGameCardCover, ToolboxCard, ToolboxGameIcon, ToolboxIconPicker } from "./ToolboxCard.jsx";
import { getGameCardCover, getToolboxCover, ToolboxCard, ToolboxGameIcon, ToolboxIconPicker } from "./ToolboxCard.jsx";
import { AddToolControls, ToolboxModules } from "./modules/index.jsx";
import { getMemosDataAfterPlannerRemoval } from "./modules/memosPlannerUtils.js";
import { ToolboxSpaces } from "./ToolboxSpaces.jsx";
@ -333,7 +333,7 @@ function ToolboxView({ siteContent, toolbox, toolboxGame, embedded, actions, sto
<EditableTitle className="toolbox-title" value={toolbox.name} fallback="Nouvelle toolbox" tutorialTarget="title" onSave={(name) => name !== toolbox.name && updateToolbox({ ...toolbox, name })} />
)}
</div>
{toolboxGame && (
{(embedded || toolboxGame) && (
<a
className="toolbox-hero-link nds-button"
data-size="sm"
@ -432,11 +432,14 @@ function ToolboxView({ siteContent, toolbox, toolboxGame, embedded, actions, sto
);
}
export function ToolboxDrawer({ gameId, game, siteContent, toolboxes, links, actions, storageUsage, storageReady = true, getModuleData, updateToolbox, updateModuleData, addImageFiles, visible = true, compact = false }) {
// Tiroir de toolbox. Sur une page de jeu, il montre la toolbox liée au jeu (`toolboxId`). Dans Sokko TCG (`chooser`), aucune liaison :
// il liste toutes les toolboxes, ouvre celle choisie et « Changer de toolbox » ramène à la liste.
export function ToolboxDrawer({ gameId, game, toolboxId = "", chooser = null, siteContent, toolboxes, links, actions, storageUsage, storageReady = true, getModuleData, updateToolbox, updateModuleData, addImageFiles, visible = true, compact = false }) {
const checklist = useGuideChecklist();
const guideChecklist = checklist.available && checklist.guideId.split("/")[0] === gameId ? checklist : undefined;
const selectedId = links[gameId] || "";
const guideChecklist = !chooser && checklist.available && checklist.guideId.split("/")[0] === gameId ? checklist : undefined;
const selectedId = toolboxId;
const toolbox = toolboxes.find((item) => item.id === selectedId);
const chooserText = siteContent.toolboxes.drawer.chooser;
const [width, setWidth] = useState(DRAWER_INITIAL_WIDTH);
const panelRef = useRef(null);
@ -479,19 +482,23 @@ export function ToolboxDrawer({ gameId, game, siteContent, toolboxes, links, act
<div className="drawer-content">
<header>
<div>
<p className="eyebrow">Toolbox liée</p>
<div className="drawer-toolbox-actions nds-toolbar" aria-label="Actions toolbox liée">
<p className="eyebrow">{chooser ? chooserText.eyebrow : "Toolbox liée"}</p>
{chooser ? toolbox && <div className="drawer-toolbox-actions nds-toolbar" aria-label={chooserText.actionsLabel}>
<button className="nds-button" data-size="sm" data-variant="secondary" type="button" onClick={() => chooser.onChoose("")}><Icon name="back" />{chooserText.changeLabel}</button>
<button className="drawer-action-button nds-icon-button" data-size="sm" onClick={() => actions.exportToolbox(selectedId)} aria-label={`Exporter ${toolbox.name}`} title="Exporter"><Icon name="export" /></button>
{actions.sharingEnabled && <button className="drawer-action-button nds-icon-button" data-size="sm" onClick={() => actions.openShareToolbox(selectedId)} aria-label={`Envoyer ${toolbox.name}`} title="Envoyer"><Icon name="share" /></button>}
</div> : <div className="drawer-toolbox-actions nds-toolbar" aria-label="Actions toolbox liée">
<button className="drawer-action-button nds-icon-button" data-size="sm" onClick={() => actions.setLinkModalGameId(gameId)} aria-label="Lier une toolbox" title="Lier"><Icon name="link" /></button>
<ImportButton className="drawer-action-button nds-icon-button import-icon-button" data-size="sm" ariaLabel="Importer une toolbox" title="Importer" icon="import" onFile={(file) => actions.importToolbox(file, gameId)} />
<button className="drawer-action-button nds-icon-button" data-size="sm" onClick={() => actions.exportToolbox(selectedId)} disabled={!selectedId} aria-label="Exporter la toolbox liée" title="Exporter"><Icon name="export" /></button>
{actions.sharingEnabled && <button className="drawer-action-button nds-icon-button" data-size="sm" onClick={() => actions.openShareToolbox(selectedId)} disabled={!selectedId} aria-label="Envoyer la toolbox liée" title="Envoyer"><Icon name="share" /></button>}
</div>
</div>}
</div>
<button className="drawer-close-button nds-icon-button" data-size="sm" onClick={() => actions.setDrawerGameId("")} aria-label="Fermer" title="Fermer"><Icon name="close" /></button>
</header>
{toolbox ? <ToolboxView siteContent={siteContent} toolbox={toolbox} toolboxGame={game} embedded actions={actions} storageUsage={storageUsage} storageReady={storageReady} getModuleData={getModuleData} updateToolbox={updateToolbox} updateModuleData={updateModuleData} addImageFiles={addImageFiles} guideChecklist={guideChecklist} /> : (
<ToolboxDrawerEmptyState gameId={gameId} toolboxes={toolboxes} links={links} actions={actions} content={siteContent.toolboxes.drawer} />
)}
{toolbox ? <ToolboxView key={toolbox.id} siteContent={siteContent} toolbox={toolbox} toolboxGame={game} embedded actions={actions} storageUsage={storageUsage} storageReady={storageReady} getModuleData={getModuleData} updateToolbox={updateToolbox} updateModuleData={updateModuleData} addImageFiles={addImageFiles} guideChecklist={guideChecklist} />
: chooser ? <ToolboxDrawerChooser toolboxes={toolboxes} getToolboxGame={chooser.getToolboxGame} onChoose={chooser.onChoose} actions={actions} content={chooserText} />
: <ToolboxDrawerEmptyState gameId={gameId} toolboxes={toolboxes} links={links} actions={actions} content={siteContent.toolboxes.drawer} />}
<StorageQuota usage={storageUsage} />
</div>
</section>
@ -499,6 +506,32 @@ export function ToolboxDrawer({ gameId, game, siteContent, toolboxes, links, act
);
}
// Liste du tiroir de Sokko TCG : une bande par toolbox (grande illustration, nom, jeu lié), dans l'ordre de la page Toolboxes.
// Une nouvelle toolbox s'ouvre aussitôt dans le tiroir, sans être liée à rien.
function ToolboxDrawerChooser({ toolboxes, getToolboxGame, onChoose, actions, content }) {
const create = () => actions.setCreateModal({ onCreated: (toolbox) => onChoose(toolbox.id) });
if (!toolboxes.length) return <section className="empty nds-empty-state drawer-toolbox-chooser-empty">
<p>{content.emptyText}</p>
<button className="nds-button" data-size="sm" data-variant="primary" type="button" onClick={create}><Icon name="add" />{content.createLabel}</button>
</section>;
return <section className="drawer-toolbox-chooser" aria-labelledby="drawer-toolbox-chooser-title">
<h2 id="drawer-toolbox-chooser-title">{content.title}</h2>
<ul className="drawer-toolbox-chooser-list">
{toolboxes.map((toolbox) => {
const game = getToolboxGame(toolbox);
const cover = getToolboxCover(toolbox, game);
return <li key={toolbox.id} className="nds-list-row drawer-toolbox-chooser-row">
<button type="button" onClick={() => onChoose(toolbox.id)}>
<span className="drawer-toolbox-chooser-cover" data-shape={cover.rect ? "image" : "icon"}><img src={cover.src} alt="" loading="lazy" /></span>
<span className="drawer-toolbox-chooser-text"><strong>{toolbox.name}</strong><small>{game ? game.title : content.freeLabel}</small></span>
</button>
</li>;
})}
</ul>
<button className="nds-button drawer-toolbox-chooser-create" data-size="sm" data-variant="dashed" type="button" onClick={create}><Icon name="add" />{content.createLabel}</button>
</section>;
}
function ToolboxDrawerEmptyState({ gameId, toolboxes, links, actions, content }) {
const linkedToolboxIds = useMemo(() => new Set(Object.values(links).filter(Boolean)), [links]);
const availableToolboxes = useMemo(

View file

@ -0,0 +1,19 @@
// Rôle : nomme les pages qui ouvrent le tiroir de toolbox : la page d'un jeu (sa toolbox liée), ou Sokko TCG dans toutes ses
// sections, où le joueur choisit n'importe laquelle de ses toolboxes dans une liste, sans liaison.
export const CARDS_TOOLBOX_TARGET_ID = "sokko-tcg";
// Le même tiroir reste ouvert d'une section de Sokko TCG à l'autre (Guilde, Expéditions, Collection…), administration comprise.
export function getRouteToolboxTargetId(route) {
const gameMatch = route.match(/^\/games\/([^/]+)/);
// `/games/sokko-tcg` n'est pas une page de jeu : elle n'ouvre pas le tiroir de Sokko TCG.
if (gameMatch) return gameMatch[1] === CARDS_TOOLBOX_TARGET_ID ? "" : gameMatch[1];
return route === "/cards" || route.startsWith("/cards/") ? CARDS_TOOLBOX_TARGET_ID : "";
}
// Toolbox affichée par le tiroir : celle liée au jeu, ou celle choisie dans Sokko TCG tant qu'elle existe encore.
export function getDrawerToolboxId(targetId, links, cardsToolboxId, toolboxes) {
if (!targetId) return "";
if (targetId !== CARDS_TOOLBOX_TARGET_ID) return links[targetId] || "";
return cardsToolboxId && toolboxes.some((toolbox) => toolbox.id === cardsToolboxId) ? cardsToolboxId : "";
}

View 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];
}

View file

@ -4,11 +4,11 @@ import { getCalendarAlertOffsets, getCurrentCalendarOccurrence, getNextCalendarA
import { getCountdownTargetMs } from "../features/toolboxes/modules/timerUtils.js";
import { moduleStorageKey } from "../features/toolboxes/storage/toolboxStorage.js";
export function getVisibleToolboxIds(route, drawerGameId, links) {
// `drawerToolboxId` : la toolbox affichée par le tiroir (liée au jeu, ou choisie dans Sokko TCG), vide tant qu'il est masqué.
export function getVisibleToolboxIds(route, drawerToolboxId) {
const visibleIds = new Set();
const toolboxMatch = route.match(/^\/toolbox\/([^/]+)/);
if (toolboxMatch?.[1]) visibleIds.add(toolboxMatch[1]);
const drawerToolboxId = drawerGameId ? links[drawerGameId] : "";
if (drawerToolboxId) visibleIds.add(drawerToolboxId);
return visibleIds;
}
@ -25,13 +25,13 @@ function formatAlertMessage(template, toolbox, label) {
.replaceAll("{toolbox}", toolbox.name);
}
export function useToolboxAlerts({ toolboxes, moduleData, links, route, drawerGameId, normalizeTimerData, normalizeCalendarData, textContent, notify }) {
export function useToolboxAlerts({ toolboxes, moduleData, route, drawerToolboxId, normalizeTimerData, normalizeCalendarData, textContent, notify }) {
const previousTargetsRef = useRef(new Map());
const resumedCalendarEventsRef = useRef(new Set());
const lastTickRef = useRef(null);
useEffect(() => {
const visibleToolboxIds = getVisibleToolboxIds(route, drawerGameId, links);
const visibleToolboxIds = getVisibleToolboxIds(route, drawerToolboxId);
const timerAlertTemplate = textContent?.timer?.alertMessage || "Compte à rebours terminé : {label}";
const calendarAlertTemplate = textContent?.calendar?.alertMessage || "Événement à venir : {label}";
const calendarResumeTemplate = textContent?.calendar?.resumeAlertMessage || "Événement en cours : {label}";
@ -96,5 +96,5 @@ export function useToolboxAlerts({ toolboxes, moduleData, links, route, drawerGa
tick();
const intervalId = window.setInterval(tick, 500);
return () => window.clearInterval(intervalId);
}, [drawerGameId, links, moduleData, normalizeCalendarData, normalizeTimerData, notify, route, textContent, toolboxes]);
}, [drawerToolboxId, moduleData, normalizeCalendarData, normalizeTimerData, notify, route, textContent, toolboxes]);
}

View file

@ -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}
/>

View file

@ -71,6 +71,98 @@ body.is-resizing-drawer * {
gap: var(--space-4);
}
/* Tiroir de Sokko TCG : une bande par toolbox. L'illustration occupe une large part de la bande (bandeau 2:1 comme les
couvertures de jeu, jusqu'à leur taille native de 240 × 120), puis le nom et le jeu lié. */
.drawer-toolbox-chooser {
display: grid;
gap: var(--space-4);
}
.drawer-toolbox-chooser h2 {
font-size: var(--font-size-md);
}
.drawer-toolbox-chooser-list {
display: grid;
gap: var(--space-3);
margin: 0;
padding: 0;
list-style: none;
}
.drawer-toolbox-chooser-row button {
min-height: 0;
gap: var(--space-4);
padding: var(--space-2);
cursor: pointer;
}
.drawer-toolbox-chooser-row button:focus-visible {
outline: 2px solid var(--color-accent-gold);
outline-offset: -2px;
}
.drawer-toolbox-chooser-cover {
display: grid;
flex: 0 0 min(240px, 42%);
aspect-ratio: 2 / 1;
overflow: hidden;
place-items: center;
border-radius: var(--radius-sm);
background: var(--gradient-nebula);
}
.drawer-toolbox-chooser-cover img {
width: 100%;
height: 100%;
object-fit: cover;
transition: transform 0.2s ease;
}
.drawer-toolbox-chooser-row:hover .drawer-toolbox-chooser-cover[data-shape="image"] img {
transform: scale(1.04);
}
.drawer-toolbox-chooser-cover[data-shape="icon"] img {
width: 40%;
height: 70%;
object-fit: contain;
}
.drawer-toolbox-chooser-text {
display: grid;
min-width: 0;
gap: var(--space-1);
text-align: left;
}
.drawer-toolbox-chooser-text strong,
.drawer-toolbox-chooser-text small {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.drawer-toolbox-chooser-text strong {
font-size: var(--font-size-lg);
}
.drawer-toolbox-chooser-text small {
color: var(--color-text-muted);
font-size: var(--font-size-sm);
font-weight: 700;
}
@media (prefers-reduced-motion: reduce) {
.drawer-toolbox-chooser-cover img {
transition: none;
}
}
.drawer-toolbox-chooser-create {
justify-self: start;
}
.drawer-link-existing h2 {
font-size: var(--font-size-md);
}