theme

package
v0.32.1 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package theme is the single source of truth for the Jentic CLI's colour scheme. The palette is the company brand from the frontend theme (github.com/jentic/jentic-frontend-theme, ui/src/index.css accent tokens), so the CLI matches the web app. Every surface — help screen, install wizard, and command output — styles through this package.

Index

Constants

View Source
const (
	SelectOn  = "◉"
	SelectOff = "○"
)

Selection glyphs (radio style): a filled ring marks the active/selected item, a hollow ring the inactive ones. Shared by the wizard hub menu and the huh form selects so selection looks identical everywhere.

Variables

View Source
var (
	Brand  = lipgloss.Color("#A3CACC") // primary teal
	Orange = lipgloss.Color("#FDBD79")
	Yellow = lipgloss.Color("#F1E38B")
	Green  = lipgloss.Color("#5EDEB9") // mint
	Pink   = lipgloss.Color("#EDADAF")
	Blue   = lipgloss.Color("#68BAEC")
	Red    = lipgloss.Color("#DB3B0F")
	Muted  = lipgloss.Color("#689296") // primary-500 grey-teal
	White  = lipgloss.Color("#FFFFFF")
)

Brand palette — hex values lifted straight from the company theme.

View Source
var (
	Heading = Themes["dark"].Styles().Heading
	Step    = Themes["dark"].Styles().Step
	Command = Themes["dark"].Styles().Command
	Dim     = Themes["dark"].Styles().Dim
	Success = Themes["dark"].Styles().Success
	Warn    = Themes["dark"].Styles().Warn
	Error   = Themes["dark"].Styles().Error
	Info    = Themes["dark"].Styles().Info
	Accent  = Themes["dark"].Styles().Accent
)

Shared styles. These are the RETIRED fixed-brand roles: they now DELEGATE to the dark palette's Styles() so dark output stays byte-identical while the migrated surfaces read palette-bound roles via StylesFromContext instead. Un-migrated call sites keep compiling against these package-level vars, which are pinned to dark. New code should prefer theme.StylesFromContext(ctx).

View Source
var Themes = map[string]Palette{
	"dark": {
		Primary:   Brand,
		Secondary: Blue,
		Error:     Red,
		Success:   Green,
		Warning:   Orange,
		Muted:     Muted,
		Command:   Green,
		Accent:    Yellow,
		Step:      Yellow,
	},
	"light": {
		Primary:   lipgloss.Color("#4B0082"),
		Secondary: lipgloss.Color("#00696A"),
		Error:     lipgloss.Color("#B22222"),
		Success:   lipgloss.Color("#1B7A1B"),
		Warning:   lipgloss.Color("#946A00"),
		Muted:     lipgloss.Color("#6B6B6B"),
		Command:   lipgloss.Color("#1B7A1B"),
		Accent:    lipgloss.Color("#8A5A00"),
		Step:      lipgloss.Color("#8A5A00"),
	},
	"no-color": {
		Primary:   lipgloss.NoColor{},
		Secondary: lipgloss.NoColor{},
		Error:     lipgloss.NoColor{},
		Success:   lipgloss.NoColor{},
		Warning:   lipgloss.NoColor{},
		Muted:     lipgloss.NoColor{},
		Command:   lipgloss.NoColor{},
		Accent:    lipgloss.NoColor{},
		Step:      lipgloss.NoColor{},
	},
}

Themes is the registry of built-in palettes, keyed by the names persisted in config (Context/Config theme) and accepted by --theme / JENTIC_THEME. The three keys are the closed set (14 BC-9): "dark", "light", "no-color". ResolveTheme falls back to "dark" for any unknown name.

The "dark"/"light" accents intentionally reuse the brand tokens (theme.go) so the runtime UI matches the banner; "no-color" zeroes every slot with lipgloss.NoColor{} so machine consumers never see an ANSI escape.

Functions

func Dimf

func Dimf(format string, a ...any) string

Dimf renders a printf-formatted string in the dim style (dark alias).

func Field

func Field(label, value string) string

Field renders an aligned "label: value" pair with a muted label and a brand-coloured value, for the key/value listings commands print (dark alias).

func Headingf

func Headingf(format string, a ...any) string

Headingf renders a printf-formatted string in the heading style (dark alias).

func Infof

func Infof(format string, a ...any) string

Infof renders a printf-formatted string in the info style (dark alias).

func Logo() string

Logo renders the gradient "jentic" wordmark. Used by the help screen and the install wizard so the brand mark is consistent everywhere (dark alias).

func LogoFor added in v0.32.0

func LogoFor(name string) string

LogoFor renders the gradient "jentic" wordmark tinted for the named theme. dark reproduces the historical fixed gradient byte-for-byte; light/no-color re-tint. Unknown names fall back to dark.

func LogoForContext added in v0.32.0

func LogoForContext(ctx context.Context) string

LogoForContext renders the logo tinted for the theme resolved into ctx.

func LogoHeader

func LogoHeader(totalWidth int, rightLines []string) string

LogoHeader renders the gradient wordmark with an optional block of status lines (e.g. version info) pinned to the top-right within totalWidth. When the terminal is too narrow to fit both (or rightLines is empty / width unknown), it falls back to just the logo. The returned string ends in a single newline (dark alias).

func LogoHeaderFor added in v0.32.0

func LogoHeaderFor(name string, totalWidth int, rightLines []string) string

LogoHeaderFor is LogoHeader tinted for the named theme (palette-aware).

func LogoHeaderForContext added in v0.32.0

func LogoHeaderForContext(ctx context.Context, totalWidth int, rightLines []string) string

LogoHeaderForContext is LogoHeaderFor tinted for the theme resolved into ctx.

func Successf

func Successf(format string, a ...any) string

Successf renders a printf-formatted string in the success style (dark alias).

func ThemeNameFromContext added in v0.32.0

func ThemeNameFromContext(ctx context.Context) string

ThemeNameFromContext returns the resolved theme name carried in ctx, or "dark" when absent (or when ctx is nil) — the name surfaces (e.g. the logo gradient) use to tint.

func VersionPanel

func VersionPanel(cliVersion, serverVersion string, serverRunning bool) []string

VersionPanel formats the CLI and server versions as a single left-to-right status line for LogoHeader to pin flush against the right edge. The server segment shows the reported version when running, "running" if it is up but reports no version, or a dim "offline" when it is not reachable.

func VersionPanelFor added in v0.32.0

func VersionPanelFor(s Styles, cliVersion, serverVersion string, serverRunning bool) []string

VersionPanelFor is VersionPanel tinted from the resolved Styles (palette-aware). It formats the CLI and server versions as a single left-to-right status line for LogoHeader to pin flush against the right edge. The server segment shows the reported version when running, "running" if it is up but reports no version, or a dim "offline" when it is not reachable.

func Warnf

func Warnf(format string, a ...any) string

Warnf renders a printf-formatted string in the warning style (dark alias).

func WithContext added in v0.32.0

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

WithContext stores the resolved Palette in the context for UI helpers that hold a context.Context but not the Audience.

func WithThemeName added in v0.32.0

func WithThemeName(ctx context.Context, name string) context.Context

WithThemeName stores the resolved theme name (for logo-gradient lookup) in ctx.

Types

type Palette added in v0.32.0

type Palette struct {
	Primary   lipgloss.TerminalColor
	Secondary lipgloss.TerminalColor
	Error     lipgloss.TerminalColor
	Success   lipgloss.TerminalColor
	Warning   lipgloss.TerminalColor
	Muted     lipgloss.TerminalColor

	// Command / Accent / Step are additional runtime slots the CLI's semantic
	// roles need but that don't collapse cleanly onto the six above (e.g. Command
	// is green and Success is also green+bold, but Step is yellow+bold and Accent
	// is plain yellow — distinct from Warning's orange). They are carried on the
	// Palette so `theme light` can re-tint them too; the dark values equal the
	// historical fixed brand tokens so dark output is unchanged.
	Command lipgloss.TerminalColor
	Accent  lipgloss.TerminalColor
	Step    lipgloss.TerminalColor
}

Palette is the semantic colour set the Audience layer (impl/3.1) styles UI accents from. It is deliberately SEPARATE from the brand palette/styles in theme.go: those are fixed company-brand tokens for the banner and installer wizard, whereas a Palette is mode/preference-resolved at runtime (dark, light, or no-color) and threads through HumanUX.

Fields are lipgloss.TerminalColor (the interface), NOT the concrete lipgloss.Color: the no-color palette assigns lipgloss.NoColor{} — a different concrete type — which does not fit a lipgloss.Color-typed field. TerminalColor is the interface both satisfy and what every lipgloss Style setter accepts.

func FromContext added in v0.32.0

func FromContext(ctx context.Context) Palette

FromContext returns the Palette carried in ctx, or the dark default if absent (or if ctx is nil — cobra hands a nil context to a command that never had one set, e.g. in unit tests that invoke a renderer directly).

func ResolveTheme added in v0.32.0

func ResolveTheme(flagOverride, configTheme string) Palette

ResolveTheme applies the HUMAN-mode precedence ladder and returns the resolved Palette. The Stage-0 Mode gate (agent/service-account -> no-color) is applied by the root interceptor (impl/3.2 §2) BEFORE this function and overrides everything here; this function only owns the human-mode ladder (impl/1.4 §3):

--theme  >  NO_COLOR / non-TTY stdout  >  JENTIC_THEME  >  config theme  >  dark

flagOverride is the --theme value (may be ""); configTheme is ActiveState.ThemeName (the persisted config `theme`).

func ResolveThemeWithName added in v0.32.0

func ResolveThemeWithName(flagOverride, configTheme string) (Palette, string)

ResolveThemeWithName is ResolveTheme that also returns the resolved theme NAME ("dark"/"light"/"no-color"). The name is needed for surfaces whose tint isn't a single palette slot — notably the logo's 6-row gradient — so they can look up a per-theme gradient. The precedence ladder is identical to ResolveTheme; an explicit --theme still wins over the auto no-color rungs.

func (Palette) Styles added in v0.32.0

func (p Palette) Styles() Styles

Styles builds the role style set from p's slots. The bold/plain choices mirror the historical fixed styles in theme.go exactly so dark output is unchanged.

type Styles added in v0.32.0

type Styles struct {
	Heading lipgloss.Style // section titles                (Primary, bold)
	Step    lipgloss.Style // numbered/step emphasis         (Step, bold)
	Command lipgloss.Style // copy-pasteable command text    (Command)
	Dim     lipgloss.Style // de-emphasised / helper text    (Muted)
	Success lipgloss.Style // success confirmations          (Success, bold)
	Warn    lipgloss.Style // warnings                       (Warning)
	Error   lipgloss.Style // errors                         (Error, bold)
	Info    lipgloss.Style // informational accents          (Secondary)
	Accent  lipgloss.Style // subtle highlight               (Accent)
	// contains filtered or unexported fields
}

Styles is the palette-bound set of semantic role styles every CLI surface renders through. It is the single seam that turns a runtime-resolved Palette into the lipgloss.Style roles that used to be fixed package-level vars in theme.go — so `--theme light`/`no-color` actually re-tint help, search, doctor, status, the wizard, and the logo instead of always emitting the dark-brand hex. Build one with Palette.Styles() (or StylesFromContext) at the top of a command and read st.Heading/st.Command/… instead of theme.Heading/….

The role→slot mapping is fixed here so every surface agrees; the dark palette (registry.go) carries slot values equal to the historical fixed tokens, so a dark Styles() reproduces the previous output byte-for-byte (guarded by a golden test).

func StylesFromContext added in v0.32.0

func StylesFromContext(ctx context.Context) Styles

StylesFromContext resolves the role style set from the Palette carried in ctx (dark default when absent). This is the primary accessor for command bodies that hold a context.Context.

func (Styles) Dimf added in v0.32.0

func (s Styles) Dimf(format string, a ...any) string

Dimf renders a printf-formatted string in the Dim role style.

func (Styles) DotDown added in v0.32.0

func (s Styles) DotDown() string

DotDown is the palette-bound status glyph for an absent/offline item (hollow).

func (Styles) DotFail added in v0.32.0

func (s Styles) DotFail() string

DotFail is the palette-bound status glyph for a failed item.

func (Styles) DotOK added in v0.32.0

func (s Styles) DotOK() string

DotOK is the palette-bound status glyph for a present/healthy item (filled), mirroring the historical fixed cmdcore.DotOK but tinted from the resolved palette so light/no-color modes change it too.

func (Styles) DotWarn added in v0.32.0

func (s Styles) DotWarn() string

DotWarn is the palette-bound status glyph for a degraded/warning item.

func (Styles) Field added in v0.32.0

func (s Styles) Field(label, value string) string

Field renders an aligned "label: value" pair — a muted label and a bright value — matching the historical package-level Field helper, but tinted from the resolved palette.

func (Styles) Headingf added in v0.32.0

func (s Styles) Headingf(format string, a ...any) string

Headingf renders a printf-formatted string in the Heading role style.

func (Styles) Infof added in v0.32.0

func (s Styles) Infof(format string, a ...any) string

Infof renders a printf-formatted string in the Info role style.

func (Styles) Successf added in v0.32.0

func (s Styles) Successf(format string, a ...any) string

Successf renders a printf-formatted string in the Success role style — the palette-bound equivalent of the historical package-level theme.Successf.

func (Styles) Warnf added in v0.32.0

func (s Styles) Warnf(format string, a ...any) string

Warnf renders a printf-formatted string in the Warn role style.

Jump to

Keyboard shortcuts

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