components

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	TrueColorCols    = 60
	TrueColorRows    = 16
	GrayscaleCols    = 60
	DefaultWidth     = TrueColorCols * 2 // 120 chars (largest mode)
	DefaultHeight    = TrueColorRows + 2 // 18 lines (title + spacing + 16 rows)
	MinPaletteWidth  = 20                // 10 columns × 2 chars
	MinPaletteHeight = 6
)
View Source
const (
	MinSliderWidth     = 10 // Minimum bar width
	DefaultSliderWidth = 28 // Default bar width
	MaxSliderWidth     = 32 // Maximum bar width
)

Variables

This section is empty.

Functions

func ValidateHex

func ValidateHex(s string) (string, bool)

ValidateHex validates and normalizes a hex color string

func ValidateRGBValue

func ValidateRGBValue(s string) (uint8, bool)

ValidateRGBValue validates an RGB component value (0-255)

Types

type ColorInput

type ColorInput struct {
	Type  InputType
	Label string

	Focused bool
	// contains filtered or unexported fields
}

ColorInput represents a color value input field

func NewColorInput

func NewColorInput(inputType InputType, label string, width int) *ColorInput

NewColorInput creates a new color input

func (*ColorInput) Blur

func (c *ColorInput) Blur()

Blur removes focus from the input

func (*ColorInput) Focus

func (c *ColorInput) Focus() tea.Cmd

Focus focuses the input

func (*ColorInput) SetValue

func (c *ColorInput) SetValue(value string)

SetValue sets the input value

func (*ColorInput) Update

func (c *ColorInput) Update(msg tea.Msg) (*ColorInput, tea.Cmd)

Update handles input messages

func (*ColorInput) Value

func (c *ColorInput) Value() string

Value returns the current value

func (*ColorInput) View

func (c *ColorInput) View() string

View renders the input

type InputType

type InputType int

InputType represents the type of color input

const (
	InputTypeHex InputType = iota
	InputTypeR
	InputTypeG
	InputTypeB
)

type Palette

type Palette struct {
	TrueColors  []colorful.Color
	Colors256   []colorful.Color
	BasicColors []colorful.Color
	Grayscale   []colorful.Color
	Solarized   []colorful.Color
	Dracula     []colorful.Color
	Nord        []colorful.Color
	Gruvbox     []colorful.Color
	Monokai     []colorful.Color
	Catppuccin  []colorful.Color
	TokyoNight  []colorful.Color
	Tailwind    []colorful.Color
	Material    []colorful.Color
	History     []colorful.Color
	Cursor      int
	Columns     int
	Focused     bool
	Mode        PaletteMode
	// contains filtered or unexported fields
}

Palette represents the color palette component

func NewPalette

func NewPalette() *Palette

NewPalette creates a new palette with auto-detected color support

func (*Palette) CurrentColor

func (p *Palette) CurrentColor() colorful.Color

CurrentColor returns the selected color

func (*Palette) GetSize

func (p *Palette) GetSize() (int, int)

GetSize returns current width and height

func (*Palette) Height

func (p *Palette) Height() int

Height returns the fixed palette height in lines (including title)

func (*Palette) SetHistory

func (p *Palette) SetHistory(hexColors []string)

SetHistory updates history colors

func (*Palette) SetSize

func (p *Palette) SetSize(width, height int)

SetSize updates the palette display size

func (*Palette) Update

func (p *Palette) Update(msg tea.Msg) (colorful.Color, bool)

Update handles input

func (*Palette) View

func (p *Palette) View() string

View renders the palette

func (*Palette) Width

func (p *Palette) Width() int

Width returns the fixed palette width in characters

type PaletteMode

type PaletteMode int

PaletteMode represents display mode

const (
	PaletteModeTrueColor  PaletteMode = iota // True color gradient
	PaletteMode256                           // 256 terminal colors
	PaletteModeBasic                         // 16 ANSI colors
	PaletteModeGrayscale                     // Grayscale
	PaletteModeSolarized                     // Solarized
	PaletteModeDracula                       // Dracula
	PaletteModeNord                          // Nord
	PaletteModeGruvbox                       // Gruvbox
	PaletteModeMonokai                       // Monokai
	PaletteModeCatppuccin                    // Catppuccin
	PaletteModeTokyoNight                    // Tokyo Night
	PaletteModeTailwind                      // Tailwind CSS
	PaletteModeMaterial                      // Material Design
	PaletteModeHistory                       // History (last)
)

type Preview

type Preview struct {
	Color  colorful.Color
	Width  int
	Height int
}

Preview represents the color preview component

func NewPreview

func NewPreview() *Preview

NewPreview creates a new preview

func (*Preview) SetColor

func (p *Preview) SetColor(c colorful.Color)

SetColor updates the preview color

func (*Preview) View

func (p *Preview) View() string

View renders the preview

type Slider

type Slider struct {
	Label   string
	Min     float64
	Max     float64
	Value   float64
	Width   int
	Focused bool
	Suffix  string
}

Slider represents an HSL slider component

func NewSlider

func NewSlider(label string, min, max, value float64, suffix string) *Slider

NewSlider creates a new slider

func (*Slider) Adjust

func (s *Slider) Adjust(delta float64)

Adjust adjusts slider value by delta

func (*Slider) SetValue

func (s *Slider) SetValue(v float64)

SetValue sets slider value with clamping

func (*Slider) Update

func (s *Slider) Update(msg tea.KeyMsg) bool

Update handles keyboard input

func (*Slider) View

func (s *Slider) View() string

View renders the slider

Jump to

Keyboard shortcuts

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