Download desktop/src/components/shared/ConfirmDialog.tsx from chenbhao/codev: direct link, hf CLI and curl.
- Browser
- Download file 1.16 kB
-
https://huggingface.co/chenbhao/codev/resolve/e40073cc959cd4729bf4009662bca374c5c4e266/desktop/src/components/shared/ConfirmDialog.tsx
- Command line
-
hf download hf://chenbhao/codev@e40073cc959cd4729bf4009662bca374c5c4e266/desktop/src/components/shared/ConfirmDialog.tsx
-
curl -L -o ConfirmDialog.tsx https://huggingface.co/chenbhao/codev/resolve/e40073cc959cd4729bf4009662bca374c5c4e266/desktop/src/components/shared/ConfirmDialog.tsx
1.16 kB
| import { Modal } from './Modal' | |
| import { Button } from './Button' | |
| import type { ReactNode } from 'react' | |
| type ConfirmDialogProps = { | |
| open: boolean | |
| onClose: () => void | |
| onConfirm: () => void | Promise<void> | |
| title: string | |
| body: ReactNode | |
| confirmLabel: string | |
| cancelLabel: string | |
| confirmVariant?: 'primary' | 'danger' | |
| loading?: boolean | |
| } | |
| export function ConfirmDialog({ | |
| open, | |
| onClose, | |
| onConfirm, | |
| title, | |
| body, | |
| confirmLabel, | |
| cancelLabel, | |
| confirmVariant = 'danger', | |
| loading = false, | |
| }: ConfirmDialogProps) { | |
| return ( | |
| <Modal | |
| open={open} | |
| onClose={loading ? () => {} : onClose} | |
| title={title} | |
| width={460} | |
| footer={( | |
| <> | |
| <Button variant="secondary" onClick={onClose} disabled={loading}> | |
| {cancelLabel} | |
| </Button> | |
| <Button variant={confirmVariant} onClick={() => void onConfirm()} loading={loading}> | |
| {confirmLabel} | |
| </Button> | |
| </> | |
| )} | |
| > | |
| {typeof body === 'string' ? ( | |
| <p className="text-sm leading-6 text-[var(--color-text-secondary)]"> | |
| {body} | |
| </p> | |
| ) : body} | |
| </Modal> | |
| ) | |
| } | |