Skip to content

Commit aca2fbb

Browse files
committed
feat: optimize actionButton interface
1 parent d6200a9 commit aca2fbb

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

src/components/dialog/ConfirmDialog.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const ConfirmDialog = (props: ConfirmDialogProps) => {
5959
<ActionButton
6060
actionFn={onCancel}
6161
closeModal={close}
62-
buttonProps={cancelButtonProps}
62+
{...cancelButtonProps}
6363
>
6464
{cancelText}
6565
</ActionButton>
@@ -119,7 +119,7 @@ const ConfirmDialog = (props: ConfirmDialogProps) => {
119119
<ActionButton
120120
actionFn={onOk}
121121
closeModal={close}
122-
buttonProps={okButtonProps}
122+
{...okButtonProps}
123123
>
124124
{okText}
125125
</ActionButton>

src/components/dialog/actionButton.tsx

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import * as React from 'react';
22
import { Button, IButton } from 'mo/components/button';
3-
export interface ActionButtonProps {
3+
export interface ActionButtonProps extends IButton{
44
actionFn?: (...args: any[]) => any | PromiseLike<any>;
55
closeModal: Function;
6-
buttonProps?: IButton;
76
}
87

98
const ActionButton: React.FC<ActionButtonProps> = (props) => {
@@ -50,9 +49,9 @@ const ActionButton: React.FC<ActionButtonProps> = (props) => {
5049
handlePromiseOnOk(returnValueOfOnOk);
5150
};
5251

53-
const { children, buttonProps } = props;
52+
const { children, ...resetProps } = props;
5453
return (
55-
<Button onClick={onClick} {...buttonProps}>
54+
<Button onClick={onClick} {...resetProps}>
5655
{children}
5756
</Button>
5857
);

src/components/dialog/style.scss

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
&-content {
4747
font-size: 18px;
4848
padding: 0 15px;
49-
pointer-events: auto;
5049
position: relative;
5150
}
5251

stories/components/17-Dialog.stories.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ stories.add('Basic Usage', () => {
2828
confirm({
2929
title: 'Are you sure you want to permanently delete ?',
3030
content: 'This action is irreversible!',
31+
cancelButtonProps: { disabled: true },
3132
onOk() {
3233
console.log('OK');
3334
},

0 commit comments

Comments
 (0)