index.js 1.5 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
  constructor(props) {
    super(props);

    this.state = {
12
      maxWidth: (props.contentWidth === 'Fixed' ? 1200 : window.innerWidth) - 330 - 165 - 4 - 26,
13 14 15 16 17
    };
  }

  static getDerivedStateFromProps(props) {
    return {
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
18
      maxWidth: (props.contentWidth === 'Fixed' ? 1200 : window.innerWidth) - 330 - 165 - 4,
19 20 21
    };
  }

jim's avatar
jim committed
22
  render() {
afc163's avatar
afc163 committed
23
    const { theme, contentWidth, logo } = this.props;
24
    const { maxWidth } = this.state;
jim's avatar
jim committed
25
    return (
26
      <div className={`${styles.head} ${theme === 'light' ? styles.light : ''}`}>
27 28 29 30
        <div
          ref={ref => {
            this.maim = ref;
          }}
afc163's avatar
afc163 committed
31
          className={`${styles.main} ${contentWidth === 'Fixed' ? styles.wide : ''}`}
32
        >
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="/">
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>
    );
  }
}