Documentation
¶
Index ¶
- Variables
- func RenderBox(title, content string, width int) string
- func RenderKeyValue(label, value string) string
- func RenderStatus(status string) string
- func TransitionTo(view View, cmd tea.Cmd) tea.Msg
- type BaseView
- type Context
- type EmptyView
- type ErrorView
- type GoBackMsg
- type LoadingView
- type View
- type ViewTransition
Constants ¶
This section is empty.
Variables ¶
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
var ( // Header / Logo StyleLogo = lipgloss.NewStyle(). Bold(true). Foreground(ColorPrimary) StyleNavBar = lipgloss.NewStyle(). Background(ColorBgDark). Padding(0, 1) Foreground(ColorMuted). Padding(0, 2) 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) 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) StyleButtonDanger = lipgloss.NewStyle(). Foreground(ColorDanger). 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 RenderKeyValue ¶
RenderKeyValue renders a label-value pair.
func RenderStatus ¶
RenderStatus renders a status with appropriate coloring.
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 ¶
NewBaseView creates a BaseView with the given context.
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 ¶
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 ¶
NewEmptyView creates a new empty view.
type ErrorView ¶
type ErrorView struct {
BaseView
// contains filtered or unexported fields
}
ErrorView displays an error message.
func NewErrorView ¶
NewErrorView creates a new error view.
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) 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 ¶
ViewTransition is a message that signals a view change.