Initial extraction of shared webui layout (base/navbar/sidebar/footer)

Pilot module for the shared design used by yasta, yasl, yaiam, yakwui,
and yamase-web: server-rendered Bootstrap dashboard chrome, imported as
a Go module instead of copy-pasted per project.
This commit is contained in:
Bjoern Kalkbrenner committed 2026-08-28 11:18:34 +02:00
commit 79f7f972f1
11 files changed
+439

No files matched your search

+72
View File
@@ -0,0 +1,72 @@
# yetano-webui-template
Shared server-rendered web UI chrome (base layout, navbar, sidebar,
footer) for the Yetano/Yak/Yamase family of ops-tool admin dashboards.
This is a real Go module (`teruna.dev/yetano/yetano-webui-template`,
package `layout`), imported by each dashboard rather than copy-pasted —
see `layout.go` for the API (`PageHeader`, `NavItem`, `NewRenderer`,
`StaticHandler`).
## Source of truth
This repo is the **source of truth** for the shared layout. It is mirrored
into the other two meta-repos as `yak-webui-template` and
`yamase-webui-template`, each of which pulls this repo in via `git
subtree` so layout/CSS changes can be synchronized without duplicating
design work. Make layout changes *here first*, then push them out — never
edit the mirrored copies directly.
### Pushing a change out to the mirrors
From inside `yak` or `yamase` (which already have this repo added as a
subtree remote — see below):
```sh
git subtree pull --prefix=yak-webui-template webui-template-origin main --squash
# resolve/verify, then:
git push origin main
```
### One-time subtree setup (already done for yak/yamase, kept here for
reference/re-setup)
```sh
git remote add webui-template-origin https://teruna.dev/yetano/yetano-webui-template.git
git subtree add --prefix=yak-webui-template webui-template-origin main --squash
```
## What's shared vs. what stays per-project
Shared here: the base HTML skeleton, navbar, sidebar (generic nav-item
list), footer, and the CSS rules that style exactly those elements
(`static/style.css` — theme root variables, navbar, `.sidebar .nav-link`
incl. the `#0b82b8` inactive-link color, footer, flash-banner alerts).
Stays in each consuming project: page-specific templates
(`templates/pages/*.html.tmpl`), page-content CSS (cards, tables, badges,
forms, buttons, markdown, ...), and anything else specific to that tool.
## Consuming this module
```go
type pageHeader = layout.PageHeader // embed this in your own page data structs
r, err := layout.NewRenderer(pagesFS, "templates/pages", pageNames, ".html.tmpl", template.FuncMap{
"buildInfo": func() string { return version.Get().Compact() },
})
...
mux.Handle("/webui-static/", layout.StaticHandler("/webui-static/"))
```
See `yetano/yasta` for a full worked example (the pilot migration of this
module).
## Migration status
| Project | Meta-repo | Status |
|---|---|---|
| `yasta` | yetano | migrated (pilot) |
| `yasl` | yetano | not yet migrated |
| `yaiam` | yetano | not yet migrated |
| `yakwui` | yak | not yet migrated |
| `yamase-web` | yamase | not yet migrated |
+3
View File
@@ -0,0 +1,3 @@
module teruna.dev/yetano/yetano-webui-template
go 1.26.3
+111
View File
@@ -0,0 +1,111 @@
// Package layout provides the shared server-rendered web UI chrome (base
// layout, navbar, sidebar, footer) used by every Yetano/Yak/Yamase
// ops-tool admin dashboard: yasta, yasl, yaiam, yakwui, and yamase-web.
//
// Consumers embed PageHeader in their own per-page data struct and use
// NewRenderer to parse the shared layout templates together with their
// own page-specific templates. Page-content styling (cards, tables,
// badges, forms, ...) stays each project's own concern; only the chrome
// that base/navbar/sidebar/footer actually render is shared here.
package layout
import (
"embed"
"fmt"
"html/template"
"io"
"io/fs"
"net/http"
)
//go:embed templates/layout
var templateFS embed.FS
//go:embed static
var staticFS embed.FS
// LayoutGlob is the glob NewRenderer uses to pull in the shared
// base/navbar/sidebar/footer templates.
const LayoutGlob = "templates/layout/*.tmpl"
// NavItem is one sidebar entry.
type NavItem struct {
ID string // matches PageHeader.ActiveNav to mark this item active
Label string
Href string // BasePath-relative, e.g. "/tasks"
}
// PageHeader holds the fields every page's own data struct should embed
// so the shared base/navbar/sidebar/footer templates can render
// regardless of which project or page is being rendered. Zero-valued
// fields simply render nothing (e.g. Username == "" hides the
// username/logout group).
type PageHeader struct {
Title string
Name string // lowercase product name, e.g. "yasta"; used in <title> and the footer
Brand string // navbar brand text, e.g. "YASTA"
BrandInitial string // single-letter favicon glyph, e.g. "y"
Subtitle string
BasePath string
NavItems []NavItem
ActiveNav string
Flash string
FlashKind string // "ok" or "error"; meaningless if Flash == ""
Username string
LogoutPath string // BasePath-relative, e.g. "/logout"; "" hides the logout link
NavbarLeftExtra template.HTML // extra markup rendered after Subtitle in the navbar's left group
NavbarRightExtra template.HTML // extra markup rendered after Username/Logout in the navbar's right group
ExtraHeadHTML template.HTML // extra <link>/<script> tags appended to <head>
ExtraBodyHTML template.HTML // extra <script> tags appended before </body>
}
// Renderer holds one independently parsed *template.Template per page:
// the shared layout files plus that one page's own file. Parsing each
// page separately -- rather than one shared template.Template built from
// every file -- keeps each page's "content" block (every page defines
// one) scoped to that page instead of colliding in a single global
// template namespace.
type Renderer struct {
pages map[string]*template.Template
}
// NewRenderer parses, for each name in pageNames, the shared layout
// templates plus pagesFS's <pageDir>/<name><pageSuffix> into its own
// Renderer entry. funcs must supply everything the templates call,
// including "buildInfo" (used by the shared footer).
func NewRenderer(pagesFS fs.FS, pageDir string, pageNames []string, pageSuffix string, funcs template.FuncMap) (*Renderer, error) {
r := &Renderer{pages: make(map[string]*template.Template, len(pageNames))}
for _, name := range pageNames {
t := template.New("base").Funcs(funcs)
t, err := t.ParseFS(templateFS, LayoutGlob)
if err != nil {
return nil, fmt.Errorf("layout: parsing shared layout templates: %w", err)
}
t, err = t.ParseFS(pagesFS, pageDir+"/"+name+pageSuffix)
if err != nil {
return nil, fmt.Errorf("layout: parsing page %q: %w", name, err)
}
r.pages[name] = t
}
return r, nil
}
// Page renders the full page (layout + content) for the given page name.
func (r *Renderer) Page(w io.Writer, page string, data any) error {
t, ok := r.pages[page]
if !ok {
return fmt.Errorf("layout: unknown page %q", page)
}
return t.ExecuteTemplate(w, "base", data)
}
// StaticHandler serves the shared vendored static assets
// (bootstrap.min.css, bootstrap.bundle.min.js, and the shared chrome
// stylesheet) under prefix.
func StaticHandler(prefix string) http.Handler {
sub, err := fs.Sub(staticFS, "static")
if err != nil {
panic(err) // static is embedded at build time; this cannot fail at runtime
}
return http.StripPrefix(prefix, http.FileServerFS(sub))
}
+64
View File
@@ -0,0 +1,64 @@
package layout
import (
"bytes"
"html/template"
"strings"
"testing"
"testing/fstest"
)
func testPagesFS() fstest.MapFS {
return fstest.MapFS{
"pages/dashboard.html.tmpl": &fstest.MapFile{Data: []byte(
`{{define "content"}}<p>hello {{.Title}}</p>{{end}}`,
)},
}
}
func testFuncs() template.FuncMap {
return template.FuncMap{"buildInfo": func() string { return "test-build" }}
}
func TestNewRendererAndPage(t *testing.T) {
r, err := NewRenderer(testPagesFS(), "pages", []string{"dashboard"}, ".html.tmpl", testFuncs())
if err != nil {
t.Fatalf("NewRenderer: %v", err)
}
var buf bytes.Buffer
data := PageHeader{
Title: "Dashboard",
Name: "example",
Brand: "EXAMPLE",
BrandInitial: "e",
BasePath: "",
NavItems: []NavItem{{ID: "dashboard", Label: "Dashboard", Href: "/"}},
ActiveNav: "dashboard",
}
if err := r.Page(&buf, "dashboard", data); err != nil {
t.Fatalf("Page: %v", err)
}
out := buf.String()
for _, want := range []string{
"<p>hello Dashboard</p>",
`class="nav-link active"`,
"test-build",
"<title>Dashboard · example</title>",
} {
if !strings.Contains(out, want) {
t.Errorf("rendered output missing %q\n---\n%s", want, out)
}
}
}
func TestPageUnknown(t *testing.T) {
r, err := NewRenderer(testPagesFS(), "pages", []string{"dashboard"}, ".html.tmpl", testFuncs())
if err != nil {
t.Fatalf("NewRenderer: %v", err)
}
if err := r.Page(&bytes.Buffer{}, "nope", PageHeader{}); err == nil {
t.Fatal("expected error for unknown page")
}
}
+7
View File
@@ -0,0 +1,7 @@
/*!
* Bootstrap v5.3.3 (https://getbootstrap.com/)
* Copyright 2011-2024 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).bootstrap=e()}(this,(function(){"use strict";const t=new Map,e={set(e,i,n){t.has(e)||t.set(e,new Map);const s=t.get(e);s.has(i)||0===s.size?s.set(i,n):console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(s.keys())[0]}.`)},get:(e,i)=>t.has(e)&&t.get(e).get(i)||null,remove(e,i){if(!t.has(e))return;const n=t.get(e);n.delete(i),0===n.size&&t.delete(e)}},i="transitionend",n=t=>(t&&window.CSS&&window.CSS.escape&&(t=t.replace(/#([^\s"#']+)/g,((t,e)=>`#${CSS.escape(e)}`))),t),s=t=>{t.dispatchEvent(new Event(i))},o=t=>!(!t||"object"!=typeof t)&&(void 0!==t.jquery&&(t=t[0]),void 0!==t.nodeType),r=t=>o(t)?t.jquery?t[0]:t:"string"==typeof t&&t.length>0?document.querySelector(n(t)):null,a=t=>{if(!o(t)||0===t.getClientRects().length)return!1;const e="visible"===getComputedStyle(t).getPropertyValue("visibility"),i=t.closest("details:not([open])");if(!i)return e;if(i!==t){const e=t.closest("summary");if(e&&e.parentNode!==i)return!1;if(null===e)return!1}return e},l=t=>!t||t.nodeType!==Node.ELEMENT_NODE||!!t.classList.contains("disabled")||(void 0!==t.disabled?t.disabled:t.hasAttribute("disabled")&&"false"!==t.getAttribute("disabled")),c=t=>{if(!document.documentElement.attachShadow)return null;if("function"==typeof t.getRootNode){const e=t.getRootNode();return e instanceof ShadowRoot?e:null}return t instanceof ShadowRoot?t:t.parentNode?c(t.parentNode):null},h=()=>{},d=t=>{t.offsetHeight},u=()=>window.jQuery&&!document.body.hasAttribute("data-bs-no-jquery")?window.jQuery:null,f=[],p=()=>"rtl"===document.documentElement.dir,m=t=>{var e;e=()=>{const e=u();if(e){const i=t.NAME,n=e.fn[i];e.fn[i]=t.jQueryInterface,e.fn[i].Constructor=t,e.fn[i].noConflict=()=>(e.fn[i]=n,t.jQueryInterface)}},"loading"===document.readyState?(f.length||document.addEventListener("DOMContentLoaded",(()=>{for(const t of f)t()})),f.push(e)):e()},g=(t,e=[],i=t)=>"function"==typeof t?t(...e):i,_=(t,e,n=!0)=>{if(!n)return void g(t);const o=(t=>{if(!t)return 0;let{transitionDuration:e,transitionDelay:i}=window.getComputedStyle(t);const n=Number.parseFloat(e),s=Number.parseFloat(i);return n||s?(e=e.split(",")[0],i=i.split(",")[0],1e3*(Number.parseFloat(e)+Number.parseFloat(i))):0})(e)+5;let r=!1;const a=({target:n})=>{n===e&&(r=!0,e.removeEventListener(i,a),g(t))};e.addEventListener(i,a),setTimeout((()=>{r||s(e)}),o)},b=(t,e,i,n)=>{const s=t.length;let o=t.indexOf(e);return-1===o?!i&&n?t[s-1]:t[0]:(o+=i?1:-1,n&&(o=(o+s)%s),t[Math.max(0,Math.min(o,s-1))])},v=/[^.]*(?=\..*)\.|.*/,y=/\..*/,w=/::\d+$/,A={};let E=1;const T={mouseenter:"mouseover",mouseleave:"mouseout"},C=new Set(["click","dblclick","mouseup","mousedown","contextmenu","mousewheel","DOMMouseScroll","mouseover","mouseout","mousemove","selectstart","selectend","keydown","keypress","keyup","orientationchange","touchstart","touchmove","touchend","touchcancel","pointerdown","pointermove","pointerup","pointerleave","pointercancel","gesturestart","gesturechange","gestureend","focus","blur","change","reset","select","submit","focusin","focusout","load","unload","beforeunload","resize","move","DOMContentLoaded","readystatechange","error","abort","scroll"]);function O(t,e){return e&&`${e}::${E++}`||t.uidEvent||E++}function x(t){const e=O(t);return t.uidEvent=e,A[e]=A[e]||{},A[e]}function k(t,e,i=null){return Object.values(t).find((t=>t.callable===e&&t.delegationSelector===i))}function L(t,e,i){const n="string"==typeof e,s=n?i:e||i;let o=I(t);return C.has(o)||(o=t),[n,s,o]}function S(t,e,i,n,s){if("string"!=typeof e||!t)return;let[o,r,a]=L(e,i,n);if(e in T){const t=t=>function(e){if(!e.relatedTarget||e.relatedTarget!==e.delegateTarget&&!e.delegateTarget.contains(e.relatedTarget))return t.call(this,e)};r=t(r)}const l=x(t),c=l[a]||(l[a]={}),h=k(c,r,o?i:null);if(h)return void(h.oneOff=h.oneOff&&s);const d=O(r,e.replace(v,"")),u=o?function(t,e,i){return function n(s){const o=t.querySelectorAll(e);for(let{target:r}=s;r&&r!==this;r=r.parentNode)for(const a of o)if(a===r)return P(s,{delegateTarget:r}),n.oneOff&&N.off(t,s.type,e,i),i.apply(r,[s])}}(t,i,r):function(t,e){return function i(n){return P(n,{delegateTarget:t}),i.oneOff&&N.off(t,n.type,e),e.apply(t,[n])}}(t,r);u.delegationSelector=o?i:null,u.callable=r,u.oneOff=s,u.uidEvent=d,c[d]=u,t.addEventListener(a,u,o)}function D(t,e,i,n,s){const o=k(e[i],n,s);o&&(t.removeEventListener(i,o,Boolean(s)),delete e[i][o.uidEvent])}function $(t,e,i,n){const s=e[i]||{};for(const[o,r]of Object.entries(s))o.includes(n)&&D(t,e,i,r.callable,r.delegationSelector)}function I(t){return t=t.replace(y,""),T[t]||t}const N={on(t,e,i,n){S(t,e,i,n,!1)},one(t,e,i,n){S(t,e,i,n,!0)},off(t,e,i,n){if("string"!=typeof e||!t)return;const[s,o,r]=L(e,i,n),a=r!==e,l=x(t),c=l[r]||{},h=e.startsWith(".");if(void 0===o){if(h)for(const i of Object.keys(l))$(t,l,i,e.slLine truncated
//# sourceMappingURL=bootstrap.bundle.min.js.map
+6
View File
@@ -0,0 +1,6 @@
@charset "UTF-8";/*!
* Bootstrap v5.3.3 (https://getbootstrap.com/)
* Copyright 2011-2024 The Bootstrap Authors
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/:root,[data-bs-theme=light]{--bs-blue:#0d6efd;--bs-indigo:#6610f2;--bs-purple:#6f42c1;--bs-pink:#d63384;--bs-red:#dc3545;--bs-orange:#fd7e14;--bs-yellow:#ffc107;--bs-green:#198754;--bs-teal:#20c997;--bs-cyan:#0dcaf0;--bs-black:#000;--bs-white:#fff;--bs-gray:#6c757d;--bs-gray-dark:#343a40;--bs-gray-100:#f8f9fa;--bs-gray-200:#e9ecef;--bs-gray-300:#dee2e6;--bs-gray-400:#ced4da;--bs-gray-500:#adb5bd;--bs-gray-600:#6c757d;--bs-gray-700:#495057;--bs-gray-800:#343a40;--bs-gray-900:#212529;--bs-primary:#0d6efd;--bs-secondary:#6c757d;--bs-success:#198754;--bs-info:#0dcaf0;--bs-warning:#ffc107;--bs-danger:#dc3545;--bs-light:#f8f9fa;--bs-dark:#212529;--bs-primary-rgb:13,110,253;--bs-secondary-rgb:108,117,125;--bs-success-rgb:25,135,84;--bs-info-rgb:13,202,240;--bs-warning-rgb:255,193,7;--bs-danger-rgb:220,53,69;--bs-light-rgb:248,249,250;--bs-dark-rgb:33,37,41;--bs-primary-text-emphasis:#052c65;--bs-secondary-text-emphasis:#2b2f32;--bs-success-text-emphasis:#0a3622;--bs-info-text-emphasis:#055160;--bs-warning-text-emphasis:#664d03;--bs-danger-text-emphasis:#58151c;--bs-light-text-emphasis:#495057;--bs-dark-text-emphasis:#495057;--bs-primary-bg-subtle:#cfe2ff;--bs-secondary-bg-subtle:#e2e3e5;--bs-success-bg-subtle:#d1e7dd;--bs-info-bg-subtle:#cff4fc;--bs-warning-bg-subtle:#fff3cd;--bs-danger-bg-subtle:#f8d7da;--bs-light-bg-subtle:#fcfcfd;--bs-dark-bg-subtle:#ced4da;--bs-primary-border-subtle:#9ec5fe;--bs-secondary-border-subtle:#c4c8cb;--bs-success-border-subtle:#a3cfbb;--bs-info-border-subtle:#9eeaf9;--bs-warning-border-subtle:#ffe69c;--bs-danger-border-subtle:#f1aeb5;--bs-light-border-subtle:#e9ecef;--bs-dark-border-subtle:#adb5bd;--bs-white-rgb:255,255,255;--bs-black-rgb:0,0,0;--bs-font-sans-serif:system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue","Noto Sans","Liberation Sans",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--bs-font-monospace:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--bs-gradient:linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0));--bs-body-font-family:var(--bs-font-sans-serif);--bs-body-font-size:1rem;--bs-body-font-weight:400;--bs-body-line-height:1.5;--bs-body-color:#212529;--bs-body-color-rgb:33,37,41;--bs-body-bg:#fff;--bs-body-bg-rgb:255,255,255;--bs-emphasis-color:#000;--bs-emphasis-color-rgb:0,0,0;--bs-secondary-color:rgba(33, 37, 41, 0.75);--bs-secondary-color-rgb:33,37,41;--bs-secondary-bg:#e9ecef;--bs-secondary-bg-rgb:233,236,239;--bs-tertiary-color:rgba(33, 37, 41, 0.5);--bs-tertiary-color-rgb:33,37,41;--bs-tertiary-bg:#f8f9fa;--bs-tertiary-bg-rgb:248,249,250;--bs-heading-color:inherit;--bs-link-color:#0d6efd;--bs-link-color-rgb:13,110,253;--bs-link-decoration:underline;--bs-link-hover-color:#0a58ca;--bs-link-hover-color-rgb:10,88,202;--bs-code-color:#d63384;--bs-highlight-color:#212529;--bs-highlight-bg:#fff3cd;--bs-border-width:1px;--bs-border-style:solid;--bs-border-color:#dee2e6;--bs-border-color-translucent:rgba(0, 0, 0, 0.175);--bs-border-radius:0.375rem;--bs-border-radius-sm:0.25rem;--bs-border-radius-lg:0.5rem;--bs-border-radius-xl:1rem;--bs-border-radius-xxl:2rem;--bs-border-radius-2xl:var(--bs-border-radius-xxl);--bs-border-radius-pill:50rem;--bs-box-shadow:0 0.5rem 1rem rgba(0, 0, 0, 0.15);--bs-box-shadow-sm:0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);--bs-box-shadow-lg:0 1rem 3rem rgba(0, 0, 0, 0.175);--bs-box-shadow-inset:inset 0 1px 2px rgba(0, 0, 0, 0.075);--bs-focus-ring-width:0.25rem;--bs-focus-ring-opacity:0.25;--bs-focus-ring-color:rgba(13, 110, 253, 0.25);--bs-form-valid-color:#198754;--bs-form-valid-border-color:#198754;--bs-form-invalid-color:#dc3545;--bs-form-invalid-border-color:#dc3545}[data-bs-theme=dark]{color-scheme:dark;--bs-body-color:#dee2e6;--bs-body-color-rgb:222,226,230;--bs-body-bg:#212529;--bs-body-bg-rgb:33,37,41;--bs-emphasis-color:#fff;--bs-emphasis-color-rgb:255,255,255;--bs-secondary-color:rgba(222, 226, 230, 0.75);--bs-secondary-color-rgb:222,226,230;--bs-secondary-bg:#343a40;--bs-secondary-bg-rgb:52,58,64;--bs-tertiary-color:rgba(222, 226, 230, 0.5);--bs-tertiary-color-rgb:222,226,230;--bs-tertiary-bg:#2b3035;--bs-tertiary-bg-rgb:43,48,53;--bs-primary-text-emphasis:#6ea8fe;--bs-secondary-text-emphasis:#a7acb1;--bs-success-text-emphasis:#75b798;--bs-info-text-emphasis:#6edff6;--bs-warning-text-emphasis:#ffda6a;--bs-danger-text-emphasis:#ea868f;--bs-light-text-emphasis:#f8f9fa;--bs-dark-text-emphasis:#dee2e6;--bs-primary-bg-subtle:#031633;--bs-secondary-bg-subtle:#161719;--bs-success-bg-subtle:#051b11;--bs-info-bg-subtle:#032830;--bs-warning-bg-subtle:#332701;--bs-danger-bg-subtle:#2c0b0e;--bs-light-bg-subtle:#343a40;--bs-dark-bg-subtle:#1a1d20;--bs-primary-border-subtle:#084298;--bs-secondary-border-subtle:#41464b;--bs-success-border-subtle:#0f5132;--bs-info-border-subtle:#087990;--bs-warning-border-subtle:#997404;--bs-danger-border-subtle:#842029;--bs-light-border-subtle:#495057;--bs-dark-border-subtle:#343a40;--bs-heading-color:inherLine truncated
/*# sourceMappingURL=bootstrap.min.css.map */
+121
View File
@@ -0,0 +1,121 @@
/* Shared web UI chrome -- the dark-theme base layout, navbar, sidebar, and
footer used by every ops-tool dashboard built on this module (yasta,
yasl, yaiam, yakwui, yamase-web). Loaded after bootstrap.min.css.
Page-content styling (cards, tables, badges, forms, ...) is each
project's own concern and lives in that project's own stylesheet,
loaded alongside this one -- see PageHeader.ExtraHeadHTML. Fixed dark
theme only -- no prefers-color-scheme, no light mode. */
:root {
--bs-body-bg: #1a1d23;
--bs-body-color: #d4d8e0;
--bs-border-color: #333;
}
html {
height: 100%;
}
/* Flex column so the footer sits right after the content when the page is
short, and grows naturally when content is long. */
body {
background: #1a1d23;
color: #d4d8e0;
font-size: 0.875rem;
min-height: 100%;
display: flex;
flex-direction: column;
}
/* bootstrap.min.css's own ".container-fluid" rule sets
"display: flex; align-items: center; justify-content: space-between"
(meant for a navbar's inner container-fluid, but the selector isn't
scoped to .navbar, so it also matches the page's own top-level
.container-fluid below). Scoped to "body > .container-fluid" -- NOT a
bare ".container-fluid" -- so this doesn't also hijack the navbar's own
inner .container-fluid. */
body > .container-fluid {
flex: 1 0 auto;
display: flex;
flex-direction: column;
align-items: stretch;
}
/* .row's own height must come from flex-grow, not a percentage
min-height: without this the sidebar's dark background only extends as
far as its own nav links on short pages instead of the full available
height. */
body > .container-fluid > .row {
flex: 1 0 auto;
}
/* --- Navbar ------------------------------------------------ */
.navbar {
background: #14171e !important;
border-bottom: 1px solid #272d3a;
padding: .6rem 1.2rem;
}
.navbar-brand {
color: #4fc3f7 !important;
letter-spacing: 2.5px;
font-size: 1rem;
}
.navbar-subtitle {
color: #5a7a9a;
font-size: .82rem;
text-decoration: none;
}
a.navbar-subtitle:hover {
color: #4fc3f7;
}
.navbar-subtitle-sep {
color: #333c4a;
margin: 0 .5rem;
}
/* --- Sidebar ------------------------------------------------ */
.sidebar {
background: #14171e;
border-right: 1px solid #272d3a;
padding-top: .5rem;
}
.sidebar .nav-link {
color: #0b82b8;
font-size: .85rem;
padding: .5rem 1rem;
border-radius: 0;
}
.sidebar .nav-link:hover {
background: rgba(79, 195, 247, .08);
color: #c8d4e4;
}
.sidebar .nav-link.active {
background: rgba(79, 195, 247, .1);
color: #4fc3f7;
font-weight: 600;
border-left: 2px solid #4fc3f7;
}
/* --- Alerts (flash banners) ---------------------------------------- */
.alert-success { background: #192e22; border-color: #2a5c3a; color: #7ecf98; }
.alert-danger { background: #2e1820; border-color: #5c2a32; color: #e08090; }
/* --- Footer ------------------------------------------------- */
.footer {
color: #4a5a72;
font-size: 0.8rem;
text-align: center;
padding: 0.8rem 1rem;
border-top: 1px solid #272d3a;
}
@media (max-width: 767.98px) {
.sidebar { border-right: none; border-bottom: 1px solid #272d3a; }
}
+30
View File
@@ -0,0 +1,30 @@
{{define "base"}}<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{.Title}}{{if .Name}} · {{.Name}}{{end}}</title>
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%3E%3Crect%20width='100'%20height='100'%20rx='20'%20fill='%2314171e'/%3E%3Ctext%20x='50'%20y='71'%20font-size='58'%20font-family='system-ui,sans-serif'%20font-weight='700'%20fill='%230b82b8'%20text-anchor='middle'%3E{{.BrandInitial}}%3C/text%3E%3C/svg%3E">
<link rel="stylesheet" href="{{.BasePath}}/webui-static/bootstrap.min.css">
<link rel="stylesheet" href="{{.BasePath}}/webui-static/style.css">
<script src="{{.BasePath}}/webui-static/bootstrap.bundle.min.js" defer></script>
{{.ExtraHeadHTML}}
</head>
<body>
{{template "navbar" .}}
<div class="container-fluid">
<div class="row">
<nav class="col-md-2 col-lg-2 sidebar d-md-block">
{{template "sidebar" .}}
</nav>
<main class="col-md-10 col-lg-10 ms-sm-auto px-md-4 py-3">
{{if .Flash}}<div class="alert alert-{{if eq .FlashKind "ok"}}success{{else}}danger{{end}}">{{.Flash}}</div>{{end}}
{{template "content" .}}
</main>
</div>
</div>
{{template "footer" .}}
{{.ExtraBodyHTML}}
</body>
</html>
{{end}}
+3
View File
@@ -0,0 +1,3 @@
{{define "footer"}}
<footer class="footer">{{.Name}} web UI · {{buildInfo}}</footer>
{{end}}
+16
View File
@@ -0,0 +1,16 @@
{{define "navbar"}}
<nav class="navbar navbar-dark navbar-expand">
<div class="container-fluid d-flex justify-content-between align-items-center">
<div class="d-flex align-items-center">
<a class="navbar-brand" href="{{.BasePath}}/">{{.Brand}}</a>
{{if .Subtitle}}<span class="navbar-subtitle">{{.Subtitle}}</span>{{end}}
{{.NavbarLeftExtra}}
</div>
<div class="d-flex align-items-center gap-2">
{{if .Username}}<span class="navbar-subtitle">{{.Username}}</span>{{end}}
{{if .LogoutPath}}<a href="{{.BasePath}}{{.LogoutPath}}" class="btn btn-outline-secondary btn-sm">Logout</a>{{end}}
{{.NavbarRightExtra}}
</div>
</div>
</nav>
{{end}}
+6
View File
@@ -0,0 +1,6 @@
{{define "sidebar"}}
<div class="nav flex-column pt-2">
{{range .NavItems}}<a class="nav-link{{if eq $.ActiveNav .ID}} active{{end}}" href="{{$.BasePath}}{{.Href}}">{{.Label}}</a>
{{end}}
</div>
{{end}}