Raxol.UI.Components.Progress.Spinner (Raxol v2.0.1)

View Source

Animated spinner component for terminal UIs.

Provides various spinner animations for loading states.

Summary

Functions

Convenience function for creating an error spinner.

Gets the frames for a specific spinner type.

Handles frame events (for compatibility with some tests).

Initializes spinner state.

Convenience function for creating a loading spinner.

Convenience function for creating a processing spinner.

Convenience function for creating a saving spinner.

Creates an animated spinner.

Returns available spinner types.

Updates spinner state.

Types

state()

@type state() :: %{
  style: atom(),
  frames: [String.t()],
  frame_index: non_neg_integer(),
  color_index: non_neg_integer(),
  colors: [atom()],
  speed: non_neg_integer(),
  text: String.t() | nil,
  text_position: atom(),
  last_update: integer()
}

Functions

error(message)

@spec error(String.t()) :: state()

Convenience function for creating an error spinner.

frames(type)

@spec frames(atom()) :: [binary()]

Gets the frames for a specific spinner type.

handle_event(arg1, context, state)

@spec handle_event(any(), map(), state()) :: {state(), list()}

Handles frame events (for compatibility with some tests).

init(props)

@spec init(map()) :: state()

Initializes spinner state.

loading()

@spec loading() :: state()

Convenience function for creating a loading spinner.

processing(message)

@spec processing(String.t()) :: state()

Convenience function for creating a processing spinner.

saving()

@spec saving() :: state()

Convenience function for creating a saving spinner.

spinner(message \\ nil, frame, opts \\ [])

@spec spinner(binary() | nil, integer(), keyword()) :: binary()

Creates an animated spinner.

Parameters

  • message - Optional message to display next to spinner
  • frame - Current animation frame number
  • opts - Options including :type for spinner style

types()

@spec types() :: [atom()]

Returns available spinner types.

update(arg1, state)

@spec update(atom(), state()) :: state()

Updates spinner state.