Skip to content

Commit

Permalink
refactor: rename ConfirmBtn to OkBtn
Browse files Browse the repository at this point in the history
  • Loading branch information
RedJue committed Aug 28, 2023
1 parent 0769072 commit 134c935
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 17 deletions.
6 changes: 3 additions & 3 deletions components/modal/ConfirmDialog.tsx
Expand Up @@ -11,7 +11,7 @@ import type { ThemeConfig } from '../config-provider';
import ConfigProvider from '../config-provider';
import { useLocale } from '../locale';
import CancelBtn from './components/ConfirmCancelBtn';
import ConfirmBtn from './components/ConfirmOkBtn';
import OkBtn from './components/ConfirmOkBtn';
import type { ModalContextProps } from './context';
import { ModalContextProvider } from './context';
import type { ModalFuncProps, ModalLocale } from './interface';
Expand Down Expand Up @@ -114,7 +114,7 @@ export function ConfirmContent(
const footerOriginNode = (
<>
<CancelBtn />
<ConfirmBtn />
<OkBtn />
</>
);

Expand All @@ -133,7 +133,7 @@ export function ConfirmContent(
<div className={`${confirmPrefixCls}-btns`}>
{typeof footer === 'function'
? footer(footerOriginNode, {
ConfirmBtn,
OkBtn,
CancelBtn,
})
: footerOriginNode}
Expand Down
7 changes: 4 additions & 3 deletions components/modal/__tests__/Modal.test.tsx
@@ -1,10 +1,11 @@
import React, { useEffect } from 'react';

import type { ModalProps } from '..';
import Modal from '..';
import { resetWarned } from '../../_util/warning';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
import { fireEvent, render } from '../../../tests/utils';
import { resetWarned } from '../../_util/warning';

jest.mock('rc-util/lib/Portal');

Expand Down Expand Up @@ -138,9 +139,9 @@ describe('Modal', () => {
render(
<Modal
open
footer={(_, { ConfirmBtn, CancelBtn }) => (
footer={(_, { OkBtn, CancelBtn }) => (
<>
<ConfirmBtn />
<OkBtn />
<CancelBtn />
<div className="custom-footer-ele">footer-ele</div>
</>
Expand Down
7 changes: 4 additions & 3 deletions components/modal/__tests__/confirm.test.tsx
@@ -1,10 +1,11 @@
import * as React from 'react';
import { SmileOutlined } from '@ant-design/icons';
import CSSMotion from 'rc-motion';
import { genCSSMotion } from 'rc-motion/lib/CSSMotion';
import KeyCode from 'rc-util/lib/KeyCode';
import { resetWarned } from 'rc-util/lib/warning';
import * as React from 'react';
import TestUtils from 'react-dom/test-utils';

import type { ModalFuncProps } from '..';
import Modal from '..';
import { act, waitFakeTimer } from '../../../tests/utils';
Expand Down Expand Up @@ -849,9 +850,9 @@ describe('Modal.confirm triggers callbacks correctly', () => {
it('Should custom footer function work width confirm', async () => {
Modal.confirm({
content: 'hai',
footer: (_, { ConfirmBtn, CancelBtn }) => (
footer: (_, { OkBtn, CancelBtn }) => (
<>
<ConfirmBtn />
<OkBtn />
<CancelBtn />
<div className="custom-footer-ele">footer-ele</div>
</>
Expand Down
8 changes: 4 additions & 4 deletions components/modal/demo/footer-render.tsx
Expand Up @@ -26,11 +26,11 @@ const App: React.FC = () => {
Modal.confirm({
title: 'Confirm',
content: 'Bla bla ...',
footer: (_, { ConfirmBtn, CancelBtn }) => (
footer: (_, { OkBtn, CancelBtn }) => (
<>
<Button>Custom Button</Button>
<CancelBtn />
<ConfirmBtn />
<OkBtn />
</>
),
});
Expand All @@ -44,11 +44,11 @@ const App: React.FC = () => {
title="Title"
onOk={handleOk}
onCancel={handleCancel}
footer={(_, { ConfirmBtn, CancelBtn }) => (
footer={(_, { OkBtn, CancelBtn }) => (
<>
<Button>Custom Button</Button>
<CancelBtn />
<ConfirmBtn />
<OkBtn />
</>
)}
>
Expand Down
2 changes: 1 addition & 1 deletion components/modal/index.en-US.md
Expand Up @@ -187,7 +187,7 @@ const confirmed = await modal.confirm({ ... });
| Property | Description | Type | Default |
| --- | --- | --- | --- |
| originNode | default node | React.ReactNode | - |
| extra | extended options | { ConfirmBtn: FC; CancelBtn: FC } | - |
| extra | extended options | { OkBtn: FC; CancelBtn: FC } | - |

## Design Token

Expand Down
2 changes: 1 addition & 1 deletion components/modal/index.zh-CN.md
Expand Up @@ -188,7 +188,7 @@ const confirmed = await modal.confirm({ ... });
| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| originNode | 默认节点 | React.ReactNode | - |
| extra | 扩展选项 | { ConfirmBtn: FC; CancelBtn: FC } | - |
| extra | 扩展选项 | { OkBtn: FC; CancelBtn: FC } | - |

## Design Token

Expand Down
3 changes: 2 additions & 1 deletion components/modal/interface.ts
@@ -1,10 +1,11 @@
import type { FC } from 'react';

import type { ButtonProps, LegacyButtonType } from '../button/button';
import type { DirectionType } from '../config-provider';

export type ModalFooterRender = (
originNode: React.ReactNode,
extra: { ConfirmBtn: FC; CancelBtn: FC },
extra: { OkBtn: FC; CancelBtn: FC },
) => React.ReactNode;
export interface ModalProps {
/** Whether the modal dialog is visible or not */
Expand Down
2 changes: 1 addition & 1 deletion components/modal/shared.tsx
Expand Up @@ -80,7 +80,7 @@ export const Footer: React.FC<
<ModalContextProvider value={btnCtxValueMemo}>
{typeof footer === 'function'
? footer(footerOriginNode, {
ConfirmBtn: NormalOkBtn,
OkBtn: NormalOkBtn,
CancelBtn: NormalCancelBtn,
})
: footerOriginNode}
Expand Down

0 comments on commit 134c935

Please sign in to comment.