index.js 1.38 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 {
afc163's avatar
afc163 committed
8 9 10
  state = {
    maxWidth: undefined,
  };
11 12 13

  static getDerivedStateFromProps(props) {
    return {
afc163's avatar
afc163 committed
14
      maxWidth: (props.contentWidth === 'Fixed' ? 1200 : window.innerWidth) - 280 - 165 - 40,
15 16 17
    };
  }

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