clipwright/dashboard/src/components/ui/Modal.jsx
juancarlos.cavero 3709d64085 feat(dashboard): make the app usable on a phone
The dashboard was a desktop layout that merely survived a narrow viewport.
The changes below are interface only; no backend behaviour, request shape or
data changes.

Navigation. Below md the 80px icon rail is gone. It cost a fifth of a 360px
screen to show seven unlabelled glyphs. In its place: a bottom tab bar with
the four everyday destinations plus "more", and a drawer behind the header's
menu button carrying the full list. All three surfaces read one `navItems`
array, so they cannot drift. The tab bar is a flex sibling of the scrolling
pane rather than a fixed overlay, so no pane needs compensating padding and
nothing hides behind it. The header gains the section name the rail used to
carry, so a phone still knows where it is.

Shell. h-dvh where supported (100vh hides its own bottom bar behind mobile
browser chrome), body overflow-x hidden, and safe-area padding for the iOS
home indicator via viewport-fit=cover.

Touch and legibility. Inputs render at 16px below sm so iOS stops zooming on
focus and never zooming back; the shared button pills get a 44px floor on
coarse pointers; the 10.5px mono labels come up to 11.5px on phones.

Density. The clip-generator hero no longer fills the fold on its own. The log
terminal starts collapsed on phones. Result cards cap the 9:16 preview so the
title, captions and actions stay on the same screen as the clip. Modals become
bottom sheets below sm — a centred dialog with 4px side margins was wasting the
only width there was. Banners, the results toolbar and the social nudge stack
instead of crushing.

Also fixes three <div>-inside-<p> blocks in Settings that the browser was
silently tearing apart.
2026-08-24 02:25:24 +02:00

71 lines
2.8 KiB
JavaScript

import { X } from 'lucide-react';
/**
* The single modal shell for the app (design.md).
* Plain dark overlay (no backdrop-blur), hairline paper2 panel.
*
* Props:
* - isOpen / onClose
* - title (string, rendered lowercase serif) — optional
* - eyebrow (string, mono UPPERCASE micro label above title) — optional
* - size: 'sm' | 'md' | 'lg' | 'xl' (max width; default 'md')
* - children: body content
* - footer: optional node pinned under the body
* - hideClose: hide the X button
*/
const SIZES = {
sm: 'max-w-sm',
md: 'max-w-md',
lg: 'max-w-2xl',
xl: 'max-w-5xl',
};
export default function Modal({ isOpen, onClose, title, eyebrow, size = 'md', children, footer, hideClose = false }) {
if (!isOpen) return null;
return (
/* Phone: a bottom sheet — anchored to the thumb, edge to edge, and free to
run taller than a centred dialog whose 4px side margins wasted the only
width there was. From sm up it is the centred dialog it always was. */
<div
className="fixed inset-0 z-[100] flex items-end sm:items-center justify-center bg-black/70 p-0 sm:p-4 animate-fade"
onMouseDown={(e) => { if (e.target === e.currentTarget && onClose) onClose(); }}
role="dialog"
aria-modal="true"
>
<div
className={`card relative w-full ${SIZES[size] || SIZES.md} max-h-[92vh] sm:max-h-[90vh] flex flex-col
rounded-b-none sm:rounded-card animate-sheet-up sm:animate-none`}
>
{/* Grab handle: the affordance that says "this sheet closes downward". */}
<div className="sm:hidden pt-2.5 pb-1 flex justify-center shrink-0" aria-hidden="true">
<span className="w-9 h-1 rounded-full bg-[color:var(--color-rule-2)]" />
</div>
{!hideClose && onClose && (
<button
onClick={onClose}
aria-label="close"
className="absolute top-3 right-3 sm:top-4 sm:right-4 z-10 p-2 rounded-full text-muted hover:text-ink hover:bg-paper3 transition-colors"
>
<X size={18} />
</button>
)}
{(title || eyebrow) && (
<div className="px-4 sm:px-6 pt-3 sm:pt-6 pb-4 border-b border-rule shrink-0">
{eyebrow && <p className="eyebrow mb-1.5">{eyebrow}</p>}
{title && <h2 className="font-display lowercase text-xl sm:text-2xl text-ink leading-tight break-words pr-10">{title}</h2>}
</div>
)}
<div className="px-4 sm:px-6 py-5 overflow-y-auto overscroll-contain custom-scrollbar grow">
{children}
</div>
{footer && (
<div className="px-4 sm:px-6 py-4 border-t border-rule shrink-0 safe-bottom">
{footer}
</div>
)}
{!footer && <div className="sm:hidden safe-bottom" />}
</div>
</div>
);
}