- Enter key now triggers createGame action on home page - Remove redundant setNickname action from home page - Remove unused code: join channel, Leave(), Stop() methods - Consolidate ID generation into game.GenerateID() - Remove unused CreatedAt field from Game struct
61 lines
1.3 KiB
Go
61 lines
1.3 KiB
Go
package ui
|
|
|
|
import (
|
|
"github.com/ryanhamamura/via/h"
|
|
)
|
|
|
|
func LobbyView(nicknameBind, createGameKeyDown, createGameClick h.H) h.H {
|
|
return h.Main(h.Class("container"),
|
|
h.Div(h.Class("lobby"),
|
|
h.H1(h.Text("Connect 4")),
|
|
h.P(h.Text("Challenge a friend to a game of Connect 4!")),
|
|
h.Form(
|
|
h.FieldSet(
|
|
h.Label(h.Text("Your Nickname"), h.Attr("for", "nickname")),
|
|
h.Input(
|
|
h.ID("nickname"),
|
|
h.Type("text"),
|
|
h.Placeholder("Enter your nickname"),
|
|
nicknameBind,
|
|
h.Attr("required"),
|
|
createGameKeyDown,
|
|
),
|
|
),
|
|
h.Button(
|
|
h.Type("button"),
|
|
h.Text("Create Game"),
|
|
createGameClick,
|
|
),
|
|
),
|
|
),
|
|
)
|
|
}
|
|
|
|
func NicknamePrompt(nicknameBind, setNicknameKeyDown, setNicknameClick h.H) h.H {
|
|
return h.Main(h.Class("container"),
|
|
h.Div(h.Class("lobby"),
|
|
h.H1(h.Text("Join Game")),
|
|
h.P(h.Text("Enter your nickname to join the game.")),
|
|
h.Form(
|
|
h.FieldSet(
|
|
h.Label(h.Text("Your Nickname"), h.Attr("for", "nickname")),
|
|
h.Input(
|
|
h.ID("nickname"),
|
|
h.Type("text"),
|
|
h.Placeholder("Enter your nickname"),
|
|
nicknameBind,
|
|
h.Attr("required"),
|
|
h.Attr("autofocus"),
|
|
setNicknameKeyDown,
|
|
),
|
|
),
|
|
h.Button(
|
|
h.Type("button"),
|
|
h.Text("Join"),
|
|
setNicknameClick,
|
|
),
|
|
),
|
|
),
|
|
)
|
|
}
|