PageHeaderLayout.js 1.27 KB
Newer Older
1
import React from 'react';
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
2
import { FormattedMessage } from 'umi/locale';
zinkey's avatar
zinkey committed
3
import Link from 'umi/link';
4
import PageHeader from '@/components/PageHeader';
jim's avatar
jim committed
5
import GridContent from './GridContent';
afc163's avatar
afc163 committed
6
import styles from './PageHeaderLayout.less';
7
import MenuContext from './MenuContext';
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
8
import { connect } from 'dva';
9

ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
10
const PageHeaderLayout = ({ children, grid, wrapperClassName, top, ...restProps }) => (
afc163's avatar
afc163 committed
11
  <div style={{ margin: '-24px -24px 0' }} className={wrapperClassName}>
nikogu's avatar
nikogu committed
12
    {top}
jim's avatar
jim committed
13
    <MenuContext.Consumer>
jim's avatar
jim committed
14
      {value => {
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
15 16
        return (
          <PageHeader
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
17
            wide={grid === 'Wide'}
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
18 19 20 21 22
            home={<FormattedMessage id="menu.home" defaultMessage="Home" />}
            {...value}
            key="pageheader"
            {...restProps}
            linkElement={Link}
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
23 24 25 26 27 28
            itemRender={item => {
              if (item.locale) {
                return <FormattedMessage id={item.locale} defaultMessage={item.name} />;
              }
              return item.name;
            }}
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
29 30
          />
        );
jim's avatar
jim committed
31
      }}
jim's avatar
jim committed
32
    </MenuContext.Consumer>
jim's avatar
jim committed
33 34 35 36 37
    {children ? (
      <div className={styles.content}>
        <GridContent>{children}</GridContent>
      </div>
    ) : null}
38 39
  </div>
);
Erwin Zhang's avatar
Erwin Zhang committed
40

ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
41 42 43
export default connect(({ setting }) => ({
  grid: setting.grid,
}))(PageHeaderLayout);