Skip to content

Commit

Permalink
v2.2 styling, home menu done, ready for production
Browse files Browse the repository at this point in the history
  • Loading branch information
LiberoHS committed Sep 10, 2019
1 parent 0d61b35 commit 16d4ac4
Show file tree
Hide file tree
Showing 9 changed files with 220 additions and 33 deletions.
8 changes: 8 additions & 0 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"dependencies": {
"@material-ui/core": "^4.4.0",
"@material-ui/icons": "^4.4.1",
"@material-ui/styles": "^4.3.3",
"react": "^16.9.0",
"react-dom": "^16.9.0",
Expand Down
4 changes: 0 additions & 4 deletions client/public/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,3 @@ button {
border-radius: 20px;
padding: 10px;
}

TableRow, Table, TableBody, TableCell {
font-size: 200px;
}
67 changes: 53 additions & 14 deletions client/src/App.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
// Started by Jeremy Lim on 03/09/2019
// Currently on v2 deployed, v2.1 local, unreleased

import React from 'react';
import { Grid, Switch, FormControlLabel } from '@material-ui/core';
import { PlayerInfo, SearchBar, TournamentInfo, TournamentList } from './components';
import ArrowBackIosIcon from '@material-ui/icons/ArrowBackIos';
import { Grid, Switch, FormControlLabel, IconButton } from '@material-ui/core';
import { HomeMenu, PlayerInfo, SearchBar, TournamentInfo, TournamentList } from './components';
import decks from './data/decks.js';
import tournamentList from './data/tournaments.js';
import players from './data/players.js';

// HOME PAGE
// Top performing decks this week
// Top performing players
// Latest tournament
// Upcoming tournaments
const buttonStyle = {
height: '100px',
width: '100px'
};

// TO-DO LIST
// Home page (done v2.2)
// Table paginations
// Sorting tournaments
// Player functionality
// Data analytics
// Data analytics (v3)
// Need to refactor Challenges filter
// Filter functionality for Cups
// Back button (done v2.1)

// class Tournament {
// constructor(name, attendance, type, format, date) {
Expand Down Expand Up @@ -53,6 +56,24 @@ class App extends React.Component {
}

// Changed states
backButton = () => {
var filteredList = tournamentList.filter((tournament, key) => {
return (tournament.type !== 'League Challenge');
});

if (this.state.show === 'list') {
this.setState({ show: 'home', currentTournament: null })
} else if (this.state.show === 'tournament') {
if (this.state.checkedChallenge === true) {
this.setState({ show: 'list', currentTournament: null, tournamentList: filteredList });
} else {
this.setState({ show: 'list', currentTournament: null, tournamentList: tournamentList });
}
} else if (this.state.show === 'player') {
this.setState({ show: 'tournament', currentPlayer: null })
}
}

setCurrentTournament = (tournament) => {
this.setState({ currentTournament: tournament, show: 'tournament' });
}
Expand Down Expand Up @@ -145,25 +166,43 @@ class App extends React.Component {
const { tournamentList, currentTournament, currentPlayer, decks, show, checkedChallenge } = this.state;
return (
<Grid>
<Grid>
<Grid>
<Grid container>
<Grid item xs={10}>
{show !== 'home' && <IconButton style={buttonStyle} onClick={this.backButton} aria-label="back">
<ArrowBackIosIcon />
</IconButton>}
<button onClick={this.homePage}>Home</button>
<button onClick={this.tournamentList}>Tournaments</button>
<button>Coming Soon in v4!</button>
</Grid>
</Grid>
<Grid>
{/* WIP */}
{show === 'home' && <HomeMenu tournaments={tournamentList} decks={decks} />}
</Grid>
<Grid>
{show === 'list' && <SearchBar onFormSubmit={this.handleChange}/>}
{/* SORT FUNCTIONALITY */}
{show === 'list' && <FormControlLabel control={
<Switch checked={checkedChallenge} onChange={this.filterChallenges} value="checkedChallenge"/>
} label='No Challenges' />}
{show === 'list' && <TournamentList setCurrentTournament={this.setCurrentTournament} tournamentList={tournamentList}/>}
{show === 'list' && <TournamentList
setCurrentTournament={this.setCurrentTournament}
tournamentList={tournamentList}/>}
</Grid>
<Grid>
{show === 'tournament' && <TournamentInfo currentTournament={currentTournament} setCurrentPlayer={this.setCurrentPlayer} decks={decks} />}
{show === 'tournament' && <TournamentInfo
currentTournament={currentTournament}
setCurrentPlayer={this.setCurrentPlayer}
decks={decks} />}
</Grid>
<Grid>
{show === 'player' && <PlayerInfo currentPlayer={currentPlayer} setCurrentPlayer={this.setCurrentPlayer} decks={decks} />}
{show === 'player' && <PlayerInfo
currentPlayer={currentPlayer}
setCurrentPlayer={this.setCurrentPlayer}
setCurrentTournament={this.setCurrentTournament}
decks={decks}
tournamentList={tournamentList} />}
</Grid>
</Grid>
)
Expand Down
128 changes: 128 additions & 0 deletions client/src/components/HomeMenu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import { Grid, Paper } from '@material-ui/core';
import { Table, TableRow, TableCell, TableHead, TableBody } from '@material-ui/core';

const headerStyle = {
color: 'white',
fontFamily: 'Muli',
fontSize: '16px'
};

const cellStyle = {
fontFamily: 'Muli',
fontSize: '20px'
};

const wip = {
fontFamily: 'Muli',
fontSize: '48px',
}

const tableGrid = {
margin: '50px',
width: '450px',
height: '700px',
backgroundColor: 'white'
};

const text = {
margin: '15px',
padding: '10px'
}

const HomeMenu = ({ tournaments, decks }) => {
function compareDecks(target) {
for (var i = 0; i < decks.length; i++) {
if (decks[i].archetype === target.deck) {
return decks[i];
}
}

return target;
}

const useStyles = makeStyles({
root: {
width: '100%',
},
tableWrapper: {
maxHeight: 600,
overflow: 'auto',
},
});

const classes = useStyles();

return (
<Grid>
<Grid container>
<Grid item xs={11} style={tableGrid}>
<h2 style={text}>Latest Tournament</h2>
<h3 style={text}>{tournaments[0].name} | {tournaments[0].date}</h3>
<Paper classname={classes.root}>
<div className={classes.tableWrapper}>
<Table>
<TableHead>
<TableRow style={{backgroundColor: '#424242'}}>
<TableCell align="center" style={headerStyle}>Placing</TableCell>
<TableCell align="center" style={headerStyle}>Name</TableCell>
<TableCell align="center" style={headerStyle}>Deck</TableCell>
<TableCell align="center"></TableCell>
</TableRow>
</TableHead>
<TableBody>
{tournaments[0].standings.map((player, key) => {
var search = compareDecks(player);
if (search.hasOwnProperty('thumbnails')) {
var sprites = search.thumbnails.map((img, key) => {
return <img key={key} src={img} style={{height: '70px', width: '70px'}} alt="rekt" />
})};

return(
<TableRow key={key}>
<TableCell align="center" style={cellStyle}>{player.placing}</TableCell>
<TableCell align="center" style={cellStyle}>{player.name}</TableCell>
<TableCell align="center" style={cellStyle}>{player.deck}</TableCell>
<TableCell align="center">
<p>{sprites}</p>
</TableCell>
</TableRow>
)})}
</TableBody>
</Table>
</div>
</Paper>
</Grid>
<Grid container>
<Grid item xs={3} style={tableGrid}>
<h2 style={text}>Upcoming Tournaments</h2>
<Paper classname={classes.root}>
<div className={classes.tableWrapper}>
<p style={wip} align="center">Coming Soon in v3!</p>
</div>
</Paper>
</Grid>
<Grid item xs={4} style={tableGrid}>
<h2 style={text}>Top Performing Decks of the Week</h2>
<Paper classname={classes.root}>
<div className={classes.tableWrapper}>
<p style={wip} align="center">Coming Soon in v3!</p>
</div>
</Paper>
</Grid>
<Grid item xs={3} style={tableGrid}>
<h2 style={text}>Top Performing Players</h2>
<Paper classname={classes.root}>
<div className={classes.tableWrapper}>
<p style={wip} align="center">Coming Soon in v3!</p>
</div>
</Paper>
</Grid>
</Grid>
</Grid>
</Grid>
)
}

export default HomeMenu;
38 changes: 25 additions & 13 deletions client/src/components/PlayerInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { Grid, Table, TableRow, TableCell, TableHead, TableBody } from '@material-ui/core';

const headerStyle = {
color: 'white',
fontFamily: 'Muli',
fontSize: '16px'
};
Expand All @@ -13,16 +14,27 @@ const cellStyle = {

// Player templating

const PlayerInfo = ({ currentPlayer, decks }) => {
const PlayerInfo = ({ setCurrentTournament, currentPlayer, decks, tournamentList }) => {
function compareDecks(target) {
for (var i = 0; i < decks.length; i++) {
if (decks[i].archetype === target.deck) {
return decks[i];
}
}

return target
return target;
}

function compareTournaments(name, date) {
for (var i = 0; i < tournamentList.length; i++) {
if (tournamentList[i].name === name && tournamentList[i].date === date) {
return tournamentList[i];
}
}

return name
}

return(
<Grid item xs={12}>
<Grid>
Expand All @@ -31,35 +43,35 @@ const PlayerInfo = ({ currentPlayer, decks }) => {
<Grid>
<Table>
<TableHead>
<TableRow>
<TableRow style={{backgroundColor: '#424242'}}>
<TableCell align="center" style={headerStyle}>Date</TableCell>
<TableCell align="center" style={headerStyle}>Tournament</TableCell>
<TableCell align="center" style={headerStyle}>Cycle</TableCell>
<TableCell align="center" style={headerStyle}>Placing</TableCell>
<TableCell align="center" style={headerStyle}>Deck</TableCell>
<TableCell align="center"></TableCell>
<TableCell align="center" style={headerStyle}>Placing</TableCell>
</TableRow>
</TableHead>
<TableBody>
{currentPlayer.achievements.map((player, key) => {
var search = compareDecks(player);
{currentPlayer.achievements.map((achievement, key) => {
var search = compareDecks(achievement);
if (search.hasOwnProperty('thumbnails')) {
var sprites = search.thumbnails.map((img, key) => {
return <img key={key} src={img} style={{height: '70px', width: '70px'}} alt="rekt" />
})};

return(
<TableRow key={key}>
<TableCell align="center" style={cellStyle}>{player.date}</TableCell>
<TableCell align="center" style={cellStyle}>{player.tournament}</TableCell>
<TableCell align="center" style={cellStyle}>{player.cycle}</TableCell>
<TableCell component="th" align="center" style={cellStyle}>
{player.placing}
<TableCell align="center" style={cellStyle}>{achievement.date}</TableCell>
<TableCell component="th" align="center">
<button onClick={() => setCurrentTournament(compareTournaments(achievement.tournament, achievement.date))}> {achievement.tournament}</button>
</TableCell>
<TableCell align="center" style={cellStyle}>{player.deck}</TableCell>
<TableCell align="center" style={cellStyle}>{achievement.deck}</TableCell>
<TableCell align="center">
<p>{sprites}</p>
</TableCell>
<TableCell align="center" style={cellStyle}>
{achievement.placing}
</TableCell>
</TableRow>
)})}
</TableBody>
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/TournamentInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { Grid, Table, TableRow, TableCell, TableHead, TableBody } from '@material-ui/core';

const headerStyle = {
color: 'white',
fontFamily: 'Muli',
fontSize: '16px'
};
Expand Down Expand Up @@ -36,7 +37,7 @@ const TournamentInfo = ({ setCurrentPlayer, currentTournament, decks }) => {
<Grid>
<Table>
<TableHead>
<TableRow>
<TableRow style={{backgroundColor: '#424242'}}>
<TableCell align="center" style={headerStyle}>Placing</TableCell>
<TableCell align="center" style={headerStyle}>Name</TableCell>
<TableCell align="center" style={headerStyle}>Deck</TableCell>
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/TournamentList.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { Grid, Table, TableRow, TableCell, TableHead, TableBody } from '@material-ui/core';

const headerStyle = {
color: 'white',
fontFamily: 'Muli',
fontSize: '16px'
};
Expand All @@ -17,7 +18,7 @@ const TournamentList = ({ setCurrentTournament, tournamentList }) => {
<Grid>
<Table>
<TableHead>
<TableRow>
<TableRow style={{backgroundColor: '#424242'}}>
<TableCell align="center" style={headerStyle}>Date</TableCell>
<TableCell align="center" style={headerStyle}>Name</TableCell>
<TableCell align="center" style={headerStyle}>Region</TableCell>
Expand Down
1 change: 1 addition & 0 deletions client/src/components/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { default as HomeMenu } from './HomeMenu';
export { default as PlayerInfo } from './PlayerInfo';
export { default as SearchBar } from './SearchBar';
export { default as TournamentInfo } from './TournamentInfo';
Expand Down

0 comments on commit 16d4ac4

Please sign in to comment.