style

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Base colors (dark terminal themes)
	MidnightColor  = "#0D1B2A" // midnight
	NavyColor      = "#1B263B" // navy
	LanternColor   = "#F4D58D" // lantern
	ChameleonColor = "#3A7D44" // chameleon
	ForestColor    = "#1E5128" // forest
	SunsetColor    = "#D88A60" // sunset
	OffWhiteColor  = "#F8F9FA" // offwhite
	WarmGrayColor  = "#CED4DA" // warmgray
	ErrorBaseColor = "#2D1B1B" // error

	// Base colors (light terminal themes)
	LightLanternColor   = "#E6A645" // dark lantern
	LightWarmGrayColor  = "#8B949E" // dark warmgray
	LightOffWhiteColor  = "#F1F3F4" // dark offwhite
	LightErrorBaseColor = "#FDEAEA" // dark errorbg

	// Adaptive color definitions for light/dark themes
	// Error colors - using sunset for better contrast
	ErrorColor = compat.AdaptiveColor{
		Light: lipgloss.Color(SunsetColor),
		Dark:  lipgloss.Color(SunsetColor),
	}

	// Warning colors - using lantern for visibility
	WarningColor = compat.AdaptiveColor{
		Light: lipgloss.Color(LightLanternColor),
		Dark:  lipgloss.Color(LanternColor),
	}

	// Success colors - using chameleon/forest
	SuccessColor = compat.AdaptiveColor{
		Light: lipgloss.Color(ForestColor),
		Dark:  lipgloss.Color(ChameleonColor),
	}

	// Info colors - using navy for light, lantern for dark
	InfoColor = compat.AdaptiveColor{
		Light: lipgloss.Color(NavyColor),
		Dark:  lipgloss.Color(LanternColor),
	}

	// Muted/secondary text
	MutedColor = compat.AdaptiveColor{
		Light: lipgloss.Color(LightWarmGrayColor),
		Dark:  lipgloss.Color(WarmGrayColor),
	}

	// Accent/primary colors
	AccentColor = compat.AdaptiveColor{
		Light: lipgloss.Color(ChameleonColor),
		Dark:  lipgloss.Color(LanternColor),
	}

	// Code/monospace text
	CodeColor = compat.AdaptiveColor{
		Light: lipgloss.Color(MidnightColor),
		Dark:  lipgloss.Color(MidnightColor),
	}

	// Primary text color
	PrimaryTextColor = compat.AdaptiveColor{
		Light: lipgloss.Color(MidnightColor),
		Dark:  lipgloss.Color(OffWhiteColor),
	}

	// Background colors
	PrimaryBgColor = compat.AdaptiveColor{
		Light: lipgloss.Color(OffWhiteColor),
		Dark:  lipgloss.Color(MidnightColor),
	}

	SecondaryBgColor = compat.AdaptiveColor{
		Light: lipgloss.Color(LightOffWhiteColor),
		Dark:  lipgloss.Color(NavyColor),
	}

	// Error background for highlighting
	ErrorBgColor = compat.AdaptiveColor{
		Light: lipgloss.Color(LightErrorBaseColor),
		Dark:  lipgloss.Color(ErrorBaseColor),
	}
)

Color palette - standardized across the application

View Source
var (
	// Base styles using adaptive colors
	ErrorStyle   = lipgloss.NewStyle().Foreground(ErrorColor).Bold(true)
	WarningStyle = lipgloss.NewStyle().Foreground(WarningColor).Bold(true)
	SuccessStyle = lipgloss.NewStyle().Foreground(SuccessColor).Bold(true)
	InfoStyle    = lipgloss.NewStyle().Foreground(InfoColor).Bold(true)
	MutedStyle   = lipgloss.NewStyle().Foreground(MutedColor)
	AccentStyle  = lipgloss.NewStyle().Foreground(AccentColor)

	// Component styles
	FileStyle = lipgloss.NewStyle().
				Foreground(AccentColor).
				Bold(true).
				Underline(true)

	PositionStyle = lipgloss.NewStyle().
					Foreground(MutedColor).
					Italic(true)

	TitleStyle = lipgloss.NewStyle().
				Bold(true).
				Foreground(PrimaryTextColor)

	MessageStyle = lipgloss.NewStyle().
					Foreground(PrimaryTextColor)

	CodeStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color(OffWhiteColor)).
				Background(CodeColor).
				Padding(1, 1)

	LineNumberStyle = lipgloss.NewStyle().
					Foreground(MutedColor).
					Width(5).
					Align(lipgloss.Right)

	ErrorLineStyle = lipgloss.NewStyle().
					Background(ErrorBgColor)

	HighlightStyle = lipgloss.NewStyle().
					Foreground(ErrorColor).
					Bold(true)

	SuggestionTitleStyle = lipgloss.NewStyle().
							Foreground(SuccessColor).
							Bold(true)

	SuggestionStyle = lipgloss.NewStyle().
					Foreground(MutedColor)

	DocsLinkStyle = lipgloss.NewStyle().
					Foreground(InfoColor).
					Underline(true)

	// Box styles with adaptive borders
	ErrorBoxStyle = lipgloss.NewStyle().
					Border(lipgloss.RoundedBorder()).
					BorderForeground(ErrorColor).
					Padding(1, 2).
					Margin(1, 0)

	WarningBoxStyle = lipgloss.NewStyle().
					Border(lipgloss.RoundedBorder()).
					BorderForeground(WarningColor).
					Padding(1, 2).
					Margin(1, 0)

	InfoBoxStyle = lipgloss.NewStyle().
					Border(lipgloss.RoundedBorder()).
					BorderForeground(InfoColor).
					Padding(1, 2).
					Margin(1, 0)

	ContextBoxStyle = lipgloss.NewStyle().
					Border(lipgloss.Border{
			Top:         "─",
			Bottom:      "─",
			Left:        "│",
			Right:       "│",
			TopLeft:     "╭",
			TopRight:    "╮",
			BottomLeft:  "╰",
			BottomRight: "╯",
		}).
		BorderForeground(MutedColor).
		Padding(0, 1).
		Margin(0, 2)
)
View Source
var (
	StepRunningStyle = lipgloss.NewStyle().
						Foreground(InfoColor)

	StepCompletedStyle = lipgloss.NewStyle().
						Foreground(SuccessColor).
						Bold(true)

	StepFailedStyle = lipgloss.NewStyle().
					Foreground(ErrorColor).
					Bold(true)

	StepNameStyle = lipgloss.NewStyle().
					Foreground(PrimaryTextColor)

	DurationStyle = lipgloss.NewStyle().
					Foreground(MutedColor).
					Italic(true)
)

Progress styles for run command

Functions

func Error

func Error(w io.Writer, message string)

Error prints an error message with styling

func ErrorIcon

func ErrorIcon() string

func FormatFilePath

func FormatFilePath(path string) string

formatFilePath formats a file path with proper styling

func FormatPosition

func FormatPosition(line int) string

formatPosition formats a position (line:column) with proper styling

func GetSeverityIcon

func GetSeverityIcon(severity string) string

getSeverityIcon returns the appropriate icon for the severity level

func GetSeverityStyle

func GetSeverityStyle(severity string) lipgloss.Style

getSeverityStyle returns the appropriate style for the severity level

func Info

func Info(w io.Writer, message string)

Info prints an info message with styling

func InfoIcon

func InfoIcon() string

func PrintJSON

func PrintJSON(w io.Writer, data interface{})

printJSON outputs data as formatted JSON

func PrintYAML

func PrintYAML(w io.Writer, data interface{})

printYAML outputs data as YAML

func RenderCodeLine

func RenderCodeLine(lineNum int, content string, isError bool) string

renderCodeLine renders a line of code with optional highlighting

func RenderHighlightIndicator

func RenderHighlightIndicator(startCol, length int) string

renderHighlightIndicator renders the caret indicators below an error line

func RenderSuggestion

func RenderSuggestion(title, description string, examples []string, docsURL string) string

renderSuggestion renders a suggestion with proper styling

func Success

func Success(w io.Writer, message string)

Success prints a success message with styling

func SuccessIcon

func SuccessIcon() string

func SuccessString

func SuccessString(message string) string

Success prints a success message with styling

func Warning

func Warning(w io.Writer, message string)

Warning prints a warning message with styling

func WarningIcon

func WarningIcon() string

Types

type Spinner

type Spinner interface {
	SetSuffix(suffix string)
	SetFinalMSG(finalMSG string)
	Start()
	Stop()
}

type SpinnerManager

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

func NewSpinnerManager

func NewSpinnerManager(w io.Writer) *SpinnerManager

func (*SpinnerManager) Start

func (s *SpinnerManager) Start() Spinner

type TerminalSpinner

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

func NewTerminalSpinner

func NewTerminalSpinner(cs []string, d time.Duration, options ...spinner.Option) *TerminalSpinner

func (*TerminalSpinner) SetFinalMSG

func (s *TerminalSpinner) SetFinalMSG(finalMSG string)

func (*TerminalSpinner) SetSuffix

func (s *TerminalSpinner) SetSuffix(suffix string)

func (*TerminalSpinner) Start

func (s *TerminalSpinner) Start()

func (*TerminalSpinner) Stop

func (s *TerminalSpinner) Stop()

type TestOption

type TestOption func(*TestSpinner)

type TestSpinner

type TestSpinner struct {
	ID string

	Delay time.Duration

	Prefix   string
	Suffix   string
	FinalMSG string

	Writer io.Writer

	HideCursor bool // kept for interface compatibility but ignored
	PreUpdate  func(s *TestSpinner)
	PostUpdate func(s *TestSpinner)
	// contains filtered or unexported fields
}

TestSpinner is a spinner implementation for testing that outputs each spinner update on a new line instead of clearing and redrawing

func NewTestSpinner

func NewTestSpinner(cs []string, d time.Duration, options ...TestOption) *TestSpinner

New provides a pointer to an instance of TestSpinner with the supplied options.

func (*TestSpinner) Color

func (s *TestSpinner) Color(colors ...string) error

Color will set the struct field for the given color to be used.

func (*TestSpinner) Lock

func (s *TestSpinner) Lock()

Lock allows for manual control to lock the spinner.

func (*TestSpinner) SetFinalMSG

func (s *TestSpinner) SetFinalMSG(finalMSG string)

func (*TestSpinner) SetSuffix

func (s *TestSpinner) SetSuffix(suffix string)

func (*TestSpinner) Start

func (s *TestSpinner) Start()

Start will start the indicator.

func (*TestSpinner) Stop

func (s *TestSpinner) Stop()

Stop stops the indicator.

func (*TestSpinner) Unlock

func (s *TestSpinner) Unlock()

Unlock allows for manual control to unlock the spinner.

func (*TestSpinner) UpdateCharSet

func (s *TestSpinner) UpdateCharSet(cs []string)

UpdateCharSet will change the current character set to the given one.

func (*TestSpinner) UpdateSpeed

func (s *TestSpinner) UpdateSpeed(d time.Duration)

UpdateSpeed will set the indicator delay to the given value.

Jump to

Keyboard shortcuts

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