Browse Source

feat(Empty): description prop support undefined/null value to remove description node

pull/17659/head
wadezhan 5 years ago
parent
commit
5df766fb5b
  1. 2
      components/empty/__tests__/index.test.js
  2. 2
      components/empty/demo/description.md
  3. 2
      components/empty/index.en-US.md
  4. 4
      components/empty/index.tsx
  5. 2
      components/empty/index.zh-CN.md

2
components/empty/__tests__/index.test.js

@ -9,7 +9,7 @@ describe('Empty', () => {
});
it('description can be false', () => {
const wrapper = mount(<Empty description={false} />);
const wrapper = mount(<Empty description={undefined} />);
expect(wrapper.find('.ant-empty-description').length).toBe(0);
});
});

2
components/empty/demo/description.md

@ -16,5 +16,5 @@ Simplest Usage with no description.
```jsx
import { Empty } from 'antd';
ReactDOM.render(<Empty description={false} />, mountNode);
ReactDOM.render(<Empty description={undefined} />, mountNode);
```

2
components/empty/index.en-US.md

@ -22,7 +22,7 @@ Empty state placeholder.
| Property | Description | Type | Default | Version |
| --- | --- | --- | --- | --- |
| description | Customize description | string \| ReactNode \| boolean | - | 3.12.0 |
| description | Customize description | string \| ReactNode | - | 3.12.0 |
| imageStyle | style of image | CSSProperties | - | 3.16.0 |
| image | Customize image. Will tread as image url when string provided. | string \| ReactNode | `Empty.PRESENTED_IMAGE_DEFAULT` | 3.12.0 |

4
components/empty/index.tsx

@ -18,7 +18,7 @@ export interface EmptyProps {
*/
imageStyle?: React.CSSProperties;
image?: React.ReactNode;
description?: React.ReactNode | boolean;
description?: React.ReactNode;
children?: React.ReactNode;
}
@ -39,7 +39,7 @@ const OriginEmpty: React.SFC<EmptyProps> = (props: EmptyProps) => (
<LocaleReceiver componentName="Empty">
{(locale: TransferLocale) => {
const prefixCls = getPrefixCls('empty', customizePrefixCls);
const des = typeof description === 'boolean' ? description : (description || locale.description);
const des = description == null ? description : (description || locale.description);
const alt = typeof des === 'string' ? des : 'empty';
let imageNode: React.ReactNode = null;

2
components/empty/index.zh-CN.md

@ -23,7 +23,7 @@ cols: 1
| 参数 | 说明 | 类型 | 默认值 | 版本 |
| --- | --- | --- | --- | --- |
| description | 自定义描述内容 | string \| ReactNode \| boolean | - | 3.12.0 |
| description | 自定义描述内容 | string \| ReactNode | - | 3.12.0 |
| imageStyle | 图片样式 | CSSProperties | - | 3.16.0 |
| image | 设置显示图片,为 string 时表示自定义图片地址。 | string \| ReactNode | `Empty.PRESENTED_IMAGE_DEFAULT` | 3.12.0 |

Loading…
Cancel
Save