From 3b8fa0766a0050c0dd026be5d6a1ce2827956530 Mon Sep 17 00:00:00 2001 From: Benjamin Chausse Date: Fri, 27 Dec 2024 17:54:43 -0500 Subject: All ui info in one location --- internal/slider/slider.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'internal/slider') diff --git a/internal/slider/slider.go b/internal/slider/slider.go index a6c6ee6..dbf4093 100644 --- a/internal/slider/slider.go +++ b/internal/slider/slider.go @@ -2,6 +2,7 @@ package slider import ( "fmt" + "strings" "github.com/ChausseBenjamin/termpicker/internal/progress" "github.com/ChausseBenjamin/termpicker/internal/ui" @@ -19,11 +20,8 @@ type Model struct { func New(label byte, maxVal int, opts ...progress.Option) Model { slider := Model{ - label: label, - progress: progress.New( - progress.WithoutPercentage(), - progress.WithColorProfile(ui.ColorProfile()), - ), + label: label, + progress: progress.New(), max: maxVal, current: maxVal / 2, mappings: newKeybinds(), @@ -34,7 +32,7 @@ func New(label byte, maxVal int, opts ...progress.Option) Model { return slider } -func (m Model) Title() string { return fmt.Sprintf("%c", m.label) } +func (m Model) Title() string { return fmt.Sprintf("%c:", m.label) } func (m Model) Init() tea.Cmd { // Triggering a frame message Update here will force the progress bar to @@ -81,5 +79,9 @@ func (m Model) ViewValue(current int) string { } func (m Model) View() string { - return fmt.Sprintf("%v: %v %v", m.Title(), m.progress.View(), m.ViewValue(m.current)) + return strings.Join([]string{ + ui.Style().SliderLabel.Render(m.Title()), + m.progress.View(), + ui.Style().SliderVal.Render(m.ViewValue(m.current)), + }, " ") } -- cgit v1.2.3