Documentation
¶
Overview ¶
Package loading has the 29 loading indicators of loading.dev (https://loading.dev, Jakub Krehel's loading-dev for React) for native UI: arcs, dots, bars and blocks that Golet draws itself, each a ui element that moves as long as it shows.
loading.Arc(c)
loading.Ring(c, loading.Options{Size: 32, Color: t.Accent, Easing: loading.EaseInOut})
ui.Row(c).Gap(8).Children(func() {
loading.BouncingDots(c, loading.Options{Size: 12})
ui.Text(c, "Thinking")
})
An indicator is Options.Size DIPs high, 20 unless set, and as wide, or wider for a row of dots; the element's own size, as Size or Fill set it, scales it. It draws in the theme's text color unless Options.Color says otherwise, and runs at loading.dev's pace unless Options.Duration says otherwise. Where the desktop asks for less motion (ui.Preferences.ReduceMotion) it stands still, in loading.dev's pose for reduced motion; Options.Paused stops it where it is.
Assistive technology sees a progress indicator of unknown length; name it with Label.
Index ¶
- Constants
- func Arc(c *ui.Context, o ...Options) ui.Element
- func Atom(c *ui.Context, o ...Options) ui.Element
- func Blocks(c *ui.Context, o ...Options) ui.Element
- func BouncingDots(c *ui.Context, o ...Options) ui.Element
- func Cascade(c *ui.Context, o ...Options) ui.Element
- func CircularDots(c *ui.Context, o ...Options) ui.Element
- func Classic(c *ui.Context, o ...Options) ui.Element
- func ClassicV2(c *ui.Context, o ...Options) ui.Element
- func Clock(c *ui.Context, o ...Options) ui.Element
- func Comet(c *ui.Context, o ...Options) ui.Element
- func Compass(c *ui.Context, o ...Options) ui.Element
- func Dual(c *ui.Context, o ...Options) ui.Element
- func Eclipse(c *ui.Context, o ...Options) ui.Element
- func Flip(c *ui.Context, o ...Options) ui.Element
- func Gather(c *ui.Context, o ...Options) ui.Element
- func Leap(c *ui.Context, o ...Options) ui.Element
- func LinearDots(c *ui.Context, o ...Options) ui.Element
- func Loading(c *ui.Context, o ...Options) ui.Element
- func Morph(c *ui.Context, o ...Options) ui.Element
- func Orbit(c *ui.Context, o ...Options) ui.Element
- func Pulse(c *ui.Context, o ...Options) ui.Element
- func Radar(c *ui.Context, o ...Options) ui.Element
- func Ring(c *ui.Context, o ...Options) ui.Element
- func Ripple(c *ui.Context, o ...Options) ui.Element
- func Slide(c *ui.Context, o ...Options) ui.Element
- func Snake(c *ui.Context, o ...Options) ui.Element
- func Swirl(c *ui.Context, o ...Options) ui.Element
- func Trace(c *ui.Context, o ...Options) ui.Element
- func Wave(c *ui.Context, o ...Options) ui.Element
- type Cap
- type Easing
- type Options
- type RippleDirection
- type Spinner
- type Sweep
- type WaveOrigin
Constants ¶
const DefaultSize = 20
DefaultSize is an indicator's height when Options.Size is 0.
Variables ¶
This section is empty.
Functions ¶
func Blocks ¶
Blocks creates nine blocks shrinking and growing in a sweep across a grid, in the order Options.Sweep says.
func BouncingDots ¶
BouncingDots creates three staggered dots bouncing up and down, in a row 1.15 times as wide as it is high.
func CircularDots ¶
CircularDots creates eight dots in a ring, the brightest going around.
func LinearDots ¶
LinearDots creates three dots lighting up in turn from left to right, in a row nearly as wide as it is high.
func Ripple ¶
Ripple creates three rings spreading out from the center, or drawing in to it, as Options.Direction says.
Types ¶
type Options ¶
type Options struct {
// Size is the indicator's height in DIPs, 20 if 0. Its width is the
// same, except for BouncingDots's and LinearDots's rows of dots.
Size float32
// Color is what the indicator draws in, the theme's Text if zero.
Color ui.Color
// Duration is the time of one cycle of the indicator's motion, its
// own (as loading.dev's) if 0.
Duration time.Duration
// Paused stops the indicator where it is, and it goes on from there
// once false again, as CSS's paused animation-play-state.
Paused bool
// Easing is how the indicators that turn (Arc, Atom, Clock, Comet,
// Dual, Orbit, Radar, Ring, Snake and Trace) turn: Linear by default.
Easing Easing
// Cap is the end of the strokes of Arc, Cascade, Dual, Ring, Snake
// and Trace: RoundCap by default.
Cap Cap
// Sweep is the order in which Blocks's blocks shrink: Diagonal by
// default.
Sweep Sweep
// Direction is where Ripple's rings go: RippleOut by default.
Direction RippleDirection
// Origin is where Wave's bars grow from: WaveCenter by default.
Origin WaveOrigin
}
Options are the settings of an indicator, each meaning loading.dev's default when zero.
type RippleDirection ¶
type RippleDirection uint8
RippleDirection is where Ripple's rings go.
const ( // RippleOut spreads the rings out from the center. RippleOut RippleDirection = iota // RippleIn draws the rings in to the center. RippleIn )
type Spinner ¶
type Spinner struct {
// Name is the indicator's name, as loading.dev's: "Arc", "Bouncing dots".
Name string
// New creates the indicator, as the function of its name does.
New func(c *ui.Context, o ...Options) ui.Element
}
A Spinner is one of the indicators, by name, as a gallery lists them.
type WaveOrigin ¶
type WaveOrigin uint8
WaveOrigin is where Wave's bars grow from.
const ( // WaveCenter grows the bars up and down from their middle. WaveCenter WaveOrigin = iota // WaveBottom grows the bars up from the bottom. WaveBottom )