Files
ServerKit/frontend/src/components/Modal.jsx
T
Juan Denis 6296887bad Remove internal plan citations from app code
Comments, docstrings and a few strings cited plan numbers ("plan 29
#9", "plan 86 §B2") from a git-ignored folder, so they pointed at
nothing; one reached users in a bottleneck hint. Code and frontend
strings are unchanged apart from those citations (checked by AST and
token comparison). A vhost still carrying the old asset comment reads
as undrifted, and a guard test keeps new citations out.
2026-10-10 15:50:45 -04:00

52 lines
1.6 KiB
React

import { Dialog, DialogContent, DialogTitle } from '@/components/ui/dialog';
import { cn } from '@/lib/utils';
// Generic modal built on the Radix Dialog primitive. SCSS owns all geometry
// (styles/components/_ui.scss → .sk-modal*). `size` picks a max-width on
// >=sm screens; mobile is always near full-width.
//
// Form mode: pass `onSubmit` and the body AND footer
// are wrapped in one <form>. This exists because a submit button must live
// inside the form it submits — without it, every modal with a form had to
// bypass `footer` and hand-roll its own footer row inside the body, which is
// why 28 files stopped using this prop. Form mode also gets Enter-to-submit
// for free, which the hand-rolled footers did not have.
export default function Modal({
open,
onClose,
title,
children,
footer,
onSubmit,
className = '',
size = 'md',
}) {
const body = (
<>
<div className="sk-modal__body">{children}</div>
{footer && <div className="sk-modal__footer">{footer}</div>}
</>
);
const handleSubmit = (event) => {
event.preventDefault();
onSubmit(event);
};
return (
<Dialog open={open} onOpenChange={(v) => !v && onClose()}>
<DialogContent className={cn('sk-modal', `sk-modal--${size}`, className)}>
{title && (
<div className="sk-modal__header">
<DialogTitle>{title}</DialogTitle>
</div>
)}
{onSubmit
? <form className="sk-modal__form" onSubmit={handleSubmit} noValidate>{body}</form>
: body}
</DialogContent>
</Dialog>
);
}