Some checks are pending
Documentation Lint & Validation / Markdown Linting (push) Waiting to run
Documentation Lint & Validation / Validate mdBook Configuration (push) Waiting to run
Documentation Lint & Validation / Content & Structure Validation (push) Waiting to run
Documentation Lint & Validation / Lint & Validation Summary (push) Blocked by required conditions
mdBook Build & Deploy / Build mdBook (push) Waiting to run
mdBook Build & Deploy / Documentation Quality Check (push) Blocked by required conditions
mdBook Build & Deploy / Deploy to GitHub Pages (push) Blocked by required conditions
mdBook Build & Deploy / Notification (push) Blocked by required conditions
Rust CI / Security Audit (push) Waiting to run
Rust CI / Check + Test + Lint (nightly) (push) Waiting to run
Rust CI / Check + Test + Lint (stable) (push) Waiting to run
73 lines
1.7 KiB
Rust
73 lines
1.7 KiB
Rust
use leptos::prelude::*;
|
|
|
|
#[cfg(target_arch = "wasm32")]
|
|
use super::client::StatCardClient;
|
|
#[cfg(not(target_arch = "wasm32"))]
|
|
use super::ssr::StatCardSSR;
|
|
|
|
/// Statistics card component
|
|
///
|
|
/// Displays a key metric with optional trend indicator.
|
|
///
|
|
/// # Examples
|
|
///
|
|
/// ```rust
|
|
/// use leptos::prelude::*;
|
|
/// use vapora_leptos_ui::StatCard;
|
|
///
|
|
/// #[component]
|
|
/// fn Dashboard() -> impl IntoView {
|
|
/// view! {
|
|
/// <StatCard
|
|
/// label="Total Users"
|
|
/// value="1,234"
|
|
/// change=Some("+12%")
|
|
/// trend_positive=true
|
|
/// />
|
|
/// }
|
|
/// }
|
|
/// ```
|
|
#[component]
|
|
pub fn StatCard(
|
|
/// Label text for the statistic
|
|
label: String,
|
|
/// Main value to display
|
|
value: String,
|
|
/// Optional change indicator (e.g., "+12%", "-5%")
|
|
#[prop(optional)]
|
|
change: Option<String>,
|
|
/// Whether the change is positive (green) or negative (red)
|
|
#[prop(default = true)]
|
|
trend_positive: bool,
|
|
/// Optional icon or content to display
|
|
#[prop(optional)]
|
|
icon: Option<Children>,
|
|
/// Additional CSS classes
|
|
#[prop(default = "")]
|
|
class: &'static str,
|
|
) -> impl IntoView {
|
|
#[cfg(not(target_arch = "wasm32"))]
|
|
return view! {
|
|
<StatCardSSR
|
|
label=label
|
|
value=value
|
|
change=change
|
|
trend_positive=trend_positive
|
|
icon=icon
|
|
class=class
|
|
/>
|
|
};
|
|
|
|
#[cfg(target_arch = "wasm32")]
|
|
return view! {
|
|
<StatCardClient
|
|
label=label
|
|
value=value
|
|
change=change
|
|
trend_positive=trend_positive
|
|
icon=icon
|
|
class=class
|
|
/>
|
|
};
|
|
}
|