/**
* A right-side slide-over that houses the full Settings form, keeping the home page
* uncluttered while the deep generation knobs stay one click away. Closes on the
* overlay, the × button, or the Escape key.
* @module web-app/components/SettingsDrawer
*/
import { useEffect } from "react";
import Settings from "./Settings.jsx";
/**
* @param {object} props
* @param {boolean} props.open Whether the drawer is shown.
* @param {Function} props.onClose Close the drawer.
* @param {object} props.settings The current settings.
* @param {Function} props.setSettings Update the settings.
* @returns {(JSX.Element|null)}
*/
import { jsxDEV as _jsxDEV, Fragment as _Fragment } from "react/jsx-dev-runtime";
export default function SettingsDrawer({
open,
onClose,
settings,
setSettings
}) {
useEffect(() => {
if (!open) return undefined;
const onKey = e => e.key === "Escape" && onClose();
document.addEventListener("keydown", onKey);
return () => document.removeEventListener("keydown", onKey);
}, [open, onClose]);
if (!open) return null;
return /*#__PURE__*/_jsxDEV(_Fragment, {
children: [/*#__PURE__*/_jsxDEV("div", {
className: "drawer-overlay",
onClick: onClose
}, void 0, false), /*#__PURE__*/_jsxDEV("aside", {
className: "drawer",
role: "dialog",
"aria-label": "Settings",
children: [/*#__PURE__*/_jsxDEV("div", {
className: "drawer-head",
children: [/*#__PURE__*/_jsxDEV("h2", {
children: "Settings"
}, void 0, false), /*#__PURE__*/_jsxDEV("div", {
className: "spacer"
}, void 0, false), /*#__PURE__*/_jsxDEV("button", {
className: "drawer-close",
onClick: onClose,
"aria-label": "Close settings",
children: "×"
}, void 0, false)]
}, void 0, true), /*#__PURE__*/_jsxDEV("div", {
className: "drawer-body",
children: /*#__PURE__*/_jsxDEV(Settings, {
settings: settings,
setSettings: setSettings
}, void 0, false)
}, void 0, false)]
}, void 0, true)]
}, void 0, true);
}