RenderCompact renders a compact version of the tab bar for narrow terminals.
()
| 268 | |
| 269 | // RenderCompact renders a compact version of the tab bar for narrow terminals. |
| 270 | func (t *TabBar) RenderCompact() string { |
| 271 | if len(t.entries) == 0 { |
| 272 | return TabNewStyle.Render("+") |
| 273 | } |
| 274 | |
| 275 | var tabs []string |
| 276 | |
| 277 | for i, entry := range t.entries { |
| 278 | tab := t.renderCompactTab(entry, i+1) |
| 279 | tabs = append(tabs, tab) |
| 280 | } |
| 281 | |
| 282 | // Compact new tab |
| 283 | newTab := TabNewStyle.Render("+") |
| 284 | tabs = append(tabs, newTab) |
| 285 | |
| 286 | return lipgloss.JoinHorizontal(lipgloss.Top, tabs...) |
| 287 | } |
| 288 | |
| 289 | // renderCompactTab renders a compact version of a tab. |
| 290 | func (t *TabBar) renderCompactTab(entry TabEntry, number int) string { |
no test coverage detected