Skip to content

Commit

Permalink
docs: optimization doc
Browse files Browse the repository at this point in the history
  • Loading branch information
RedJue committed Aug 22, 2023
1 parent 71b2175 commit 6adc8c6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
12 changes: 10 additions & 2 deletions components/modal/index.en-US.md
Expand Up @@ -54,7 +54,7 @@ Common props ref:[Common props](/docs/react/common-props)
| confirmLoading | Whether to apply loading visual effect for OK button or not | boolean | false | |
| destroyOnClose | Whether to unmount child components on onClose | boolean | false | |
| focusTriggerAfterClose | Whether need to focus trigger element after dialog is closed | boolean | true | 4.9.0 |
| footer | Footer content, set as `footer={null}` when you don't need default buttons | (originNode: React.ReactNode, extra: { ConfirmBtn: FC; CancelBtn: FC }) => React.ReactNode \| React.ReactNode | (OK and Cancel buttons) | |
| footer | Footer content, set as `footer={null}` when you don't need default buttons | (params:[footerRenderParams](/components/modal-cn#footerrenderparams))=> React.ReactNode \| React.ReactNode | (OK and Cancel buttons) | |
| forceRender | Force render Modal | boolean | false | |
| getContainer | The mounted node for Modal but still display at fullscreen | HTMLElement \| () => HTMLElement \| Selectors \| false | document.body | |
| keyboard | Whether support press esc to close | boolean | true | |
Expand Down Expand Up @@ -104,7 +104,7 @@ The items listed above are all functions, expecting a settings object as paramet
| className | The className of container | string | - | |
| closeIcon | Custom close icon. 5.7.0: close button will be hidden when setting to `null` or `false` | boolean \| ReactNode | <CloseOutlined /> | |
| content | Content | ReactNode | - | |
| footer | Footer content, set as `footer: null` when you don't need default buttons | (originNode: React.ReactNode, extra: { ConfirmBtn: FC; CancelBtn: FC }) => React.ReactNode \| React.ReactNode | - | 5.9.0 |
| footer | Footer content, set as `footer: null` when you don't need default buttons | (params:[footerRenderParams](/components/modal-cn#footerrenderparams))=> React.ReactNode \| React.ReactNode | - | 5.9.0 |
| getContainer | Return the mount node for Modal | HTMLElement \| () => HTMLElement \| Selectors \| false | document.body | |
| icon | Custom icon | ReactNode | <ExclamationCircleFilled /> | |
| keyboard | Whether support press esc to close | boolean | true | |
Expand Down Expand Up @@ -181,6 +181,14 @@ return <div>{contextHolder}</div>;
const confirmed = await modal.confirm({ ... });
```

## footerRenderParams

<!-- prettier-ignore -->
| Property | Description | Type | Default |
| --- | --- | --- | --- |
| originNode | default node | React.ReactNode | - |
| extra | extended options | { ConfirmBtn: FC; CancelBtn: FC } | - |

## Design Token

<ComponentTokenTable component="Modal"></ComponentTokenTable>
Expand Down
12 changes: 10 additions & 2 deletions components/modal/index.zh-CN.md
Expand Up @@ -55,7 +55,7 @@ demo:
| confirmLoading | 确定按钮 loading | boolean | false | |
| destroyOnClose | 关闭时销毁 Modal 里的子元素 | boolean | false | |
| focusTriggerAfterClose | 对话框关闭后是否需要聚焦触发元素 | boolean | true | 4.9.0 |
| footer | 底部内容,当不需要默认底部按钮时,可以设为 `footer={null}` | (originNode: React.ReactNode, extra: { ConfirmBtn: FC; CancelBtn: FC }) => React.ReactNode \| React.ReactNode | (确定取消按钮) | 5.9.0 |
| footer | 底部内容,当不需要默认底部按钮时,可以设为 `footer={null}` | (params:[footerRenderParams](/components/modal-cn#footerrenderparams))=> React.ReactNode \| React.ReactNode | (确定取消按钮) | 5.9.0 |
| forceRender | 强制渲染 Modal | boolean | false | |
| getContainer | 指定 Modal 挂载的节点,但依旧为全屏展示,`false` 为挂载在当前位置 | HTMLElement \| () => HTMLElement \| Selectors \| false | document.body | |
| keyboard | 是否支持键盘 esc 关闭 | boolean | true | |
Expand Down Expand Up @@ -105,7 +105,7 @@ demo:
| className | 容器类名 | string | - | |
| closeIcon | 自定义关闭图标。5.7.0:设置为 `null``false` 时隐藏关闭按钮 | boolean \| ReactNode | &lt;CloseOutlined /> | |
| content | 内容 | ReactNode | - | |
| footer | 底部内容,当不需要默认底部按钮时,可以设为 `footer: null` | (originNode: React.ReactNode, extra: { ConfirmBtn: FC; CancelBtn: FC }) => React.ReactNode \| React.ReactNode | - | 5.9.0 |
| footer | 底部内容,当不需要默认底部按钮时,可以设为 `footer: null` | (params:[footerRenderParams](/components/modal-cn#footerrenderparams))=> React.ReactNode \| React.ReactNode | - | 5.9.0 |
| getContainer | 指定 Modal 挂载的 HTML 节点, false 为挂载在当前 dom | HTMLElement \| () => HTMLElement \| Selectors \| false | document.body | |
| icon | 自定义图标 | ReactNode | &lt;ExclamationCircleFilled /> | |
| keyboard | 是否支持键盘 esc 关闭 | boolean | true | |
Expand Down Expand Up @@ -182,6 +182,14 @@ return <div>{contextHolder}</div>;
const confirmed = await modal.confirm({ ... });
```

## footerRenderParams

<!-- prettier-ignore -->
| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| originNode | 默认节点 | React.ReactNode | - |
| extra | 扩展选项 | { ConfirmBtn: FC; CancelBtn: FC } | - |

## Design Token

<ComponentTokenTable component="Modal"></ComponentTokenTable>
Expand Down
8 changes: 5 additions & 3 deletions components/modal/interface.ts
Expand Up @@ -2,6 +2,10 @@ 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 },
) => React.ReactNode;
export interface ModalProps {
/** Whether the modal dialog is visible or not */
open?: boolean;
Expand All @@ -23,9 +27,7 @@ export interface ModalProps {
/** Width of the modal dialog */
width?: string | number;
/** Footer content */
footer?:
| ((originNode: React.ReactNode, extra: { ConfirmBtn: FC; CancelBtn: FC }) => React.ReactNode)
| React.ReactNode;
footer?: ModalFooterRender | React.ReactNode;
/** Text of the OK button */
okText?: React.ReactNode;
/** Button `type` of the OK button */
Expand Down

0 comments on commit 6adc8c6

Please sign in to comment.