views

package
v0.17.2 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Brand colors
	ColorPrimary   = lipgloss.Color("#7B68EE") // OVHcloud purple
	ColorSecondary = lipgloss.Color("#00FF7F") // Green accent
	ColorDanger    = lipgloss.Color("#FF6B6B") // Red for errors/warnings
	ColorWarning   = lipgloss.Color("#FFD700") // Yellow for warnings
	ColorMuted     = lipgloss.Color("#888888") // Gray for secondary text
	ColorDimmed    = lipgloss.Color("#666666") // Darker gray
	ColorWhite     = lipgloss.Color("#FFFFFF")
	ColorBlack     = lipgloss.Color("#000000")

	// Background colors
	ColorBgDark    = lipgloss.Color("#1a1a1a")
	ColorBgMedium  = lipgloss.Color("#2a2a2a")
	ColorBgBorder  = lipgloss.Color("#444444")
	ColorBgBorder2 = lipgloss.Color("240")
)

Color palette - OVHcloud brand colors and common UI colors

View Source
var (
	StyleLogo = lipgloss.NewStyle().
				Bold(true).
				Foreground(ColorPrimary)

	// Navigation bar
	StyleNavBar = lipgloss.NewStyle().
				Background(ColorBgDark).
				Padding(0, 1)

	StyleNavItem = lipgloss.NewStyle().
					Foreground(ColorMuted).
					Padding(0, 2)

	StyleNavItemSelected = lipgloss.NewStyle().
							Foreground(ColorSecondary).
							Bold(true).
							Padding(0, 2).
							Background(ColorBgMedium)

	// Content area
	StyleContentBox = lipgloss.NewStyle().
					BorderStyle(lipgloss.RoundedBorder()).
					BorderForeground(ColorBgBorder).
					Padding(1, 2)

	// Title for current product
	StyleProductTitle = lipgloss.NewStyle().
						Bold(true).
						Foreground(ColorWhite).
						Background(ColorPrimary).
						Padding(0, 2)

	// Detail view boxes
	StyleBoxTitle = lipgloss.NewStyle().
					Bold(true).
					Foreground(ColorPrimary)

	StyleLabel = lipgloss.NewStyle().
				Foreground(ColorMuted).
				Width(18)

	StyleValue = lipgloss.NewStyle().
				Foreground(ColorWhite)

	StyleStatusRunning = lipgloss.NewStyle().
						Foreground(ColorSecondary)

	StyleStatusStopped = lipgloss.NewStyle().
						Foreground(ColorDanger)

	StyleStatusWarning = lipgloss.NewStyle().
						Foreground(ColorWarning)

	// Footer
	StyleFooter = lipgloss.NewStyle().
				Foreground(ColorDimmed).
				Padding(0, 1)

	// Error and loading
	StyleError = lipgloss.NewStyle().
				Foreground(lipgloss.Color("#FF0000")).
				Bold(true).
				Padding(1, 2)

	StyleLoading = lipgloss.NewStyle().
					Foreground(ColorPrimary).
					Padding(1, 2)

	// Buttons and actions
	StyleButtonSelected = lipgloss.NewStyle().
						Background(ColorPrimary).
						Foreground(ColorWhite).
						Bold(true).
						Padding(0, 1)

	StyleButton = lipgloss.NewStyle().
				Foreground(ColorMuted).
				Padding(0, 1)

	StyleButtonDisabled = lipgloss.NewStyle().
						Foreground(lipgloss.Color("#444444")).
						Padding(0, 1)

	StyleButtonDanger = lipgloss.NewStyle().
						Foreground(ColorDanger).
						Padding(0, 1)

	StyleButtonDangerSelected = lipgloss.NewStyle().
								Background(ColorDanger).
								Foreground(ColorWhite).
								Bold(true).
								Padding(0, 1)

	StyleButtonSuccess = lipgloss.NewStyle().
						Foreground(ColorSecondary).
						Padding(0, 1)

	// Input fields
	StyleInput = lipgloss.NewStyle().
				Foreground(ColorSecondary)

	StyleInputLabel = lipgloss.NewStyle().
					Foreground(ColorMuted)

	// Help text
	StyleHelp = lipgloss.NewStyle().
				Foreground(ColorDimmed)

	// Headers and titles
	StyleHeader = lipgloss.NewStyle().
				Bold(true).
				Foreground(ColorPrimary)

	StyleSubheader = lipgloss.NewStyle().
					Bold(true).
					Foreground(ColorWhite)

	// Table styles
	StyleTableHeader = lipgloss.NewStyle().
						BorderStyle(lipgloss.NormalBorder()).
						BorderForeground(ColorBgBorder2).
						BorderBottom(true).
						Bold(true)

	StyleTableSelected = lipgloss.NewStyle().
						Foreground(lipgloss.Color("229")).
						Background(lipgloss.Color("57")).
						Bold(false)

	// Notification styles
	StyleNotificationSuccess = lipgloss.NewStyle().
								Foreground(ColorSecondary).
								Bold(true)

	StyleNotificationError = lipgloss.NewStyle().
							Foreground(ColorDanger).
							Bold(true)

	// Additional status styles
	StyleStatusReady = lipgloss.NewStyle().
						Foreground(ColorSecondary)

	StyleStatusError = lipgloss.NewStyle().
						Foreground(ColorDanger)

	// Filter style
	StyleFilter = lipgloss.NewStyle().
				Foreground(ColorSecondary).
				Background(ColorBgMedium)

	// Subtle text
	StyleSubtle = lipgloss.NewStyle().
				Foreground(ColorMuted)

	// Highlight style
	StyleHighlight = lipgloss.NewStyle().
					Foreground(ColorSecondary).
					Bold(true)

	// Info style
	StyleInfo = lipgloss.NewStyle().
				Foreground(ColorPrimary).
				Bold(true)
)

Shared styles for consistent UI rendering

Functions

func RenderBox

func RenderBox(title, content string, width int) string

RenderBox creates a bordered box with a title.

func RenderKeyValue

func RenderKeyValue(label, value string) string

RenderKeyValue renders a label-value pair.

func RenderStatus

func RenderStatus(status string) string

RenderStatus renders a status with appropriate coloring.

func TransitionTo

func TransitionTo(view View, cmd tea.Cmd) tea.Msg

TransitionTo creates a ViewTransition message.

Types

type BaseView

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

BaseView provides common functionality for views. Embed this in view structs to get default implementations.

func NewBaseView

func NewBaseView(ctx *Context) BaseView

NewBaseView creates a BaseView with the given context.

func (*BaseView) Context

func (v *BaseView) Context() *Context

Context returns the shared context.

func (*BaseView) Update

func (v *BaseView) Update(msg tea.Msg) (tea.Cmd, View)

Update default implementation - returns nil (no transition, no command).

type Context

type Context struct {
	// CloudProject is the current OVH cloud project ID.
	CloudProject string
	// CloudProjectName is the display name of the current project.
	CloudProjectName string
	// Width and Height are the terminal dimensions.
	Width  int
	Height int
	// Notification is a temporary message to display.
	Notification       string
	NotificationExpiry int64 // Unix timestamp
}

Context provides shared state and services to all views. This is passed to view constructors and stored in views that need it.

func (*Context) SetNotification

func (c *Context) SetNotification(msg string, durationSec int)

SetNotification sets a notification message with expiry.

type EmptyView

type EmptyView struct {
	BaseView
	// contains filtered or unexported fields
}

EmptyView displays an empty state with a creation prompt.

func NewEmptyView

func NewEmptyView(ctx *Context, productName string, canCreate bool) *EmptyView

NewEmptyView creates a new empty view.

func (*EmptyView) HandleKey

func (v *EmptyView) HandleKey(msg tea.KeyMsg) tea.Cmd

func (*EmptyView) HelpText

func (v *EmptyView) HelpText() string

func (*EmptyView) Render

func (v *EmptyView) Render(width, height int) string

func (*EmptyView) Title

func (v *EmptyView) Title() string

type ErrorView

type ErrorView struct {
	BaseView
	// contains filtered or unexported fields
}

ErrorView displays an error message.

func NewErrorView

func NewErrorView(ctx *Context, errorMsg string) *ErrorView

NewErrorView creates a new error view.

func (*ErrorView) HandleKey

func (v *ErrorView) HandleKey(msg tea.KeyMsg) tea.Cmd

func (*ErrorView) HelpText

func (v *ErrorView) HelpText() string

func (*ErrorView) Render

func (v *ErrorView) Render(width, height int) string

func (*ErrorView) Title

func (v *ErrorView) Title() string

type GoBackMsg

type GoBackMsg struct{}

GoBackMsg signals the controller to go back to the previous view.

type LoadingView

type LoadingView struct {
	BaseView
	// contains filtered or unexported fields
}

LoadingView displays a loading indicator with an optional message.

func NewLoadingView

func NewLoadingView(ctx *Context, message string, showSplash bool) *LoadingView

NewLoadingView creates a new loading view.

func (*LoadingView) HandleKey

func (v *LoadingView) HandleKey(msg tea.KeyMsg) tea.Cmd

func (*LoadingView) HelpText

func (v *LoadingView) HelpText() string

func (*LoadingView) Render

func (v *LoadingView) Render(width, height int) string

func (*LoadingView) Title

func (v *LoadingView) Title() string

type View

type View interface {
	// Render returns the view content as a string.
	// width and height are the available dimensions for rendering.
	Render(width, height int) string

	// HandleKey processes keyboard input and returns a command.
	// It may return a ViewTransition to switch to a different view.
	HandleKey(msg tea.KeyMsg) tea.Cmd

	// Update handles async messages (API responses, timers, etc.)
	// Returns a command and optionally a new view if transitioning.
	Update(msg tea.Msg) (tea.Cmd, View)

	// Title returns the view's title for the header bar.
	Title() string

	// HelpText returns contextual help text for the footer.
	HelpText() string
}

View is the interface that all browser views must implement. Each view encapsulates its own state, rendering, and key handling.

type ViewTransition

type ViewTransition struct {
	NewView View
	Cmd     tea.Cmd // Optional command to run after transition
}

ViewTransition is a message that signals a view change.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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