mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-11 21:11:36 +01:00
34 lines
805 B
TypeScript
34 lines
805 B
TypeScript
import type { Color } from '@yaakapp-internal/plugins';
|
|
import { Button } from './Button';
|
|
import { HStack } from './Stacks';
|
|
|
|
export interface ConfirmProps {
|
|
onHide: () => void;
|
|
onResult: (result: boolean) => void;
|
|
confirmText?: string;
|
|
color?: Color;
|
|
}
|
|
|
|
export function Confirm({ onHide, onResult, confirmText, color = 'primary' }: ConfirmProps) {
|
|
const handleHide = () => {
|
|
onResult(false);
|
|
onHide();
|
|
};
|
|
|
|
const handleSuccess = () => {
|
|
onResult(true);
|
|
onHide();
|
|
};
|
|
|
|
return (
|
|
<HStack space={2} justifyContent="start" className="mt-2 mb-4 flex-row-reverse">
|
|
<Button color={color} onClick={handleSuccess}>
|
|
{confirmText ?? 'Confirm'}
|
|
</Button>
|
|
<Button onClick={handleHide} variant="border">
|
|
Cancel
|
|
</Button>
|
|
</HStack>
|
|
);
|
|
}
|