- User registration/login with bcrypt password hashing - SQLite database with goose migrations and sqlc-generated queries - Games and players persisted to database, resumable after restart - Guest play still supported alongside authenticated users - Auth UI components (login/register forms, auth header, guest banner)
69 lines
1.5 KiB
Go
69 lines
1.5 KiB
Go
package ui
|
|
|
|
import (
|
|
"github.com/ryanhamamura/via/h"
|
|
)
|
|
|
|
func LobbyView(nicknameBind, createGameKeyDown, createGameClick h.H, isLoggedIn bool, username string, logoutClick h.H) h.H {
|
|
var authSection h.H
|
|
if isLoggedIn {
|
|
authSection = AuthHeader(username, logoutClick)
|
|
} else {
|
|
authSection = GuestBanner()
|
|
}
|
|
|
|
return h.Main(h.Class("container"),
|
|
h.Div(h.Class("lobby"),
|
|
authSection,
|
|
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,
|
|
),
|
|
),
|
|
),
|
|
)
|
|
}
|