Documentation ¶
Index ¶
- Variables
- type FrameMsg
- type Model
- func (m *Model) DecrPercent(v float64) tea.Cmd
- func (m *Model) IncrPercent(v float64) tea.Cmd
- func (m Model) Init() tea.Cmd
- func (m Model) Percent() float64
- func (m *Model) SetPercent(p float64) tea.Cmd
- func (m *Model) SetSpringOptions(frequency, damping float64)
- func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (m Model) View() string
- func (m Model) ViewAs(percent float64) string
- type Option
- func WithDefaultGradient() Option
- func WithDefaultScaledGradient() Option
- func WithGradient(colorA, colorB string) Option
- func WithScaledGradient(colorA, colorB string) Option
- func WithSolidFill(color string) Option
- func WithSpringOptions(frequency, damping float64) Option
- func WithWidth(w int) Option
- func WithoutPercentage() Option
Constants ¶
This section is empty.
Variables ¶
var NewModel = New
NewModel returns a model with default values.
Deprecated. Use New instead.
Functions ¶
This section is empty.
Types ¶
type FrameMsg ¶
type FrameMsg struct {
// contains filtered or unexported fields
}
FrameMsg indicates that an animation step should occur.
type Model ¶
type Model struct { // Total width of the progress bar, including percentage, if set. Width int // "Filled" sections of the progress bar. Full rune FullColor string // "Empty" sections of progress bar. Empty rune EmptyColor string // Settings for rendering the numeric percentage. ShowPercentage bool PercentFormat string // a fmt string for a float PercentageStyle lipgloss.Style // contains filtered or unexported fields }
Model stores values we'll use when rendering the progress bar.
func (*Model) DecrPercent ¶
DecrPercent decrements the percentage by a given amount, returning a command necessary to animate the progress bar to the new percentage.
If you're rendering with ViewAs you won't need this.
func (*Model) IncrPercent ¶
IncrPercent increments the percentage by a given amount, returning a command necessary to animate the progress bar to the new percentage.
If you're rendering with ViewAs you won't need this.
func (Model) Percent ¶
Percent returns the current percentage state of the model. This is only relevant when you're animating the progress bar.
If you're rendering with ViewAs you won't need this.
func (*Model) SetPercent ¶
SetPercent sets the percentage state of the model as well as a command necessary for animating the progress bar to this new percentage.
If you're rendering with ViewAs you won't need this.
func (*Model) SetSpringOptions ¶
SetSpringOptions sets the frequency and damping for the current spring. Frequency corresponds to speed, and damping to bounciness. For details see:
func (Model) Update ¶
Update is used to animation the progress bar during transitions. Use SetPercent to create the command you'll need to trigger the animation.
If you're rendering with ViewAs you won't need this.
type Option ¶
type Option func(*Model)
Option is used to set options in NewModel. For example:
progress := NewModel( WithRamp("#ff0000", "#0000ff"), WithoutPercentage(), )
func WithDefaultGradient ¶
func WithDefaultGradient() Option
WithDefaultGradient sets a gradient fill with default colors.
func WithDefaultScaledGradient ¶
func WithDefaultScaledGradient() Option
WithDefaultScaledGradient sets a gradient with default colors, and scales the gradient to fit the filled portion of the ramp.
func WithGradient ¶
WithGradient sets a gradient fill blending between two colors.
func WithScaledGradient ¶
WithScaledGradient scales the gradient to fit the width of the filled portion of the progress bar.
func WithSolidFill ¶
WithSolidFill sets the progress to use a solid fill with the given color.
func WithSpringOptions ¶
WithSpringOptions sets the initial frequency and damping options for the progressbar's built-in spring-based animation. Frequency corresponds to speed, and damping to bounciness. For details see:
func WithWidth ¶
WithWidth sets the initial width of the progress bar. Note that you can also set the width via the Width property, which can come in handy if you're waiting for a tea.WindowSizeMsg.
func WithoutPercentage ¶
func WithoutPercentage() Option
WithoutPercentage hides the numeric percentage.