components

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusSuccess = "success"
	StatusError   = "error"
	StatusWarning = "warning"
	StatusInfo    = "info"
	StatusLoading = "loading"
)

Status types

Variables

View Source
var Keys = KeyMap{
	GoBack: key.NewBinding(
		key.WithKeys("esc"),
		key.WithHelp("esc", "go back"),
	),
	Up: key.NewBinding(
		key.WithKeys("up"),
		key.WithHelp("↑", "move up"),
	),
	Down: key.NewBinding(
		key.WithKeys("down"),
		key.WithHelp("↓", "move down"),
	),
	Left: key.NewBinding(
		key.WithKeys("left"),
		key.WithHelp("←", "move left"),
	),
	Right: key.NewBinding(
		key.WithKeys("right"),
		key.WithHelp("→", "move right"),
	),
	Help: key.NewBinding(
		key.WithKeys("?"),
		key.WithHelp("?", "toggle help"),
	),
	Quit: key.NewBinding(
		key.WithKeys("q", "ctrl+c"),
		key.WithHelp("q", "quit"),
	),
	Refresh: key.NewBinding(
		key.WithKeys("r"),
		key.WithHelp("r", "refresh data"),
	),
	Logs: key.NewBinding(
		key.WithKeys("l"),
		key.WithHelp("l", "toggle logs view"),
	),
	Tab: key.NewBinding(
		key.WithKeys("tab"),
		key.WithHelp("tab", "switch focus"),
	),
	NextPage: key.NewBinding(
		key.WithKeys("n"),
		key.WithHelp("n", "next page"),
	),
	PrevPage: key.NewBinding(
		key.WithKeys("p"),
		key.WithHelp("p", "previous page"),
	),
	FollowMode: key.NewBinding(
		key.WithKeys("f"),
		key.WithHelp("f", "toggle follow mode"),
	),
}

Functions

func NewHelpModel

func NewHelpModel() help.Model

NewHelpModel creates a new help model with the default keyMap

Types

type EmptyScreenComponent

type EmptyScreenComponent struct {
	Icon        string
	Title       string
	Description string
	Action      string
	Style       lipgloss.Style
	// contains filtered or unexported fields
}

EmptyScreenComponent represents a reusable empty state component

func NewEmptyScreenComponent

func NewEmptyScreenComponent(title, description string, width, height int) *EmptyScreenComponent

NewEmptyScreenComponent creates a new empty screen component

func NewNoDataEmptyScreen

func NewNoDataEmptyScreen(width, height int) *EmptyScreenComponent

Common empty screen types

func NewNoLogsEmptyScreen

func NewNoLogsEmptyScreen(width, height int) *EmptyScreenComponent

func (*EmptyScreenComponent) Render

func (e *EmptyScreenComponent) Render() string

Render returns the formatted empty screen string

func (*EmptyScreenComponent) SetAction

func (e *EmptyScreenComponent) SetAction(action string) *EmptyScreenComponent

SetAction sets the action text for the empty screen

func (*EmptyScreenComponent) SetIcon

SetIcon sets the icon for the empty screen

func (*EmptyScreenComponent) SetStyle

SetStyle allows customizing the empty screen style

type HelpComponent

type HelpComponent struct {
	Title       string
	Description string

	Style lipgloss.Style
	// contains filtered or unexported fields
}

HelpComponent represents a reusable help component using bubbles help

func NewHelpComponent

func NewHelpComponent(title, description string) *HelpComponent

NewHelpComponent creates a new help component

func (*HelpComponent) GetHelpModel

func (h *HelpComponent) GetHelpModel() help.Model

GetHelpModel returns the underlying help model for direct manipulation

func (*HelpComponent) IsShowingAll

func (h *HelpComponent) IsShowingAll() bool

IsShowingAll returns whether the full help is being shown

func (*HelpComponent) Render

func (h *HelpComponent) Render() string

Render returns the formatted help string

func (*HelpComponent) SetWidth

func (h *HelpComponent) SetWidth(width int)

SetWidth sets the width of the help component

func (*HelpComponent) ShowAll

func (h *HelpComponent) ShowAll(show bool)

ShowAll toggles the help view between short and full

func (*HelpComponent) ToggleHelp

func (h *HelpComponent) ToggleHelp()

ToggleHelp toggles the help view

type KeyMap

type KeyMap struct {
	Up         key.Binding
	Down       key.Binding
	Left       key.Binding
	Right      key.Binding
	Help       key.Binding
	Quit       key.Binding
	Refresh    key.Binding
	Logs       key.Binding
	Tab        key.Binding
	GoBack     key.Binding
	NextPage   key.Binding
	PrevPage   key.Binding
	FollowMode key.Binding
	// contains filtered or unexported fields
}

KeyMap defines a set of keybindings. To work for help it must satisfy key.Map. It could also very easily be a map[string]key.Binding.

func (KeyMap) FullHelp

func (k KeyMap) FullHelp() [][]key.Binding

FullHelp returns keybindings for the expanded help view. It's part of the key.Map interface.

func (*KeyMap) GetBasicShortHelpNames

func (k *KeyMap) GetBasicShortHelpNames() []LiteralBindingName

func (*KeyMap) SetShortHelpByNames

func (k *KeyMap) SetShortHelpByNames(fieldNames ...LiteralBindingName)

SetShortHelp sets the short help using field names from the KeyMap

func (KeyMap) ShortHelp

func (k KeyMap) ShortHelp() []key.Binding

ShortHelp returns keybindings to be shown in the mini help view. It's part of the key.Map interface.

type LiteralBindingName

type LiteralBindingName string
const (
	LiteralBindingNameUp         LiteralBindingName = "up"
	LiteralBindingNameDown       LiteralBindingName = "down"
	LiteralBindingNameLeft       LiteralBindingName = "left"
	LiteralBindingNameRight      LiteralBindingName = "right"
	LiteralBindingNameHelp       LiteralBindingName = "help"
	LiteralBindingNameQuit       LiteralBindingName = "quit"
	LiteralBindingNameRefresh    LiteralBindingName = "refresh"
	LiteralBindingNameLogs       LiteralBindingName = "logs"
	LiteralBindingNameTab        LiteralBindingName = "tab"
	LiteralBindingNameGoBack     LiteralBindingName = "go_back"
	LiteralBindingNameNextPage   LiteralBindingName = "next_page"
	LiteralBindingNamePrevPage   LiteralBindingName = "prev_page"
	LiteralBindingNameFollowMode LiteralBindingName = "follow_mode"
)

type StatusComponent

type StatusComponent struct {
	Status    string
	Message   string
	Timestamp time.Time
	Style     lipgloss.Style
	// contains filtered or unexported fields
}

StatusComponent represents a reusable status component

func NewStatusComponent

func NewStatusComponent(status, message string) *StatusComponent

NewStatusComponent creates a new status component

func (*StatusComponent) Render

func (s *StatusComponent) Render(followMode bool) string

Render returns the formatted status string

func (*StatusComponent) SetAlwaysOnDisplayMessage

func (s *StatusComponent) SetAlwaysOnDisplayMessage(alwaysOnDisplayMessage string) *StatusComponent

func (*StatusComponent) SetShortHelpMessage

func (s *StatusComponent) SetShortHelpMessage(shortHelpMessage string) *StatusComponent

func (*StatusComponent) SetStyle

func (s *StatusComponent) SetStyle(style lipgloss.Style) *StatusComponent

SetStyle allows customizing the status style

func (*StatusComponent) UpdateStatus

func (s *StatusComponent) UpdateStatus(status string) *StatusComponent

func (*StatusComponent) UpdateStatusMessage

func (s *StatusComponent) UpdateStatusMessage(message string) *StatusComponent

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL