ui

package
v1.17.1 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package ui defines Harbor's terminal design tokens and geometry primitives.

Index

Constants

View Source
const (
	// OuterPadding is the horizontal canvas inset.
	OuterPadding = 2
	// SidebarWidth is the fixed sidebar width.
	SidebarWidth = 42
	// ActionBreakpoint is the first width with horizontal actions.
	ActionBreakpoint = 80
	// SidebarBreakpoint is the final width with an overlay sidebar.
	SidebarBreakpoint = 120
	// HomeComposerWidth is the minimum wide-terminal composer cap.
	HomeComposerWidth = 75
	// DialogMedium is the medium dialog cap.
	DialogMedium = 60
	// DialogLarge is the large dialog cap.
	DialogLarge = 88
	// DialogXLarge is the extra-large dialog cap.
	DialogXLarge = 116
	// AutocompleteRows is the maximum autocomplete height.
	AutocompleteRows = 10
)

Variables

This section is empty.

Functions

func Composer

func Composer(theme Theme, width int, posture, identity string) string

Composer renders the open-edge detached composer shell.

func ComposerGeometry

func ComposerGeometry(layout Layout, lines int) (int, int)

ComposerGeometry returns the capped composer width and viewport-derived height.

func ComposerWithText

func ComposerWithText(theme Theme, width int, posture, status, identity, draft string) string

ComposerWithText renders the detached foundation composer.

func DescribeLayout

func DescribeLayout(layout Layout) string

DescribeLayout returns a stable geometry summary used by smoke gates.

func DialogGeometry

func DialogGeometry(layout Layout, requestedWidth, rows int) (int, int, int)

DialogGeometry returns a fixed dialog's capped width, height, and top row.

func HeavyCard

func HeavyCard(theme Theme, role Role, width int, lines ...string) string

HeavyCard renders a selective heavy-left-rule card.

func LiveComposer

func LiveComposer(theme Theme, width int, posture, status, identity, draft string, cursor, selectionStart, selectionEnd int) string

LiveComposer renders a wrapped operational draft with an exact cursor and inverse-styled selection. It contains no fabricated Runtime metadata.

func PadRight

func PadRight(value string, width int) string

PadRight clips and pads text to exactly width visible cells.

func Truncate

func Truncate(value string, width int) string

Truncate clips a string to visible cells.

func Width

func Width(value string) int

Width is Harbor's only visible-cell width implementation.

Types

type Cluster

type Cluster struct {
	Text  string
	Width int
}

Cluster is one grapheme and its visible width.

func Clusters

func Clusters(value string) []Cluster

Clusters splits plain text using x/ansi's grapheme-aware truncation. It deliberately shares the same width authority as every layout operation.

The input MUST be plain text. On styled input ansi.Truncate returns a re-terminated string that is not a prefix of the source, so the scan could never advance; the prefix guard below consumes the remainder in one cluster instead of looping forever. Callers rendering styled content keep text and style separate (the canvas takes plain text plus one style per write).

type Environment

type Environment struct {
	TERM, COLORTERM string
	NoColor, Light  bool
}

Environment describes terminal capabilities used to compile a theme.

func EnvironmentFrom

func EnvironmentFrom(lookup func(string) (string, bool)) Environment

EnvironmentFrom reads terminal capability variables. NO_COLOR is enabled by presence, including an explicitly empty value.

type Layout

type Layout struct {
	Width, Height                    int
	ContentWidth, ContentHeight      int
	MainWidth, SidebarWidth          int
	HorizontalActions, JoinedSidebar bool
}

Layout is the explicit pre-style root geometry.

func Measure

func Measure(width, height int) Layout

Measure calculates root geometry without styling.

type Mode

type Mode uint8

Mode identifies a dark or light terminal background.

const (
	ModeDark Mode = iota
	ModeLight
)

type Profile

type Profile uint8

Profile identifies the terminal color capability.

const (
	ProfileTrueColor Profile = iota
	ProfileANSI256
	ProfileANSI16
	ProfileMono
)

type Role

type Role uint8

Role names a semantic color; components never choose literal colors.

const (
	RolePrimary Role = iota
	RoleSecondary
	RoleAccent
	RoleError
	RoleWarning
	RoleSuccess
	RoleInfo
	RoleText
	RoleMuted
	RoleCanvas
	RolePanel
	RoleElement
	RoleBorder
	// Brand roles carry the Harbor mark's palette — the lighthouse beam,
	// beacon light, tower, and sea from the canonical logo — so even the
	// pixel mark stays inside the semantic token system.
	RoleBrandBeam
	RoleBrandLight
	RoleBrandTower
	RoleBrandSea
)

type Theme

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

Theme is an immutable compiled semantic palette.

func CompileTheme

func CompileTheme(environment Environment) Theme

CompileTheme selects profile and background mode from terminal capabilities.

func NewTheme

func NewTheme(mode Mode, profile Profile) Theme

NewTheme compiles one terminal palette.

func (Theme) Mode

func (t Theme) Mode() Mode

Mode returns the compiled background mode.

func (Theme) Profile

func (t Theme) Profile() Profile

Profile returns the compiled terminal capability.

func (Theme) SemanticValue

func (t Theme) SemanticValue(role Role) string

SemanticValue exposes a compiled role for style conformance tests.

func (Theme) Style

func (t Theme) Style(foreground Role, background *Role) lipgloss.Style

Style returns a style for a semantic foreground/background pair.

Jump to

Keyboard shortcuts

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