Skip to content

Commit

Permalink
feat: progress
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed Feb 26, 2024
1 parent e9bbc86 commit 577d38a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions progress/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ type Model struct {
}

// New returns a model with default values.
func New(opts ...Option) Model {
func New(ctx *tea.Context, opts ...Option) Model {

Check failure on line 178 in progress/progress.go

View workflow job for this annotation

GitHub Actions / test (~1.18, ubuntu-latest)

undefined: tea.Context

Check failure on line 178 in progress/progress.go

View workflow job for this annotation

GitHub Actions / test (^1, ubuntu-latest)

undefined: tea.Context

Check failure on line 178 in progress/progress.go

View workflow job for this annotation

GitHub Actions / coverage (^1.18, ubuntu-latest)

undefined: tea.Context

Check failure on line 178 in progress/progress.go

View workflow job for this annotation

GitHub Actions / test (^1, macos-latest)

undefined: tea.Context
m := Model{
id: nextID(),
Width: defaultWidth,
Expand All @@ -185,7 +185,7 @@ func New(opts ...Option) Model {
EmptyColor: "#606060",
ShowPercentage: true,
PercentFormat: " %3.0f%%",
colorProfile: termenv.ColorProfile(),
colorProfile: ctx.Renderer.ColorProfile(),
}
if !m.springCustomized {
m.SetSpringOptions(defaultFrequency, defaultDamping)
Expand Down
7 changes: 4 additions & 3 deletions progress/progress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"strings"
"testing"

tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/muesli/termenv"
)

Expand All @@ -12,7 +14,6 @@ const (
)

func TestGradient(t *testing.T) {

colA := "#FF0000"
colB := "#00FF00"

Expand All @@ -32,7 +33,8 @@ func TestGradient(t *testing.T) {
}

t.Run(descr, func(t *testing.T) {
p = New(opts...)
ctx := &tea.Context{Renderer: lipgloss.DefaultRenderer()}

Check failure on line 36 in progress/progress_test.go

View workflow job for this annotation

GitHub Actions / coverage (^1.18, ubuntu-latest)

undefined: tea.Context
p = New(ctx, opts...)

// build the expected colors by colorizing an empty string and then cutting off the following reset sequence
sb := strings.Builder{}
Expand Down Expand Up @@ -62,5 +64,4 @@ func TestGradient(t *testing.T) {
}
})
}

}

0 comments on commit 577d38a

Please sign in to comment.