refactored view package
This commit is contained in:
52
internal/view/baseview/layout.templ
Normal file
52
internal/view/baseview/layout.templ
Normal file
@@ -0,0 +1,52 @@
|
||||
package baseview
|
||||
|
||||
import "git.haelnorr.com/h/oslstats/internal/view/popup"
|
||||
import "git.haelnorr.com/h/oslstats/internal/contexts"
|
||||
|
||||
// Global base layout for all pages
|
||||
templ Layout(title string) {
|
||||
{{ devInfo := contexts.DevMode(ctx) }}
|
||||
<!DOCTYPE html>
|
||||
<html
|
||||
lang="en"
|
||||
x-data="{ theme: localStorage.getItem('theme') || 'system'}"
|
||||
x-init="$watch('theme', (val) => localStorage.setItem('theme', val))"
|
||||
x-bind:class="{'dark': theme === 'dark' || (theme === 'system' &&
|
||||
window.matchMedia('(prefers-color-scheme: dark)').matches)}"
|
||||
>
|
||||
<head>
|
||||
<script src="/static/js/theme.js"></script>
|
||||
<meta charset="UTF-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>{ title }</title>
|
||||
<link rel="icon" type="image/x-icon" href="/static/assets/favicon.ico"/>
|
||||
<link href="/static/css/output.css" rel="stylesheet"/>
|
||||
<script src="/static/vendored/htmx@2.0.8.min.js"></script>
|
||||
<script src="/static/vendored/htmx-ext-ws.min.js"></script>
|
||||
<script src="/static/vendored/alpinejs@3.15.4.min.js" defer></script>
|
||||
if devInfo.HTMXLog {
|
||||
<script>
|
||||
htmx.logAll();
|
||||
</script>
|
||||
}
|
||||
</head>
|
||||
<body
|
||||
class="bg-base text-text ubuntu-mono-regular overflow-x-hidden"
|
||||
hx-ext="ws"
|
||||
ws-connect={ devInfo.WebsocketBase + "/ws/notifications" }
|
||||
>
|
||||
@popup.ErrorModalContainer()
|
||||
@popup.ToastContainer()
|
||||
<div
|
||||
id="main-content"
|
||||
class="flex flex-col h-screen justify-between"
|
||||
>
|
||||
@Navbar()
|
||||
<div id="page-content" class="mb-auto md:px-5 md:pt-5">
|
||||
{ children... }
|
||||
</div>
|
||||
@Footer()
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
}
|
||||
Reference in New Issue
Block a user