summaryrefslogtreecommitdiff
path: root/view/login.templ
blob: 1beb1d627754d8b4e1676b26558956cb3ab6d6dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package view

import (
    "stevenlr.com/locker/model"
)

templ LoginFormError(currentUser *model.User, err string) {
    if currentUser == nil {
        <div class="login-form">
            <form
                hx-post="/login"
                hx-target-error="closest .login-form"
                class="
                    w-80
                    mx-auto
                    flex flex-col
                    gap-4
                "
            >
                    @TextField("user", "User name")
                    @PasswordField("password", "Password")
                    @Button("submit", "Sign in", templ.Attributes{})
                    if err != "" {
                        <span class="text-red-400">{ err }</span>
                    }
            </form>
        </div>
    } else {
        <div class="
                flex flex-row items-baseline justify-start
             "
        >
            <h1
                class="
                    grow
                    text-slate-300 text-4xl font-semibold
                "
            >Prout prout</h1>
            <div
                class="
                    flex flex-row justify-end items-center gap-4
                "
            >
                <p>Signed in as <b>{ currentUser.Name }</b></p>
                @SecondaryButton("button", "Sign out", templ.Attributes{
                    "hx-post": "/logout",
                    "hx-refresh": true,
                })
            </div>
        </div>
    }
}

templ LoginForm(currentUser *model.User) {
    @LoginFormError(currentUser, "")
}