Files
default-creds-tui/ui/header.go
T
Hadi 624a723b16 init
Signed-off-by: Hadi <[email protected]>
2026-08-27 00:05:08 +02:00

38 lines
954 B
Go

package ui
import (
"strings"
"charm.land/lipgloss/v2"
zone "github.com/lrstanley/bubblezone/v2"
"github.com/anotherhadi/ilovetui/style"
)
const searchBoxZone = "search-box"
func (m Model) renderHeader() string {
title := clampToWidth(headerStyle.Render("Default Creds TUI")+subtleStyle.Render(" · "+m.sourceLabel()), m.width)
return strings.Join([]string{title, "", m.renderSearchBox(), ""}, "\n")
}
func (m Model) renderSearchBox() string {
box := style.S.Panel
titleColor := style.S.Subtle
if m.searching {
box = style.S.PanelFocused
titleColor = style.S.Primary
}
box = box.Padding(0, 1)
width := max(m.width, 10)
var rendered string
if style.S.NerdFonts {
rendered = box.Width(width).Render(m.searchInput.View())
} else {
title := lipgloss.NewStyle().Foreground(titleColor).Render("Search")
rendered = style.RenderWithTitle(box, title, m.searchInput.View(), width, 3)
}
return zone.Mark(searchBoxZone, rendered)
}