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