theme

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package theme owns the application color palette and the bridge from user config (a Theme struct deserialized from config.json) into the mutable lipgloss colors used by package ui. The visualizers package still has hardcoded colors today; migrating those to read from this palette is a separate piece of work.

Lipgloss styles capture their colors by value at construction time, so callers must construct/rebuild any styles that reference these vars AFTER Apply has run. The ui.RebuildStyles function in package ui takes care of that for the main UI palette.

Default returns the current palette as a Theme so first-time setup can write every overridable role to config.json. Validate checks every non-empty hex value before Apply, naming each offending path so users can fix typos without grepping the source.

Index

Constants

This section is empty.

Variables

View Source
var (
	Primary       = lipgloss.AdaptiveColor{Light: "#874BFD", Dark: "#58f796"}
	Secondary     = lipgloss.AdaptiveColor{Light: "#6232CC", Dark: "#b48eff"}
	Muted         = lipgloss.AdaptiveColor{Light: "#9B9B9B", Dark: "#626262"}
	Subtle        = lipgloss.AdaptiveColor{Light: "#6C6C6C", Dark: "#8a8a8a"}
	Dim           = lipgloss.AdaptiveColor{Light: "#BCBCBC", Dark: "#444444"}
	Error         = lipgloss.AdaptiveColor{Light: "#FF0000", Dark: "#ff0087"}
	Text          = lipgloss.AdaptiveColor{Light: "#1a1a1a", Dark: "#dddddd"}
	TextDim       = lipgloss.AdaptiveColor{Light: "#A49FA5", Dark: "#777777"}
	Tip           = lipgloss.AdaptiveColor{Light: "#D4A017", Dark: "#FFD866"}
	OnPrimary     = lipgloss.AdaptiveColor{Light: "#000000", Dark: "#000000"}
	GradientStart = lipgloss.AdaptiveColor{Light: "#e4d4f7", Dark: "#110a24"}
	GradientEnd   = lipgloss.AdaptiveColor{Light: "#f8f5fc", Dark: "#040208"}
)

Palette — exported, mutable. Reassigned by Apply at startup.

Functions

func Apply

func Apply(t Theme)

Apply reassigns palette package vars from t. Empty hex strings preserve the existing value, so users can override one role (or one mode of a role) without touching the others.

func Validate

func Validate(t Theme) error

Validate checks that every non-empty hex value in t is well-formed. On failure the error names every offending path (e.g. "theme.primary.light") and the offending value, so the user can spot fixes without searching.

Types

type Theme

type Theme struct {
	Primary       Variant `json:"primary,omitzero"`
	Secondary     Variant `json:"secondary,omitzero"`
	Muted         Variant `json:"muted,omitzero"`
	Subtle        Variant `json:"subtle,omitzero"`
	Dim           Variant `json:"dim,omitzero"`
	Error         Variant `json:"error,omitzero"`
	Text          Variant `json:"text,omitzero"`
	TextDim       Variant `json:"text_dim,omitzero"`
	Tip           Variant `json:"tip,omitzero"`
	OnPrimary     Variant `json:"on_primary,omitzero"`
	GradientStart Variant `json:"gradient_start,omitzero"`
	GradientEnd   Variant `json:"gradient_end,omitzero"`
}

Theme is the user-overridable palette. Zero-valued entries preserve package defaults. omitzero (Go 1.24+) is used on the outer struct fields because omitempty is a no-op on struct values — it would emit the role even when fully empty.

func Default

func Default() Theme

Default returns a Theme populated with the current palette defaults. Used by the first-time setup flow so a freshly written config.json shows the user every overridable role with its current value.

type Variant

type Variant struct {
	Light string `json:"light,omitempty"`
	Dark  string `json:"dark,omitempty"`
}

Variant is a {light, dark} hex pair for one palette role. Empty string fields preserve the existing palette default at Apply time, so users can override one mode without clobbering the other.

Jump to

Keyboard shortcuts

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