feat: dashboard UI/UX overhaul from full review

Shared foundation:
- New Modal component on native <dialog>.showModal() (focus trap, inert
  background, Escape, focus restore, scroll lock); all eight dialogs and
  both globalThis.confirm calls migrated to it
- Design tokens for success/warning/danger surfaces; pill danger variant;
  .sr-only utility; toast layering above dialog backdrops; not-allowed
  cursor for validity-disabled buttons

Conversations/attention: auto-scroll with jump-to-latest, per-conversation
draft persistence, suggestion undo, 30s auto-refresh with refresh controls,
unread emphasis and counts, blur-consistent share dialog, empty-accounts
guidance, collapsed user lookup, relative timestamps, danger pills for
critical items

Media/library/outreach: click-blurred-to-reveal, lightbox with arrow
navigation and captions, dirty-form preservation across refetches, upload
validation with thumbnail preview, save feedback, result counts with
load-more and clear-filters, ticking countdowns from a single clock

Overview/performance/operations/settings: mutation errors inside the
confirm dialog, live sending-window countdown, offline-aware loading
states, per-panel loading/error with retry, 7/30/90-day range toggle,
console scroll yielding with shown/retained counts, risky-save matching
by subreddit name instead of index, useBlocker unsaved-changes guard,
single-pass validation with focus-to-first-error, access panel JSON
validation and input reset

Tests: 806 -> 844 passing; both typechecks clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Jamie BruntonandClaude Fable 5 committed 2026-08-10 09:07:42 +01:00
1 parent 82be197b79
commit e984bf20ac
46 files changed
+2462 -495

No files matched your search

+79
View File
@@ -0,0 +1,79 @@
import { useEffect, useRef, useState, type PropsWithChildren, type ReactNode } from 'react';
interface ModalProps {
/** Class applied to the <dialog> element itself (it is the visible card). */
className?: string;
/** Blocks Escape/backdrop dismissal while a mutation is in flight. */
isDismissLocked?: boolean;
/** Close when the backdrop (the ::backdrop area of the dialog) is pressed. */
closeOnBackdrop?: boolean;
label?: string;
labelledBy?: string;
onClose(): void;
}
/**
* Shared modal built on native <dialog>.showModal(): the browser provides
* focus trapping, inert background, and Escape handling. Render conditionally;
* mounting opens the dialog and unmounting restores focus to the opener.
*/
export function Modal({
children,
className,
closeOnBackdrop = false,
isDismissLocked = false,
label,
labelledBy,
onClose,
}: PropsWithChildren<ModalProps>): ReactNode {
const dialogRef = useRef<HTMLDialogElement>(null);
const onCloseRef = useRef(onClose);
onCloseRef.current = onClose;
const dismissLockedRef = useRef(isDismissLocked);
dismissLockedRef.current = isDismissLocked;
// Captured at first render, before autoFocus moves focus into the dialog.
const [previouslyFocused] = useState(() => document.activeElement);
useEffect(() => {
const dialog = dialogRef.current;
if (!dialog) return;
if (!dialog.open) {
if (typeof dialog.showModal === 'function') dialog.showModal();
else dialog.setAttribute('open', '');
}
return () => {
if (previouslyFocused instanceof HTMLElement && previouslyFocused.isConnected) {
previouslyFocused.focus();
}
};
}, [previouslyFocused]);
function requestClose(): void {
if (!dismissLockedRef.current) onCloseRef.current();
}
return (
<dialog
aria-label={label}
aria-labelledby={labelledBy}
className={className ? `modal ${className}` : 'modal'}
onCancel={(event) => {
event.preventDefault();
requestClose();
}}
onKeyDown={(event) => {
if (event.key === 'Escape') {
event.preventDefault();
requestClose();
}
}}
onMouseDown={(event) => {
if (closeOnBackdrop && event.target === event.currentTarget) requestClose();
}}
ref={dialogRef}
>
{children}
</dialog>
);
}