Skip to content

Commit

Permalink
feat: optimize actionButton interface
Browse files Browse the repository at this point in the history
  • Loading branch information
mumiao committed Dec 12, 2020
1 parent d6200a9 commit aca2fbb
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/components/dialog/ConfirmDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const ConfirmDialog = (props: ConfirmDialogProps) => {
<ActionButton
actionFn={onCancel}
closeModal={close}
buttonProps={cancelButtonProps}
{...cancelButtonProps}
>
{cancelText}
</ActionButton>
Expand Down Expand Up @@ -119,7 +119,7 @@ const ConfirmDialog = (props: ConfirmDialogProps) => {
<ActionButton
actionFn={onOk}
closeModal={close}
buttonProps={okButtonProps}
{...okButtonProps}
>
{okText}
</ActionButton>
Expand Down
7 changes: 3 additions & 4 deletions src/components/dialog/actionButton.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import * as React from 'react';
import { Button, IButton } from 'mo/components/button';
export interface ActionButtonProps {
export interface ActionButtonProps extends IButton{
actionFn?: (...args: any[]) => any | PromiseLike<any>;
closeModal: Function;
buttonProps?: IButton;
}

const ActionButton: React.FC<ActionButtonProps> = (props) => {
Expand Down Expand Up @@ -50,9 +49,9 @@ const ActionButton: React.FC<ActionButtonProps> = (props) => {
handlePromiseOnOk(returnValueOfOnOk);
};

const { children, buttonProps } = props;
const { children, ...resetProps } = props;
return (
<Button onClick={onClick} {...buttonProps}>
<Button onClick={onClick} {...resetProps}>
{children}
</Button>
);
Expand Down
1 change: 0 additions & 1 deletion src/components/dialog/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
&-content {
font-size: 18px;
padding: 0 15px;
pointer-events: auto;
position: relative;
}

Expand Down
1 change: 1 addition & 0 deletions stories/components/17-Dialog.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ stories.add('Basic Usage', () => {
confirm({
title: 'Are you sure you want to permanently delete ?',
content: 'This action is irreversible!',
cancelButtonProps: { disabled: true },
onOk() {
console.log('OK');
},
Expand Down

0 comments on commit aca2fbb

Please sign in to comment.