import React from 'react';
import { RouteContext, GridContent } from '@ant-design/pro-layout';
import { PageHeader, Tabs, Typography } from 'antd';
import styles from './index.less';
import { TabsProps } from 'antd/lib/tabs';
interface IPageHeaderTabConfig {
tabList?: Array<{
key: string;
tab: string;
}>;
tabActiveKey?: TabsProps['activeKey'];
onTabChange?: TabsProps['onChange'];
tabBarExtraContent?: TabsProps['tabBarExtraContent'];
}
interface IPageHeaderWrapperProps extends IPageHeaderTabConfig {
content?: React.ReactNode;
title: React.ReactNode;
extraContent?: React.ReactNode;
}
/**
* render Footer tabList
* In order to be compatible with the old version of the PageHeader
* basically all the functions are implemented.
*/
const renderFooter = ({
tabList,
tabActiveKey,
onTabChange,
tabBarExtraContent,
}: IPageHeaderTabConfig) => {
return tabList && tabList.length ? (
{
if (onTabChange) {
onTabChange(key);
}
}}
tabBarExtraContent={tabBarExtraContent}
>
{tabList.map(item => (
))}
) : null;
};
const PageHeaderWrapper: React.SFC = ({
children,
title,
content,
extraContent,
...restProps
}) => (
{value => (
{title || value.title}
}
footer={renderFooter(restProps)}
>
{content &&
{content}
}
{extraContent &&
{extraContent}
}
{children ? (
{children}
) : null}
)}
);
export default PageHeaderWrapper;