Documentation
¶
Overview ¶
Package theme is the single source of truth for jcode's built-in color themes. The same Theme structs drive lipgloss colors in the terminal UI (internal/tui) and CSS custom properties in the web frontend.
Web consumption is via generated CSS: `go generate ./internal/theme/...` (see gen/) writes web/src/styles/tokens.generated.css with one html[data-theme="<name>"] block per theme, so the two renderers can never drift — the web tokens are a pure function of this file.
Index ¶
Constants ¶
const ( DefaultDark = "jcode-dark" DefaultLight = "jcode-light" )
Built-in defaults for each appearance. Used as the startup fallback when no theme is persisted, picked by terminal-background detection.
Variables ¶
This section is empty.
Functions ¶
func Default ¶
func Default(a Appearance) string
Default returns the built-in default theme name for the given appearance.
Types ¶
type Appearance ¶
type Appearance string
Appearance categorizes a theme as light or dark. It selects the markdown (glamour) style in the TUI and the meta theme-color / .dark class in web.
const ( Dark Appearance = "dark" Light Appearance = "light" )
type Theme ¶
type Theme struct {
Name string
DisplayName string
Appearance Appearance
// Brand / accent
Primary string // brand accent: assistant label, logo, focused chrome
OnPrimary string // text/icons on a Primary fill (prompt pill, focused button)
Accent string // secondary accent (cyan family): tool labels, spinner
BorderFocus string // focused/active border (defaults to Primary)
// Surfaces & text
Bg string // root application background
Surface string // elevated panel/card/dialog/sidebar background
MutedSurface string // muted/secondary surface (badges, disabled rows, bars)
SelectionBg string // selection / active-row highlight background
Text string // primary foreground text
TextDim string // secondary/dim text
TextMuted string // lowest-emphasis text: section titles, separators, args
Border string // default borders, dividers, rules
// Semantic foregrounds + subtle background washes
Success string
Warning string
Error string
Info string
SuccessBg string // green wash (also diff-added background)
WarningBg string
ErrorBg string // red wash (also diff-removed background)
InfoBg string
Destructive string // vivid destructive action (delete buttons)
// Special roles
PlanMode string // plan-mode indicator (soft purple)
Subagent string // subagent accent (purple)
RoleUser string // user turn accent
// Diff foregrounds (brighter than Success/Error)
DiffAddedFg string
DiffRemovedFg string
}
Theme is a complete semantic color palette. Every field is a #RRGGBB hex string. Tokens are semantic (their role), never positional, so a theme is just a different set of values for the same roles.
func All ¶
func All() []Theme
All returns the built-in themes in display order (darks first, then lights).
func Resolve ¶
Resolve returns the named theme, or the default dark theme if the name is empty or unknown. It always returns a valid theme.
func (Theme) CSSVariables ¶
CSSVariables returns the theme's web CSS custom properties in a stable order (so generated output is deterministic for drift checks). The variable names match those already consumed by the web app, plus a few new ones for tokens that had no prior web equivalent (--color-accent, --color-on-primary, --color-border-focus, --color-plan-mode, --color-subagent, --color-selection, --color-role-user, --color-text-muted, --color-diff-*).
func (Theme) GlamourStyle ¶
GlamourStyle returns the glamour standard-style name for markdown rendering.