index.tsx 1.27 KB
Newer Older
1
import React from 'react';
愚道's avatar
愚道 committed
2 3
import { RouteContext } from '@ant-design/pro-layout';
import { PageHeader, Typography } from 'antd';
4
import styles from './index.less';
愚道's avatar
愚道 committed
5
import { GridContent } from '@ant-design/pro-layout';
6

愚道's avatar
愚道 committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
interface IPageHeaderWrapperProps {
  content?: React.ReactNode;
  title?: React.ReactNode;
  extraContent?: React.ReactNode;
}

const PageHeaderWrapper: React.SFC<IPageHeaderWrapperProps> = ({
  children,
  content,
  title,
  extraContent,
  ...restProps
}) => (
  <RouteContext.Consumer>
    {value => (
      <div style={{ margin: '-24px -24px 0' }}>
        <PageHeader
          title={title}
          {...restProps}
          {...value}
        >
          <div className={styles.detail}>
            <div className={styles.main}>
              <div className={styles.row}>
                {content && <div className={styles.content}>{content}</div>}
                {extraContent && <div className={styles.extraContent}>{extraContent}</div>}
              </div>
            </div>
          </div>
        </PageHeader>
        {children ? (
          <GridContent>
            <div className={styles['children-content']}>{children}</div>
          </GridContent>
        ) : null}
      </div>
    )}
  </RouteContext.Consumer>
45 46 47
);

export default PageHeaderWrapper;