index.js 1.46 KB
Newer Older
jim's avatar
jim committed
1
import React, { PureComponent } from 'react';
zinkey's avatar
zinkey committed
2
import Link from 'umi/link';
jim's avatar
jim committed
3
import RightContent from '../GlobalHeader/RightContent';
Erwin Zhang's avatar
Erwin Zhang committed
4
import BaseMenu from '../SiderMenu/BaseMenu';
jim's avatar
jim committed
5 6 7
import styles from './index.less';

export default class TopNavHeader extends PureComponent {
8 9 10 11 12 13 14 15 16 17 18 19 20 21
  constructor(props) {
    super(props);

    this.state = {
      maxWidth: (props.grid === 'Wide' ? 1200 : window.innerWidth) - 324 - 165 - 4,
    };
  }

  static getDerivedStateFromProps(props) {
    return {
      maxWidth: (props.grid === 'Wide' ? 1200 : window.innerWidth) - 324 - 165 - 4,
    };
  }

jim's avatar
jim committed
22
  render() {
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
23
    const { theme, grid, logo } = this.props;
24
    const { maxWidth } = this.state;
jim's avatar
jim committed
25
    return (
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
26
      <div className={`${styles.head} ${theme === 'light' ? styles.light : ''}`}>
27 28 29 30 31 32
        <div
          ref={ref => {
            this.maim = ref;
          }}
          className={`${styles.main} ${grid === 'Wide' ? styles.wide : ''}`}
        >
jim's avatar
jim committed
33
          <div className={styles.left}>
34
            <div className={styles.logo} key="logo" id="logo">
jim's avatar
jim committed
35
              <Link to="/">
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
36
                <img src={logo} alt="logo" />
jim's avatar
jim committed
37 38 39
                <h1>Ant Design Pro</h1>
              </Link>
            </div>
40 41 42 43 44 45 46
            <div
              style={{
                maxWidth,
              }}
            >
              <BaseMenu {...this.props} style={{ border: 'none', height: 64 }} />
            </div>
jim's avatar
jim committed
47
          </div>
48
          <RightContent {...this.props} />
jim's avatar
jim committed
49 50 51 52 53
        </div>
      </div>
    );
  }
}