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)
| 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. |
| 106 | func 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 | } |
no test coverage detected