qorzen_oxide/ui/layout/
mod.rs

1// src/ui/layout/mod.rs - Layout system components
2
3use dioxus::prelude::*;
4
5// Module declarations
6mod footer;
7mod header;
8mod main_layout;
9mod sidebar;
10
11// Re-exports
12pub use footer::Footer;
13pub use header::Header;
14pub use main_layout::Layout;
15pub use sidebar::Sidebar;
16
17/// Layout configuration props
18#[derive(Props, Clone, PartialEq)]
19pub struct LayoutProps {
20    /// Children to render in the main content area
21    pub children: Element,
22    /// Optional custom class for the layout
23    #[props(default = "".to_string())]
24    pub class: String,
25    /// Whether to show the header
26    #[props(default = true)]
27    pub show_header: bool,
28    /// Whether to show the sidebar
29    #[props(default = true)]
30    pub show_sidebar: bool,
31    /// Whether to show the footer
32    #[props(default = true)]
33    pub show_footer: bool,
34}
35
36/// Responsive layout breakpoints (matching Tailwind defaults)
37pub struct Breakpoints;
38
39impl Breakpoints {
40    pub const SM: &'static str = "640px"; // Tailwind sm
41    pub const MD: &'static str = "768px"; // Tailwind md
42    pub const LG: &'static str = "1024px"; // Tailwind lg
43    pub const XL: &'static str = "1280px"; // Tailwind xl
44    pub const XXL: &'static str = "1536px"; // Tailwind 2xl
45}
46
47/// Common layout utilities
48pub mod utils {
49    /// Check if the current viewport is mobile-sized
50    pub fn is_mobile() -> bool {
51        // In a real app, this would check the actual viewport
52        // For now, return false (desktop)
53        false
54    }
55
56    /// Check if the current viewport is tablet-sized
57    pub fn is_tablet() -> bool {
58        // In a real app, this would check the actual viewport
59        false
60    }
61
62    /// Check if the current viewport is desktop-sized
63    pub fn is_desktop() -> bool {
64        // In a real app, this would check the actual viewport
65        true
66    }
67
68    /// Get responsive classes based on viewport
69    pub fn responsive_classes(_mobile: &str, _tablet: &str, desktop: &str) -> String {
70        // In a real app, this would return the appropriate class based on viewport
71        // For now, return desktop classes
72        desktop.to_string()
73    }
74}
75
76#[cfg(test)]
77mod tests {
78    use super::*;
79
80    #[test]
81    fn test_breakpoints() {
82        assert_eq!(Breakpoints::SM, "640px");
83        assert_eq!(Breakpoints::MD, "768px");
84        assert_eq!(Breakpoints::LG, "1024px");
85    }
86
87    #[test]
88    fn test_responsive_utils() {
89        assert!(utils::is_desktop());
90        assert!(!utils::is_mobile());
91        assert!(!utils::is_tablet());
92    }
93}