material_dioxus/
circular_progress.rs

1use dioxus::{core::AttributeValue, prelude::*};
2use wasm_bindgen::prelude::*;
3
4#[wasm_bindgen(module = "/build/mwc-circular-progress.js")]
5extern "C" {
6    #[derive(Debug)]
7    type CircularProgress;
8
9    // This needs to be added to each component
10    #[wasm_bindgen(getter, static_method_of = CircularProgress)]
11    fn _dummy_loader() -> JsValue;
12}
13
14// call the macro with the type
15loader_hack!(CircularProgress);
16
17/// Props for [`MatCircularProgress`]
18///
19/// [MWC Documentation for properties](https://github.com/material-components/material-components-web-components/tree/v0.27.0/packages/circular-progress#propertiesattributes)
20#[derive(Props, PartialEq)]
21pub struct CircularProgressProps {
22    #[props(default)]
23    pub indeterminate: bool,
24    #[props(default)]
25    pub progress: f32,
26    #[props(default)]
27    pub density: i64,
28    #[props(default)]
29    pub closed: bool,
30
31    #[props(into, default)]
32    pub style: String,
33    #[props(into, default)]
34    pub class: String,
35    #[props(into)]
36    pub slot: Option<String>,
37}
38
39fn render(cx: Scope<CircularProgressProps>) -> Element {
40    render! {
41        mwc-circular-progress {
42            indeterminate: bool_attr!(cx.props.indeterminate),
43            progress: AttributeValue::Float(cx.props.progress.into()),
44            density: AttributeValue::Int(cx.props.density),
45            closed: bool_attr!(cx.props.closed),
46
47            style: string_attr!(cx.props.style),
48            class: string_attr!(cx.props.class),
49            slot: optional_string_attr!(cx.props.slot),
50        }
51    }
52}
53
54component!(
55    MatCircularProgress,
56    CircularProgressProps,
57    render,
58    CircularProgress,
59    "circular-progress"
60);