summaryrefslogtreecommitdiff
path: root/sw-ui
diff options
context:
space:
mode:
Diffstat (limited to 'sw-ui')
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/Application.kt19
1 files changed, 16 insertions, 3 deletions
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/Application.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/Application.kt
index 9850f8c0..385abb18 100644
--- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/Application.kt
+++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/Application.kt
@@ -9,13 +9,26 @@ import org.luxons.sevenwonders.ui.router.Route
import react.RBuilder
import react.router.dom.*
-fun RBuilder.application() = hashRouter {
+fun RBuilder.application() = HashRouter {
errorDialog()
- switch {
+ Switch {
route(Route.GAME_BROWSER.path) { gameBrowser() }
route(Route.GAME.path) { gameScene() }
route(Route.LOBBY.path) { lobby() }
route(Route.HOME.path, exact = true) { home() }
- redirect(from = "*", to = "/")
+ Redirect {
+ attrs {
+ from = "*"
+ to = "/"
+ }
+ }
+ }
+}
+
+private fun RBuilder.route(path: String, exact: Boolean = false, render: RBuilder.() -> Unit) {
+ Route {
+ attrs.path = arrayOf(path)
+ attrs.exact = exact
+ render()
}
}
bgstack15