xtablo-source/backend/templates/app_layout_helpers.go
Arthur Belleville 9b0d335329
feat(15-02): create app_layout.templ and app_layout_helpers.go with sidebar sub-components
- Create backend/templates/app_layout_helpers.go: sidebarNavItem struct, sidebarNavItemClass, isActivePath, sidebarNavItemID, sidebarPrimaryNavItems
- Create backend/templates/app_layout.templ: SidebarNavIcon, SidebarNavItemRow, SidebarProjectsSection, SidebarOrganizationFooter, DashboardSidebar, AppLayout
- templ generate and go build exit 0; all existing tests pass
2026-05-16 21:43:15 +02:00

55 lines
1.8 KiB
Go

package templates
import "strings"
// sidebarNavItem describes one entry in the sidebar primary navigation list.
type sidebarNavItem struct {
Href string
Label string
Icon string
Active bool
DividerAfter bool
}
// sidebarNavItemClass returns the CSS class string for a nav item.
// Active items receive "sidebar-nav-item is-active"; inactive receive "sidebar-nav-item".
func sidebarNavItemClass(active bool) string {
if active {
return "sidebar-nav-item is-active"
}
return "sidebar-nav-item"
}
// isActivePath reports whether activePath matches href.
// Returns false when activePath is empty or blank.
func isActivePath(activePath string, href string) bool {
return strings.TrimSpace(activePath) != "" && activePath == href
}
// sidebarNavItemID returns a stable HTML id attribute for the given nav href.
func sidebarNavItemID(href string) string {
switch href {
case "/":
return "sidebar-nav-home"
default:
slug := strings.Trim(strings.ReplaceAll(href, "/", "-"), "-")
if slug == "" {
slug = "item"
}
return "sidebar-nav-" + slug
}
}
// sidebarPrimaryNavItems returns the ordered list of primary nav items with
// active state computed from activePath.
//
// Per D-N01/D-N02: Tasks, Chat, and Files are visual-only (no Href) in Phase 15.
func sidebarPrimaryNavItems(activePath string) []sidebarNavItem {
return []sidebarNavItem{
{Href: "/", Label: "Dashboard", Icon: "panels", Active: isActivePath(activePath, "/"), DividerAfter: true},
{Href: "", Label: "Tasks", Icon: "tasks", Active: false},
{Href: "/planning", Label: "Planning", Icon: "planning", Active: isActivePath(activePath, "/planning")},
{Href: "", Label: "Chat", Icon: "chat", Active: false},
{Href: "", Label: "Files", Icon: "files", Active: false},
}
}