Add shorts_yt_quota module, Shorts UI quota banner, overview tweaks (hide upcoming opens, align events panel height), Electron desktop client scaffold, and deploy scripts; update README. Co-authored-by: Cursor <cursoragent@cursor.com>
61 lines
1.6 KiB
TypeScript
61 lines
1.6 KiB
TypeScript
import { useEffect, useState, type ReactNode } from "react";
|
|
import { createPortal } from "react-dom";
|
|
|
|
type ModalProps = {
|
|
open: boolean;
|
|
onClose: () => void;
|
|
children: ReactNode;
|
|
/** Panel wrapper classes (the dialog card). */
|
|
panelClassName?: string;
|
|
zIndex?: number;
|
|
};
|
|
|
|
/**
|
|
* Viewport-locked overlay. Always portals to document.body so parent
|
|
* transforms (e.g. Shell `.page-enter`) cannot trap `position: fixed`.
|
|
*/
|
|
export function Modal({
|
|
open,
|
|
onClose,
|
|
children,
|
|
panelClassName = "max-h-[90vh] w-full max-w-2xl overflow-y-auto rounded-2xl border border-white/10 bg-[#0b1626] p-5 shadow-2xl",
|
|
zIndex = 80,
|
|
}: ModalProps) {
|
|
const [mounted, setMounted] = useState(false);
|
|
|
|
useEffect(() => {
|
|
setMounted(true);
|
|
}, []);
|
|
|
|
useEffect(() => {
|
|
if (!open) return;
|
|
const onKey = (e: KeyboardEvent) => {
|
|
if (e.key === "Escape") onClose();
|
|
};
|
|
window.addEventListener("keydown", onKey);
|
|
const prev = document.body.style.overflow;
|
|
document.body.style.overflow = "hidden";
|
|
return () => {
|
|
window.removeEventListener("keydown", onKey);
|
|
document.body.style.overflow = prev;
|
|
};
|
|
}, [open, onClose]);
|
|
|
|
if (!mounted || !open) return null;
|
|
|
|
return createPortal(
|
|
<div
|
|
className="fixed inset-0 flex items-center justify-center bg-black/70 p-4 backdrop-blur-[2px]"
|
|
style={{ zIndex, position: "fixed", top: 0, left: 0, right: 0, bottom: 0 }}
|
|
onClick={onClose}
|
|
role="dialog"
|
|
aria-modal="true"
|
|
>
|
|
<div className={panelClassName} onClick={(e) => e.stopPropagation()}>
|
|
{children}
|
|
</div>
|
|
</div>,
|
|
document.body,
|
|
);
|
|
}
|