summaryrefslogtreecommitdiff
path: root/frontend/src/containers/App/index.js
blob: 70f99b6bd3017230513415fa45b06d33aa675d20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import React, { Component } from 'react'
import { connect } from 'react-redux'
import {
  Banner,
  Heading,
  Space,
  Button,
  InlineForm,
  Text
} from 'rebass'
import { Flex } from 'reflexbox'
import Modal from '../../components/modals/username'
import GameBrowser from '../GameBrowser'

class App extends Component {
  state = {
    usernameModal: false,
  }

  componentDidMount() {

  }

  toggleModal = (key) => {
    return (e) => {
      const val = !this.state[key]
      this.setState({ [key]: val })
    }
  }

  createGame = (e) => {
    e.preventDefault()
    if (this._gameName !== undefined) {
      this.props.createGame(this._gameName)
    }
  }

  render() {
    return (
      <div>
        <Banner
          align="center"
          style={{minHeight: '30vh'}}
          backgroundImage="https://images.unsplash.com/photo-1431207446535-a9296cf995b1?dpr=1&auto=format&fit=crop&w=1199&h=799&q=80&cs=tinysrgb&crop="
        >
          <Heading level={1}>Seven Wonders</Heading>
        </Banner>
        <Flex align="center" p={1}>
          <InlineForm
            buttonLabel="Create Game"
            label="Game name"
            name="game_name"
            onChange={(e) => this._gameName = e.target.value}
            onClick={this.createGame}
          >

          </InlineForm>
          <Space auto />
          <Text><b>Username:</b> Cesar92</Text>
          <Space x={1} />
          <Button
            onClick={this.toggleModal('usernameModal')}
            children="Change"/>
        </Flex>
        <GameBrowser />
        <Modal toggleModal={this.toggleModal} modalOpen={this.state.usernameModal} />
      </div>
    )
  }
}

const mapStateToProps = (state) => ({

})

import { initializeWs } from "./actions";
import { createGame } from '../GameBrowser/actions'
const mapDispatchToProps = {
  initializeWs,
  createGame
}

export default connect(mapStateToProps, mapDispatchToProps)(App)
bgstack15