From 446433d6805147523b8689b88447d054010ca5d7 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Wed, 21 Jul 2021 15:00:30 -0400 Subject: [PATCH] Use Lip Gloss to style percentage in progress bubble --- progress/progress.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/progress/progress.go b/progress/progress.go index eaf869c..a66d933 100644 --- a/progress/progress.go +++ b/progress/progress.go @@ -9,6 +9,7 @@ import ( tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/harmonica" + "github.com/charmbracelet/lipgloss" "github.com/lucasb-eyer/go-colorful" "github.com/muesli/reflow/ansi" "github.com/muesli/termenv" @@ -129,7 +130,7 @@ type Model struct { // Settings for rendering the numeric percentage. ShowPercentage bool PercentFormat string // a fmt string for a float - PercentageStyle *termenv.Style + PercentageStyle lipgloss.Style // Members for animated transitons. spring harmonica.Spring @@ -301,9 +302,7 @@ func (m Model) percentageView(percent float64) string { } percent = math.Max(0, math.Min(1, percent)) percentage := fmt.Sprintf(m.PercentFormat, percent*100) //nolint:gomnd - if m.PercentageStyle != nil { - percentage = m.PercentageStyle.Styled(percentage) - } + percentage = m.PercentageStyle.Inline(true).Render(percentage) return percentage }