Documentation
¶
Overview ¶
Package style provides styling and coloring for the TUI.
Index ¶
- Constants
- Variables
- func BranchStyle(isCurrent, isTrunk, isDim bool) lipgloss.Style
- func ColorBranchName(branchName string, isCurrent bool) string
- func ColorBranchNameBold(branchName string, isCurrent bool) string
- func ColorBranchNameBoldWithTrunk(branchName string, isCurrent bool, isTrunk bool) string
- func ColorBranchNameWithTrunk(branchName string, isCurrent bool, isTrunk bool) string
- func ColorCyan(text string) string
- func ColorDim(text string) string
- func ColorGreen(text string) string
- func ColorMagenta(text string) string
- func ColorNeedsRestack(text string) string
- func ColorPRNumber(prNumber int) string
- func ColorPRNumberByState(prNumber int, state string, isDraft bool) string
- func ColorPRState(state string, isDraft bool) string
- func ColorRed(text string) string
- func ColorSHA(sha string) string
- func ColorScope(scope string) string
- func ColorYellow(text string) string
- func DimColor() color.Color
- func DimStyle() lipgloss.Style
- func FormatBranchModificationError(err *errors.BranchModificationError) string
- func FormatShortLine(line string, circleIndex, arrowIndex int, isCurrent bool, overallIndent int) string
- func GetLogShortColor(text string, index int) string
- func GetScopeColor(scope string) (color.Color, bool)
- func HelpDescStyle() lipgloss.Style
- func HelpKeyStyle() lipgloss.Style
- func HelpSeparatorStyle() lipgloss.Style
- func IconCIFailing() string
- func IconCIPassing() string
- func IconCIPending() string
- func IconFrozen() string
- func IconLocked() string
- func IconReviewApproved() string
- func IconReviewChangesRequested() string
- func InsertStyle() lipgloss.Style
- func IsDarkBackground() bool
- func PadToWidth(rendered string, targetWidth int) string
- func RenderMarkdown(content string) string
- func Selection() lipgloss.Style
- func SelectionCursorStyle() lipgloss.Style
- func SubtleStyle() lipgloss.Style
- type CommonStyles
- type DashboardStyles
- type HeaderStyles
- type LayoutStyles
- type SelectionStyles
- type StatusIcons
- type StatusStyles
- type Theme
Constants ¶
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.
const ( SelectionCursor = "▸ " // Cursor symbol for selected items SelectionPadding = " " // Same width as cursor for unselected items )
Selection cursor constants
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.
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.
const ( MarginVertical = 1 MarginHorizontal = 2 )
Standard margin values for consistent layout.
Variables ¶
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 ¶
BranchStyle returns the unified style for a branch name
func ColorBranchName ¶
ColorBranchName colors a branch name based on whether it's current
func ColorBranchNameBold ¶
ColorBranchNameBold colors a branch name with bold if current (green)
func ColorBranchNameBoldWithTrunk ¶
ColorBranchNameBoldWithTrunk colors a branch name with bold if current and trunk status
func ColorBranchNameWithTrunk ¶
ColorBranchNameWithTrunk colors a branch name based on whether it's current and trunk status
func ColorNeedsRestack ¶
ColorNeedsRestack colors restack suggestion text.
func ColorPRNumber ¶
ColorPRNumber colors a PR number (yellow)
func ColorPRNumberByState ¶
ColorPRNumberByState colors PR number based on state
func ColorPRState ¶
ColorPRState colors PR state text based on state and draft status
func ColorScope ¶
ColorScope colors a scope string deterministically
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 ¶
GetLogShortColor returns a styled string with the color from StackitColors
func GetScopeColor ¶
GetScopeColor returns a deterministic color for a scope string
func HelpDescStyle ¶
HelpDescStyle returns a style for help descriptions. Uses a more visible color than the default bubbles help style.
func HelpKeyStyle ¶
HelpKeyStyle returns a style for help key bindings. Uses a more visible color than the default bubbles help style.
func HelpSeparatorStyle ¶
HelpSeparatorStyle returns a style for help separators (the • between items).
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 ¶
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 ¶
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 ¶
RenderMarkdown renders markdown content for terminal display. If rendering fails, it returns the original content as a fallback.
func SelectionCursorStyle ¶
SelectionCursorStyle returns the style for the selection cursor
func SubtleStyle ¶
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
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 ¶
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.