unlimited team battle POC
parent
5b26ceaaaa
commit
4cf2a2a53c
|
@ -62,9 +62,9 @@ object teamBattle {
|
||||||
title = tour.name(),
|
title = tour.name(),
|
||||||
moreCss = cssTag("tournament.show.team-battle")
|
moreCss = cssTag("tournament.show.team-battle")
|
||||||
)(
|
)(
|
||||||
main(cls := "tour__battle-standing box")(
|
main(cls := "box")(
|
||||||
h1(a(href := routes.Tournament.show(tour.id))(tour.name())),
|
h1(a(href := routes.Tournament.show(tour.id))(tour.name())),
|
||||||
table(cls := "slist slist-pad tour__team-standing")(
|
table(cls := "slist slist-pad tour__team-standing tour__team-standing--full")(
|
||||||
tbody(
|
tbody(
|
||||||
standing.map { t =>
|
standing.map { t =>
|
||||||
tr(
|
tr(
|
||||||
|
|
|
@ -91,11 +91,21 @@ team {
|
||||||
td {
|
td {
|
||||||
padding: 1rem 0.5rem;
|
padding: 1rem 0.5rem;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.tour__battle-standing {
|
.more-teams {
|
||||||
td {
|
padding: 0 !important;
|
||||||
padding: 2rem 1rem;
|
|
||||||
|
a {
|
||||||
|
padding: 1rem 0;
|
||||||
|
display: block;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&--full {
|
||||||
|
td {
|
||||||
|
padding: 2rem 1rem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ export interface TournamentOpts extends Untyped {
|
||||||
export interface TournamentData extends Untyped {
|
export interface TournamentData extends Untyped {
|
||||||
teamBattle?: TeamBattle;
|
teamBattle?: TeamBattle;
|
||||||
teamStanding?: RankedTeam[];
|
teamStanding?: RankedTeam[];
|
||||||
|
myTeam?: RankedTeam;
|
||||||
featured?: FeaturedGame;
|
featured?: FeaturedGame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
|
import TournamentController from '../ctrl';
|
||||||
|
import { bind, onInsert, playerName } from './util';
|
||||||
import { h } from 'snabbdom'
|
import { h } from 'snabbdom'
|
||||||
|
import { TeamBattle, RankedTeam, TournamentData, MaybeVNode } from '../interfaces';
|
||||||
import { VNode } from 'snabbdom/vnode';
|
import { VNode } from 'snabbdom/vnode';
|
||||||
|
|
||||||
import { bind, onInsert, playerName } from './util';
|
|
||||||
import { TeamBattle, RankedTeam } from '../interfaces';
|
|
||||||
import TournamentController from '../ctrl';
|
|
||||||
|
|
||||||
export function joinWithTeamSelector(ctrl: TournamentController) {
|
export function joinWithTeamSelector(ctrl: TournamentController) {
|
||||||
const onClose = () => {
|
const onClose = () => {
|
||||||
|
@ -46,12 +46,37 @@ export function joinWithTeamSelector(ctrl: TournamentController) {
|
||||||
|
|
||||||
export function teamStanding(ctrl: TournamentController, klass?: string): VNode | null {
|
export function teamStanding(ctrl: TournamentController, klass?: string): VNode | null {
|
||||||
const battle = ctrl.data.teamBattle,
|
const battle = ctrl.data.teamBattle,
|
||||||
standing = ctrl.data.teamStanding;
|
standing = ctrl.data.teamStanding,
|
||||||
|
bigBattle = battle && Object.keys(battle.teams).length > 10;
|
||||||
return battle && standing ? h('table.slist.tour__team-standing' + (klass ? '.' + klass : ''), [
|
return battle && standing ? h('table.slist.tour__team-standing' + (klass ? '.' + klass : ''), [
|
||||||
h('tbody', standing.map(rt => teamTr(ctrl, battle, rt)))
|
h('tbody', [
|
||||||
|
...standing.map(rt => teamTr(ctrl, battle, rt)),
|
||||||
|
...(bigBattle ? [
|
||||||
|
extraTeams(ctrl.data),
|
||||||
|
myTeam(ctrl, battle)
|
||||||
|
] : [])
|
||||||
|
])
|
||||||
]) : null;
|
]) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function extraTeams(tour: TournamentData): VNode {
|
||||||
|
return h('tr',
|
||||||
|
h('td.more-teams', {
|
||||||
|
attrs: { colspan: 4 }
|
||||||
|
}, h('a', {
|
||||||
|
attrs: {
|
||||||
|
href: `/tournament/${tour.id}/teams`
|
||||||
|
},
|
||||||
|
}, 'View all teams')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function myTeam(ctrl: TournamentController, battle: TeamBattle): MaybeVNode {
|
||||||
|
const team = ctrl.data.myTeam;
|
||||||
|
return team && team.rank > 10 ? teamTr(ctrl, battle, team) : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
export function teamName(battle: TeamBattle, teamId: string): VNode {
|
export function teamName(battle: TeamBattle, teamId: string): VNode {
|
||||||
return h('team.ttc-' + Object.keys(battle.teams).indexOf(teamId), battle.teams[teamId]);
|
return h('team.ttc-' + Object.keys(battle.teams).indexOf(teamId), battle.teams[teamId]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue