style

package
v0.17.14 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package style provides styling and coloring for the TUI.

Index

Constants

View Source
const (
	// ColorPrimary is magenta, used for emphasis, titles, and active states
	ColorPrimary = "205"
	// ColorSuccess is green, used for done/success states
	ColorSuccess = "42"
	// ColorSuccessAlt is an alternate green for selected items
	ColorSuccessAlt = "2"
	// ColorError is red, used for error states
	ColorError = "196"
	// ColorErrorAlt is an alternate red for inline errors
	ColorErrorAlt = "1"
	// ColorWarning is orange, used for warning states
	ColorWarning = "214"
	// ColorWarningAlt is yellow for inline warnings
	ColorWarningAlt = "3"
	// ColorSecondary is blue, used for branch names and secondary emphasis
	ColorSecondary = "12"
	// ColorAccent is cyan, used for selection backgrounds
	ColorAccent = "6"
	// ColorInsert is bright green, used for new/inserted items
	ColorInsert = "10"
	// ColorPending is dark gray, used for pending/inactive states
	ColorPending = "240"
	// ColorDim is medium gray, used for de-emphasized text
	ColorDimValue = "241"
	// ColorSubtle is medium-dark gray, used for secondary text
	ColorSubtleValue = "243"
	// ColorMerged is magenta variant, used for merged PR states
	ColorMerged = "5"
)

Color constants for consistent styling across TUI components. Use these instead of magic color numbers.

View Source
const (
	SelectionCursor  = "▸ " // Cursor symbol for selected items
	SelectionPadding = "  " // Same width as cursor for unselected items
)

Selection cursor constants

View Source
const (
	// CheckboxColumnWidth is the display width for the checkbox column.
	// Widest value is "[🔒]" which renders as 4 display columns.
	CheckboxColumnWidth = 4

	// StatusIconColumnWidth is the display width for the status icon column.
	// Widest value is "⏳" which renders as 2 display columns.
	StatusIconColumnWidth = 2
)

Column width constants for alignment in the stack list. These ensure columns stay aligned regardless of unicode character widths.

View Source
const (
	// ColorDashboardBackground is a dark gray for selected row backgrounds.
	ColorDashboardBackground = "236"
	// ColorDashboardWhite is white for text on dark backgrounds.
	ColorDashboardWhite = "15"
	// ColorDashboardBlack is black for text on light backgrounds.
	ColorDashboardBlack = "0"
	// ColorDashboardGray is medium gray for disabled text.
	ColorDashboardGray = "7"
	// ColorDashboardDarkGray is dark gray for disabled backgrounds.
	ColorDashboardDarkGray = "8"
	// ColorDashboardBorder is dim gray for panel borders.
	ColorDashboardBorder = "240"
	// ColorDashboardFocusedBorder is brighter for the focused pane border.
	ColorDashboardFocusedBorder = "252"
)

Dashboard color constants shared between the real dashboard and story previews.

View Source
const (
	MarginVertical   = 1
	MarginHorizontal = 2
)

Standard margin values for consistent layout.

Variables

View Source
var StackitColors = [][]int{
	{76, 203, 241},
	{77, 202, 125},
	{110, 173, 38},
	{245, 200, 0},
	{248, 144, 72},
	{244, 98, 81},
	{235, 130, 188},
	{159, 131, 228},
	{80, 132, 243},
}

StackitColors defines the color palette for branch visualization Matching the TypeScript version

Functions

func BranchStyle

func BranchStyle(isCurrent, isTrunk, isDim bool) lipgloss.Style

BranchStyle returns the unified style for a branch name

func ColorBranchName

func ColorBranchName(branchName string, isCurrent bool) string

ColorBranchName colors a branch name based on whether it's current

func ColorBranchNameBold

func ColorBranchNameBold(branchName string, isCurrent bool) string

ColorBranchNameBold colors a branch name with bold if current (green)

func ColorBranchNameBoldWithTrunk

func ColorBranchNameBoldWithTrunk(branchName string, isCurrent bool, isTrunk bool) string

ColorBranchNameBoldWithTrunk colors a branch name with bold if current and trunk status

func ColorBranchNameWithTrunk

func ColorBranchNameWithTrunk(branchName string, isCurrent bool, isTrunk bool) string

ColorBranchNameWithTrunk colors a branch name based on whether it's current and trunk status

func ColorCyan

func ColorCyan(text string) string

ColorCyan colors text cyan

func ColorDim

func ColorDim(text string) string

ColorDim makes text dim/gray (adaptive to terminal background)

func ColorGreen

func ColorGreen(text string) string

ColorGreen colors text green

func ColorMagenta

func ColorMagenta(text string) string

ColorMagenta colors text magenta

func ColorNeedsRestack

func ColorNeedsRestack(text string) string

ColorNeedsRestack colors restack suggestion text.

func ColorPRNumber

func ColorPRNumber(prNumber int) string

ColorPRNumber colors a PR number (yellow)

func ColorPRNumberByState

func ColorPRNumberByState(prNumber int, state string, isDraft bool) string

ColorPRNumberByState colors PR number based on state

func ColorPRState

func ColorPRState(state string, isDraft bool) string

ColorPRState colors PR state text based on state and draft status

func ColorRed

func ColorRed(text string) string

ColorRed colors text red

func ColorSHA

func ColorSHA(sha string) string

ColorSHA colors a git SHA (yellow)

func ColorScope

func ColorScope(scope string) string

ColorScope colors a scope string deterministically

func ColorYellow

func ColorYellow(text string) string

ColorYellow colors text yellow

func DimColor

func DimColor() color.Color

DimColor returns the dim color value (adaptive to terminal background)

func DimStyle

func DimStyle() lipgloss.Style

DimStyle returns a style for dim/muted text (adaptive to terminal background)

func FormatBranchModificationError

func FormatBranchModificationError(err *errors.BranchModificationError) string

FormatBranchModificationError formats a BranchModificationError with colors and helpful instructions

func FormatShortLine

func FormatShortLine(line string, circleIndex, arrowIndex int, isCurrent bool, overallIndent int) string

FormatShortLine applies color formatting to a short log line

func GetLogShortColor

func GetLogShortColor(text string, index int) string

GetLogShortColor returns a styled string with the color from StackitColors

func GetScopeColor

func GetScopeColor(scope string) (color.Color, bool)

GetScopeColor returns a deterministic color for a scope string

func HelpDescStyle

func HelpDescStyle() lipgloss.Style

HelpDescStyle returns a style for help descriptions. Uses a more visible color than the default bubbles help style.

func HelpKeyStyle

func HelpKeyStyle() lipgloss.Style

HelpKeyStyle returns a style for help key bindings. Uses a more visible color than the default bubbles help style.

func HelpSeparatorStyle

func HelpSeparatorStyle() lipgloss.Style

HelpSeparatorStyle returns a style for help separators (the • between items).

func IconCIFailing

func IconCIFailing() string

IconCIFailing returns a red dot for failing CI

func IconCIPassing

func IconCIPassing() string

IconCIPassing returns a green dot for passing CI

func IconCIPending

func IconCIPending() string

IconCIPending returns a yellow dot for pending CI

func IconFrozen

func IconFrozen() string

IconFrozen returns the frozen icon (snowflake)

func IconLocked

func IconLocked() string

IconLocked returns the locked icon (lock)

func IconReviewApproved

func IconReviewApproved() string

IconReviewApproved returns the approved icon (green checkmark)

func IconReviewChangesRequested

func IconReviewChangesRequested() string

IconReviewChangesRequested returns the changes requested icon (orange warning)

func InsertStyle

func InsertStyle() lipgloss.Style

InsertStyle returns the style for insert/new item indicators.

func IsDarkBackground

func IsDarkBackground() bool

IsDarkBackground returns true if the terminal has a dark background

func PadToWidth

func PadToWidth(rendered string, targetWidth int) string

PadToWidth pads a rendered string with spaces to reach targetWidth display columns. It uses lipgloss.Width() to measure actual display width, handling unicode correctly.

func RenderMarkdown

func RenderMarkdown(content string) string

RenderMarkdown renders markdown content for terminal display. If rendering fails, it returns the original content as a fallback.

func Selection

func Selection() lipgloss.Style

Selection returns a style for selected items

func SelectionCursorStyle

func SelectionCursorStyle() lipgloss.Style

SelectionCursorStyle returns the style for the selection cursor

func SubtleStyle

func SubtleStyle() lipgloss.Style

SubtleStyle returns a style for subtle/secondary text (adaptive to terminal background)

Types

type CommonStyles

type CommonStyles struct {
	// Bold style for emphasized text
	Bold lipgloss.Style
	// Dim style for de-emphasized text (adaptive to terminal background)
	Dim lipgloss.Style
	// Subtle style for secondary text (adaptive to terminal background)
	Subtle lipgloss.Style
	// Branch style for branch names
	Branch lipgloss.Style
	// URL style for links
	URL lipgloss.Style
	// Spinner style for animated spinners
	Spinner lipgloss.Style
}

CommonStyles contains commonly used text styles.

func DefaultCommonStyles

func DefaultCommonStyles() CommonStyles

DefaultCommonStyles returns the standard common styles for stackit TUIs.

type DashboardStyles

type DashboardStyles struct {
	Title        lipgloss.Style
	HeaderStatus lipgloss.Style
	HeaderBorder lipgloss.Style
	PaneHeader   lipgloss.Style
	SelectedRow  lipgloss.Style
	Footer       lipgloss.Style
	ErrorText    lipgloss.Style

	// Pane styles
	LeftPane  lipgloss.Style
	RightPane lipgloss.Style
	ActionBar lipgloss.Style

	// Badge styles
	BadgeReady      lipgloss.Style
	BadgePending    lipgloss.Style
	BadgeBlocked    lipgloss.Style
	BadgeIncomplete lipgloss.Style

	// Button styles
	ButtonPrimary lipgloss.Style

	// Help styles
	HelpTitle   lipgloss.Style
	HelpSection lipgloss.Style
	HelpKey     lipgloss.Style
	HelpDesc    lipgloss.Style

	// Dialog
	Dialog lipgloss.Style
}

DashboardStyles holds all styles for the shippable work dashboard. Both the real dashboard and st-tui stories use these to stay in sync.

func DefaultDashboardStyles

func DefaultDashboardStyles() DashboardStyles

DefaultDashboardStyles returns the canonical dashboard styles.

type HeaderStyles

type HeaderStyles struct {
	// Title is bold magenta for primary headers
	Title lipgloss.Style
	// Subtitle is for secondary headers with top margin
	Subtitle lipgloss.Style
	// Help is gray for help text
	Help lipgloss.Style
}

HeaderStyles contains styles for titles and headers.

func DefaultHeaderStyles

func DefaultHeaderStyles() HeaderStyles

DefaultHeaderStyles returns the standard header styles for stackit TUIs.

type LayoutStyles

type LayoutStyles struct {
	// Container is the standard container with margins
	Container lipgloss.Style
	// Compact is minimal spacing
	Compact lipgloss.Style
	// Spacious is extra spacing
	Spacious lipgloss.Style
}

LayoutStyles contains styles for layout and spacing.

func DefaultLayoutStyles

func DefaultLayoutStyles() LayoutStyles

DefaultLayoutStyles returns the standard layout styles for stackit TUIs.

type SelectionStyles

type SelectionStyles struct {
	// Cursor is bold magenta for the selection indicator
	Cursor lipgloss.Style
	// Selected is green for currently selected items
	Selected lipgloss.Style
	// Unselected is gray for non-selected items
	Unselected lipgloss.Style
	// Highlighted is for items with cursor focus (different from selected)
	Highlighted lipgloss.Style
}

SelectionStyles contains styles for selection UI elements.

func DefaultSelectionStyles

func DefaultSelectionStyles() SelectionStyles

DefaultSelectionStyles returns the standard selection styles for stackit TUIs.

type StatusIcons

type StatusIcons struct {
	Pending string
	Active  string
	Done    string
	Error   string
	Warning string
}

StatusIcons contains icon characters for status indicators.

func DefaultStatusIcons

func DefaultStatusIcons() StatusIcons

DefaultStatusIcons returns the standard status icons for stackit TUIs.

type StatusStyles

type StatusStyles struct {
	// Pending style for items not yet started
	Pending lipgloss.Style
	// Active style for items currently in progress
	Active lipgloss.Style
	// Done style for successfully completed items
	Done lipgloss.Style
	// Error style for failed items
	Error lipgloss.Style
	// Warning style for items needing attention
	Warning lipgloss.Style
}

StatusStyles contains styles for status indicators used across TUI components. This provides a consistent look for pending, active, done, and error states.

func DefaultStatusStyles

func DefaultStatusStyles() StatusStyles

DefaultStatusStyles returns the standard status styles for stackit TUIs.

type Theme

type Theme int

Theme represents the terminal background type

const (
	// ThemeDark is for terminals with dark backgrounds
	ThemeDark Theme = iota
	// ThemeLight is for terminals with light backgrounds
	ThemeLight
)

func DetectTheme

func DetectTheme() Theme

DetectTheme returns whether the terminal has a dark or light background. The result is cached after the first call.

Jump to

Keyboard shortcuts

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