Module theme

Module theme 

Source
Expand description

Token-based theme system for Git-Iris.

This module provides a flexible, TOML-configurable theme system that supports:

  • Color primitives defined in a palette
  • Semantic tokens that reference palette colors or other tokens
  • Composed styles with foreground, background, and modifiers
  • Gradient definitions for smooth color transitions
  • Runtime theme switching with thread-safe global state

§Theme File Format

Themes are defined in TOML files with the following structure:

[meta]
name = "My Theme"
author = "Your Name"
variant = "dark"  # or "light"

[palette]
purple_500 = "#e135ff"
cyan_400 = "#80ffea"

[tokens]
text.primary = "#f8f8f2"
accent.primary = "purple_500"  # references palette
success = "cyan_400"

[styles]
keyword = { fg = "accent.primary", bold = true }

[gradients]
primary = ["purple_500", "cyan_400"]

§Usage

use git_iris::theme;

// Get current theme
let theme = theme::current();

// Access colors
let color = theme.color("accent.primary");

// Access styles
let style = theme.style("keyword");

// Access gradients
let gradient_color = theme.gradient("primary", 0.5);

Modules§

adapters
Adapters for converting theme types to framework-specific types.
builtins
Builtin themes embedded in the binary.

Structs§

Gradient
A color gradient defined by a series of color stops.
Theme
A resolved theme with all tokens and styles ready for use.
ThemeColor
A theme color in RGB format.
ThemeInfo
Information about an available theme.
ThemeMeta
Theme metadata.
ThemeStyle
A composed style with foreground, background, and modifiers.

Enums§

ThemeError
Errors that can occur when loading or resolving themes.
ThemeVariant
Theme variant - light or dark.

Functions§

current
Get the current active theme.
list_available_themes
List all available themes.
load_theme
Load and set a theme from a file path.
load_theme_by_name
Load and set a theme by name (searches discovery paths).
set_theme
Set the active theme.