Skip to content

Commit

Permalink
#11 - Rebase, resolve lint and style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Fezzzi committed Mar 27, 2020
1 parent 6341e74 commit 5c920b5
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 27 deletions.
12 changes: 6 additions & 6 deletions frontend/src/app/components/Leaderboard/LeaderboardRow.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { TextSpan, KingSpan, TextDiv, ListItem, StyledLink } from '../../../styles/blocks'
import { PositionDiv, KingDiv, TextSpan, ListItem, StyledLink } from '../../../styles/blocks'
import { createProfilePath } from '../../const/routes'

const trophies = [
Expand All @@ -10,14 +10,14 @@ const trophies = [

export const LeaderboardRow = ({ player, king, position, points }) => (
<ListItem>
<TextSpan align="left">{
<PositionDiv>{
position > 3 ? (position + '.') : <img src={trophies[position - 1]} />
}</TextSpan>
}</PositionDiv>
{king && king.id === player.id
? <KingSpan>King of The Hill<br/>since {king.since.toLocaleDateString()}</KingSpan>
? <KingDiv>King of The Hill<br/>since {king.since.toLocaleDateString()}</KingDiv>
: ''}
<TextDiv>
<TextSpan>
<StyledLink to={createProfilePath(player.id)}>{player.name} ({points})</StyledLink>
</TextDiv>
</TextSpan>
</ListItem>
)
12 changes: 6 additions & 6 deletions frontend/src/app/modules/matches/matches-computations.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,27 +80,27 @@ export const computeKingStreakDuration = (matchesLast, usersLast) => {
}, new Map())

const kingId = usersLast[0].id
let matchFound = false;
for (let match of matchesLast) {
let matchFound = false
for (const match of matchesLast) {
const players = [...match.team1, ...match.team2]

// #1 recomptute king's rating before in case he played the match
const kingPlayer = players.find(player => player.id === kingId)
const kingWon = false;
let kingWon = false
if (kingPlayer) {
kingWon = usersMap[kingId] > kingPlayer.matchRating
usersMap[kingId] = kingPlayer.matchRating
}

// #2 check whether none of the other players beat the king
for (let player of players) {
for (const player of players) {
usersMap[player.id] = player.matchRating
matchFound |= (player.id !== kingId && player.matchRating > usersMap[kingId])
}

// #3 check if king was first before winning
if (kingPlayer && kingWon && !matchFound) {
for (let key in usersMap) {
for (const key in usersMap) {
matchFound |= (usersMap[key] > usersMap[kingId])
}
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/styles/blocks/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
Title, Subtitle, TextSpan, KingSpan, TextDiv, WinnerSpan, BattleLabel,
Title, Subtitle, TextSpan, KingDiv, PositionDiv, WinnerSpan, BattleLabel,
FiltersBlock, FiltersSpan, StyledHyperLink,
} from './typo'
import { Nav, Container, GridContainer, Box, ProfileDetail } from './layout'
Expand All @@ -10,7 +10,7 @@ import { SelectBox, Label, Input } from './inputs'
import { Logo } from './logo'

export {
Title, Subtitle, TextSpan, KingSpan, TextDiv, WinnerSpan, BattleLabel,
Title, Subtitle, TextSpan, KingDiv, PositionDiv, WinnerSpan, BattleLabel,
FiltersBlock, FiltersSpan, StyledHyperLink,
Nav, Container, GridContainer, Box, ProfileDetail,
ListCon, ListItem,
Expand Down
1 change: 1 addition & 0 deletions frontend/src/styles/blocks/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const ListItem = styled.li`
list-style: none;
border: 1px solid var(--cBorder);
align-items: center;
position: relative;
&:nth-child(even) {
background: var(--bgColorListSec);
Expand Down
28 changes: 15 additions & 13 deletions frontend/src/styles/blocks/typo.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,22 @@ const TextSpan = styled.span`
padding: 0 5px;
`

const KingSpan = styled.span`
font-size: 14px;
font-style: italic;
float: right;
color: var(--cFont);
padding: 0 5px;
const PositionDiv = styled.div`
font-weight: 400;
padding: 0 5px;
z-index: 1;
position: absolute;
left: 15px;
`

const TextDiv = styled.div`
text-align: ${props => props.textAlign};
float: ${props => props.align || 'none'};
font-weight: 400;
padding: 0 5px
width: calc(100% - 41px)
const KingDiv = styled.div`
font-size: 14px;
font-style: italic;
color: var(--cFont);
padding: 0 5px;
z-index: 1;
position: absolute;
right: 15px;
`

const FiltersSpan = styled.span`
Expand Down Expand Up @@ -79,6 +81,6 @@ const StyledHyperLink = styled.a`
`

export {
Title, Subtitle, TextSpan, KingSpan, TextDiv, WinnerSpan, BattleLabel,
Title, Subtitle, TextSpan, KingDiv, PositionDiv, WinnerSpan, BattleLabel,
FiltersBlock, FiltersSpan, StyledHyperLink,
}

0 comments on commit 5c920b5

Please sign in to comment.