goipam/web/templates/mainComponents.templ

107 lines
2.7 KiB
Plaintext

package templates
templ head(title string) {
<head>
<meta charset="UTF-8"/>
<link rel="stylesheet" href="/static/bulma.min.css"/>
<link rel="stylesheet" href="/static/materialsymbols.css"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>{ title }</title>
</head>
}
templ footer(timestamp string) {
<footer class="footer is-fixed-bottom">
<div class="content has-text-centered">
<p>
<strong>GoIPAM</strong> by <a href="https://www.jmbit.de">Johannes Bülow</a> &copy; { timestamp } .
The source code is licensed <a href="https://opensource.org/license/gpl-2-0/">GPLv2</a>.
Using <a href="https://bulma.io/">Bulma</a>, <a href="https://htmx.org/">HTMX</a>, <a href="https://templ.guide/">Templ</a>, <a href="https://gin-gonic.com/">Gin</a> and <a href="https://gorm.io/">GORM</a>.
</p>
</div>
<script src="/static/htmx.min.js"></script>
<script src="/static/bulmaScripts.js"></script>
</footer>
}
templ navbar(loggedIn bool) {
<nav id="navbarTop" class="navbar is-transparent is-fixed-top pb-3" role="navigation" aria-label="main navigation">
<div class="navbar-brand">
<a class="navbar-item has-text-centered" href="/">
<p class="title">GoIPAM</p>
</a>
<a role="button" class="navbar-burger" aria-label="menu" aria-expanded="false" data-target="navbarTop">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
</div>
<div id="navbar" class="navbar-menu">
<div class="navbar-start">
<a class="navbar-item" href="/index.html">
Home
</a>
<a class="navbar-item">
Page
</a>
</div>
<div class="navbar-end">
<div class="navbar-item">
@loginButton(loggedIn)
</div>
</div>
</div>
</nav>
}
templ loginButton(loggedIn bool) {
if loggedIn {
<a class="navbar-link" href="/profile/">
Profile
</a>
<div class="buttons">
<a class="button is-light" href="/logout.html">
Log out
</a>
</div>
} else {
<div class="buttons">
<a class="button is-light" href="/login.html">
Log in
</a>
</div>
}
}
templ ErrorMessage(title string, content string) {
<article class="message container">
<div class="message-header">
<p>{ title }</p>
<button class="delete" aria-label="delete"></button>
</div>
<div class="message-body">
{ content }
</div>
</article>
}
// wrapBase handles the basics of HTML
templ wrapBase(metaContent utils.MetaContent, title string, err error) {
<!DOCTYPE HTML>
<html>
@head(title)
<body class="has-navbar-fixed-top">
@navbar(metaContent.IsLoggedIn)
if err != nil {
@ErrorMessage("Error", err.Error())
}
{ children... }
@footer(metaContent.Timestamp)
</body>
</html>
}
templ Empty() {
<div id="empty"></div>
}