From 65734464d95415857c1264b30c5af1542917bf72 Mon Sep 17 00:00:00 2001
From: mumiao <1270865802zl@gmail.com>
Date: Tue, 18 Oct 2022 18:03:29 +0800
Subject: [PATCH 1/7] refactor: optimize modal confirm button style and fix
redundacy header for confirmDialog Component
---
src/components/dialog/confirmDialog.tsx | 17 ++++++++---------
src/components/dialog/modal.tsx | 4 ++--
src/components/dialog/style.scss | 22 ++++++++++++++--------
stories/components/17-Dialog.stories.tsx | 15 ++++++++++-----
4 files changed, 34 insertions(+), 24 deletions(-)
diff --git a/src/components/dialog/confirmDialog.tsx b/src/components/dialog/confirmDialog.tsx
index 34eae9c47..9a7837846 100644
--- a/src/components/dialog/confirmDialog.tsx
+++ b/src/components/dialog/confirmDialog.tsx
@@ -29,14 +29,14 @@ const ConfirmDialog = (props: ConfirmDialogProps) => {
onOk,
close,
maskStyle,
- okText = 'delete',
+ okText = 'Ok',
okButtonProps,
- cancelText = 'cancel',
+ cancelText = 'Cancel',
cancelButtonProps,
+ okCancel,
bodyStyle,
- closable = true,
+ closable = false,
className,
- okCancel,
width = 520,
style = {},
mask = true,
@@ -44,11 +44,10 @@ const ConfirmDialog = (props: ConfirmDialogProps) => {
transitionName = 'zoom',
maskTransitionName = 'fade',
type,
- ...resetProps
+ ...restProps
} = props;
const confirmDescriperClassName = iconConfirmClassName(type);
-
const classString = classNames(
confirmClassName,
confirmDescriperClassName,
@@ -73,16 +72,16 @@ const ConfirmDialog = (props: ConfirmDialogProps) => {
[centeredConfirmClassName]: !!props.centered,
})}
onCancel={() => close({ triggerCancel: true })}
- title=""
transitionName={transitionName}
- footer=""
maskTransitionName={maskTransitionName}
mask={mask}
maskClosable={maskClosable}
style={style}
width={width}
closable={closable}
- {...resetProps}
+ {...restProps}
+ footer=""
+ title=""
>
diff --git a/src/components/dialog/modal.tsx b/src/components/dialog/modal.tsx
index 087bb3cad..d6a1e48fc 100644
--- a/src/components/dialog/modal.tsx
+++ b/src/components/dialog/modal.tsx
@@ -89,8 +89,8 @@ export const Modal: React.FC
= (props: IModalProps) => {
centered,
getContainer,
closeIcon,
- cancelText = 'cancel',
- okText = 'ok',
+ cancelText = 'Cancel',
+ okText = 'Ok',
...restProps
} = props;
diff --git a/src/components/dialog/style.scss b/src/components/dialog/style.scss
index 0b2502087..fc1aa7761 100644
--- a/src/components/dialog/style.scss
+++ b/src/components/dialog/style.scss
@@ -63,16 +63,17 @@
background: var(--notificationCenterHeader-background);
color: var(--notificationCenterHeader-foreground);
font-size: 24px;
- padding: 16px 0;
+ padding: 16px 0px;
}
&-footer {
display: flex;
- font-size: 13px;
+ flex-direction: row;
justify-content: flex-end;
- padding: 20px 10px 10px;
-
- .mo-botton {
+ padding: 10px 16px;
+ border-radius: 0 0 2px 2px;
+ .mo-btn {
+ margin-left: 8px;
width: fit-content;
}
}
@@ -98,10 +99,10 @@
&--x {
display: block;
font-size: 16px;
- height: 40px;
+ height: 54px;
line-height: 40px;
text-align: center;
- width: 40px;
+ width: 54px;
}
}
}
@@ -155,7 +156,12 @@
&__btns {
display: flex;
+ flex-direction: row;
justify-content: flex-end;
- padding: 20px 10px 10px;
+ padding: 10px 16px;
+ .mo-btn {
+ margin-left: 8px;
+ width: fit-content;
+ }
}
}
diff --git a/stories/components/17-Dialog.stories.tsx b/stories/components/17-Dialog.stories.tsx
index ce167fa91..d5d9d6e80 100644
--- a/stories/components/17-Dialog.stories.tsx
+++ b/stories/components/17-Dialog.stories.tsx
@@ -24,14 +24,19 @@ stories.add('Basic Usage', () => {
function showConfirm() {
confirm({
- title: 'Are you sure you want to permanently delete ?',
- content: 'This action is irreversible!',
- cancelButtonProps: { disabled: true },
+ title: 'Tweet us your feedback',
+ content: (
+
+
Some contents...
+
Some contents...
+
Some contents...
+
+ ),
onOk() {
- console.log('OK');
+ console.log('onOk');
},
onCancel() {
- console.log('Cancel');
+ console.log('onCancel');
},
});
}
From 7a548be67f1947fee5c09456d6c3f1a1e743ec6e Mon Sep 17 00:00:00 2001
From: mumiao <1270865802zl@gmail.com>
Date: Fri, 21 Oct 2022 11:12:56 +0800
Subject: [PATCH 2/7] fix: resolve modal.confirm can not destory problems
---
src/components/dialog/actionButton.tsx | 19 ++++++++++---------
src/components/dialog/confirm.tsx | 9 ++-------
src/components/dialog/confirmDialog.tsx | 13 +++++--------
3 files changed, 17 insertions(+), 24 deletions(-)
diff --git a/src/components/dialog/actionButton.tsx b/src/components/dialog/actionButton.tsx
index d2d5333c2..1219e296f 100644
--- a/src/components/dialog/actionButton.tsx
+++ b/src/components/dialog/actionButton.tsx
@@ -2,20 +2,21 @@ import React, { useRef } from 'react';
import { Button, IButtonProps } from 'mo/components/button';
export interface ActionButtonProps extends IButtonProps {
actionFn?: (...args: any[]) => any | PromiseLike;
- closeModal: Function;
+ close?: Function;
+ buttonProps?: IButtonProps;
}
const ActionButton: React.FC = (props) => {
const clickedRef = useRef(false);
+ const { close } = props;
const handlePromiseOnOk = (returnValueOfOnOk?: PromiseLike) => {
- const { closeModal } = props;
if (!returnValueOfOnOk || !returnValueOfOnOk.then) {
return;
}
returnValueOfOnOk.then(
(...args: any[]) => {
- closeModal(...args);
+ close?.(...args);
},
(e: Error) => {
// eslint-disable-next-line no-console
@@ -26,32 +27,32 @@ const ActionButton: React.FC = (props) => {
};
const onClick = () => {
- const { actionFn, closeModal } = props;
+ const { actionFn, close } = props;
if (clickedRef.current) {
return;
}
clickedRef.current = true;
if (!actionFn) {
- closeModal();
+ close?.();
return;
}
let returnValueOfOnOk;
if (actionFn!.length) {
- returnValueOfOnOk = actionFn(closeModal);
+ returnValueOfOnOk = actionFn(close);
clickedRef.current = false;
} else {
returnValueOfOnOk = actionFn();
if (!returnValueOfOnOk) {
- closeModal();
+ close?.();
return;
}
}
handlePromiseOnOk(returnValueOfOnOk);
};
- const { children, ...resetProps } = props;
+ const { children, buttonProps } = props;
return (
-