Documentation
¶
Overview ¶
Package progress provides progress bar and spinner components.
Available variants:
- New() creates a progress bar (template: "lvt:progress:default:v1")
- NewCircular() creates a circular progress (template: "lvt:progress:circular:v1")
- NewSpinner() creates a spinner (template: "lvt:progress:spinner:v1")
Example usage:
// In your controller/state
UploadProgress: progress.New("upload",
progress.WithValue(75),
progress.WithShowLabel(true),
)
// In your template
{{template "lvt:progress:default:v1" .UploadProgress}}
Index ¶
- func Templates() *base.TemplateSet
- type CircularOption
- func WithCircularColor(color Color) CircularOption
- func WithCircularIndeterminate(indeterminate bool) CircularOption
- func WithCircularLabel(label string) CircularOption
- func WithCircularMax(max float64) CircularOption
- func WithCircularShowLabel(show bool) CircularOption
- func WithCircularSize(size int) CircularOption
- func WithCircularStrokeWidth(width int) CircularOption
- func WithCircularStyled(styled bool) CircularOption
- func WithCircularValue(value float64) CircularOption
- type CircularProgress
- func (c *CircularProgress) Center() int
- func (c *CircularProgress) Circumference() float64
- func (c *CircularProgress) ColorClass() string
- func (c *CircularProgress) DashOffset() float64
- func (c *CircularProgress) DisplayLabel() string
- func (c *CircularProgress) Percentage() float64
- func (c *CircularProgress) PercentageStr() string
- func (c *CircularProgress) Radius() int
- func (c *CircularProgress) Styles() styles.CircularProgressStyles
- type Color
- type Option
- func WithAnimated(animated bool) Option
- func WithColor(color Color) Option
- func WithIndeterminate(indeterminate bool) Option
- func WithLabel(label string) Option
- func WithMax(max float64) Option
- func WithShowLabel(show bool) Option
- func WithSize(size Size) Option
- func WithStriped(striped bool) Option
- func WithStyled(styled bool) Option
- func WithValue(value float64) Option
- type Progress
- func (p *Progress) ColorClass() string
- func (p *Progress) Complete()
- func (p *Progress) Decrement(amount float64)
- func (p *Progress) DisplayLabel() string
- func (p *Progress) Increment(amount float64)
- func (p *Progress) IsComplete() bool
- func (p *Progress) Percentage() float64
- func (p *Progress) PercentageStr() string
- func (p *Progress) Reset()
- func (p *Progress) SetValue(value float64)
- func (p *Progress) SizeClass() string
- func (p *Progress) Styles() styles.ProgressStyles
- type Size
- type Spinner
- type SpinnerOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Templates ¶
func Templates() *base.TemplateSet
Templates returns the progress component's template set for registration with the LiveTemplate framework.
Example usage in main.go:
import "github.com/livetemplate/lvt/components/progress"
tmpl, err := livetemplate.New("app",
livetemplate.WithComponentTemplates(progress.Templates()),
)
Available templates:
- "lvt:progress:default:v1" - Linear progress bar
- "lvt:progress:circular:v1" - Circular progress indicator
- "lvt:progress:spinner:v1" - Loading spinner
Types ¶
type CircularOption ¶
type CircularOption func(*CircularProgress)
CircularOption is a functional option for circular progress.
func WithCircularColor ¶
func WithCircularColor(color Color) CircularOption
WithCircularColor sets the color.
func WithCircularIndeterminate ¶
func WithCircularIndeterminate(indeterminate bool) CircularOption
WithCircularIndeterminate enables spinning mode.
func WithCircularLabel ¶
func WithCircularLabel(label string) CircularOption
WithCircularLabel sets a custom label.
func WithCircularMax ¶
func WithCircularMax(max float64) CircularOption
WithCircularMax sets the maximum value.
func WithCircularShowLabel ¶
func WithCircularShowLabel(show bool) CircularOption
WithCircularShowLabel shows percentage in center.
func WithCircularSize ¶
func WithCircularSize(size int) CircularOption
WithCircularSize sets the size in pixels.
func WithCircularStrokeWidth ¶
func WithCircularStrokeWidth(width int) CircularOption
WithCircularStrokeWidth sets the stroke width.
func WithCircularStyled ¶
func WithCircularStyled(styled bool) CircularOption
WithCircularStyled enables Tailwind CSS styling.
func WithCircularValue ¶
func WithCircularValue(value float64) CircularOption
WithCircularValue sets the current progress value.
type CircularProgress ¶
type CircularProgress struct {
base.Base
// Value is the current progress (0-100)
Value float64
// Max is the maximum value (default 100)
Max float64
// Size in pixels
Size int
// StrokeWidth of the circle
StrokeWidth int
// Color of the progress
Color Color
// ShowLabel shows percentage in center
ShowLabel bool
// Label is custom label text
Label string
// Indeterminate shows spinning animation
Indeterminate bool
}
CircularProgress is a circular progress indicator.
func NewCircular ¶
func NewCircular(id string, opts ...CircularOption) *CircularProgress
NewCircular creates a circular progress indicator.
Example:
c := progress.NewCircular("loading",
progress.WithCircularValue(75),
progress.WithCircularSize(80),
)
func (*CircularProgress) Center ¶
func (c *CircularProgress) Center() int
Center returns the center point of the SVG.
func (*CircularProgress) Circumference ¶
func (c *CircularProgress) Circumference() float64
Circumference returns the circle circumference.
func (*CircularProgress) ColorClass ¶
func (c *CircularProgress) ColorClass() string
ColorClass returns CSS class for color.
func (*CircularProgress) DashOffset ¶
func (c *CircularProgress) DashOffset() float64
DashOffset returns the stroke-dashoffset for progress.
func (*CircularProgress) DisplayLabel ¶
func (c *CircularProgress) DisplayLabel() string
DisplayLabel returns the label to display.
func (*CircularProgress) Percentage ¶
func (c *CircularProgress) Percentage() float64
Percentage returns the progress percentage.
func (*CircularProgress) PercentageStr ¶
func (c *CircularProgress) PercentageStr() string
PercentageStr returns the percentage as formatted string.
func (*CircularProgress) Radius ¶
func (c *CircularProgress) Radius() int
Radius returns the circle radius.
func (*CircularProgress) Styles ¶
func (c *CircularProgress) Styles() styles.CircularProgressStyles
Styles returns the resolved CircularProgressStyles for this component.
type Option ¶
type Option func(*Progress)
Option is a functional option for configuring progress bars.
func WithIndeterminate ¶
WithIndeterminate enables indeterminate mode.
type Progress ¶
type Progress struct {
base.Base
// Value is the current progress (0-100)
Value float64
// Max is the maximum value (default 100)
Max float64
// Size of the progress bar
Size Size
// Color of the progress bar
Color Color
// ShowLabel shows percentage label
ShowLabel bool
// Label is custom label text (overrides percentage)
Label string
// Striped shows striped pattern
Striped bool
// Animated animates the stripes
Animated bool
// Indeterminate shows indeterminate animation
Indeterminate bool
}
Progress is a linear progress bar component. Use template "lvt:progress:default:v1" to render.
func New ¶
New creates a progress bar.
Example:
p := progress.New("download",
progress.WithValue(50),
progress.WithShowLabel(true),
)
func (*Progress) ColorClass ¶
ColorClass returns CSS class for color.
func (*Progress) DisplayLabel ¶
DisplayLabel returns the label to display.
func (*Progress) IsComplete ¶
IsComplete returns true if value equals max.
func (*Progress) Percentage ¶
Percentage returns the progress percentage (0-100).
func (*Progress) PercentageStr ¶
PercentageStr returns the percentage as a formatted string.
func (*Progress) Styles ¶
func (p *Progress) Styles() styles.ProgressStyles
Styles returns the resolved ProgressStyles for this component.
type Spinner ¶
type Spinner struct {
base.Base
// Size of the spinner (sm, md, lg)
Size string
// Color of the spinner
Color Color
// Label for accessibility
Label string
}
Spinner is a loading spinner component.
func NewSpinner ¶
func NewSpinner(id string, opts ...SpinnerOption) *Spinner
NewSpinner creates a spinner.
Example:
s := progress.NewSpinner("loading",
progress.WithSpinnerSize("lg"),
)
func (*Spinner) ColorClass ¶
ColorClass returns CSS class for spinner color.
func (*Spinner) Styles ¶
func (s *Spinner) Styles() styles.SpinnerStyles
Styles returns the resolved SpinnerStyles for this component.
type SpinnerOption ¶
type SpinnerOption func(*Spinner)
SpinnerOption is a functional option for spinners.
func WithSpinnerColor ¶
func WithSpinnerColor(color Color) SpinnerOption
WithSpinnerColor sets the spinner color.
func WithSpinnerLabel ¶
func WithSpinnerLabel(label string) SpinnerOption
WithSpinnerLabel sets the accessibility label.
func WithSpinnerSize ¶
func WithSpinnerSize(size string) SpinnerOption
WithSpinnerSize sets the spinner size.
func WithSpinnerStyled ¶
func WithSpinnerStyled(styled bool) SpinnerOption
WithSpinnerStyled enables Tailwind CSS styling.