styles

package
v0.74.3 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: MIT Imports: 3 Imported by: 0

README

styles Package

The styles package provides centralized color constants, adaptive color variables, border definitions, and pre-configured lipgloss styles for consistent terminal output across the codebase.

Overview

All colors use compat.AdaptiveColor to automatically choose between light and dark variants based on the terminal's background. The dark palette is inspired by the Dracula theme; the light palette uses darker, more saturated colors for good contrast on light backgrounds.

Public API

The styles package exports the following:

Category Exports
Adaptive colors ColorError, ColorWarning, ColorSuccess, ColorInfo, ColorPurple, ColorYellow, ColorComment, ColorForeground, ColorBackground, ColorBorder, ColorTableAltRow
Border styles RoundedBorder, NormalBorder, ThickBorder
Pre-configured lipgloss.Style Error, Warning, Success, Info, FilePath, LineNumber, Command, Progress, Prompt, Count, Verbose, Header, TableHeader, TableCell, TableTitle, TableBorder, ErrorBox, ServerName, ServerType, TreeEnumerator, TreeNode
Huh theme HuhThemehuh.ThemeFunc for Dracula-inspired interactive forms

Adaptive Color Variables

These variables provide compat.AdaptiveColor values that auto-select the correct shade at render time:

Variable Semantic use Light Dark
ColorError Error messages, critical issues #D73737 #FF5555
ColorWarning Warnings, cautionary information #E67E22 #FFB86C
ColorSuccess Success messages, confirmations #27AE60 #50FA7B
ColorInfo Informational messages #2980B9 #8BE9FD
ColorPurple File paths, commands, highlights #8E44AD #BD93F9
ColorYellow Progress, attention-grabbing content #B7950B #F1FA8C
ColorComment Secondary/muted information, line numbers #6C7A89 #6272A4
ColorForeground Primary text content #2C3E50 #F8F8F2
ColorBackground Highlighted backgrounds #ECF0F1 #282A36
ColorBorder Table borders and dividers #BDC3C7 #44475A
ColorTableAltRow Alternating table row backgrounds #F5F5F5 #1A1A1A

Border Definitions

Variable Style Usage
RoundedBorder ╭╮╰╯ rounded corners Tables, boxes, panels (primary)
NormalBorder Straight lines Left-side emphasis, subtle dividers
ThickBorder Thick lines Reserved for maximum visual emphasis

Pre-configured Styles

These lipgloss.Style values are ready to use directly:

Variable Color Usage
Error Red, bold Error messages
Warning Orange, bold Warning messages
Success Green, bold Success confirmations
Info Cyan, bold Informational messages
FilePath Purple, bold File paths
LineNumber Comment/muted Line numbers in diffs
ContextLine Foreground Context lines in diffs
Highlight Error bg, background fg (inverted) Highlighted error text
Location Warning/orange, bold Location references
Command Purple, bold CLI commands
Progress Yellow Progress indicators
Prompt Success/green, bold Interactive prompts
Count Info/cyan, bold Numeric counts
Verbose Comment/muted, italic Verbose/debug output
ListHeader Success/green, bold, underline List section headers
ListItem Foreground List items
TableHeader Comment/muted, bold Table column headers
TableCell Foreground Table cell content
TableTotal Success/green, bold Table total/summary rows
TableTitle Success/green, bold Table titles
TableBorder Border color Table border lines
ServerName Purple, bold MCP server names
ServerType Info/cyan MCP server type labels
ErrorBox Error color, rounded border Error message boxes
Header Success/green, bold, bottom margin Section headers
TreeEnumerator Border color Tree branch characters
TreeNode Foreground Tree node text

Usage Examples

import "github.com/github/gh-aw/pkg/styles"

// Use pre-configured styles
fmt.Println(styles.Error.Render("Something went wrong"))
fmt.Println(styles.Success.Render("Operation completed"))
fmt.Println(styles.Command.Render("gh aw compile"))

// Use adaptive colors for custom styles
customStyle := lipgloss.NewStyle().
    Foreground(styles.ColorInfo).
    Bold(true)
fmt.Println(customStyle.Render("Custom styled text"))

Huh Theme

The package also exports HuhTheme — a huh.ThemeFunc that applies the same Dracula-inspired color palette to interactive forms rendered with the huh library.

import "github.com/github/gh-aw/pkg/styles"

form := huh.NewForm(...).WithTheme(styles.HuhTheme)

Design Notes

  • Colors are defined with both light and dark hex constants (hexColor*Light, hexColor*Dark) so tests can assert exact color values without depending on the lipgloss type system.
  • The package uses charm.land/lipgloss/v2 and charm.land/lipgloss/v2/compat for adaptive color support.
  • For visual examples and detailed usage guidelines, see scratchpad/styles-guide.md.
  • All * styles export pre-configured lipgloss.Style values (not functions), so they can be used with method chaining: styles.Error.Copy().Underline(true).

This specification is automatically maintained by the spec-extractor workflow.

Documentation

Overview

Package styles provides no-op style definitions for Wasm builds. All styles return text unchanged (no ANSI codes).

Index

Constants

This section is empty.

Variables

View Source
var (
	ColorError       = WasmColor{}
	ColorWarning     = WasmColor{}
	ColorSuccess     = WasmColor{}
	ColorInfo        = WasmColor{}
	ColorPurple      = WasmColor{}
	ColorYellow      = WasmColor{}
	ColorComment     = WasmColor{}
	ColorForeground  = WasmColor{}
	ColorBackground  = WasmColor{}
	ColorBorder      = WasmColor{}
	ColorTableAltRow = WasmColor{}
)

Adaptive color variables (no-op in Wasm)

View Source
var (
	RoundedBorder = WasmBorder{}
	NormalBorder  = WasmBorder{}
	ThickBorder   = WasmBorder{}
)

Border definitions (no-op in Wasm)

View Source
var (
	Error          = WasmStyle{}
	Warning        = WasmStyle{}
	Success        = WasmStyle{}
	Info           = WasmStyle{}
	FilePath       = WasmStyle{}
	LineNumber     = WasmStyle{}
	ContextLine    = WasmStyle{}
	Highlight      = WasmStyle{}
	Location       = WasmStyle{}
	Command        = WasmStyle{}
	Progress       = WasmStyle{}
	Prompt         = WasmStyle{}
	Count          = WasmStyle{}
	Verbose        = WasmStyle{}
	ListHeader     = WasmStyle{}
	ListItem       = WasmStyle{}
	TableHeader    = WasmStyle{}
	TableCell      = WasmStyle{}
	TableTotal     = WasmStyle{}
	TableTitle     = WasmStyle{}
	TableBorder    = WasmStyle{}
	ServerName     = WasmStyle{}
	ServerType     = WasmStyle{}
	ErrorBox       = WasmStyle{}
	Header         = WasmStyle{}
	TreeEnumerator = WasmStyle{}
	TreeNode       = WasmStyle{}
)

Pre-configured styles (all no-op in Wasm)

Functions

This section is empty.

Types

type WasmBorder added in v0.45.4

type WasmBorder struct{}

WasmBorder is a no-op border placeholder.

type WasmColor added in v0.45.4

type WasmColor struct{}

WasmColor is a no-op color placeholder that implements color.Color.

func (WasmColor) RGBA added in v0.74.3

func (c WasmColor) RGBA() (r, g, b, a uint32)

RGBA implements color.Color. Returns transparent black (no-op in Wasm).

type WasmStyle added in v0.45.4

type WasmStyle struct{}

WasmStyle is a no-op style that returns text unchanged.

func (WasmStyle) Render added in v0.45.4

func (s WasmStyle) Render(text ...string) string

Render returns text unchanged.

Jump to

Keyboard shortcuts

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