♻️ progressbar
All checks were successful
ci/woodpecker/push/test Pipeline was successful

This commit is contained in:
JMARyA 2025-02-23 04:34:21 +01:00
parent a79da3d797
commit b8ed8da199
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263

View file

@ -555,16 +555,24 @@ pub fn HelpIcon() -> PreEscaped<String> {
} }
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn ProgressBar(percentage: u8, label: bool) -> PreEscaped<String> { pub fn ProgressBar<C: UIColor + 'static>(
assert!(percentage < 100, "Percentage must be less than 100"); mut percentage: u8,
label: bool,
color: C,
) -> PreEscaped<String> {
if percentage > 100 {
percentage = 100;
}
let color = color.color_class();
html! { html! {
@if label { @if label {
div class="w-full bg-gray-200 rounded-full dark:bg-gray-700" { div class="w-full bg-gray-200 rounded-full dark:bg-gray-700" {
div class="bg-blue-600 text-xs font-medium text-blue-100 text-center p-0.5 leading-none rounded-full" style=(format!("width: {percentage}%")) { (format!("{percentage}%")) }; div class=(format!("bg-{color} text-xs font-medium text-blue-100 text-center p-0.5 leading-none rounded-full")) style=(format!("width: {percentage}%")) { (format!("{percentage}%")) };
}; };
} @else { } @else {
div class="w-full bg-gray-200 rounded-full h-2.5 dark:bg-gray-700" { div class="w-full bg-gray-200 rounded-full h-2.5 dark:bg-gray-700" {
div class="bg-blue-600 h-2.5 rounded-full" style=(format!("width: {percentage}%")) {}; div class=(format!("bg-{color} h-2.5 rounded-full")) style=(format!("width: {percentage}%")) {};
}; };
} }
} }