ant-design/components/config-provider/renderEmpty.tsx

30 lines
802 B
TypeScript
Raw Normal View History

2018-12-26 16:01:00 +08:00
import * as React from 'react';
import Empty from '../empty';
import { ConfigConsumer, ConfigConsumerProps } from '.';
2018-12-26 16:01:00 +08:00
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} />;
2018-12-26 16:01:00 +08:00
case 'Select':
case 'TreeSelect':
case 'Cascader':
case 'Transfer':
return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} className={`${prefix}-small`} />;
2018-12-26 16:01:00 +08:00
default:
return <Empty />;
}
}}
</ConfigConsumer>
);
export type RenderEmptyHandler = typeof renderEmpty;
export default renderEmpty;