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