Browse Source

Push Before HTML Upload

master
Unknown 6 years ago
parent
commit
304f72ee21
7 changed files with 41 additions and 26 deletions
  1. +16
    -10
      googletrendsgame/src/App.js
  2. +1
    -0
      googletrendsgame/src/components/GameScreen.js
  3. +19
    -12
      googletrendsgame/src/components/RoomList.js
  4. +3
    -2
      googletrendsgame/src/components/RoomListItem.js
  5. +0
    -0
      googletrendsgame/src/components/User.js
  6. +1
    -1
      googletrendsgame/src/components/activeButton.js
  7. +1
    -1
      googletrendsgame/src/components/nicknameInput.js

+ 16
- 10
googletrendsgame/src/App.js View File

@ -13,19 +13,26 @@ class App extends Component {
super(props);
this.state={
progression: 'createRoom',
roomList: []
progression: 'register',
roomsList: []
}
this.modifyStateToCreateRoom = this.modifyStateToCreateRoom.bind(this);
}
componentDidMount(){
modifyStateToCreateRoom() {
this.setState({
progression: 'createRoom'
});
}
stateHandler(){
socket.on('sendRooms', payload => this.setState({
progression: 'roomChoose',
roomList: payload.rooms
}));
componentDidMount(){
socket.on('sendRooms', payload => {
const rooms = payload.rooms;
this.setState({
progression: 'roomChoose',
roomsList: rooms
})
});
}
render() {
@ -34,9 +41,8 @@ class App extends Component {
<NicknameInput socket = {socket}/>
)
} else if(this.state.progression === 'roomChoose') {
return(
<RoomList roomArray = {this.state.roomList}/>
<RoomList stateModifier={this.modifyStateToCreateRoom} roomArray = {this.state.roomsList}/>
)
} else if (this.state.progression === 'createRoom') {

+ 1
- 0
googletrendsgame/src/components/GameScreen.js View File

@ -0,0 +1 @@
import React, {Component} from 'react';

+ 19
- 12
googletrendsgame/src/components/RoomList.js View File

@ -1,18 +1,25 @@
import React, { Component } from 'react';
import RoomListItem from 'roomListItem';
import React from 'react';
import RoomListItem from './RoomListItem';
import {modifyStateToCreateRoom} from '../App'
class RoomList extends Component {
renderRooms(roomArray) {
return(
<RoomListItem key = {room.name} roomName = {room.name} private = {room.passwordBool} capacity = {room.capacity} occupancy = {room.occupants} />
)
}
render(){
export default (props) => {
let rooms = props.roomArray;
console.log(rooms);
if (rooms.length != 0) {
let roomsList = rooms.map((room) =>
<RoomListItem roomName={room.name} private={room.passwordBool} capacity={room.capacity} occupancy={room.occupants} />
);
return(
<div>
{this.props.roomArray.map(this.renderRooms)}
<div>{roomsList}</div>
<button>Create Room</button>
</div>
);
} else {
return (
<div>
<div>No current rooms, you should create one!</div>
<button onClick={props.stateModifier}>Create Room</button>
</div>
)
}

+ 3
- 2
googletrendsgame/src/components/RoomListItem.js View File

@ -1,10 +1,11 @@
import React from 'react';
export default (props) => {
var privateString =''
if (props.private = false){
const privateString = "Public"
privateString = "Public"
} else {
const privateString = "Private"
privateString = "Private"
}
return(
<div>

+ 0
- 0
googletrendsgame/src/components/User.js View File


+ 1
- 1
googletrendsgame/src/components/activeButton.js View File

@ -16,7 +16,7 @@ export default class activeButton extends Component {
)
}
case 'createRoom':
if(this.props.passInput != '' && this.props.capacityInput != '' && this.props.capacityInput <= 25 && this.props.capacityInput>=2 && this.props.capacityInput.length <= 2){
if(this.props.passInput !== '' && this.props.capacityInput !== '' && this.props.capacityInput <= 25 && this.props.capacityInput>=2 && this.props.capacityInput.length <= 2){
return(
<button>Create Room</button>
)

+ 1
- 1
googletrendsgame/src/components/nicknameInput.js View File

@ -25,7 +25,7 @@ export default class NicknameInput extends Component {
render() {
return(
<form onSubmit={this.sendNickname}>
<input placeholder="Enter a nickname..." onChange = {this.onInputChange} value={this.state.fieldValue} />
<input maxLength="30" placeholder="Enter a nickname..." onChange = {this.onInputChange} value={this.state.fieldValue} />
<span>
<ActiveButton input = {this.state.fieldValue} type='register' />
</span>

Loading…
Cancel
Save