-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from MomHelpMe/front/feat/tournament-page-rebu…
…ilding Front/feat/tournament page rebuilding
- Loading branch information
Showing
5 changed files
with
433 additions
and
41 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { Component } from "../core/Component.js"; | ||
|
||
export class TournamentHistory extends Component { | ||
|
||
initState() { | ||
return { idx: 0 }; | ||
} | ||
|
||
template () { | ||
|
||
const { gameInfo } = this.props; | ||
|
||
const game = Object.values(gameInfo)[this.state.idx]; | ||
const day = Object.keys(gameInfo)[this.state.idx]; | ||
this.size = Object.keys(gameInfo).length - 1; | ||
|
||
// 게임 1의 데이터 | ||
const game1_nick1 = Object.keys(game.game1)[0]; | ||
const game1_score1 = game.game1[game1_nick1]; | ||
const game1_nick2 = Object.keys(game.game1)[1]; | ||
const game1_score2 = game.game1[game1_nick2]; | ||
|
||
// 게임 2의 데이터 | ||
const game2_nick1 = Object.keys(game.game2)[0]; | ||
const game2_score1 = game.game2[game2_nick1]; | ||
const game2_nick2 = Object.keys(game.game2)[1]; | ||
const game2_score2 = game.game2[game2_nick2]; | ||
|
||
// 게임 3의 데이터 | ||
const game3_nick1 = Object.keys(game.game3)[0]; | ||
const game3_score1 = game.game3[game3_nick1]; | ||
const game3_nick2 = Object.keys(game.game3)[1]; | ||
const game3_score2 = game.game3[game3_nick2]; | ||
|
||
return ` | ||
<div id="tournament-crown-box"> | ||
<img id="crown" src="/img/crown.png"></img> | ||
</div> | ||
<div id="tournament-players"> | ||
<div class="tournament-win" id="tournament-nick">${game3_score1 > game3_score2 ? game3_nick1 : game3_nick2}</div> | ||
</div> | ||
<div id="tournament-lines"> | ||
<div id="tournament-line1"> | ||
<div class="${game3_score1 > game3_score2 ? "tournament-win-score" : "tournament-lose-score"}" id="tournament-left-score">${game3_score1}</div> | ||
<div class="${game3_score1 < game3_score2 ? "tournament-win-score" : "tournament-lose-score"}" id="tournament-right-score">${game3_score2}</div> | ||
</div> | ||
</div> | ||
<div id="tournament-players"> | ||
<div class="${game3_score1 > game3_score2 ? "tournament-win" : "tournament-lose"}" id="tournament-nick">${game3_nick1}</div> | ||
<div class="${game3_score1 < game3_score2 ? "tournament-win" : "tournament-lose"}" id="tournament-nick">${game3_nick2}</div> | ||
</div> | ||
<div id="tournament-lines"> | ||
<div id="tournament-line2"> | ||
<div class="${game1_score1 > game1_score2 ? "tournament-win-score" : "tournament-lose-score"}" id="tournament-left-score">${game1_score1}</div> | ||
<div class="${game1_score1 < game1_score2 ? "tournament-win-score" : "tournament-lose-score"}" id="tournament-right-score">${game1_score2}</div> | ||
</div> | ||
<div id="tournament-line2"> | ||
<div class="${game2_score1 > game2_score2 ? "tournament-win-score" : "tournament-lose-score"}" id="tournament-left-score">${game2_score1}</div> | ||
<div class="${game2_score1 < game2_score2 ? "tournament-win-score" : "tournament-lose-score"}" id="tournament-right-score">${game2_score2}</div> | ||
</div> | ||
</div> | ||
<div id="tournament-players"> | ||
<div class="${game1_score1 > game1_score2 ? "tournament-win" : "tournament-lose"}" id="tournament-nick2">${game1_nick1}</div> | ||
<div class="${game1_score1 < game1_score2 ? "tournament-win" : "tournament-lose"}" id="tournament-nick2">${game1_nick2}</div> | ||
<div id="tournament-blank"></div> | ||
<div class="${game2_score1 > game2_score2 ? "tournament-win" : "tournament-lose"}" id="tournament-nick2">${game2_nick1}</div> | ||
<div class="${game2_score1 < game2_score2 ? "tournament-win" : "tournament-lose"}" id="tournament-nick2">${game2_nick2}</div> | ||
</div> | ||
<div id="tournament-history-button-box"> | ||
<div id="tournament-prev-button"></div> | ||
<div id="tournament-game-name">${day} - Game</div> | ||
<div id="tournament-next-button"></div> | ||
</div> | ||
`; | ||
} | ||
|
||
setEvent(){ | ||
this.addEvent('click', '#tournament-prev-button', (event) => { | ||
console.log("prev"); | ||
console.log(this.state.idx); | ||
if (this.state.idx > 0) this.state.idx--; | ||
console.log(this.state.idx); | ||
}); | ||
|
||
this.addEvent('click', '#tournament-next-button', (event) => { | ||
console.log("next"); | ||
console.log(this.state.idx); | ||
if (this.state.idx < this.size) this.state.idx++; | ||
console.log(this.state.idx); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.