Skip to main content

standout_render/style/
mod.rs

1//! Style system for named styles, aliases, and stylesheets.
2//!
3//! Stylesheets can be written in CSS (preferred) or YAML (legacy). The
4//! [`StylesheetRegistry`] auto-detects the format from content when loading.
5//!
6//! This module provides the complete styling infrastructure:
7//!
8//! ## Core Types
9//!
10//! - [`StyleValue`]: A style that can be either concrete or an alias
11//! - [`Styles`]: A registry of named styles
12//! - [`StyleValidationError`]: Errors from style validation
13//!
14//! ## Stylesheet Parsing
15//!
16//! - [`parse_css`]: Parse CSS source into theme variants
17//! - [`parse_stylesheet`]: Parse YAML source into theme variants (legacy)
18//! - [`ThemeVariants`]: Styles resolved for base/light/dark modes
19//! - [`StylesheetRegistry`]: File-based theme management (auto-detects CSS/YAML)
20//!
21//! ## YAML Schema
22//!
23//! ```yaml
24//! # Simple style with attributes
25//! header:
26//!   fg: cyan
27//!   bold: true
28//!
29//! # Shorthand for single attribute
30//! bold_text: bold
31//! accent: cyan
32//!
33//! # Shorthand for multiple attributes
34//! warning: "yellow italic"
35//!
36//! # Adaptive style with mode-specific overrides
37//! panel:
38//!   bg: gray
39//!   light:
40//!     bg: "#f5f5f5"
41//!   dark:
42//!     bg: "#1a1a1a"
43//!
44//! # Aliases
45//! disabled: muted
46//! ```
47//!
48//! ## Color Formats
49//!
50//! ```yaml
51//! fg: red               # Named (16 ANSI colors)
52//! fg: bright_yellow     # Bright variants
53//! fg: 208               # 256-color palette
54//! fg: "#ff6b35"         # RGB hex
55//! fg: [255, 107, 53]    # RGB tuple
56//! ```
57//!
58//! ## Example
59//!
60//! ```rust
61//! use standout_render::style::{parse_stylesheet, ThemeVariants};
62//! use standout_render::ColorMode;
63//!
64//! let yaml = r#"
65//! header:
66//!   fg: cyan
67//!   bold: true
68//! footer:
69//!   dim: true
70//!   light:
71//!     fg: black
72//!   dark:
73//!     fg: white
74//! "#;
75//!
76//! let variants = parse_stylesheet(yaml, None).unwrap();
77//! let dark_styles = variants.resolve(Some(ColorMode::Dark));
78//! ```
79
80// Core style types
81mod error;
82mod registry;
83mod value;
84
85// Stylesheet parsing (YAML and CSS)
86mod attributes;
87mod color;
88mod css_parser;
89mod definition;
90mod file_registry;
91mod parser;
92
93// Core exports
94pub use error::{StyleValidationError, StylesheetError};
95pub use registry::{Styles, DEFAULT_MISSING_STYLE_INDICATOR};
96pub use value::StyleValue;
97
98// Stylesheet parsing exports
99pub use attributes::StyleAttributes;
100pub use color::ColorDef;
101pub use css_parser::parse_css;
102pub use definition::StyleDefinition;
103pub(crate) use file_registry::parse_theme_content;
104pub use file_registry::{StylesheetRegistry, STYLESHEET_EXTENSIONS};
105pub use parser::{parse_stylesheet, ThemeVariants};