Skip to content

Commit

Permalink
feat: Popconfirm title and description props
Browse files Browse the repository at this point in the history
feat: Popconfirm title and description props(update partial docs)

feat: Popconfirm title and description props(change the title display logicv)

feat: Popconfirm title and description props(change the title display logic )2
  • Loading branch information
xhh0223 committed Dec 5, 2022
1 parent e85da35 commit c6728e0
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 2 deletions.
11 changes: 10 additions & 1 deletion components/popconfirm/PurePanel.tsx
Expand Up @@ -29,6 +29,7 @@ export interface OverlayProps
| 'okType'
| 'showCancel'
| 'title'
| 'description'
> {
prefixCls: string;
close?: Function;
Expand All @@ -42,6 +43,7 @@ export const Overlay: React.FC<OverlayProps> = (props) => {
okButtonProps,
cancelButtonProps,
title,
description,
cancelText,
okText,
okType = 'primary',
Expand All @@ -60,8 +62,15 @@ export const Overlay: React.FC<OverlayProps> = (props) => {
<div className={`${prefixCls}-inner-content`}>
<div className={`${prefixCls}-message`}>
{icon && <span className={`${prefixCls}-message-icon`}>{icon}</span>}
<div className={`${prefixCls}-message-title`}>{getRenderPropValue(title)}</div>
<div
className={classNames(`${prefixCls}-message-title`, {
[`${prefixCls}-message-title-only`]: !!description,
})}
>
{getRenderPropValue(title)}
</div>
</div>
<div className={`${prefixCls}-description`}>{getRenderPropValue(description)}</div>
<div className={`${prefixCls}-buttons`}>
{showCancel && (
<Button onClick={onCancel} size="small" {...cancelButtonProps}>
Expand Down
3 changes: 2 additions & 1 deletion components/popconfirm/demo/basic.tsx
Expand Up @@ -13,7 +13,8 @@ const cancel = (e: React.MouseEvent<HTMLElement>) => {

const App: React.FC = () => (
<Popconfirm
title="Are you sure to delete this task?"
title="删除任务"
description="Are you sure to delete this task?"
onConfirm={confirm}
onCancel={cancel}
okText="Yes"
Expand Down
1 change: 1 addition & 0 deletions components/popconfirm/index.en-US.md
Expand Up @@ -40,6 +40,7 @@ The difference with the `confirm` modal dialog is that it's more lightweight tha
| okType | Button `type` of the Confirm button | string | `primary` | |
| showCancel | Show cancel button | boolean | true | 4.18.0 |
| title | The title of the confirmation box | ReactNode \| () => ReactNode | - | |
| title | The description of the confirmation box title | ReactNode \| () => ReactNode | - | |
| onCancel | A callback of cancel | function(e) | - | |
| onConfirm | A callback of confirmation | function(e) | - | |

Expand Down
1 change: 1 addition & 0 deletions components/popconfirm/index.tsx
Expand Up @@ -15,6 +15,7 @@ import usePopconfirmStyle from './style';

export interface PopconfirmProps extends AbstractTooltipProps {
title: React.ReactNode | RenderFunction;
description?: React.ReactNode | RenderFunction;
disabled?: boolean;
onConfirm?: (e?: React.MouseEvent<HTMLElement>) => void;
onCancel?: (e?: React.MouseEvent<HTMLElement>) => void;
Expand Down
1 change: 1 addition & 0 deletions components/popconfirm/index.zh-CN.md
Expand Up @@ -41,6 +41,7 @@ demo:
| okType | 确认按钮类型 | string | `primary` | |
| showCancel | 是否显示取消按钮 | boolean | true | 4.18.0 |
| title | 确认框的描述 | ReactNode \| () => ReactNode | - | |
| description | 对确认框标题的描述 | ReactNode \| () => ReactNode | - | |
| onCancel | 点击取消的回调 | function(e) | - | |
| onConfirm | 点击确认的回调 | function(e) | - | |

Expand Down
13 changes: 13 additions & 0 deletions components/popconfirm/style/index.tsx
Expand Up @@ -17,6 +17,7 @@ const genBaseStyle: GenerateStyle<PopconfirmToken> = (token) => {
colorWarning,
marginXS,
fontSize,
fontWeightStrong,
lineHeight,
} = token;

Expand Down Expand Up @@ -49,6 +50,18 @@ const genBaseStyle: GenerateStyle<PopconfirmToken> = (token) => {
flex: 'auto',
marginInlineStart: marginXS,
},

'&-title-only': {
fontWeight: fontWeightStrong,
},
},

[`${componentCls}-description`]: {
position: 'relative',
marginInlineStart: fontSize + marginXS,
marginBottom: marginXS,
color: colorText,
fontSize,
},

[`${componentCls}-buttons`]: {
Expand Down

0 comments on commit c6728e0

Please sign in to comment.