fix style

This commit is contained in:
tommy
2025-11-07 15:58:27 +08:00
parent 50ec5bd920
commit 8640db6334
10 changed files with 55 additions and 6 deletions

View File

@@ -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,

View File

@@ -67,11 +67,13 @@ impl CheckboxChipOption {
}
}
#[allow(dead_code)]
pub fn with_description(mut self, description: impl Into<String>) -> Self {
self.description = Some(description.into());
self
}
#[allow(dead_code)]
pub fn disabled(mut self) -> Self {
self.disabled = true;
self

View File

@@ -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() {

View File

@@ -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 {

View File

@@ -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<EventHandler<FormEvent>>,
#[props(optional)] on_change: Option<EventHandler<FormEvent>>,
) -> Element {
@@ -34,6 +35,7 @@ pub fn Input(
disabled,
readonly,
required,
autofocus,
id: id_attr,
name: name_attr,
value: resolved_value,

View File

@@ -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<String>,

View File

@@ -105,6 +105,7 @@ pub struct RadioChipOption {
}
impl RadioChipOption {
#[allow(dead_code)]
pub fn new(label: impl Into<String>, value: impl Into<String>) -> Self {
Self {
label: label.into(),
@@ -114,11 +115,13 @@ impl RadioChipOption {
}
}
#[allow(dead_code)]
pub fn with_description(mut self, description: impl Into<String>) -> Self {
self.description = Some(description.into());
self
}
#[allow(dead_code)]
pub fn disabled(mut self) -> Self {
self.disabled = true;
self

View File

@@ -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,

View File

@@ -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,
}

View File

@@ -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::*;