From a89737e67c362191d52f1aed0fd2bbe68b602e68 Mon Sep 17 00:00:00 2001 From: Joffrey Bion Date: Sat, 21 Mar 2020 19:23:41 +0100 Subject: Improve GameList conversion from TypeScript --- .../ui/components/gameBrowser/GameList.kt | 37 ++++++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'sw-ui-kt/src') diff --git a/sw-ui-kt/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/GameList.kt b/sw-ui-kt/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/GameList.kt index 40ad826a..206ef749 100644 --- a/sw-ui-kt/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/GameList.kt +++ b/sw-ui-kt/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/GameList.kt @@ -1,6 +1,9 @@ package org.luxons.sevenwonders.ui.components.gameBrowser +import kotlinx.css.VerticalAlign +import kotlinx.css.verticalAlign import kotlinx.html.js.onClickFunction +import kotlinx.html.title import org.luxons.sevenwonders.model.api.LobbyDTO import org.luxons.sevenwonders.model.api.State import org.luxons.sevenwonders.ui.redux.RequestJoinGameAction @@ -10,6 +13,8 @@ import react.RComponent import react.RProps import react.RState import react.dom.* +import styled.css +import styled.styledSpan interface GameListStateProps : RProps { var games: List @@ -29,7 +34,7 @@ class GameListPresenter(props: GameListProps) : RComponent Unit) = tr { + attrs { + key = lobby.id.toString() + } th { +lobby.name } th { gameStatus(lobby.state) } th { playerCount(lobby.players.size) } @@ -52,14 +60,37 @@ private fun RBuilder.gameListItemRow(lobby: LobbyDTO, joinGame: (Long) -> Unit) } private fun RBuilder.gameStatus(state: State) { + // TODO + // {state} + // const statusIntents = { + // 'LOBBY': Intent.SUCCESS, + // 'PLAYING': Intent.WARNING, + // }; span { +state.toString() } } private fun RBuilder.playerCount(nPlayers: Int) { - span { - +nPlayers.toString() + //
+ // + // {nbPlayers} + //
; + + // CSS: + // .playerCountIcon, .playerCount { + // vertical-align: middle; + // } + div { + attrs { + title = "Number of players" + } + styledSpan { + css { + verticalAlign = VerticalAlign.middle + } + +nPlayers.toString() + } } } -- cgit