mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-25 16:58:00 +08:00
addc7bd266
* feat: rewrite component empty * refactor: use static variable * refactor: extraction function for component empty * docs: update docs and demo * feature: image add image style prop * docs: update doc of component empty * docs: add since comment to imageStyle prop * test: update snapshots * style: use number in style * docs: update docs of component empty * docs: update doc of component empty * test: fix test broken * docs: update docs for empty component * refactor: rewrite empty component * docs: update doc of component empty * doc: change image size
30 lines
833 B
TypeScript
30 lines
833 B
TypeScript
import * as React from 'react';
|
|
import Empty from '../empty';
|
|
import { ConfigConsumer, ConfigConsumerProps } from '.';
|
|
|
|
const renderEmpty = (componentName?: string): React.ReactNode => (
|
|
<ConfigConsumer>
|
|
{({ getPrefixCls }: ConfigConsumerProps) => {
|
|
const prefix = getPrefixCls('empty');
|
|
|
|
switch (componentName) {
|
|
case 'Table':
|
|
case 'List':
|
|
return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} className={`${prefix}-normal`} />;
|
|
|
|
case 'Select':
|
|
case 'TreeSelect':
|
|
case 'Cascader':
|
|
case 'Transfer':
|
|
return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} className={`${prefix}-small`} />;
|
|
default:
|
|
return <Empty />;
|
|
}
|
|
}}
|
|
</ConfigConsumer>
|
|
);
|
|
|
|
export type RenderEmptyHandler = typeof renderEmpty;
|
|
|
|
export default renderEmpty;
|