Refine toolbox navigation and local data controls
All checks were successful
Deploy Sokko G / deploy (push) Successful in 20s

This commit is contained in:
Shinuwa 2026-10-15 10:52:34 +02:00
parent 954240adf9
commit 2f2e79d200
27 changed files with 614 additions and 302 deletions

View file

@ -4,7 +4,7 @@ export function GamesPage({ siteContent, games, gamesError }) {
return (
<>
<section className="page-hero nds-page-hero">
<section className="page-hero nds-page-hero primary-list-hero">
<div>
<p className="eyebrow">{content.eyebrow}</p>
<h1>{content.title}</h1>

View file

@ -3,9 +3,9 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { GuidedTooltipTour } from "../../components/GuidedTooltipTour.jsx";
import { Icon } from "../../components/Icon.jsx";
import { ImportButton } from "../../components/ImportButton.jsx";
import { ToolboxManagementModal } from "../../components/ToolboxModals.jsx";
import { useGuideChecklist } from "../games/useGuideChecklist.js";
import { StorageQuota } from "../../components/StorageQuota.jsx";
import { ToastPositionSwitch } from "../../components/ToastPositionSwitch.jsx";
import { useGroupedReorder } from "../../hooks/useGroupedReorder.js";
import { useInlineEdit } from "../../hooks/useInlineEdit.js";
import { compressImage } from "../../utils/imageCompression.js";
@ -61,8 +61,9 @@ async function copyText(value) {
}
}
export function ToolboxesPage({ siteContent, toolboxes, getToolboxGame, actions, storageUsage, toastPosition, setToastPosition, onOpenAutoBackup }) {
export function ToolboxesPage({ siteContent, toolboxes, getToolboxGame, actions, storageUsage, toastPosition, setToastPosition }) {
const content = siteContent.toolboxes;
const [managementOpen, setManagementOpen] = useState(false);
const {
itemReorder,
getItemProps,
@ -88,76 +89,61 @@ export function ToolboxesPage({ siteContent, toolboxes, getToolboxGame, actions,
return (
<div className="toolbox-page">
<section className="page-hero nds-page-hero">
<section className="page-hero nds-page-hero primary-list-hero toolbox-list-hero">
<div>
<p className="eyebrow">{content.eyebrow}</p>
<h1>{content.title}</h1>
<p>{content.summary}</p>
<a className="hero-library-button library-link-button nds-button" data-size="sm" href="#/library"><Icon name="book" />{content.libraryLink}</a>
<div className="actions nds-toolbar toolbox-list-primary-actions" aria-label={content.primaryActionsLabel}>
<button className="nds-button" data-size="sm" data-variant="primary" aria-label={content.newButton} onClick={() => actions.setCreateModal({})}><Icon name="add" />{content.createShortButton}</button>
<ImportButton className="nds-button" data-size="sm" label={content.importOne} icon="import" onFile={actions.importToolbox} />
</div>
</div>
</section>
<section className="toolbar nds-toolbar toolbox-actions-row">
<div>
<button className="nds-button" data-size="sm" data-variant="primary" onClick={() => actions.setCreateModal({})}>{content.newButton}</button>
<ImportButton className="nds-button" data-size="sm" label={content.importOne} onFile={actions.importToolbox} />
</div>
<div>
<button className="nds-button" data-size="sm" data-variant="primary" type="button" onClick={onOpenAutoBackup}>{content.autoBackup.title}</button>
<button className="nds-button" data-size="sm" onClick={actions.exportAllToolboxes}>{content.exportAll}</button>
<ImportButton className="nds-button" data-size="sm" label={content.importAll} onFile={actions.importAllToolboxes} />
</div>
<section className="toolbox-list-actions nds-toolbar" aria-label={content.collectionActionsLabel}>
<button className="nds-button" data-size="sm" type="button" onClick={() => setManagementOpen(true)}><Icon name="settings" />{content.manageButton}</button>
<a className="library-link-button nds-button" data-size="sm" href="#/library" aria-label={content.libraryLink} title={content.libraryLink}><Icon name="book" /><span className="toolbox-list-action-label">{content.libraryLink}</span></a>
</section>
<section className="toolbox-preferences-row" aria-label={content.preferencesLabel}>
<div>
<p className="eyebrow">{content.preferencesLabel}</p>
<strong>{content.toastPositionLabel}</strong>
<section className="toolbox-collection" aria-labelledby="toolbox-collection-title">
<header className="toolbox-collection-heading">
<div>
<p className="eyebrow">{content.collectionEyebrow}</p>
<div className="toolbox-collection-title-row">
<h2 id="toolbox-collection-title">{content.collectionTitle}</h2>
<span className="nds-badge" data-variant="neutral">{toolboxes.length}</span>
</div>
</div>
</header>
<div className="cards">
{toolboxes.length ? toolboxes.map((toolbox) => (
<ToolboxCard
key={toolbox.id}
toolbox={toolbox}
game={getToolboxGame(toolbox)}
actions={actions}
reorder={{ itemReorder, getItemProps, isItemDragging, isItemDropTarget, getDropPlacement }}
/>
)) : (
<div className="empty nds-empty-state toolbox-list-empty">
<h2>{content.emptyTitle}</h2>
<p>{content.emptyText}</p>
<button className="nds-button" data-size="sm" data-variant="primary" type="button" onClick={() => actions.setCreateModal({})}>{content.emptyAction}</button>
</div>
)}
</div>
<ToastPositionSwitch
position={toastPosition}
onChange={setToastPosition}
labels={{
title: content.toastPositionLabel,
left: content.toastPositionLeft,
right: content.toastPositionRight
}}
/>
</section>
<section className="cards">
<StorageHelpCard help={content.storageHelp} />
{toolboxes.length ? toolboxes.map((toolbox) => (
<ToolboxCard
key={toolbox.id}
toolbox={toolbox}
game={getToolboxGame(toolbox)}
actions={actions}
reorder={{ itemReorder, getItemProps, isItemDragging, isItemDropTarget, getDropPlacement }}
/>
)) : (
<div className="empty nds-empty-state"><h2>{content.emptyTitle}</h2><p>{content.emptyText}</p></div>
)}
</section>
<StorageQuota usage={storageUsage} />
{managementOpen && <ToolboxManagementModal
content={content}
toastPosition={toastPosition}
setToastPosition={setToastPosition}
actions={actions}
onClose={() => setManagementOpen(false)}
/>}
</div>
);
}
function StorageHelpCard({ help }) {
return (
<article className="card nds-card storage-help-card" aria-labelledby="storage-help-title">
<div className="card-body nds-card-body">
<div className="storage-help-heading">
<span className="storage-help-mark" aria-hidden="true" />
<div><p className="eyebrow">IndexedDB</p><h2 id="storage-help-title">{help.title}</h2></div>
</div>
<p className="storage-help-intro">{help.text}</p>
<ul className="storage-help-list">
{help.items.map((item, index) => <li key={item}><span>{index + 1}</span><p>{item}</p></li>)}
</ul>
</div>
</article>
);
}
export function ToolboxPage(props) {
const { toolboxId, toolboxes, getToolboxGame } = props;
const toolbox = toolboxes.find((item) => item.id === toolboxId);