From 8a44f06fb154104fc90269118101cf976d842323 Mon Sep 17 00:00:00 2001 From: luxick Date: Wed, 15 Oct 2025 09:45:17 +0200 Subject: [PATCH] Move menu bar styling to template --- internal/server/template_data.go | 42 +++++++++++++++----------------- web/templates/menubar.html | 4 +-- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/internal/server/template_data.go b/internal/server/template_data.go index 02e6e76..64d4bb5 100644 --- a/internal/server/template_data.go +++ b/internal/server/template_data.go @@ -1,7 +1,5 @@ package server -import "html/template" - // This file defines the data structures and helper functions for the template system. // // The template system uses Go's html/template package to provide: @@ -25,13 +23,13 @@ type PageData struct { // MenuGroup represents a dropdown menu in the navbar. type MenuGroup struct { - LabelHTML template.HTML - Items []MenuItem + Label string + Items []MenuItem } // MenuItem represents a single menu item. type MenuItem struct { - LabelHTML template.HTML + Label string URL string IsDivider bool } @@ -42,29 +40,29 @@ func DefaultMenuBar() PageData { ShowClock: true, MenuGroups: []MenuGroup{ { - LabelHTML: template.HTML(`File`), + Label: "File", Items: []MenuItem{ - {LabelHTML: template.HTML(`New`), URL: "#!"}, - {LabelHTML: template.HTML(`Open`), URL: "#!"}, - {LabelHTML: template.HTML(`Save`), URL: "#!"}, - {LabelHTML: template.HTML(`Save As`), URL: "#!"}, + {Label: "New", URL: "#!"}, + {Label: "Open", URL: "#!"}, + {Label: "Save", URL: "#!"}, + {Label: "Save As", URL: "#!"}, {IsDivider: true}, - {LabelHTML: template.HTML(`Exit`), URL: "#!"}, + {Label: "Exit", URL: "#!"}, }, }, { - LabelHTML: template.HTML(`Edit`), + Label: "Edit", Items: []MenuItem{ - {LabelHTML: template.HTML(`Cut`), URL: "#!"}, - {LabelHTML: template.HTML(`Copy`), URL: "#!"}, - {LabelHTML: template.HTML(`Paste`), URL: "#!"}, + {Label: "Cut", URL: "#!"}, + {Label: "Copy", URL: "#!"}, + {Label: "Paste", URL: "#!"}, }, }, { - LabelHTML: template.HTML(`Help`), + Label: "Help", Items: []MenuItem{ - {LabelHTML: template.HTML(`Documentation`), URL: "#!"}, - {LabelHTML: template.HTML(`About`), URL: "#!"}, + {Label: "Documentation", URL: "#!"}, + {Label: "About", URL: "#!"}, }, }, }, @@ -75,11 +73,11 @@ func DefaultMenuBar() PageData { func AdminMenuBar() PageData { data := DefaultMenuBar() data.MenuGroups = append(data.MenuGroups, MenuGroup{ - LabelHTML: template.HTML(`Admin`), + Label: "Admin", Items: []MenuItem{ - {LabelHTML: template.HTML(`Users`), URL: "/admin/users"}, - {LabelHTML: template.HTML(`Settings`), URL: "/admin/settings"}, - {LabelHTML: template.HTML(`Logs`), URL: "/admin/logs"}, + {Label: "Users", URL: "/admin/users"}, + {Label: "Settings", URL: "/admin/settings"}, + {Label: "Logs", URL: "/admin/logs"}, }, }) return data diff --git a/web/templates/menubar.html b/web/templates/menubar.html index f6edcb4..62c86be 100644 --- a/web/templates/menubar.html +++ b/web/templates/menubar.html @@ -3,14 +3,14 @@