/** @jsx h */
import { h, Component } from 'preact';
import './style.scss';

import Align from '../../components/Align';
import ButtonMute from '../../components/ButtonMute';
import ButtonEnterVR from '../../components/ButtonEnterVR';
import ButtonAbout from '../../components/ButtonAbout';
import ButtonAddRoom from '../../components/ButtonAddRoom';
import About from '../../components/About';

export default class Menu extends Component {
  constructor() {
    super();
    this.state = {
      about: false,
    };
    this.toggleAbout = this.toggleAbout.bind(this);
  }

  toggleAbout() {
    this.setState({
      about: !this.state.about,
    });
  }

  render() {
    const {
      enterVR = true,
      addRoom = true,
      about = true,
      mute = true,
    } = this.props;
    return (
      <div>
        { this.state.about && <About onClose={this.toggleAbout} />}
        <Align type="top-left" rows>
          { about && <ButtonAbout onClick={this.toggleAbout} /> }
          { mute && <ButtonMute /> }
        </Align>
        <Align type="bottom-right">
          { enterVR && <ButtonEnterVR label /> }
          { addRoom && <ButtonAddRoom label /> }
        </Align>
      </div>
    );
  }
}

@@ -70,16 +70,52 @@
 scss';%0A%0A
+import router from '../../router';%0A%0A
 import A
@@ -150,16 +150,16 @@
 Align';%0A
-
 import B
@@ -380,16 +380,72 @@
 dRoom';%0A
+import ButtonClose from '../../components/ButtonClose';%0A
 import A
@@ -656,16 +656,58 @@
 (this);%0A
+    this.goHome = this.goHome.bind(this);%0A
   %7D%0A%0A  t
@@ -786,16 +786,104 @@
 );%0A  %7D%0A%0A
+  goHome() %7B%0A    // TODO: switch camera to orthographic?%0A    router.navigate('/');%0A  %7D%0A%0A
   render
@@ -1378,32 +1378,32 @@
 Room label /%3E %7D%0A
-
         %3C/Align%3E
@@ -1399,24 +1399,187 @@
    %3C/Align%3E%0A
+        %7B%0A          close && (%0A            %3CAlign type=%22top-right%22%3E%0A              %3CButtonClose onClick=%7Bthis.goHome%7D /%3E%0A            %3C/Align%3E%0A          )%0A        %7D%0A
       %3C/div%3E

add home button to menu