Skip to content

File tree

3 files changed

+101
-72
lines changed

3 files changed

+101
-72
lines changed
 

‎src/packages/dialog/dialog.scss

+2-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
align-items: center;
99
width: $dialog-width;
1010
min-width: $dialog-min-width;
11+
/* #ifndef harmony*/
1112
max-height: 67%;
13+
/* #endif */
1214
min-height: $dialog-min-height;
1315
padding: $dialog-padding;
1416
box-sizing: border-box;
@@ -112,15 +114,10 @@
112114
min-width: 100%;
113115
}
114116

115-
.nut-dialog-footer-ok {
116-
order: 1;
117-
}
118-
119117
.nut-dialog-footer-cancel {
120118
margin: 0;
121119
color: $color-text;
122120
font-size: $font-size-base;
123-
order: 2;
124121
display: flex;
125122
justify-content: center;
126123
margin-top: $dialog-vertical-footer-ok-margin-top;

‎src/packages/dialog/dialog.taro.tsx

+98-67
Original file line numberDiff line numberDiff line change
@@ -122,43 +122,68 @@ export const BaseDialog: FunctionComponent<Partial<DialogBasicProps>> & {
122122
const btnClass =
123123
hideCancelButton || hideConfirmButton ? `${classPrefix}-footer-block` : ''
124124

125+
const renderCancelOfVertical = () => {
126+
return (
127+
!hideCancelButton && (
128+
<View
129+
className={`${classPrefix}-footer-cancel ${btnClass}`}
130+
onClick={(e: ITouchEvent) => handleCancel(e)}
131+
>
132+
{cancelText || locale.cancel}
133+
</View>
134+
)
135+
)
136+
}
137+
138+
const renderCancel = () => {
139+
return (
140+
!hideCancelButton && (
141+
<Button
142+
type="default"
143+
size="large"
144+
className={`${classPrefix}-footer-cancel ${btnClass}`}
145+
onClick={(e: React.MouseEvent<HTMLButtonElement>) =>
146+
handleCancel(e)
147+
}
148+
>
149+
{cancelText || locale.cancel}
150+
</Button>
151+
)
152+
)
153+
}
154+
155+
const renderConfirm = () => {
156+
return (
157+
!hideConfirmButton && (
158+
<Button
159+
size="large"
160+
type="primary"
161+
className={classNames(`${classPrefix}-footer-ok ${btnClass}`, {
162+
disabled: disableConfirmButton,
163+
})}
164+
disabled={disableConfirmButton}
165+
onClick={(e: React.MouseEvent<HTMLButtonElement>) => handleOk(e)}
166+
loading={loading}
167+
>
168+
{confirmText || locale.confirm}
169+
</Button>
170+
)
171+
)
172+
}
173+
125174
return (
126175
footer || (
127176
<>
128-
{!hideCancelButton &&
129-
(footerDirection === 'vertical' ? (
130-
<View
131-
className={`${classPrefix}-footer-cancel ${btnClass}`}
132-
onClick={(e: ITouchEvent) => handleCancel(e)}
133-
>
134-
{cancelText || locale.cancel}
135-
</View>
136-
) : (
137-
<Button
138-
type="default"
139-
size="large"
140-
className={`${classPrefix}-footer-cancel ${btnClass}`}
141-
onClick={(e: React.MouseEvent<HTMLButtonElement>) =>
142-
handleCancel(e)
143-
}
144-
>
145-
{cancelText || locale.cancel}
146-
</Button>
147-
))}
148-
149-
{!hideConfirmButton && (
150-
<Button
151-
size="large"
152-
type="primary"
153-
className={classNames(`${classPrefix}-footer-ok ${btnClass}`, {
154-
disabled: disableConfirmButton,
155-
})}
156-
disabled={disableConfirmButton}
157-
onClick={(e: React.MouseEvent<HTMLButtonElement>) => handleOk(e)}
158-
loading={loading}
159-
>
160-
{confirmText || locale.confirm}
161-
</Button>
177+
{footerDirection === 'vertical' ? (
178+
<>
179+
{renderConfirm()}
180+
{renderCancelOfVertical()}
181+
</>
182+
) : (
183+
<>
184+
{renderCancel()}
185+
{renderConfirm()}
186+
</>
162187
)}
163188
</>
164189
)
@@ -193,46 +218,52 @@ export const BaseDialog: FunctionComponent<Partial<DialogBasicProps>> & {
193218
}
194219
}
195220

221+
const renderContent = () => {
222+
return (
223+
<CSSTransition
224+
in={visible}
225+
timeout={300}
226+
classNames="fadeDialog"
227+
unmountOnExit
228+
appear
229+
>
230+
<Content
231+
className={className}
232+
style={style}
233+
title={title}
234+
header={header}
235+
close={renderCloseIcon()}
236+
footer={renderFooter()}
237+
footerDirection={footerDirection}
238+
visible={visible}
239+
>
240+
{content || children}
241+
</Content>
242+
</CSSTransition>
243+
)
244+
}
245+
196246
return (
197247
<View
198248
style={{ display: visible ? 'block' : 'none' }}
199249
ref={refObject}
200250
catchMove={lockScroll}
201251
>
202-
<>
203-
{overlay && (
204-
<Overlay
205-
zIndex={zIndex}
206-
visible={visible}
207-
style={overlayStyle}
208-
className={overlayClassName}
209-
closeOnOverlayClick={closeOnOverlayClick}
210-
lockScroll={lockScroll}
211-
onClick={onHandleClickOverlay}
212-
/>
213-
)}
214-
215-
<CSSTransition
216-
in={visible}
217-
timeout={300}
218-
classNames="fadeDialog"
219-
unmountOnExit
220-
appear
252+
{overlay ? (
253+
<Overlay
254+
zIndex={zIndex}
255+
visible={visible}
256+
style={overlayStyle}
257+
className={overlayClassName}
258+
closeOnOverlayClick={closeOnOverlayClick}
259+
lockScroll={lockScroll}
260+
onClick={onHandleClickOverlay}
221261
>
222-
<Content
223-
className={className}
224-
style={style}
225-
title={title}
226-
header={header}
227-
close={renderCloseIcon()}
228-
footer={renderFooter()}
229-
footerDirection={footerDirection}
230-
visible={visible}
231-
>
232-
{content || children}
233-
</Content>
234-
</CSSTransition>
235-
</>
262+
{renderContent()}
263+
</Overlay>
264+
) : (
265+
renderContent()
266+
)}
236267
</View>
237268
)
238269
}

‎src/packages/dialog/dialog.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ const BaseDialog: ForwardRefRenderFunction<
9393
{!hideCancelButton &&
9494
(footerDirection === 'vertical' ? (
9595
<div
96+
style={{ order: 2 }}
9697
className={`${classPrefix}-footer-cancel ${btnClass}`}
9798
onClick={(e) => handleCancel(e)}
9899
>

0 commit comments

Comments
 (0)
Please sign in to comment.