From b556cdfa2292e8870d72544bfbf836fcec9f0aac Mon Sep 17 00:00:00 2001 From: punkfairie <23287005+punkfairie@users.noreply.github.com> Date: Sat, 7 Sep 2024 16:01:47 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20feat(ui):=20List=20bullets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index b16f7a9..8da7932 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,7 @@ import ( "github.com/charmbracelet/bubbles/key" tea "github.com/charmbracelet/bubbletea" gloss "github.com/charmbracelet/lipgloss" + "github.com/charmbracelet/lipgloss/list" "golang.org/x/term" "gopkg.in/yaml.v3" ) @@ -17,7 +18,6 @@ var width, height, _ = term.GetSize(int(os.Stdout.Fd())) type menu struct { order SoftwarePackages current int - done int keys keyMap help help.Model inputStyle gloss.Style @@ -25,7 +25,7 @@ type menu struct { func initialModel() menu { return menu{ - current: 0, + current: 3, keys: keys, help: help.New(), } @@ -174,12 +174,24 @@ func (m menu) View() string { Width(int(float64(width) * 0.3)) mainContent := "" - sidebarContent := "" + + softwareListEnumerator := func(l list.Items, i int) string { + if m.current == i { + return ">" + } else if m.current > i { + return "" + } + return "" + } + + software := list.New().Enumerator(softwareListEnumerator) for _, item := range m.order { - sidebarContent += fmt.Sprintf("%s\n", item.Name) + software.Item(item.Name) } + sidebarContent := software.String() + main := mainStyle.Render(mainContent) sidebar := sidebarStyle.Render(sidebarContent)