nightshade_api/web/base/
progress.rs1use leptos::prelude::*;
2
3#[component]
6pub fn Progress(
7 #[prop(into)] value: Signal<f64>,
8 #[prop(default = 1.0)] max: f64,
9) -> impl IntoView {
10 let ceiling = if max <= 0.0 { 1.0 } else { max };
11 let percent = move || (value.get() / ceiling).clamp(0.0, 1.0) * 100.0;
12 view! {
13 <div
14 class="nightshade-progress"
15 role="progressbar"
16 aria-valuemin="0"
17 aria-valuemax=ceiling.to_string()
18 aria-valuenow=move || value.get().to_string()
19 >
20 <div class="nightshade-progress-fill" style=move || format!("width:{}%", percent())></div>
21 </div>
22 }
23}