Documentation
¶
Overview ¶
Package theme provides GTK CSS styling for UI components.
Package theme provides GTK CSS styling for UI components.
Index ¶
- func Coalesce(values ...string) string
- func FontCSSVars(fonts FontConfig) string
- func GenerateCSS(p Palette) string
- func GenerateCSSFull(p Palette, scale float64, fonts FontConfig, modeColors ModeColors) string
- func GenerateCSSWithScale(p Palette, scale float64) string
- func GenerateCSSWithScaleAndFonts(p Palette, scale float64, fonts FontConfig) string
- func GenerateFindHighlightCSS(p Palette) string
- func HexToRGBA(hex string) (r, g, b, a float32)
- func ValidateHexColor(color string) error
- type FontConfig
- type Manager
- func (m *Manager) ApplyToDisplay(ctx context.Context, display *gdk.Display)
- func (m *Manager) GetBackgroundRGBA() (r, g, b, a float32)
- func (m *Manager) GetCurrentPalette() Palette
- func (m *Manager) GetDarkPalette() Palette
- func (m *Manager) GetLightPalette() Palette
- func (m *Manager) GetModeColors() ModeColors
- func (m *Manager) GetWebUIThemeCSS() string
- func (m *Manager) PrefersDark() bool
- func (m *Manager) SetColorScheme(ctx context.Context, scheme string, display *gdk.Display)
- func (m *Manager) UpdateFromConfig(ctx context.Context, appearance *entity.AppearanceConfig, uiScale float64, ...)
- type ModeColors
- type Palette
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FontCSSVars ¶
func FontCSSVars(fonts FontConfig) string
FontCSSVars generates CSS custom properties for fonts.
func GenerateCSS ¶
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 ¶
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 ¶
GenerateFindHighlightCSS builds CSS to style find-in-page matches using the accent color.
func HexToRGBA ¶ added in v0.20.1
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 ¶
ValidateHexColor checks if a string is a valid hex color.
Types ¶
type FontConfig ¶
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, appearance *entity.AppearanceConfig, uiScale float64, styling *entity.WorkspaceStylingConfig, resolver port.ColorSchemeResolver, ) *Manager
NewManager creates a new theme manager from configuration. The ColorSchemeResolver is required for proper color scheme detection.
appearance controls fonts, palette overrides and color scheme. uiScale is the GTK UI scale factor (0 or negative means use default 1.0). styling controls mode indicator colors; may be nil to use defaults.
func (*Manager) ApplyToDisplay ¶
ApplyToDisplay loads the theme CSS into the display.
func (*Manager) GetBackgroundRGBA ¶ added in v0.20.1
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 ¶
GetCurrentPalette returns the active palette based on current scheme.
func (*Manager) GetDarkPalette ¶
GetDarkPalette returns the dark theme palette.
func (*Manager) GetLightPalette ¶
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 ¶
GetWebUIThemeCSS returns CSS text that defines both light and dark variables. WebUI uses `:root` for light and `.dark` overrides for dark.
func (*Manager) PrefersDark ¶
PrefersDark returns true if dark mode is active.
func (*Manager) SetColorScheme ¶
SetColorScheme changes the active color scheme at runtime.
func (*Manager) UpdateFromConfig ¶
func (m *Manager) UpdateFromConfig( ctx context.Context, appearance *entity.AppearanceConfig, uiScale float64, styling *entity.WorkspaceStylingConfig, display *gdk.Display, )
UpdateFromConfig updates the theme manager state from new config values.
appearance controls fonts, palette overrides and color scheme. uiScale is the GTK UI scale factor (0 or negative means keep existing scale). styling controls mode indicator colors; may be nil to keep existing colors.
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 *entity.ColorPalette, isDark bool) Palette
PaletteFromConfig creates a Palette from config values, filling missing values with defaults.
func (Palette) ToWebCSSVars ¶
ToWebCSSVars generates CSS custom properties for web UI (Tailwind compatibility). Maps GTK palette names to Tailwind variable names used in the WebUI homepage.