summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/CreateGameForm.kt53
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/home/ChooseNameForm.kt63
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/names/RandomNameGenerator.kt (renamed from sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/home/RandomNameGenerator.kt)60
3 files changed, 109 insertions, 67 deletions
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 ae79125b..acc64aaf 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
@@ -4,9 +4,9 @@ import blueprintjs.core.*
import blueprintjs.icons.*
import csstype.*
import emotion.react.*
+import org.luxons.sevenwonders.ui.names.*
import org.luxons.sevenwonders.ui.redux.*
import react.*
-import react.dom.html.ReactHTML.div
import react.dom.html.ReactHTML.form
val CreateGameForm = VFC {
@@ -15,34 +15,43 @@ val CreateGameForm = VFC {
val dispatch = useSwDispatch()
val createGame = { dispatch(RequestCreateGame(gameName)) }
- div {
+ form {
css {
display = Display.flex
flexDirection = FlexDirection.row
- justifyContent = JustifyContent.spaceBetween
}
- form {
- onSubmit = { e ->
- e.preventDefault()
+ onSubmit = { e ->
+ e.preventDefault()
+ createGame()
+ }
+
+ BpInputGroup {
+ large = true
+ placeholder = "Game name"
+ value = gameName
+ onChange = { e ->
+ val input = e.currentTarget
+ gameName = input.value
+ }
+ rightElement = BpButton.create {
+ title = "Generate random name"
+ icon = IconNames.RANDOM
+ minimal = true
+ onClick = { gameName = randomGameName() }
+ }
+ }
+ BpButton {
+ title = "Create the game"
+ intent = Intent.PRIMARY
+ icon = IconNames.ARROW_RIGHT
+ large = true
+ onClick = { e ->
+ e.preventDefault() // prevents refreshing the page when pressing Enter
createGame()
}
- BpInputGroup {
- large = true
- placeholder = "Game name"
- onChange = { e ->
- val input = e.currentTarget
- gameName = input.value
- }
- rightElement = BpButton.create {
- minimal = true
- intent = Intent.PRIMARY
- icon = IconNames.ADD
- onClick = { e ->
- e.preventDefault() // prevents refreshing the page when pressing Enter
- createGame()
- }
- }
+ css {
+ marginLeft = 0.2.rem
}
}
}
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/home/ChooseNameForm.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/home/ChooseNameForm.kt
index 8de9f53e..47c76a91 100644
--- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/home/ChooseNameForm.kt
+++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/home/ChooseNameForm.kt
@@ -4,13 +4,10 @@ import blueprintjs.core.*
import blueprintjs.icons.*
import csstype.*
import emotion.react.*
+import org.luxons.sevenwonders.ui.names.*
import org.luxons.sevenwonders.ui.redux.*
-import org.luxons.sevenwonders.ui.utils.*
import react.*
-import react.dom.events.*
-import react.dom.html.ReactHTML.div
import react.dom.html.ReactHTML.form
-import web.html.*
val ChooseNameForm = VFC {
val dispatch = useSwDispatch()
@@ -35,56 +32,34 @@ private val ChooseNameFormPresenter = FC<ChooseNameFormPresenterProps> { props -
e.preventDefault()
props.chooseUsername(usernameState)
}
- RandomNameButton {
- onClick = { usernameState = randomGreekName() }
- }
- spacer()
BpInputGroup {
large = true
placeholder = "Username"
- rightElement = SubmitButton.create {
- onClick = { e ->
- e.preventDefault()
- props.chooseUsername(usernameState)
- }
- }
value = usernameState
onChange = { e ->
val input = e.currentTarget
usernameState = input.value
}
+ rightElement = BpButton.create {
+ title = "Generate random name"
+ icon = IconNames.RANDOM
+ minimal = true
+ onClick = { usernameState = randomGreekName() }
+ }
}
- }
-}
-
-private external interface SpecificButtonProps : Props {
- var onClick: MouseEventHandler<HTMLElement>?
-}
-
-private val SubmitButton = FC<SpecificButtonProps> { props ->
- BpButton {
- minimal = true
- icon = IconNames.ARROW_RIGHT
- intent = Intent.PRIMARY
- onClick = props.onClick
- }
-}
-
-private val RandomNameButton = FC<SpecificButtonProps> { props ->
- BpButton {
- title = "Generate random name"
- large = true
- icon = IconNames.RANDOM
- intent = Intent.PRIMARY
- onClick = props.onClick
- }
-}
+ BpButton {
+ title = "Start"
+ icon = IconNames.ARROW_RIGHT
+ intent = Intent.PRIMARY
+ large = true
+ onClick = { e ->
+ e.preventDefault()
+ props.chooseUsername(usernameState)
+ }
-// TODO this is so bad I'm dying inside
-private fun ChildrenBuilder.spacer() {
- div {
- css {
- margin = Margin(all = 2.px)
+ css {
+ marginLeft = 0.2.rem
+ }
}
}
}
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/home/RandomNameGenerator.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/names/RandomNameGenerator.kt
index 2394fa20..393df78d 100644
--- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/home/RandomNameGenerator.kt
+++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/names/RandomNameGenerator.kt
@@ -1,12 +1,70 @@
-package org.luxons.sevenwonders.ui.components.home
+package org.luxons.sevenwonders.ui.names
import kotlin.random.Random
+internal fun randomGameName(): String = gameNames.random()
+
internal fun randomGreekName(): String {
val randName = prefixes.random() + suffixes.random()
return if (Random.nextBoolean()) randName else "$randName of ${cities.random()}"
}
+private val gameNames = listOf(
+ "Age of Antiquity",
+ "Age of Civilization",
+ "Age of Discovery",
+ "Age of Empires",
+ "Age of Wonders",
+ "Ancient Capitals",
+ "Ancient Kingdoms",
+ "Ancient Wonders",
+ "Cities of Antiquity",
+ "City of Wonders",
+ "Empire Builders",
+ "Empires of the Past",
+ "Great Monuments",
+ "Legendary Cities",
+ "Legends of the Past",
+ "Lost Empires",
+ "Magnificent Monuments",
+ "Magnificent Seven",
+ "Monuments of the Past",
+ "Monuments of the World",
+ "Mythical Kingdoms",
+ "Secrets of the Past",
+ "Seven Ancient Wonders",
+ "Seven Colossi",
+ "Seven Kingdoms",
+ "Seven Marvels",
+ "Seven Wonders Adventures",
+ "Seven Wonders Chronicles",
+ "Seven Wonders Enigma",
+ "Seven Wonders Expedition",
+ "Seven Wonders Frontier",
+ "Seven Wonders Legacy",
+ "Seven Wonders Odyssey",
+ "Seven Wonders Quest",
+ "Seven Wonders Saga",
+ "Seven Wonders Treasures",
+ "Seven Wonders Voyage",
+ "Seven Wonders and Beyond",
+ "The Great Discoveries",
+ "The Legacy of Wonders",
+ "The Magic of Seven",
+ "The Marvelous Seven",
+ "The Mysteries of Antiquity",
+ "The Seven Continents",
+ "The Seven Kingdoms",
+ "The Seven Legends",
+ "The Seven Secrets",
+ "The Seven Treasures",
+ "Wonders of Nature",
+ "Wonders of the Ages",
+ "Wonders of the World",
+ "Wonders of Time",
+ "World Treasures",
+)
+
private val prefixes =
listOf(
"Aba",
bgstack15