mirror of
https://github.com/Maks1mS/bubbles.git
synced 2025-03-14 04:53:43 +03:00
length field changed to width
This commit is contained in:
parent
38d59517fb
commit
65a17d039e
@ -18,8 +18,8 @@ type Model struct {
|
|||||||
// Left side color of progress bar. By default, it's #fc00ff
|
// Left side color of progress bar. By default, it's #fc00ff
|
||||||
EndColor colorful.Color
|
EndColor colorful.Color
|
||||||
|
|
||||||
// Length of progress bar in symbols.
|
// Width of progress bar in symbols.
|
||||||
Length int
|
Width int
|
||||||
|
|
||||||
// Which part of bar need to visualise. Can be 0.0 < Progress < 1.0, if value is bigger or smaller, it'll
|
// Which part of bar need to visualise. Can be 0.0 < Progress < 1.0, if value is bigger or smaller, it'll
|
||||||
// be mapped to this values
|
// be mapped to this values
|
||||||
@ -43,7 +43,7 @@ func NewModel(size int) *Model {
|
|||||||
return &Model{
|
return &Model{
|
||||||
StartColor: startColor,
|
StartColor: startColor,
|
||||||
EndColor: endColor,
|
EndColor: endColor,
|
||||||
Length: size,
|
Width: size,
|
||||||
FilamentSymbol: '█',
|
FilamentSymbol: '█',
|
||||||
EmptySymbol: '░',
|
EmptySymbol: '░',
|
||||||
}
|
}
|
||||||
@ -70,9 +70,9 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Model) View() string {
|
func (m *Model) View() string {
|
||||||
ramp := make([]string, int(float64(m.Length)*m.Progress))
|
ramp := make([]string, int(float64(m.Width)*m.Progress))
|
||||||
for i := 0; i < len(ramp); i++ {
|
for i := 0; i < len(ramp); i++ {
|
||||||
gradientPart := float64(m.Length)
|
gradientPart := float64(m.Width)
|
||||||
if m.FullGradientMode {
|
if m.FullGradientMode {
|
||||||
gradientPart = float64(len(ramp))
|
gradientPart = float64(len(ramp))
|
||||||
}
|
}
|
||||||
@ -86,6 +86,6 @@ func (m *Model) View() string {
|
|||||||
fullCells += termenv.String(string(m.FilamentSymbol)).Foreground(termenv.ColorProfile().Color(ramp[i])).String()
|
fullCells += termenv.String(string(m.FilamentSymbol)).Foreground(termenv.ColorProfile().Color(ramp[i])).String()
|
||||||
}
|
}
|
||||||
|
|
||||||
fullCells += strings.Repeat(string(m.EmptySymbol), m.Length-len(ramp))
|
fullCells += strings.Repeat(string(m.EmptySymbol), m.Width-len(ramp))
|
||||||
return fullCells
|
return fullCells
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user