tailwind_rs_core/
lib.rs

1//! # tailwind-rs-core
2//!
3//! Core types and utilities for the tailwind-rs library.
4//! This crate provides the fundamental building blocks for Tailwind CSS integration in Rust.
5
6pub mod classes;
7pub mod color;
8pub mod config;
9pub mod custom_variant;
10pub mod error;
11pub mod performance;
12pub mod responsive;
13pub mod theme;
14pub mod theme_new;
15pub mod utils;
16pub mod utilities;
17pub mod validation;
18
19#[cfg(test)]
20mod property_tests;
21
22#[cfg(test)]
23mod api_stability;
24
25// Re-export commonly used types
26pub use classes::{ClassBuilder, ClassSet};
27pub use color::Color;
28pub use config::{BuildConfig, TailwindConfig};
29pub use custom_variant::{CustomVariant, CustomVariantManager, CustomVariantType};
30pub use error::{Result, TailwindError};
31pub use performance::{CacheStats, ClassCache, OptimizationLevel, PerformanceOptimizer};
32pub use responsive::{
33    AlignItems, Breakpoint, FlexDirection, FlexWrap, JustifyContent, Responsive, ResponsiveBuilder,
34    ResponsiveFlex, ResponsiveGrid, ResponsiveValue, State,
35};
36pub use theme::{BorderRadius, BoxShadow, Spacing, Theme, ThemeValue};
37pub use theme_new::{
38    AnimationScale, BorderScale, FontFamily, FontSizeScale, FontWeightScale, LetterSpacingScale,
39    LineHeightScale, ShadowScale, SpacingScale, SpacingSize, Theme as NewTheme, ThemePreset,
40    ThemeVariant, ThemedComponent, TypographyScale,
41};
42pub use utilities::*;
43pub use validation::{ClassValidator, ErrorReporter, ValidationError, ValidationRules};
44
45// Build system types
46pub struct TailwindBuilder;
47pub struct CssOptimizer;
48
49impl Default for TailwindBuilder {
50    fn default() -> Self {
51        Self::new()
52    }
53}
54
55impl TailwindBuilder {
56    pub fn new() -> Self {
57        Self
58    }
59
60    pub fn scan_source(self, _path: &std::path::Path) -> Self {
61        self
62    }
63
64    pub fn output_css(self, _path: &std::path::Path) -> Self {
65        self
66    }
67
68    pub fn config_file(self, _path: &std::path::Path) -> Self {
69        self
70    }
71
72    pub fn enable_tree_shaking(self) -> Self {
73        self
74    }
75
76    pub fn enable_minification(self) -> Self {
77        self
78    }
79
80    pub fn enable_source_maps(self) -> Self {
81        self
82    }
83
84    pub async fn build(self) -> Result<()> {
85        Ok(())
86    }
87}
88
89impl Default for CssOptimizer {
90    fn default() -> Self {
91        Self::new()
92    }
93}
94
95impl CssOptimizer {
96    pub fn new() -> Self {
97        Self
98    }
99
100    pub fn input_file(self, _path: &std::path::Path) -> Self {
101        self
102    }
103
104    pub fn output_file(self, _path: &std::path::Path) -> Self {
105        self
106    }
107
108    pub fn optimization_level(self, _level: u8) -> Self {
109        self
110    }
111
112    pub fn remove_unused_classes(self) -> Self {
113        self
114    }
115
116    pub fn minify(self) -> Self {
117        self
118    }
119
120    pub fn generate_source_maps(self) -> Self {
121        self
122    }
123
124    pub async fn optimize(self) -> Result<()> {
125        Ok(())
126    }
127}
128
129/// Version information
130pub const VERSION: &str = env!("CARGO_PKG_VERSION");
131
132/// Default configuration values
133pub mod defaults {
134    use super::*;
135
136    pub const DEFAULT_THEME: &str = "default";
137    pub const DEFAULT_BREAKPOINT: Breakpoint = Breakpoint::Base;
138    pub const DEFAULT_SPACING: Spacing = Spacing::Rem(1.0);
139
140    pub fn default_color() -> Color {
141        Color::Blue
142    }
143}
144
145#[cfg(test)]
146mod tests {
147    use super::*;
148
149    #[test]
150    fn test_version_constant() {
151        assert!(!VERSION.is_empty());
152        assert!(VERSION.chars().any(|c| c.is_ascii_digit()));
153    }
154
155    #[test]
156    fn test_defaults() {
157        assert_eq!(defaults::DEFAULT_THEME, "default");
158        assert_eq!(defaults::DEFAULT_BREAKPOINT, Breakpoint::Base);
159        assert_eq!(defaults::default_color(), Color::Blue);
160        assert_eq!(defaults::DEFAULT_SPACING, Spacing::Rem(1.0));
161    }
162}