summaryrefslogtreecommitdiff
path: root/pages/base.templ
blob: ce945ae06eadeae30e27bab315e5645680fb5362 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package pages

templ baseWithHeader(header templ.Component) {
    <!DOCTYPE html>
    <html lang="de">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="icon" type="image/svg+xml" href="/static/favicon.svg" sizes="16x16 32x32 48x48">
        <title>Kosten</title>
        <link href="/static/custom.css" rel="stylesheet">
        <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
        <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
        if header != nil {
            @header
        }
    </head>
    <body>
        { children... }
    </body>
    </html>
}

func base() templ.Component {
    return baseWithHeader(nil)
}

templ navlink(path, descr string) {
    <li class="nav-item">
        <a  class={"nav-link", templ.KV("active", isCurrPath(ctx, path))} 
            href={templ.URL(path)}>{descr}</a>
    </li>
}

templ navlinks() {
    @navlink("/categories", "Kategorien")
    @navlink("/recur", "Regelmäßig")
}

templ userlinks() {
    <li><a class="dropdown-item" href="/logout">Logout</a></li>
}

templ navbar() {
    /* different inline svgs */
    <svg xmlns="http://www.w3.org/2000/svg" class="d-none">
        <symbol id="search" viewBox="0 0 16 16">
            <path d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z"></path>
        </symbol>
        <symbol id="person" viewBox="0 0 16 16">
            <path d="M8 8a3 3 0 1 0 0-6 3 3 0 0 0 0 6m2-3a2 2 0 1 1-4 0 2 2 0 0 1 4 0m4 8c0 1-1 1-1 1H3s-1 0-1-1 1-4 6-4 6 3 6 4m-1-.004c-.001-.246-.154-.986-.832-1.664C11.516 10.68 10.289 10 8 10s-3.516.68-4.168 1.332c-.678.678-.83 1.418-.832 1.664z"/>
        </symbol>
    </svg>

    /* The Navbar */
    <nav class="navbar sticky-top bg-dark-subtle navbar-expand-lg shadow mb-2">
        <div class="container-fluid" >
            <a class="navbar-brand" href="/">
                <img src="/static/euro-money.svg" alt="Logo" width="32" height="32" class="d-inline-block"/> Kosten
            </a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav nav-underline me-auto">
                    @navlinks()
                </ul>
                <form class="d-flex" role="search">
                    <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
                    <button class="btn btn-outline-dark" type="submit"><svg class="svg"><use xlink:href="#search"></use></svg></button>
                </form>
                <div class="dropdown ms-3">
                    <button class="btn btn-outline-primary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
                        <svg class="svg"><use xlink:href="#person"></use></svg>
                    </button>
                    <ul class="dropdown-menu dropdown-menu-lg-end">
                        @userlinks()
                    </ul>
                </div>
            </div>          
        </div>
    </nav>
}

templ content() {
    @base() {
        @navbar()
         <main class="container-lg">
            {children...}
         </main>
    }
}