diff --git a/components/empty/__tests__/index.test.js b/components/empty/__tests__/index.test.js index 7b37cdc823..a883a7cd20 100644 --- a/components/empty/__tests__/index.test.js +++ b/components/empty/__tests__/index.test.js @@ -7,4 +7,9 @@ describe('Empty', () => { const wrapper = mount(); expect(wrapper.find('.ant-empty-image').props().style.height).toBe(20); }); + + it('description can be false', () => { + const wrapper = mount(); + expect(wrapper.find('.ant-empty-description').length).toBe(0); + }); }); diff --git a/components/empty/demo/description.md b/components/empty/demo/description.md new file mode 100644 index 0000000000..f0202177bd --- /dev/null +++ b/components/empty/demo/description.md @@ -0,0 +1,20 @@ +--- +order: 0 +title: + zh-CN: 无描述 + en-US: Basic +--- + +## zh-CN + +无描述展示。 + +## en-US + +Simplest Usage with no description. + +```jsx +import { Empty } from 'antd'; + +ReactDOM.render(, mountNode); +``` diff --git a/components/empty/index.en-US.md b/components/empty/index.en-US.md index 1ed5f68be6..6061cc0171 100644 --- a/components/empty/index.en-US.md +++ b/components/empty/index.en-US.md @@ -22,7 +22,7 @@ Empty state placeholder. | Property | Description | Type | Default | Version | | --- | --- | --- | --- | --- | -| description | Customize description | string \| ReactNode | - | 3.12.0 | +| description | Customize description | string \| ReactNode \| boolean | - | 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 | diff --git a/components/empty/index.tsx b/components/empty/index.tsx index ef1fffc2c5..aa259b1772 100644 --- a/components/empty/index.tsx +++ b/components/empty/index.tsx @@ -18,7 +18,7 @@ export interface EmptyProps { */ imageStyle?: React.CSSProperties; image?: React.ReactNode; - description?: React.ReactNode; + description?: React.ReactNode | boolean; children?: React.ReactNode; } @@ -39,7 +39,7 @@ const OriginEmpty: React.SFC = (props: EmptyProps) => ( {(locale: TransferLocale) => { const prefixCls = getPrefixCls('empty', customizePrefixCls); - const des = description || locale.description; + const des = typeof description === 'boolean' ? description : (description || locale.description); const alt = typeof des === 'string' ? des : 'empty'; let imageNode: React.ReactNode = null; @@ -64,7 +64,7 @@ const OriginEmpty: React.SFC = (props: EmptyProps) => (
{imageNode}
-

{des}

+ {des &&

{des}

} {children &&
{children}
} ); diff --git a/components/empty/index.zh-CN.md b/components/empty/index.zh-CN.md index b7c31b46b4..b8fc93e614 100644 --- a/components/empty/index.zh-CN.md +++ b/components/empty/index.zh-CN.md @@ -23,7 +23,7 @@ cols: 1 | 参数 | 说明 | 类型 | 默认值 | 版本 | | --- | --- | --- | --- | --- | -| description | 自定义描述内容 | string \| ReactNode | - | 3.12.0 | +| description | 自定义描述内容 | string \| ReactNode \| boolean | - | 3.12.0 | | imageStyle | 图片样式 | CSSProperties | - | 3.16.0 | | image | 设置显示图片,为 string 时表示自定义图片地址。 | string \| ReactNode | `Empty.PRESENTED_IMAGE_DEFAULT` | 3.12.0 |