theme

package
v0.27.2 Latest Latest
Warning

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

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

Documentation

Overview

Package theme provides GTK CSS styling for UI components.

Package theme provides GTK CSS styling for UI components.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Coalesce

func Coalesce(values ...string) string

Coalesce returns the first non-empty string.

func FontCSSVars

func FontCSSVars(fonts FontConfig) string

FontCSSVars generates CSS custom properties for fonts.

func GenerateCSS

func GenerateCSS(p Palette) string

GenerateCSS creates GTK4 CSS using the provided palette with default scale.

func GenerateCSSFull added in v0.22.0

func GenerateCSSFull(p Palette, scale float64, fonts FontConfig, modeColors ModeColors) string

GenerateCSSFull creates GTK4 CSS using all provided configuration. Scale affects font sizes and widget padding/margins proportionally.

func GenerateCSSWithScale

func GenerateCSSWithScale(p Palette, scale float64) string

GenerateCSSWithScale creates GTK4 CSS using the provided palette and UI scale factor. Scale affects font sizes and widget padding/margins proportionally.

func GenerateCSSWithScaleAndFonts

func GenerateCSSWithScaleAndFonts(p Palette, scale float64, fonts FontConfig) string

GenerateCSSWithScaleAndFonts creates GTK4 CSS using the provided palette, UI scale factor and fonts. Scale affects font sizes and widget padding/margins proportionally. Uses default mode colors.

func GenerateFindHighlightCSS

func GenerateFindHighlightCSS(p Palette) string

GenerateFindHighlightCSS builds CSS to style find-in-page matches using the accent color.

func HexToRGBA added in v0.20.1

func HexToRGBA(hex string) (r, g, b, a float32)

HexToRGBA converts a hex color string to RGBA float32 values (0.0-1.0). Supports #RGB, #RRGGBB, and #RRGGBBAA formats. Returns opaque black (0,0,0,1) if parsing fails.

func ValidateHexColor

func ValidateHexColor(color string) error

ValidateHexColor checks if a string is a valid hex color.

Types

type FontConfig

type FontConfig struct {
	SansFont      string
	MonospaceFont string
}

FontConfig holds font settings for CSS generation.

func DefaultFontConfig

func DefaultFontConfig() FontConfig

DefaultFontConfig returns safe font fallbacks.

type Manager

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

Manager handles theme state and CSS application.

func NewManager

func NewManager(ctx context.Context, cfg *config.Config, resolver port.ColorSchemeResolver) *Manager

NewManager creates a new theme manager from configuration. The ColorSchemeResolver is required for proper color scheme detection.

func (*Manager) ApplyToDisplay

func (m *Manager) ApplyToDisplay(ctx context.Context, display *gdk.Display)

ApplyToDisplay loads the theme CSS into the display.

func (*Manager) GetBackgroundRGBA added in v0.20.1

func (m *Manager) GetBackgroundRGBA() (r, g, b, a float32)

GetBackgroundRGBA returns the current theme's background color as RGBA float32 values. Used to set WebView background color to eliminate white flash during loading.

func (*Manager) GetCurrentPalette

func (m *Manager) GetCurrentPalette() Palette

GetCurrentPalette returns the active palette based on current scheme.

func (*Manager) GetDarkPalette

func (m *Manager) GetDarkPalette() Palette

GetDarkPalette returns the dark theme palette.

func (*Manager) GetLightPalette

func (m *Manager) GetLightPalette() Palette

GetLightPalette returns the light theme palette.

func (*Manager) GetModeColors added in v0.22.0

func (m *Manager) GetModeColors() ModeColors

GetModeColors returns the modal mode indicator colors.

func (*Manager) GetWebUIThemeCSS

func (m *Manager) GetWebUIThemeCSS() string

GetWebUIThemeCSS returns CSS text that defines both light and dark variables. WebUI uses `:root` for light and `.dark` overrides for dark.

func (*Manager) PrefersDark

func (m *Manager) PrefersDark() bool

PrefersDark returns true if dark mode is active.

func (*Manager) SetColorScheme

func (m *Manager) SetColorScheme(ctx context.Context, scheme string, display *gdk.Display)

SetColorScheme changes the active color scheme at runtime.

func (*Manager) UpdateFromConfig

func (m *Manager) UpdateFromConfig(ctx context.Context, cfg *config.Config, display *gdk.Display)

UpdateFromConfig updates the theme manager state from a new config.

type ModeColors added in v0.22.0

type ModeColors struct {
	PaneMode    string // Color for pane mode (default: #4A90E2 blue)
	TabMode     string // Color for tab mode (default: #FFA500 orange)
	SessionMode string // Color for session mode (default: #9B59B6 purple)
	ResizeMode  string // Color for resize mode (default: #00D4AA teal)
}

ModeColors holds colors for modal mode indicators (borders and toasters).

func DefaultModeColors added in v0.22.0

func DefaultModeColors() ModeColors

DefaultModeColors returns the default mode indicator colors.

func (ModeColors) ToCSSVars added in v0.22.0

func (m ModeColors) ToCSSVars() string

ToCSSVars generates CSS custom property declarations for mode colors.

type Palette

type Palette struct {
	Background     string // Main background color
	Surface        string // Elevated surfaces (cards, popups)
	SurfaceVariant string // Secondary surfaces
	Text           string // Primary text color
	Muted          string // Secondary/disabled text
	Accent         string // Primary accent color (actions, highlights)
	Border         string // Border and divider lines
	// Semantic status colors (not user-editable, derived defaults)
	Success     string // Success/positive feedback
	Warning     string // Warning/caution feedback
	Destructive string // Error/destructive actions
}

Palette holds semantic color tokens for theming.

func DefaultDarkPalette

func DefaultDarkPalette() Palette

DefaultDarkPalette returns the default dark theme palette.

func DefaultLightPalette

func DefaultLightPalette() Palette

DefaultLightPalette returns the default light theme palette.

func PaletteFromConfig

func PaletteFromConfig(cfg *config.ColorPalette, isDark bool) Palette

PaletteFromConfig creates a Palette from config values, filling missing values with defaults.

func (Palette) ToCSSVars

func (p Palette) ToCSSVars() string

ToCSSVars generates CSS custom property declarations for GTK.

func (Palette) ToWebCSSVars

func (p Palette) ToWebCSSVars() string

ToWebCSSVars generates CSS custom properties for web UI (Tailwind compatibility). Maps GTK palette names to Tailwind variable names used in the WebUI homepage.

func (Palette) Validate

func (p Palette) Validate() error

Validate checks all palette colors are valid hex values.

Jump to

Keyboard shortcuts

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