Profile system: - Profile store (Zustand + persist) with CRUD + import/export - ProfileSaveForm, ProfileCard, ProfileList components - Load profile populates editor form (channel, social, rig, video settings) Game preset system: - Preset store with CRUD + import/export - PresetSaveForm, PresetCard, PresetList, PresetSelector components - Load preset populates game fields (name, genre, platform, store links) Expanded content: - 5 new video types: dlc, newgame_plus, challenge, side_quest, secret (12 total) - 5 new genres: fighting, stealth, survival_craft, roguelike, metroidvania (15 total) - 4 new social fields: twitch, tiktok, instagram, streamlabs (12 total) - 2 new rig fields: motherboard, controller (8 total) - 2 new platforms: humble, amazon (9 total) - Tag pools for all new genres and video types New UI: - Modal + ConfirmDialog primitives - ProfilesPage with tab-based profile/preset management - Import/Export JSON for profiles and presets - DraftIndicator + Clear draft button in editor - PresetSelector dropdown in EditorPage i18n: 134 UI keys + 41 template keys across EN/VI/JA (all validated) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
61 lines
1.8 KiB
TypeScript
61 lines
1.8 KiB
TypeScript
import { useEffect, useRef, type ReactNode } from "react";
|
|
import { X } from "lucide-react";
|
|
import clsx from "clsx";
|
|
|
|
interface ModalProps {
|
|
open: boolean;
|
|
onClose: () => void;
|
|
title?: string;
|
|
children: ReactNode;
|
|
footer?: ReactNode;
|
|
className?: string;
|
|
}
|
|
|
|
export function Modal({ open, onClose, title, children, footer, className }: ModalProps) {
|
|
const overlayRef = useRef<HTMLDivElement>(null);
|
|
|
|
useEffect(() => {
|
|
if (!open) return;
|
|
const handleEsc = (e: KeyboardEvent) => {
|
|
if (e.key === "Escape") onClose();
|
|
};
|
|
document.addEventListener("keydown", handleEsc);
|
|
return () => document.removeEventListener("keydown", handleEsc);
|
|
}, [open, onClose]);
|
|
|
|
if (!open) return null;
|
|
|
|
return (
|
|
<div
|
|
ref={overlayRef}
|
|
className="fixed inset-0 z-50 flex items-center justify-center bg-black/60"
|
|
onClick={(e) => {
|
|
if (e.target === overlayRef.current) onClose();
|
|
}}
|
|
>
|
|
<div
|
|
className={clsx(
|
|
"mx-4 flex max-h-[85vh] w-full max-w-lg flex-col rounded-xl border border-border bg-surface-1 shadow-2xl",
|
|
className,
|
|
)}
|
|
>
|
|
{title && (
|
|
<div className="flex items-center justify-between border-b border-border px-5 py-4">
|
|
<h2 className="text-base font-semibold text-text-primary">{title}</h2>
|
|
<button
|
|
onClick={onClose}
|
|
className="rounded-lg p-1 text-text-muted hover:bg-surface-2 hover:text-text-primary"
|
|
>
|
|
<X className="h-4 w-4" />
|
|
</button>
|
|
</div>
|
|
)}
|
|
<div className="flex-1 overflow-y-auto px-5 py-4">{children}</div>
|
|
{footer && (
|
|
<div className="flex justify-end gap-2 border-t border-border px-5 py-3">{footer}</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|