Documentation
¶
Overview ¶
Package common provides shared UI components and styles.
Package common provides shared UI components and styles.
Index ¶
- Constants
- Variables
- func FormatCommitMessage(msg CommitMessageContent, maxWidth int) string
- func GetContentWidth(terminalWidth int) int
- func IsWarnErr(err error) bool
- func RenderResult(r Result) string
- type CommitMessageContent
- type LuckyResult
- type MultiTaskModel
- type Result
- type ResultType
- type SingleTaskModel
- type Task
- type TaskState
- type WarnErr
Constants ¶
const ( SymbolSuccess = "✓" SymbolError = "✗" SymbolWarning = "⚠" SymbolPending = "○" SymbolRunning = "●" )
Status indicator symbols.
const MaxContentWidth = 120
MaxContentWidth defines the maximum display width for content.
Variables ¶
var ( ColorPrimary = lipgloss.AdaptiveColor{Light: "#9A4AFF", Dark: "#EE6FF8"} ColorBorder = lipgloss.AdaptiveColor{Light: "#9F72FF", Dark: "#AD58B4"} ColorTitleBg = lipgloss.AdaptiveColor{Light: "#16A34A", Dark: "#22C55E"} // Unified green ColorTitleFg = lipgloss.AdaptiveColor{Light: "#FFFFFF", Dark: "#FFFFFF"} ColorSuccess = lipgloss.AdaptiveColor{Light: "#16A34A", Dark: "#22C55E"} // Same as TitleBg ColorWarning = lipgloss.AdaptiveColor{Light: "#D97706", Dark: "#FBBF24"} ColorError = lipgloss.AdaptiveColor{Light: "#DC2626", Dark: "#F87171"} ColorText = lipgloss.AdaptiveColor{Light: "#1A1A1A", Dark: "#DDDDDD"} ColorMuted = lipgloss.AdaptiveColor{Light: "#6F6C6C", Dark: "#7A7A7A"} // Commit message colors ColorCommitType = lipgloss.AdaptiveColor{Light: "#CA8A04", Dark: "#FACC15"} // Yellow for type ColorCommitScope = lipgloss.AdaptiveColor{Light: "#C026D3", Dark: "#E879F9"} // Magenta for scope ColorCommitSubject = lipgloss.AdaptiveColor{Light: "#FFFFFF", Dark: "#FFFFFF"} // White for subject ColorCommitBody = lipgloss.AdaptiveColor{Light: "#16A34A", Dark: "#4ADE80"} // Green for body ColorCommitSOB = lipgloss.AdaptiveColor{Light: "#6B7280", Dark: "#9CA3AF"} // Gray for signed-off-by )
Adaptive colors for light and dark terminals.
var ( StyleSuccess = lipgloss.NewStyle().Foreground(ColorSuccess) StyleWarning = lipgloss.NewStyle().Foreground(ColorWarning) StyleError = lipgloss.NewStyle().Foreground(ColorError) StyleMuted = lipgloss.NewStyle().Foreground(ColorMuted) StylePrimary = lipgloss.NewStyle().Foreground(ColorPrimary) StyleTitle = lipgloss.NewStyle().Bold(true).Foreground(ColorPrimary).MarginBottom(1) StyleCommitType = lipgloss.NewStyle().Foreground(ColorPrimary).Bold(true) )
Reusable lipgloss styles.
Functions ¶
func FormatCommitMessage ¶
func FormatCommitMessage(msg CommitMessageContent, maxWidth int) string
FormatCommitMessage formats a commit message with colored parts. Header: yellow(type) + magenta(scope) + white(subject) Body: green Footer: blue SOB: gray maxWidth: maximum line width for wrapping (0 = no wrapping)
func GetContentWidth ¶
GetContentWidth calculates the appropriate content width for the given terminal width. If terminalWidth is 0, it auto-detects the terminal width. It returns the smaller of (terminalWidth - 4) or MaxContentWidth, with a minimum of 40.
func RenderResult ¶
RenderResult renders a Result with adaptive terminal width. The output automatically adjusts to terminal width (capped at MaxContentWidth), and preserves URLs and file paths on single lines without wrapping.
Types ¶
type CommitMessageContent ¶
CommitMessageContent holds the parts of a commit message for styled rendering.
type LuckyResult ¶
LuckyResult represents the result of a lucky commit operation.
func RunLuckyCommit ¶
RunLuckyCommit runs lucky_commit with an animated spinner. Returns the result of the operation.
type MultiTaskModel ¶
type MultiTaskModel struct {
// contains filtered or unexported fields
}
MultiTaskModel is a model for running multiple tasks sequentially with progress display.
func NewMultiTaskModel ¶
func NewMultiTaskModel(title string, tasks []Task) MultiTaskModel
NewMultiTaskModel creates a new multi-task model.
func (MultiTaskModel) HasError ¶
func (m MultiTaskModel) HasError() bool
HasError returns true if any task failed (non-warning).
type Result ¶
type Result struct {
Type ResultType
Title string
Content string // Pre-formatted content with ANSI colors
Note string // Optional note displayed at the bottom (e.g., quote)
}
Result represents a formatted message to display to the user.
type ResultType ¶
type ResultType int
ResultType indicates the severity level of a result message.
const ( ResultSuccess ResultType = iota ResultError ResultWarning )
Result type constants.
type SingleTaskModel ¶
type SingleTaskModel struct {
// contains filtered or unexported fields
}
SingleTaskModel is a model for running a single task with a spinner.
func NewSingleTaskModel ¶
func NewSingleTaskModel(message string, task Task) SingleTaskModel
NewSingleTaskModel creates a new single-task model.