Update dialog logic to support defining buttons/icon from anywhere
This commit is contained in:
parent
48af9bced1
commit
7c4028f8f1
9 changed files with 182 additions and 121 deletions
|
@ -1,9 +1,9 @@
|
|||
import React from 'react';
|
||||
import { Dialog } from '@/components/elements/dialog/index';
|
||||
import { DialogProps } from '@/components/elements/dialog/Dialog';
|
||||
import { FullDialogProps } from '@/components/elements/dialog/Dialog';
|
||||
import { Button } from '@/components/elements/button/index';
|
||||
|
||||
type ConfirmationProps = Omit<DialogProps, 'description' | 'children'> & {
|
||||
type ConfirmationProps = Omit<FullDialogProps, 'description' | 'children'> & {
|
||||
children: React.ReactNode;
|
||||
confirm?: string | undefined;
|
||||
onConfirmed: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
||||
|
@ -13,10 +13,10 @@ export default ({ confirm = 'Okay', children, onConfirmed, ...props }: Confirmat
|
|||
return (
|
||||
<Dialog {...props} description={typeof children === 'string' ? children : undefined}>
|
||||
{typeof children !== 'string' && children}
|
||||
<Dialog.Buttons>
|
||||
<Dialog.Footer>
|
||||
<Button.Text onClick={props.onClose}>Cancel</Button.Text>
|
||||
<Button.Danger onClick={onConfirmed}>{confirm}</Button.Danger>
|
||||
</Dialog.Buttons>
|
||||
</Dialog.Footer>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue