<commit_before>import React, { Component, PropTypes } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import * as actionCreators from './actions';
import App from 'grommet-udacity/components/App';
import { MobileNav, LogoImage, Navbar } from 'components';
import { updatePageTitle, getTitleFromRoute } from 'utils/a11y';
import Header from 'grommet-udacity/components/Header';
import Title from 'grommet-udacity/components/Title';
import MenuIcon from 'grommet-udacity/components/icons/base/Menu';

class Main extends Component {
  constructor() {
    super();
    this.handleToggleNav = this.handleToggleNav.bind(this);
    this.handleSetMobile = this.handleSetMobile.bind(this);
  }
  componentDidMount() {
    const {
      pathname,
    } = this.props.location;
    updatePageTitle(getTitleFromRoute(pathname));
    this.handleSetMobile();
    if (window) {
      window.addEventListener('resize', this.handleSetMobile);
    }
  }
  componentWillReceiveProps(newProps) {
    const {
      pathname,
    } = this.props.location;
    const newPathname = newProps.location.pathname;
    if (newPathname !== pathname) {
      updatePageTitle(getTitleFromRoute(newPathname));
    }
  }
  componentWillUnmount() {
    if (window) {
      window.removeEventListener('resize', this.handleSetMobile);
    }
  }
  handleSetMobile() {
    const isMobile = window.innerWidth <= 768;
    const {
      appSetMobile,
    } = this.props.actions;
    appSetMobile(isMobile);
  }
  handleToggleNav() {
    const {
      appToggleNav,
    } = this.props.actions;
    appToggleNav();
  }
  render() {
    const {
      user,
      isMobile,
      navIsActive,
      navLinks,
    } = this.props;
    return (
      <App centered={false}>
        {!isMobile ?
          <main>
            <Navbar onSearch={(e) => e} />
            {React.cloneElement(this.props.children, this.props)}
          </main>
        :
          <MobileNav
            user={user}
            navActive={navIsActive}
            onToggleNav={this.handleToggleNav}
            navLinks={navLinks}
          >
            <Header
              direction="row"
              justify="between"
              large
              pad={{ horizontal: 'medium', between: 'small' }}
            >
              {!navIsActive &&
                <Title onClick={this.handleToggleNav} a11yTitle="Open Menu Left">
                  <LogoImage />
                </Title>
              }
              <Title onClick={this.handleToggleNav} a11yTitle="Open Menu Right">
                <MenuIcon colorIndex="brand" size="medium" type="control" />
              </Title>
            </Header>
            {React.cloneElement(this.props.children, this.props)}
          </MobileNav>
        }
      </App>
    );
  }
}

Main.propTypes = {
  children: React.children,
  location: PropTypes.object.isRequired,
  user: PropTypes.object,
  isMobile: PropTypes.bool.isRequired,
  navIsActive: PropTypes.bool.isRequired,<commit_msg>Feat: update app component to link to home page when icon clicked<commit_after>import React, { Component, PropTypes } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import * as actionCreators from './actions';
import App from 'grommet-udacity/components/App';
import { MobileNav, LogoImage, Navbar } from 'components';
import { updatePageTitle, getTitleFromRoute } from 'utils/a11y';
import Header from 'grommet-udacity/components/Header';
import Title from 'grommet-udacity/components/Title';
import Anchor from 'grommet-udacity/components/Anchor';
import MenuIcon from 'grommet-udacity/components/icons/base/Menu';

class Main extends Component {
  constructor() {
    super();
    this.handleToggleNav = this.handleToggleNav.bind(this);
    this.handleSetMobile = this.handleSetMobile.bind(this);
  }
  componentDidMount() {
    const {
      pathname,
    } = this.props.location;
    updatePageTitle(getTitleFromRoute(pathname));
    this.handleSetMobile();
    if (window) {
      window.addEventListener('resize', this.handleSetMobile);
    }
  }
  componentWillReceiveProps(newProps) {
    const {
      pathname,
    } = this.props.location;
    const newPathname = newProps.location.pathname;
    if (newPathname !== pathname) {
      updatePageTitle(getTitleFromRoute(newPathname));
    }
  }
  componentWillUnmount() {
    if (window) {
      window.removeEventListener('resize', this.handleSetMobile);
    }
  }
  handleSetMobile() {
    const isMobile = window.innerWidth <= 768;
    const {
      appSetMobile,
    } = this.props.actions;
    appSetMobile(isMobile);
  }
  handleToggleNav() {
    const {
      appToggleNav,
    } = this.props.actions;
    appToggleNav();
  }
  render() {
    const {
      user,
      isMobile,
      navIsActive,
      navLinks,
    } = this.props;
    return (
      <App centered={false}>
        {!isMobile ?
          <main>
            <Navbar onSearch={(e) => e} />
            {React.cloneElement(this.props.children, this.props)}
          </main>
        :
          <MobileNav
            user={user}
            navActive={navIsActive}
            onToggleNav={this.handleToggleNav}
            navLinks={navLinks}
          >
            <Header
              direction="row"
              justify="between"
              large
              pad={{ horizontal: 'medium', between: 'small' }}
            >
              {!navIsActive &&
                <Title a11yTitle="Go Home">
                  <Anchor href="/">
                    <LogoImage />
                  </Anchor>
                </Title>
              }
              <Title onClick={this.handleToggleNav} a11yTitle="Open Menu Right">
                <MenuIcon colorIndex="brand" size="medium" type="control" />
              </Title>
            </Header>
            {React.cloneElement(this.props.children, this.props)}
          </MobileNav>
        }
      </App>
    );
  }
}

Main.propTypes = {
  children: React.children,
  location: PropTypes.object.isRequired,
  user: PropTypes.object,
  isMobile: PropTypes.bool.isRequired,
  navIsActive: PropTypes.bool.isRequired,
{'fraction_non_alphanumeric': 0.12050534499514091, 'fraction_numerical': 0.0029154518950437317, 'mean_word_length': 2.325255788906839, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3493738', 'n_tokens_mistral': 1798, 'n_tokens_neox': 1791, 'n_words': 339}