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

@ -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(