From 7b0bd441490a3da2d22e6fae9dac64027e290261 Mon Sep 17 00:00:00 2001 From: Joffrey Bion Date: Sat, 20 Feb 2021 13:25:29 +0100 Subject: Rework GameBrowser style Resolves: https://github.com/joffrey-bion/seven-wonders/issues/68 --- .../sevenwonders/ui/components/GlobalStyles.kt | 5 + .../ui/components/gameBrowser/CreateGameForm.kt | 2 +- .../ui/components/gameBrowser/GameBrowser.kt | 48 +++++++- .../ui/components/gameBrowser/GameBrowserStyles.kt | 19 +++ .../ui/components/gameBrowser/GameList.kt | 135 +++++++++++++++++---- .../luxons/sevenwonders/ui/components/home/Home.kt | 2 +- .../sevenwonders/ui/components/home/HomeStyles.kt | 5 - 7 files changed, 179 insertions(+), 37 deletions(-) create mode 100644 sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/GameBrowserStyles.kt (limited to 'sw-ui/src/main') diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/GlobalStyles.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/GlobalStyles.kt index 1477dd98..f9ea80b5 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/GlobalStyles.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/GlobalStyles.kt @@ -6,6 +6,11 @@ import styled.StyleSheet object GlobalStyles : StyleSheet("GlobalStyles", isStatic = true) { + val zeusBackground by css { + background = "url('images/backgrounds/zeus-temple.jpg') center no-repeat" + backgroundSize = "cover" + } + val fullscreen by css { position = Position.fixed top = 0.px diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/CreateGameForm.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/CreateGameForm.kt index e060af9c..10adb648 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/CreateGameForm.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/CreateGameForm.kt @@ -44,6 +44,7 @@ private class CreateGameForm(props: CreateGameFormProps) : RComponent val input = e.currentTarget as HTMLInputElement @@ -52,7 +53,6 @@ private class CreateGameForm(props: CreateGameFormProps) : RComponent(props) { override fun RBuilder.render() { + if (props.games.isEmpty()) { + noGamesInfo() + } else { + gamesTable() + } + } + + private fun RBuilder.noGamesInfo() { + bpNonIdealState( + icon = "geosearch", + title = "No games to join", + ) { + styledDiv { + attrs { + classes += "bp3-running-text" + } + css { + maxWidth = 35.rem + } + +"Nobody seems to be playing at the moment. " + +"Don't be disappointed, you can always create your own game, and play with bots if you're alone." + } + } + } + + private fun RBuilder.gamesTable() { bpHtmlTable { + attrs { + className = GameBrowserStyles.getClassName { it::gameTable } + } + columnWidthsSpec() thead { gameListHeaderRow() } @@ -48,24 +69,84 @@ class GameListPresenter(props: GameListProps) : RComponent.columnWidthsSpec() { + colGroup { + styledCol { + css { + width = 40.rem + } + } + styledCol { + css { + width = 5.rem + textAlign = TextAlign.center + } + } + styledCol { + css { + width = 5.rem + textAlign = TextAlign.center // use inline style on th instead to overcome blueprint style + } + } + styledCol { + css { + width = 3.rem + textAlign = TextAlign.center + } + } + } + } + private fun RBuilder.gameListHeaderRow() = tr { - th { +"Name" } - th { +"Status" } - th { +"Nb Players" } - th { +"Join" } + th { + +"Name" + } + th { + inlineStyles { gameTableHeaderCellStyle() } + +"Status" + } + th { + inlineStyles { gameTableHeaderCellStyle() } + +"Players" + } + th { + inlineStyles { gameTableHeaderCellStyle() } + +"Join" + } } private fun RBuilder.gameListItemRow(lobby: LobbyDTO) = styledTr { - css { - verticalAlign = VerticalAlign.middle - } attrs { key = lobby.id.toString() } - td { +lobby.name } - td { gameStatus(lobby.state) } - td { playerCount(lobby.players.size) } - td { joinButton(lobby) } + // inline styles necessary to overcome BlueprintJS's verticalAlign=top + td { + inlineStyles { gameTableCellStyle() } + +lobby.name + } + td { + inlineStyles { + textAlign = TextAlign.center + gameTableCellStyle() + } + gameStatus(lobby.state) + } + td { + inlineStyles { gameTableCellStyle() } + playerCount(lobby.players.size) + } + td { + inlineStyles { gameTableCellStyle() } + joinButton(lobby) + } + } + + private fun StyledElement.gameTableHeaderCellStyle() { + textAlign = TextAlign.center + } + + private fun StyledElement.gameTableCellStyle() { + verticalAlign = VerticalAlign.middle } private fun RBuilder.gameStatus(state: State) { @@ -84,13 +165,16 @@ class GameListPresenter(props: GameListProps) : RComponent