components

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SepRight          = "\ue0b0" // Powerline right arrow (solid)
	SepRightThin      = "\ue0b1" // Powerline right arrow (thin)
	SepLeft           = "\ue0b2" // Powerline left arrow (solid)
	SepLeftThin       = "\ue0b3" // Powerline left arrow (thin)
	SepDiagonalRight  = "\ue0bc" // Powerline diagonal right (bottom-left to top-right)
	SepDiagonalLeft   = "\ue0ba" // Powerline diagonal left (top-left to bottom-right)
	SepDiagonalRightR = "\ue0be" // Powerline diagonal right reverse
	SepDiagonalLeftR  = "\ue0b8" // Powerline diagonal left reverse
)

Powerline separator characters (Unicode code points for powerline fonts)

Variables

View Source
var (

	// HintStyle is exported for consistent hint styling across views
	HintStyle = lipgloss.NewStyle().
		Foreground(lipgloss.Color("#9AA0A6")).
		Italic(true)
)
View Source
var PredefinedTimeRanges = []TimeRange{
	{Label: "1h", Duration: 1 * time.Hour, Key: "1"},
	{Label: "6h", Duration: 6 * time.Hour, Key: "2"},
	{Label: "24h", Duration: 24 * time.Hour, Key: "3"},
	{Label: "7d", Duration: 7 * 24 * time.Hour, Key: "4"},
	{Label: "30d", Duration: 30 * 24 * time.Hour, Key: "5"},
}

PredefinedTimeRanges are the standard time ranges available

Functions

func NewGCPSpinner

func NewGCPSpinner() spinner.Model

NewGCPSpinner creates a spinner.Model with standard GCP blue styling.

func ParseMetadata

func ParseMetadata(text string) (map[string]string, error)

ParseMetadata parses the editor text into a metadata map Supports formats:

  • key=value
  • key: value
  • key="multi-line\nvalue"
  • key: | indented multi-line value

func RenderError

func RenderError(err error) string

RenderError formats an error for display in the TUI with user-friendly messages

func RenderInlineError

func RenderInlineError(err error) string

RenderInlineError formats an error as a simple styled message for form/creation views. Unlike RenderError, it omits retry hints since forms have their own navigation.

func RenderMetricBar

func RenderMetricBar(label string, currentValue, avgValue, peakValue float64, peakTime time.Time, width int) string

RenderMetricBar renders a horizontal bar chart for a metric Returns a multi-line string with the bar and stats

func RenderMetricBarWithLabel

func RenderMetricBarWithLabel(label string, currentValue, avgValue, peakValue float64, peakTime time.Time, width int) string

RenderMetricBarWithLabel renders a metric bar with a header label

func RenderSparkline

func RenderSparkline(data []float64, width int) string

RenderSparkline converts a slice of data points to a Unicode sparkline Example: []float64{1, 3, 5, 7, 5, 3, 1} → "▁▃▅▇▅▃▁"

func RenderSparklineWithLabel

func RenderSparklineWithLabel(label string, data []float64, width int) string

RenderSparklineWithLabel renders sparkline with label Example: "CPU (6h): ▁▂▃▄▅▆▇█▇▆▅▄▃▂▁"

func RenderTimeRangeSelector

func RenderTimeRangeSelector(activeRange time.Duration, autoRefresh bool, lastUpdated time.Time) string

RenderTimeRangeSelector renders a time range selector with highlighted active range

func SerializeMetadata

func SerializeMetadata(metadata map[string]string) string

SerializeMetadata converts a metadata map to editable text format

func Validate

func Validate(metadata map[string]string) []string

Validate validates the parsed metadata against GCP constraints

Types

type Clickable

type Clickable interface {
	// UpdateRegions recalculates clickable regions based on current state
	// offsetX, offsetY are the component's top-left corner in screen coordinates
	// Called after View() but before mouse event processing
	UpdateRegions(offsetX, offsetY int)

	// GetRegions returns current clickable regions
	GetRegions() []mouse.Region

	// HandleRegionClick processes a click on a specific region
	// regionID identifies which region was clicked
	// Returns a tea.Cmd to execute in response to the click
	HandleRegionClick(regionID string) tea.Cmd
}

Clickable interface for components that handle mouse clicks

type Footer struct {

	// Fixed slots - nil means slot is hidden, empty string shows just separator
	Left1   *string
	Left2   *string
	Left3   *string
	Center1 *string
	Center2 *string
	Center3 *string
	Right1  *string
	Right2  *string
	Right3  *string

	// Pre-rendered sections (already styled, for custom styling)
	CenterRendered   string
	CenterRenderedBg lipgloss.Color // Background color for separator styling
	Right1Rendered   string
	Right1RenderedBg lipgloss.Color // Background color for separator styling
	Right2Rendered   string
	Right2RenderedBg lipgloss.Color
	Right3Rendered   string
	Right3RenderedBg lipgloss.Color
	// contains filtered or unexported fields
}

Footer displays a multi-section status bar with powerline separators

func NewFooter

func NewFooter() *Footer

NewFooter creates a new footer with default styles

func (*Footer) ClearCenter

func (f *Footer) ClearCenter()

ClearCenter clears all center slots

func (*Footer) ClearLeft1

func (f *Footer) ClearLeft1()

ClearLeft1 hides the first left slot

func (*Footer) ClearLeft2

func (f *Footer) ClearLeft2()

ClearLeft2 hides the second left slot

func (*Footer) ClearLeft3

func (f *Footer) ClearLeft3()

ClearLeft3 hides the third left slot

func (*Footer) ClearRight1

func (f *Footer) ClearRight1()

ClearRight1 hides the first right slot

func (*Footer) ClearRight1Styled

func (f *Footer) ClearRight1Styled()

ClearRight1Styled clears the pre-rendered right1 content

func (*Footer) ClearRight2

func (f *Footer) ClearRight2()

ClearRight2 hides the second right slot

func (*Footer) ClearRight2Styled

func (f *Footer) ClearRight2Styled()

ClearRight2Styled clears the pre-rendered right2 content

func (*Footer) ClearRight3

func (f *Footer) ClearRight3()

ClearRight3 hides the third right slot

func (*Footer) ClearRight3Styled

func (f *Footer) ClearRight3Styled()

ClearRight3Styled clears the pre-rendered right3 content

func (*Footer) GetRegions

func (f *Footer) GetRegions() []mouse.Region

GetRegions returns current clickable regions

func (*Footer) HandleRegionClick

func (f *Footer) HandleRegionClick(regionID string) tea.Cmd

HandleRegionClick processes a click on a footer region

func (*Footer) SetCenter1

func (f *Footer) SetCenter1(s string)

SetCenter1 sets the first center slot

func (*Footer) SetCenter2

func (f *Footer) SetCenter2(s string)

SetCenter2 sets the second center slot

func (*Footer) SetCenter3

func (f *Footer) SetCenter3(s string)

SetCenter3 sets the third center slot

func (*Footer) SetCenterStyled

func (f *Footer) SetCenterStyled(rendered string, bg lipgloss.Color)

SetCenterStyled sets pre-rendered content for center (bypasses default styling) The bg color is used for powerline separator styling

func (*Footer) SetLeft1

func (f *Footer) SetLeft1(s string)

SetLeft1 sets the first left slot

func (*Footer) SetLeft2

func (f *Footer) SetLeft2(s string)

SetLeft2 sets the second left slot

func (*Footer) SetLeft3

func (f *Footer) SetLeft3(s string)

SetLeft3 sets the third left slot

func (*Footer) SetRight1

func (f *Footer) SetRight1(s string)

SetRight1 sets the first right slot

func (*Footer) SetRight1Styled

func (f *Footer) SetRight1Styled(rendered string, bg lipgloss.Color)

SetRight1Styled sets pre-rendered content for right1 (bypasses default styling) The bg color is used for powerline separator styling

func (*Footer) SetRight2

func (f *Footer) SetRight2(s string)

SetRight2 sets the second right slot

func (*Footer) SetRight2Styled

func (f *Footer) SetRight2Styled(rendered string, bg lipgloss.Color)

SetRight2Styled sets pre-rendered content for right2 (bypasses default styling) The bg color is used for powerline separator styling

func (*Footer) SetRight3

func (f *Footer) SetRight3(s string)

SetRight3 sets the third right slot

func (*Footer) SetRight3Styled

func (f *Footer) SetRight3Styled(rendered string, bg lipgloss.Color)

SetRight3Styled sets pre-rendered content for right3 (bypasses default styling) The bg color is used for powerline separator styling

func (*Footer) SetStyles

func (f *Footer) SetStyles(styles FooterStyles)

SetStyles sets custom footer styles

func (*Footer) SetWidth

func (f *Footer) SetWidth(width int)

SetWidth sets the footer width

func (*Footer) UpdateRegions

func (f *Footer) UpdateRegions(offsetX, offsetY int)

UpdateRegions recalculates clickable regions based on footer state

func (*Footer) View

func (f *Footer) View() string

View renders the footer

type FooterProjectClickedMsg

type FooterProjectClickedMsg struct{}

FooterProjectClickedMsg is sent when the project section is clicked

type FooterStyles

type FooterStyles struct {
	// Left group styles
	Left1Bg lipgloss.Color
	Left1Fg lipgloss.Color
	Left2Bg lipgloss.Color
	Left2Fg lipgloss.Color
	Left3Bg lipgloss.Color
	Left3Fg lipgloss.Color

	// Center group styles
	CenterBg lipgloss.Color
	CenterFg lipgloss.Color

	// Right group styles
	Right1Bg lipgloss.Color
	Right1Fg lipgloss.Color
	Right2Bg lipgloss.Color
	Right2Fg lipgloss.Color
	Right3Bg lipgloss.Color
	Right3Fg lipgloss.Color

	// Background for spacing between groups
	SpacerBg lipgloss.Color
}

FooterStyles defines colors for each section slot

func DefaultFooterStyles

func DefaultFooterStyles() FooterStyles

DefaultFooterStyles returns GCP-inspired footer colors

type GoogleColors

type GoogleColors struct {
	G  lipgloss.Style // Blue #4285F4
	O1 lipgloss.Style // Red #EA4335
	O2 lipgloss.Style // Yellow #FBBC05
	G2 lipgloss.Style // Blue #4285F4
	L  lipgloss.Style // Green #34A853
	E  lipgloss.Style // Red #EA4335
}

GoogleColors holds styles for rainbow-colored "Google" text

type Header struct {
	// contains filtered or unexported fields
}

Header displays the app title with rainbow Google and powerline breadcrumbs

func NewHeader

func NewHeader() *Header

NewHeader creates a new header component

func (*Header) SetCategory

func (h *Header) SetCategory(category string)

SetCategory sets the current category (e.g., "Compute Engine") for breadcrumbs

func (*Header) SetProject

func (h *Header) SetProject(projectID string)

SetProject sets the current project ID for breadcrumbs

func (*Header) SetResources

func (h *Header) SetResources(resources []string)

SetResources sets the resource path for breadcrumbs (e.g., ["my-instance"])

func (*Header) SetSize

func (h *Header) SetSize(width int)

SetSize sets the header width

func (*Header) View

func (h *Header) View() string

View renders the header

func (*Header) Width

func (h *Header) Width() int

Width returns the header width

type HeaderStyles

type HeaderStyles struct {
	Title               lipgloss.Style
	Muted               lipgloss.Style
	GoogleColors        GoogleColors
	BreadcrumbProject   lipgloss.Style
	BreadcrumbCategory  lipgloss.Style
	BreadcrumbResource  lipgloss.Style
	BreadcrumbSeparator lipgloss.Style
}

HeaderStyles defines colors for header rendering

func DefaultHeaderStyles

func DefaultHeaderStyles() HeaderStyles

DefaultHeaderStyles returns the default header styles with GCP colors

type LoadingSpinner

type LoadingSpinner struct {
	// contains filtered or unexported fields
}

LoadingSpinner wraps the bubbles spinner with custom styling

func NewLoadingSpinner

func NewLoadingSpinner(message string) LoadingSpinner

NewLoadingSpinner creates a new loading spinner with a message

func (LoadingSpinner) Init

func (l LoadingSpinner) Init() tea.Cmd

Init starts the spinner animation

func (*LoadingSpinner) SetMessage

func (l *LoadingSpinner) SetMessage(message string)

SetMessage updates the loading message

func (LoadingSpinner) Tick

func (l LoadingSpinner) Tick() tea.Cmd

Tick returns a command to continue spinner animation

func (LoadingSpinner) Update

func (l LoadingSpinner) Update(msg tea.Msg) (LoadingSpinner, tea.Cmd)

Update handles spinner tick messages

func (LoadingSpinner) View

func (l LoadingSpinner) View() string

View renders the spinner with message

type MetadataEditor

type MetadataEditor struct {
	// contains filtered or unexported fields
}

MetadataEditor wraps a textarea for editing instance metadata

func NewMetadataEditor

func NewMetadataEditor() MetadataEditor

NewMetadataEditor creates a new metadata editor with optional initial content

func (*MetadataEditor) Blur

func (m *MetadataEditor) Blur()

Blur blurs the editor

func (*MetadataEditor) Focus

func (m *MetadataEditor) Focus() tea.Cmd

Focus focuses the editor

func (*MetadataEditor) GetContent

func (m *MetadataEditor) GetContent() string

GetContent returns the current editor content

func (MetadataEditor) Init

func (m MetadataEditor) Init() tea.Cmd

Init initializes the editor

func (*MetadataEditor) IsDirty

func (m *MetadataEditor) IsDirty() bool

IsDirty returns true if content has changed

func (*MetadataEditor) SetContent

func (m *MetadataEditor) SetContent(content string)

SetContent sets the editor content and stores it as original

func (*MetadataEditor) SetSize

func (m *MetadataEditor) SetSize(width, height int)

SetSize sets the editor dimensions

func (MetadataEditor) Update

func (m MetadataEditor) Update(msg tea.Msg) (MetadataEditor, tea.Cmd)

Update handles textarea messages

func (MetadataEditor) View

func (m MetadataEditor) View() string

View renders the editor

type StatusBar

type StatusBar struct {
	// contains filtered or unexported fields
}

StatusBar displays contextual information at the bottom of the screen

func NewStatusBar

func NewStatusBar() StatusBar

NewStatusBar creates a new status bar

func (*StatusBar) SetCenter

func (s *StatusBar) SetCenter(content string)

SetCenter sets the center-aligned content

func (*StatusBar) SetLeft

func (s *StatusBar) SetLeft(content string)

SetLeft sets the left-aligned content

func (*StatusBar) SetRight

func (s *StatusBar) SetRight(content string)

SetRight sets the right-aligned content

func (*StatusBar) SetWidth

func (s *StatusBar) SetWidth(width int)

SetWidth sets the status bar width

func (StatusBar) View

func (s StatusBar) View() string

View renders the status bar

type TimeRange

type TimeRange struct {
	Label    string
	Duration time.Duration
	Key      string
}

TimeRange represents a selectable time range

Directories

Path Synopsis
Package actionmenu provides a popup action menu component for views.
Package actionmenu provides a popup action menu component for views.
Package confirm provides confirmation dialogs for destructive actions.
Package confirm provides confirmation dialogs for destructive actions.
Package diff provides a component for displaying before/after comparisons with confirmation dialog for changes.
Package diff provides a component for displaying before/after comparisons with confirmation dialog for changes.
Package footer provides an enhanced footer component with dynamic content.
Package footer provides an enhanced footer component with dynamic content.
Package forms provides reusable form components for editing GCP resources.
Package forms provides reusable form components for editing GCP resources.
Package inputdialog provides a simple modal input dialog for capturing text input.
Package inputdialog provides a simple modal input dialog for capturing text input.
Package labeledit provides a component for editing key-value label pairs used in GCP resources like VM instances.
Package labeledit provides a component for editing key-value label pairs used in GCP resources like VM instances.
Package links provides a component for navigable links within detail views.
Package links provides a component for navigable links within detail views.
Package sortmenu provides a popup sort column selector for table views.
Package sortmenu provides a popup sort column selector for table views.
Package table provides a reusable table component with GCP styling and filtering support.
Package table provides a reusable table component with GCP styling and filtering support.
Package tabs provides a reusable tab bar component for detail views.
Package tabs provides a reusable tab bar component for detail views.
Package textarea provides a multi-line text editor with GCP styling.
Package textarea provides a multi-line text editor with GCP styling.
Package timer provides countdown and elapsed time components with GCP styling.
Package timer provides countdown and elapsed time components with GCP styling.
Package viewport provides a scrollable content container with GCP styling.
Package viewport provides a scrollable content container with GCP styling.

Jump to

Keyboard shortcuts

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