mirror of
https://github.com/zoriya/bubbles.git
synced 2026-08-05 04:36:07 +00:00
feat: progress
This commit is contained in:
@@ -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 {
|
||||
m := Model{
|
||||
id: nextID(),
|
||||
Width: defaultWidth,
|
||||
@@ -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)
|
||||
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
"github.com/muesli/termenv"
|
||||
)
|
||||
|
||||
@@ -12,7 +14,6 @@ const (
|
||||
)
|
||||
|
||||
func TestGradient(t *testing.T) {
|
||||
|
||||
colA := "#FF0000"
|
||||
colB := "#00FF00"
|
||||
|
||||
@@ -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()}
|
||||
p = New(ctx, opts...)
|
||||
|
||||
// build the expected colors by colorizing an empty string and then cutting off the following reset sequence
|
||||
sb := strings.Builder{}
|
||||
@@ -62,5 +64,4 @@ func TestGradient(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user