diff options
author | Benjamin Chausse <benjamin@chausse.xyz> | 2024-12-27 17:54:43 -0500 |
---|---|---|
committer | Benjamin Chausse <benjamin@chausse.xyz> | 2024-12-27 17:54:43 -0500 |
commit | 3b8fa0766a0050c0dd026be5d6a1ce2827956530 (patch) | |
tree | e6e6e0d05da592fe36aade35201a52898209ceb1 /internal/slider/slider.go | |
parent | 858c07f0b805558b0961514200ffb822dd2248cf (diff) |
All ui info in one location
Diffstat (limited to 'internal/slider/slider.go')
-rw-r--r-- | internal/slider/slider.go | 16 |
1 files changed, 9 insertions, 7 deletions
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)), + }, " ") } |