add ability for menus to contain images (needed to handle EMInds top menu "hack")

This commit is contained in:
2026-03-06 22:09:02 -07:00
parent 89f70a3aa5
commit 406de6985e
4 changed files with 77 additions and 31 deletions
+1
View File
@@ -31,6 +31,7 @@ import (
type MenuItem struct {
Text string `yaml:"text"`
Link string `yaml:"link"`
Image string `yaml:"image"`
Disabled bool `yaml:"disabled"`
Hazard bool `yaml:"hazard"`
Permission string `yaml:"permission"`
+32 -8
View File
@@ -8,13 +8,25 @@
*}
{{ block leftMenu(menu) }}
<div class="mb-2 mt-2">
<div class="font-bold mb-1">{{ menu.Title }}</div>
{{ if menu.Title != "" }}
<div class="font-bold mb-1">{{ menu.Title }}</div>
{{ end }}
{{ range _, it := menu.Items }}
{{ if it.Show(.) }}
{{ if it.Disabled }}
<div class="text-gray-500 mb-1">{{ it.Text }}</div>
{{ if it.Image != "" }}
{{ if it.Link != "" && !it.Disabled }}
<a href="{{ it.Link }}"><img src="{{ it.Image }}" alt="{{ it.Text }}"></a>
{{ else }}
<img src="{{ it.Image }}" alt="{{ it.Text }}">
{{ end }}
{{ else }}
<a href="{{ it.Link }}" class="text-blue-700 hover:text-blue-900">{{ it.Text }}</a>
{{ if it.Disabled }}
<div class="text-gray-500 mb-1">{{ it.Text }}</div>
{{ else if it.Link != "" }}
<a href="{{ it.Link }}" class="text-blue-700 hover:text-blue-900">{{ it.Text }}</a>
{{ else }}
<div class="mb-1">{{ it.Text }}</div>
{{ end }}
{{ end }}
{{ end }}
{{ end }}
@@ -26,13 +38,25 @@
<div class="mb-1">
<img src="{{ ExtractCommunityLogo(__comm, .) }}" alt="{{ __comm.Name }}" class="w-28 h-16 rounded">
</div>
<div class="font-bold mb-1">{{ menu.Title }}</div>
{{ if menu.Title != "" }}
<div class="font-bold mb-1">{{ menu.Title }}</div>
{{ end }}
{{ range _, it := menu.Items }}
{{ if it.Show(.) }}
{{ if it.Disabled }}
<div class="text-gray-500 mb-1">{{ it.Text }}</div>
{{ if it.Image != "" }}
{{ if it.Link != "" && !it.Disabled }}
<a href="{{ it.Link }}"><img src="{{ it.Image }}" alt="{{ it.Text }}"></a>
{{ else }}
<img src="{{ it.Image }}" alt="{{ it.Text }}">
{{ end }}
{{ else }}
<div class="mb-1"><a href="{{ it.Link }}" class="text-blue-700 hover:text-blue-900">{{ it.Text }}</a></div>
{{ if it.Disabled }}
<div class="text-gray-500 mb-1">{{ it.Text }}</div>
{{ else if it.Link != "" }}
<div class="mb-1"><a href="{{ it.Link }}" class="text-blue-700 hover:text-blue-900">{{ it.Text }}</a></div>
{{ else }}
<div class="mb-1">{{ it.Text }}</div>
{{ end }}
{{ end }}
{{ end }}
{{ end }}
+34 -23
View File
@@ -8,36 +8,47 @@
*}
<div class="p-4">
<!-- Page Title -->
<div class="mb-6">
{{ if menu.Subtitle != "" }}
<div class="flex items-baseline gap-3 mb-2">
<h1 class="text-blue-800 text-4xl font-bold">{{ menu.Title }}</h1>
<h2 class="text-blue-800 text-2xl font-bold">{{ menu.Subtitle }}</h2>
</div>
{{ else }}
<h1 class="text-blue-800 text-4xl font-bold mb-2">{{ menu.Title }}</h1>
{{ end }}
<hr class="border-2 border-gray-400 w-4/5 mb-4">
</div>
{{ if menu.Title != "" }}
<div class="mb-6">
{{ if menu.Subtitle != "" }}
<div class="flex items-baseline gap-3 mb-2">
<h1 class="text-blue-800 text-4xl font-bold">{{ menu.Title }}</h1>
<h2 class="text-blue-800 text-2xl font-bold">{{ menu.Subtitle }}</h2>
</div>
{{ else }}
<h1 class="text-blue-800 text-4xl font-bold mb-2">{{ menu.Title }}</h1>
{{ end }}
<hr class="border-2 border-gray-400 w-4/5 mb-4">
</div>
{{ end }}
<!-- Administration Menu -->
<!-- Rendered Menu -->
<div class="max-w-2xl">
<div class="bg-gray-50 p-6 rounded-lg">
<nav class="space-y-3">
{{ ctxt := . }}
{{ range menu.Items }}
{{ range _, m := menu.Items }}
{{ vis := true }}
{{ if .Ifdef != "" && !defs[.Ifdef] }}{{ vis = false }}{{ end }}
{{ if vis && .Show(ctxt) }}
{{ if m.Ifdef != "" && !defs[m.Ifdef] }}{{ vis = false }}{{ end }}
{{ if vis && m.Show(.) }}
<div class="flex items-start gap-3">
<span class="text-lg pt-0.5">🟣</span>
{{ if .Disabled }}
<span class="text-gray-500 font-medium">{{ .Text }}</span>
{{ else }}
{{ if .Hazard }}
<a href="{{ .Link }}" class="text-red-700 hover:text-red-900 font-medium">⚠️ {{ .Text }}</a>
{{ if m.Image != "" }}
{{ if it.Link != "" && !it.Disabled }}
<a href="{{ it.Link }}"><img src="{{ it.Image }}" alt="{{ it.Text }}"></a>
{{ else }}
<a href="{{ .Link }}" class="text-blue-700 hover:text-blue-900 font-medium">{{ .Text }}</a>
<img src="{{ it.Image }}" alt="{{ it.Text }}">
{{ end }}
{{ else }}
<span class="text-lg pt-0.5">🟣</span>
{{ if m.Disabled }}
<span class="text-gray-500 font-medium">{{ m.Text }}</span>
{{ else if m.Link != "" }}
{{ if m.Hazard }}
<a href="{{ m.Link }}" class="text-red-700 hover:text-red-900 font-medium">⚠️ {{ m.Text }}</a>
{{ else }}
<a href="{{ m.Link }}" class="text-blue-700 hover:text-blue-900 font-medium">{{ m.Text }}</a>
{{ end }}
{{ else }}
<span class="font-medium">{{ m.Text }}</span>
{{ end }}
{{ end }}
</div>