diff --git a/src/components/ui/aspect_ratio.rs b/src/components/ui/aspect_ratio.rs index aff3765..b1ee95f 100644 --- a/src/components/ui/aspect_ratio.rs +++ b/src/components/ui/aspect_ratio.rs @@ -1,5 +1,17 @@ use dioxus::prelude::*; use super::utils::merge_class; + +/// A simple wrapper component that maintains a specified aspect ratio for its content. +/// +/// # Example +/// ```rust +/// rsx! { +/// AspectRatio { +/// ratio: 16.0 / 9.0, +/// img { src: "/image.jpg" } +/// } +/// } +/// ``` #[component] pub fn AspectRatio( #[props(default = 1.0f32)] ratio: f32, diff --git a/src/components/ui/checkbox.rs b/src/components/ui/checkbox.rs index 26b2cb5..a1152b6 100644 --- a/src/components/ui/checkbox.rs +++ b/src/components/ui/checkbox.rs @@ -67,11 +67,13 @@ impl CheckboxChipOption { } } + #[allow(dead_code)] pub fn with_description(mut self, description: impl Into) -> Self { self.description = Some(description.into()); self } + #[allow(dead_code)] pub fn disabled(mut self) -> Self { self.disabled = true; self diff --git a/src/components/ui/combobox.rs b/src/components/ui/combobox.rs index 3cef7b2..eccc781 100644 --- a/src/components/ui/combobox.rs +++ b/src/components/ui/combobox.rs @@ -1,5 +1,6 @@ use dioxus::prelude::*; use super::utils::merge_class; +use super::input::Input; #[derive(Clone, PartialEq)] pub struct ComboboxOption { pub label: String, @@ -139,13 +140,12 @@ fn ComboboxContent( class: "ui-combobox-content", div { class: "ui-combobox-search", - input { + Input { class: "ui-combobox-input", placeholder: search_placeholder, - r#type: "text", autofocus: true, - value: "{query()}", - oninput: move |event| query.set(event.value()), + value: query(), + on_input: move |event: FormEvent| query.set(event.value()) } } if filtered_options.is_empty() { diff --git a/src/components/ui/command.rs b/src/components/ui/command.rs index fdd575c..aa82923 100644 --- a/src/components/ui/command.rs +++ b/src/components/ui/command.rs @@ -1,4 +1,5 @@ use dioxus::prelude::*; +use super::input::Input; #[derive(Clone, PartialEq)] pub struct CommandItem { @@ -90,11 +91,11 @@ pub fn CommandPalette( div { class: "ui-command-header", span { style: "font-size: 0.85rem; opacity: 0.6;", "⌘K" } - input { + Input { class: "ui-command-input", value: query(), placeholder: placeholder.clone(), - oninput: move |event| query.set(event.value()), + on_input: move |event: FormEvent| query.set(event.value()) } } div { diff --git a/src/components/ui/input.rs b/src/components/ui/input.rs index 2db6ed3..1a7d864 100644 --- a/src/components/ui/input.rs +++ b/src/components/ui/input.rs @@ -13,6 +13,7 @@ pub fn Input( #[props(default)] disabled: bool, #[props(default)] readonly: bool, #[props(default)] required: bool, + #[props(default)] autofocus: bool, #[props(optional)] on_input: Option>, #[props(optional)] on_change: Option>, ) -> Element { @@ -34,6 +35,7 @@ pub fn Input( disabled, readonly, required, + autofocus, id: id_attr, name: name_attr, value: resolved_value, diff --git a/src/components/ui/label.rs b/src/components/ui/label.rs index 22e15ad..f915bd3 100644 --- a/src/components/ui/label.rs +++ b/src/components/ui/label.rs @@ -1,5 +1,17 @@ use dioxus::prelude::*; use super::utils::merge_class; + +/// Label component for form fields with consistent styling. +/// +/// # Example +/// ```rust +/// rsx! { +/// Label { +/// r#for: "email", +/// "Email Address" +/// } +/// } +/// ``` #[component] pub fn Label( #[props(into, default)] class: Option, diff --git a/src/components/ui/radio_group.rs b/src/components/ui/radio_group.rs index 8c387ca..d68c332 100644 --- a/src/components/ui/radio_group.rs +++ b/src/components/ui/radio_group.rs @@ -105,6 +105,7 @@ pub struct RadioChipOption { } impl RadioChipOption { + #[allow(dead_code)] pub fn new(label: impl Into, value: impl Into) -> Self { Self { label: label.into(), @@ -114,11 +115,13 @@ impl RadioChipOption { } } + #[allow(dead_code)] pub fn with_description(mut self, description: impl Into) -> Self { self.description = Some(description.into()); self } + #[allow(dead_code)] pub fn disabled(mut self) -> Self { self.disabled = true; self diff --git a/src/components/ui/separator.rs b/src/components/ui/separator.rs index 45360a7..9b7e0b2 100644 --- a/src/components/ui/separator.rs +++ b/src/components/ui/separator.rs @@ -1,5 +1,14 @@ use dioxus::prelude::*; use super::utils::merge_class; + +/// Horizontal or vertical separator/divider component. +/// +/// # Example +/// ```rust +/// rsx! { +/// Separator { orientation: SeparatorOrientation::Horizontal } +/// } +/// ``` #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum SeparatorOrientation { Horizontal, diff --git a/src/components/ui/tabs.rs b/src/components/ui/tabs.rs index bfb3e65..d993be2 100644 --- a/src/components/ui/tabs.rs +++ b/src/components/ui/tabs.rs @@ -1,8 +1,10 @@ use dioxus::prelude::*; use super::utils::merge_class; + #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum TabsOrientation { Horizontal, + #[allow(dead_code)] Vertical, } diff --git a/src/components/ui/utils.rs b/src/components/ui/utils.rs index ac6274e..4176183 100644 --- a/src/components/ui/utils.rs +++ b/src/components/ui/utils.rs @@ -17,6 +17,12 @@ pub fn data_bool(value: bool) -> &'static str { } } +/// Trait for types that can be converted to a static string representation. +/// Useful for variant enums that need to be used as CSS classes or data attributes. +pub trait AsStaticStr { + fn as_str(&self) -> &'static str; +} + #[cfg(test)] mod tests { use super::*;