A lightweight Clip Studio Paint alternative with real-time multiplayer collaborative drawing. Built with Tauri and React.
TypeScript animationcartoonclip-studio-paintcollaborativedesktop-appdigital-paintingdrawing-appillustrationmangamultiplayeropen-sourcerusttaurithreejswebglwebtoon
import React, { useEffect } from 'react';
import { Trash2, EyeOff, AlertTriangle, X, FileText } from 'lucide-react';
import { RecentDocument, formatFileSize } from '../utils/recentDocumentsManager';
import { isImeComposing, useI18n } from '../i18n';
interface DeleteDocumentModalProps {
isOpen: boolean;
document: RecentDocument | null;
onClose: () => void;
onHideFromApp: (doc: RecentDocument) => void;
onPermanentlyDelete: (doc: RecentDocument) => void;
}
export const DeleteDocumentModal: React.FC<DeleteDocumentModalProps> = ({
isOpen,
document,
onClose,
onHideFromApp,
onPermanentlyDelete,
}) => {
const { t } = useI18n();
useEffect(() => {
if (!isOpen) return;
const handleKeyDown = (e: KeyboardEvent) => {
if (isImeComposing(e)) return;
if (e.key === 'Escape') {
e.preventDefault();
e.stopPropagation();
onClose();
}
};
window.addEventListener('keydown', handleKeyDown, true);
return () => window.removeEventListener('keydown', handleKeyDown, true);
}, [isOpen, onClose]);
if (!isOpen || !document) return null;
return (
<div
role="dialog"
aria-modal="true"
aria-labelledby="delete-document-modal-title"
className="fixed inset-0 z-50 flex items-center justify-center bg-ui-overlay p-4 select-none"
onClick={onClose}
>
<div
onClick={(e) => e.stopPropagation()}
className="bg-ui-panel rounded-ui-lg shadow-ui-popover w-full max-w-[430px] overflow-hidden text-xs text-ui-primary border border-ui-default"
>
{/* Title Bar */}
<div className="h-10 px-4 flex items-center justify-between bg-ui-header border-b border-ui-subtle">
<div className="flex items-center gap-2 min-w-0">
<Trash2 className="w-3.5 h-3.5 text-ui-danger shrink-0" />
<span
id="delete-document-modal-title"
className="text-xs font-medium text-ui-primary tracking-wide"
>
{t('Delete Document')}
</span>
</div>
<button
type="button"
onClick={onClose}
aria-label={t('Close')}
title={t('Cancel (Esc)')}
className="w-6 h-6 rounded-ui-sm flex items-center justify-center text-ui-muted hover:text-ui-primary hover:bg-ui-control-hover transition-colors cursor-pointer"
>
<X className="w-3.5 h-3.5" />
</button>
</div>
{/* Content */}
<div className="p-4 space-y-3">
{/* Target File Info */}
<div className="bg-ui-header border border-ui-subtle rounded-ui-md p-2.5 flex items-center gap-3">
<div className="w-11 h-11 bg-ui-panel border border-ui-subtle overflow-hidden shrink-0 flex items-center justify-center rounded-ui-sm">
{document.coverUrl ? (
<img
src={document.coverUrl}
alt={document.title}
className="w-full h-full object-cover"
/>
) : (
<FileText className="w-4 h-4 text-ui-icon-muted" />
)}
</div>
<div className="flex-1 min-w-0">
<div className="text-xs font-medium text-ui-primary truncate" title={document.title}>
{document.title}
</div>
<div className="text-[10px] text-ui-muted font-ui-mono tabular-nums truncate mt-0.5" title={document.path}>
{formatFileSize(document.size)} • {document.path}
</div>
</div>
</div>
<div className="text-[11px] font-medium text-ui-muted uppercase tracking-wider pt-0.5">
{t('Select action')}
</div>
<div className="space-y-2">
{/* Action 1: Remove from list */}
<button
type="button"
onClick={() => onHideFromApp(document)}
className="w-full flex items-start gap-3 p-3 rounded-ui-md bg-ui-control hover:bg-ui-control-hover border border-ui-subtle hover:border-ui-default text-left transition-colors cursor-pointer"
>
<div className="w-7 h-7 rounded-ui-sm bg-ui-header border border-ui-subtle flex items-center justify-center shrink-0 text-ui-icon-muted">
<EyeOff className="w-3.5 h-3.5" />
</div>
<div className="min-w-0">
<div className="text-xs font-medium text-ui-primary">
{t('Remove from Recent List')}
</div>
<div className="text-[11px] text-ui-muted mt-0.5 leading-snug">
{t('Removes entry from the studio. Keeps the file intact on disk.')}
</div>
</div>
</button>
{/* Action 2: Permanently delete */}
<button
type="button"
onClick={() => onPermanentlyDelete(document)}
className="w-full flex items-start gap-3 p-3 rounded-ui-md bg-ui-danger/10 hover:bg-ui-danger/15 border border-ui-danger/30 hover:border-ui-danger/50 text-left transition-colors cursor-pointer"
>
<div className="w-7 h-7 rounded-ui-sm bg-ui-danger/15 border border-ui-danger/30 flex items-center justify-center shrink-0 text-ui-danger">
<AlertTriangle className="w-3.5 h-3.5" />
</div>
<div className="min-w-0">
<div className="text-xs font-medium text-ui-danger">
{t('Permanently Delete from Disk')}
</div>
<div className="text-[11px] text-ui-danger/80 mt-0.5 leading-snug">
{t('Erases file permanently from storage. Cannot be undone.')}
</div>
</div>
</button>
</div>
</div>
{/* Footer */}
<div className="px-4 py-2.5 bg-ui-header border-t border-ui-subtle flex items-center justify-end">
<button
type="button"
onClick={onClose}
className="px-3.5 py-1.5 rounded-ui-sm bg-ui-control hover:bg-ui-control-hover border border-ui-default text-xs font-medium text-ui-primary transition-colors cursor-pointer"
>
{t('Cancel')}
</button>
</div>
</div>
</div>
);
};