- Add BreadcrumbItem struct to app_layout_helpers.go - Update AppLayout to accept 8 parameters (was 5) - Add minimal breadcrumb/headerActions stubs in layout body
62 lines
2 KiB
Go
62 lines
2 KiB
Go
package templates
|
|
|
|
import "strings"
|
|
|
|
// BreadcrumbItem represents one crumb in the top header breadcrumb trail.
|
|
// If Href is empty, the item renders as plain text (current page — no link).
|
|
type BreadcrumbItem struct {
|
|
Label string
|
|
Href string
|
|
}
|
|
|
|
// 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},
|
|
}
|
|
}
|