MCPcopy Create free account
hub / github.com/OverloadBlitz/cloudcent-cli / renderNavHeader

Function renderNavHeader

internal/tui/views/utils.go:106–131  ·  view source on GitHub ↗

renderNavHeader builds the shared navigation header box used by every view. activeView is the name of the currently active view (must match an entry in navItems). The nav is left-aligned inside the box.

(activeView string, headerFocused, viewActive bool, version string, width int)

Source from the content-addressed store, hash-verified

104// activeView is the name of the currently active view (must match an entry in
105// navItems). The nav is left-aligned inside the box.
106func renderNavHeader(activeView string, headerFocused, viewActive bool, version string, width int) string {
107 navStrs := make([]string, len(navItems))
108 for i, item := range navItems {
109 if item == activeView && viewActive {
110 if headerFocused {
111 navStrs[i] = styleFocused("> " + item)
112 } else {
113 navStrs[i] = lipgloss.NewStyle().Foreground(colorCyan).Bold(true).Render("> " + item)
114 }
115 } else {
116 navStrs[i] = lipgloss.NewStyle().Foreground(colorDarkGray).Render(item)
117 }
118 }
119 nav := strings.Join(navStrs, lipgloss.NewStyle().Foreground(colorDarkGray).Render(" | "))
120
121 borderColor := colorDarkGray
122 if headerFocused {
123 borderColor = colorGreen
124 } else if viewActive {
125 borderColor = colorCyan
126 }
127
128 rawTitle := fmt.Sprintf(" CloudCent CLI v%s ", version)
129 styledTitle := lipgloss.NewStyle().Foreground(colorWhite).Bold(true).Render(rawTitle)
130 return boxWithTitle(styledTitle, nav, borderColor, width)
131}

Callers 4

renderHeaderMethod · 0.85
RenderMethod · 0.85
RenderMethod · 0.85
RenderMethod · 0.85

Calls 3

styleFocusedFunction · 0.85
boxWithTitleFunction · 0.85
RenderMethod · 0.45

Tested by

no test coverage detected