mirror of
https://github.com/anotherhadi/default-creds-tui.git
synced 2026-10-05 10:58:25 +02:00
38 lines
954 B
Go
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)
|
|
}
|