From bacb927e5f001f4186abb94259d752d8a4c1d8e6 Mon Sep 17 00:00:00 2001 From: Benjamin Chausse Date: Mon, 25 Nov 2024 22:32:32 -0500 Subject: underline+bold+bright to indicate active tab (#17) --- internal/switcher/switcher.go | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/internal/switcher/switcher.go b/internal/switcher/switcher.go index 74f0d6b..f368224 100644 --- a/internal/switcher/switcher.go +++ b/internal/switcher/switcher.go @@ -3,6 +3,7 @@ package switcher import ( "fmt" "log/slog" + "strings" "github.com/ChausseBenjamin/termpicker/internal/colors" "github.com/ChausseBenjamin/termpicker/internal/notices" @@ -92,14 +93,29 @@ func (m Model) Init() tea.Cmd { } func (m Model) View() string { - tabs := "|" + norm := lipgloss.NewStyle().Faint(true) + bright := lipgloss.NewStyle().Faint(false) + + delims := [3]string{"[ ", " | ", "]"} + for i, d := range delims { + delims[i] = bright.Render(d) + } + + var sections []string for i, p := range m.pickers { if i == m.active { - tabs += fmt.Sprintf(">%s<|", p.Title()) + sections = append( + sections, + bright. + Underline(true). + Bold(true). + Render(p.Title()), + ) } else { - tabs += fmt.Sprintf(" %s |", p.Title()) + sections = append(sections, norm.Render(p.Title())) } } + tabs := "[ " + strings.Join(sections, " | ") + " ]" pickerView := m.pickers[m.active].View() boxStyle := lipgloss.NewStyle().Border(lipgloss.RoundedBorder(), true, true, false, true) -- cgit v1.2.3