eigent/src/components/ui/alertDialog.tsx
Tong Chen a23c30db13
Some checks are pending
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
CodeQL Advanced / Analyze (python) (push) Waiting to run
Pre-commit / pre-commit (push) Waiting to run
Test / Run Python Tests (push) Waiting to run
Feat skills (#1221)
Co-authored-by: Pakchoioioi <happy.regina.bai@gmail.com>
Co-authored-by: Douglas Lai <115660088+Douglasymlai@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Douglas <douglas.ym.lai@gmail.com>
Co-authored-by: Wendong-Fan <133094783+Wendong-Fan@users.noreply.github.com>
Co-authored-by: Wendong-Fan <w3ndong.fan@gmail.com>
2026-02-19 02:29:21 +08:00

96 lines
3 KiB
TypeScript

// ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. =========
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. =========
import { Button } from '@/components/ui/button';
import { AnimatePresence, motion } from 'framer-motion';
type ButtonVariant =
| 'primary'
| 'secondary'
| 'outline'
| 'ghost'
| 'success'
| 'cuation'
| 'information'
| 'warning';
interface ConfirmModalProps {
isOpen: boolean;
onClose: () => void;
onConfirm: () => void;
title?: string;
message?: string;
confirmText?: string;
cancelText?: string;
confirmVariant?: ButtonVariant;
}
export default function ConfirmModal({
isOpen,
onClose,
onConfirm,
title = 'Confirm Title',
message = 'Confirm content?',
confirmText = 'Confirm',
cancelText = 'Cancel',
confirmVariant = 'cuation',
}: ConfirmModalProps) {
return (
<AnimatePresence>
{isOpen && (
<>
{/* Background overlay */}
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
className="alert-dialog fixed inset-0 z-[99] bg-black/20"
style={{ backgroundColor: 'rgba(0, 0, 0, 0.2)' }}
onClick={onClose}
/>
{/* Modal */}
<motion.div
initial={{ opacity: 0, scale: 0.9, y: 20 }}
animate={{ opacity: 1, scale: 1, y: 0 }}
exit={{ opacity: 0, scale: 0.9, y: 20 }}
className="alert-dialog-wrapper fixed left-1/2 top-1/2 z-[100] max-w-md rounded-xl -translate-x-1/2 -translate-y-1/2"
>
<div className="p-6 rounded-xl border border-popup-border bg-surface-tertiary shadow-perfect">
<span className="mb-2 text-body-lg font-bold text-text-primary">
{title}
</span>
<p className="mb-6 text-label-md text-text-label">{message}</p>
<div className="flex justify-end gap-3">
<Button variant="ghost" onClick={onClose}>
{cancelText}
</Button>
<Button
variant={confirmVariant}
onClick={() => {
onConfirm();
onClose();
}}
>
{confirmText}
</Button>
</div>
</div>
</motion.div>
</>
)}
</AnimatePresence>
);
}