(props: ProgressProps)
| 52 | /// - `--progress-value`: A value between 0 and 100 representing the current progress percentage. |
| 53 | #[component] |
| 54 | pub fn Progress(props: ProgressProps) -> Element { |
| 55 | // Calculate percentage for styling and "data-state" |
| 56 | let percentage = use_memo(move || { |
| 57 | props.value.cloned().map(|v| { |
| 58 | let max = (props.max)(); |
| 59 | (v / max) * 100.0 |
| 60 | }) |
| 61 | }); |
| 62 | |
| 63 | let state = use_memo(move || match percentage() { |
| 64 | Some(_) => "loading", |
| 65 | None => "indeterminate", |
| 66 | }); |
| 67 | |
| 68 | rsx! { |
| 69 | div { |
| 70 | role: "progressbar", |
| 71 | "aria-valuemin": 0, |
| 72 | "aria-valuemax": props.max, |
| 73 | "aria-valuenow": props.value.cloned(), |
| 74 | "data-state": state, |
| 75 | "data-value": props.value.cloned().map(|v| v.to_string()), |
| 76 | "data-max": props.max, |
| 77 | style: percentage().map(|p| format!("--progress-value: {p}%")), |
| 78 | ..props.attributes, |
| 79 | |
| 80 | {props.children} |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | /// The props for the [`ProgressIndicator`] component. |
| 86 | #[derive(Props, Clone, PartialEq)] |
nothing calls this directly
no outgoing calls
no test coverage detected