1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//! Comprehensive theme system for ratatui-toolkit widgets.
//!
//! This module provides a complete theming solution for TUI applications,
//! with support for loading themes from JSON files in the opencode format.
//!
//! # Overview
//!
//! The theme system consists of:
//!
//! - [`AppTheme`] - The main theme struct with all widget colors
//! - [`ThemeVariant`] - Dark/light mode selection
//! - [`DiffColors`] - Colors for CodeDiff widget
//! - [`MarkdownColors`] - Colors for MarkdownWidget
//! - [`SyntaxColors`] - Colors for syntax highlighting
//! - [`loader`] - JSON theme file loading utilities
//!
//! # Builtin Themes
//!
//! The crate includes 33 builtin themes that can be loaded by name:
//!
//! ```rust
//! use ratatui_toolkit::services::theme::{loader, ThemeVariant};
//!
//! // Load a builtin theme
//! let theme = loader::load_builtin_theme("gruvbox", ThemeVariant::Dark)
//! .expect("Failed to load theme");
//!
//! // See all available themes
//! for name in loader::BUILTIN_THEMES {
//! println!("{}", name);
//! }
//! ```
//!
//! # Custom Themes
//!
//! You can create custom themes from JSON files or strings:
//!
//! ```rust
//! use ratatui_toolkit::services::theme::{AppTheme, ThemeVariant};
//!
//! let json = r#"{
//! "defs": {
//! "myPrimary": "#ff6600"
//! },
//! "theme": {
//! "primary": { "dark": "myPrimary", "light": "myPrimary" }
//! }
//! }"#;
//!
//! let theme = AppTheme::from_json(json, ThemeVariant::Dark)
//! .expect("Failed to parse theme");
//! ```
//!
//! # JSON Format
//!
//! The opencode theme format uses:
//!
//! - `defs`: Named color definitions (e.g., `"darkBg0": "#282828"`)
//! - `theme`: Semantic mappings with variant support
//!
//! ```json
//! {
//! "defs": {
//! "colorName": "#hexcode"
//! },
//! "theme": {
//! "primary": { "dark": "colorName", "light": "colorName" },
//! "error": "#ff0000"
//! }
//! }
//! ```
//!
//! # Usage with Widgets
//!
//! ```rust,no_run
//! use ratatui::style::Style;
//! use ratatui_toolkit::services::theme::AppTheme;
//!
//! let theme = AppTheme::default();
//!
//! // Use UI colors
//! let primary_style = Style::default().fg(theme.primary);
//! let error_style = Style::default().fg(theme.error);
//!
//! // Use diff colors
//! let added_style = Style::default().fg(theme.diff.added);
//!
//! // Use markdown colors
//! let heading_style = Style::default().fg(theme.markdown.heading);
//! ```
// Re-export main types at module level
pub use AppTheme;
pub use DiffColors;
pub use MarkdownColors;
pub use SyntaxColors;
pub use ThemeVariant;