From 1247914bace58c67ee1caacb8aa305b1ecf663dd Mon Sep 17 00:00:00 2001 From: drew Date: Mon, 28 Jul 2025 13:00:30 +0400 Subject: [PATCH] fix: styling of the main menu --- tui/choice.go | 54 ++++++++++++++++++++++++++++++++----------------- tui/composer.go | 1 - tui/inbox.go | 2 -- 3 files changed, 36 insertions(+), 21 deletions(-) diff --git a/tui/choice.go b/tui/choice.go index 31197ef9e3470f2af9a1d9fa31f51b7224717e8b..b431f01f331eafda4bfebc5a91b7106d34d35d9b 100644 --- a/tui/choice.go +++ b/tui/choice.go @@ -2,22 +2,32 @@ package tui import ( "fmt" + "strings" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" ) var ( + // A more beautiful style for the main menu + docStyle = lipgloss.NewStyle().Margin(1, 2) + titleStyle = lipgloss.NewStyle(). - Bold(true). - Foreground(lipgloss.Color("#FAFAFA")). - Background(lipgloss.Color("#7D56F4")). - PaddingLeft(2). - PaddingRight(2) - - choiceStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("205")). - PaddingLeft(2) + Foreground(lipgloss.Color("#FFFDF5")). + Background(lipgloss.Color("#25A065")). + Padding(0, 1) + + helpStyle = lipgloss.NewStyle(). + Foreground(lipgloss.Color("241")) + + // Styling for the choice list + listHeader = lipgloss.NewStyle(). + Foreground(lipgloss.Color("241")). + PaddingBottom(1) + + // Custom item styles + itemStyle = lipgloss.NewStyle().PaddingLeft(2) + selectedItemStyle = lipgloss.NewStyle().PaddingLeft(2).Foreground(lipgloss.Color("205")) ) type Choice struct { @@ -41,7 +51,7 @@ func (m Choice) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.cursor-- } case "down", "j": - if m.cursor < 1 { + if m.cursor < 1 { // We have two choices m.cursor++ } case "enter": @@ -56,21 +66,29 @@ func (m Choice) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } func (m Choice) View() string { - s := "What would you like to do?\n\n" + var b strings.Builder - choices := []string{"View Inbox", "Compose Email"} + // Title + b.WriteString(titleStyle.Render("Email CLI") + "\n\n") + + // Header + b.WriteString(listHeader.Render("What would you like to do?")) + b.WriteString("\n\n") + // Choices + choices := []string{"View Inbox", "Compose Email"} for i, choice := range choices { - cursor := " " if m.cursor == i { - cursor = ">" - s += choiceStyle.Render(fmt.Sprintf("%s %s\n", cursor, choice)) + b.WriteString(selectedItemStyle.Render(fmt.Sprintf("> %s", choice))) } else { - s += fmt.Sprintf("%s %s\n", cursor, choice) + b.WriteString(itemStyle.Render(fmt.Sprintf(" %s", choice))) } + b.WriteString("\n") } - s += "\nPress q to quit.\n" + // Help + b.WriteString("\n\n") + b.WriteString(helpStyle.Render("Use ↑/↓ to navigate, enter to select, and q to quit.")) - return s + return docStyle.Render(b.String()) } \ No newline at end of file diff --git a/tui/composer.go b/tui/composer.go index 83cdb56291f7cdc25f5f932f53c297fafb01122f..de3b5c27fa861a8563c30b073f2cff31e72ab66b 100644 --- a/tui/composer.go +++ b/tui/composer.go @@ -13,7 +13,6 @@ var ( blurredStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("240")) cursorStyle = focusedStyle.Copy() noStyle = lipgloss.NewStyle() - helpStyle = blurredStyle.Copy() focusedButton = focusedStyle.Copy().Render("[ Send ]") blurredButton = blurredStyle.Copy().Render("[ Send ]") emailRecipientStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("205")).Bold(true) diff --git a/tui/inbox.go b/tui/inbox.go index f6e9c2d73e47b2a1225a6accd22a81b57959ad31..09ba116cae8cf78241271003b2772a7ef311a2f0 100644 --- a/tui/inbox.go +++ b/tui/inbox.go @@ -11,8 +11,6 @@ import ( ) var ( - itemStyle = lipgloss.NewStyle().PaddingLeft(4) - selectedItemStyle = lipgloss.NewStyle().PaddingLeft(2).Foreground(lipgloss.Color("205")) paginationStyle = list.DefaultStyles().PaginationStyle.PaddingLeft(4) inboxHelpStyle = list.DefaultStyles().HelpStyle.PaddingLeft(4).PaddingBottom(1) )