theme

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultName = "kong"

DefaultName is the built-in theme used when no override is provided.

Variables

This section is empty.

Functions

func Available

func Available() []string

Available returns the list of registered theme IDs (sorted).

func AvailableDisplayNames

func AvailableDisplayNames() map[string]string

AvailableDisplayNames returns a map of theme IDs to display names.

func ContextWithPalette

func ContextWithPalette(ctx context.Context, p Palette) context.Context

ContextWithPalette stores the palette on the context.

func CurrentName

func CurrentName() string

CurrentName returns the ID of the active palette.

func Exists

func Exists(name string) bool

Exists returns true when a theme is registered.

func SetCurrent

func SetCurrent(name string) error

SetCurrent sets the active palette.

Types

type Color

type Color struct {
	Light string
	Dark  string
}

Color stores light and dark variants for adaptive rendering.

func (Color) Adaptive

func (c Color) Adaptive() lipgloss.AdaptiveColor

Adaptive converts the color into a lipgloss adaptive color.

type Flag

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

Flag is a pflag.Value implementation for theme IDs.

func NewFlag

func NewFlag(defaultValue string) *Flag

NewFlag returns a Flag with the provided default value.

func (*Flag) Set

func (f *Flag) Set(v string) error

Set implements pflag.Value.

func (*Flag) String

func (f *Flag) String() string

String implements pflag.Value.

func (*Flag) Type

func (f *Flag) Type() string

Type implements pflag.Value.

func (*Flag) Value

func (f *Flag) Value() string

Value returns the currently selected theme ID.

type Palette

type Palette struct {
	Name        string
	DisplayName string
	About       string
	Colors      map[Token]Color
}

Palette represents a concrete theme.

func Current

func Current() Palette

Current returns the active palette.

func FromContext

func FromContext(ctx context.Context) Palette

FromContext returns the palette stored on the context or the current palette.

func Get

func Get(name string) (Palette, bool)

Get returns the palette with the provided name.

func (Palette) Adaptive

func (p Palette) Adaptive(token Token) lipgloss.AdaptiveColor

Adaptive returns the lipgloss adaptive color for the provided token.

func (Palette) BackgroundStyle

func (p Palette) BackgroundStyle(token Token) lipgloss.Style

BackgroundStyle returns a lipgloss style with the background set to the requested token.

func (Palette) Color

func (p Palette) Color(token Token) Color

Color returns a color for the provided token, falling back to the default palette.

func (Palette) ForegroundStyle

func (p Palette) ForegroundStyle(token Token) lipgloss.Style

ForegroundStyle returns a lipgloss style with the foreground set to the requested token.

type Token

type Token string

Token represents a semantic color slot within the CLI.

const (
	ColorTextPrimary   Token = "text.primary"
	ColorTextSecondary Token = "text.secondary"
	ColorTextMuted     Token = "text.muted"
	ColorBorder        Token = "border"
	ColorSurface       Token = "surface"
	ColorSurfaceText   Token = "surface.text"
	ColorPrimary       Token = "primary"
	ColorPrimaryText   Token = "primary.text"
	ColorAccent        Token = "accent"
	ColorAccentText    Token = "accent.text"
	ColorSuccess       Token = "success"
	ColorSuccessText   Token = "success.text"
	ColorInfo          Token = "info"
	ColorInfoText      Token = "info.text"
	ColorWarning       Token = "warning"
	ColorWarningText   Token = "warning.text"
	ColorDanger        Token = "danger"
	ColorDangerText    Token = "danger.text"
	ColorHighlight     Token = "highlight"
)

Jump to

Keyboard shortcuts

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