material_yew/
circular_progress.rs

1use crate::{bool_to_option, to_option_string};
2use wasm_bindgen::prelude::*;
3use yew::prelude::*;
4
5#[wasm_bindgen(module = "/build/mwc-circular-progress.js")]
6extern "C" {
7    #[derive(Debug)]
8    type CircularProgress;
9
10    // This needs to be added to each component
11    #[wasm_bindgen(getter, static_method_of = CircularProgress)]
12    fn _dummy_loader() -> JsValue;
13}
14
15// call the macro with the type
16loader_hack!(CircularProgress);
17
18/// Props for [`MatCircularProgress`]
19///
20/// [MWC Documentation for properties](https://github.com/material-components/material-components-web-components/tree/v0.27.0/packages/circular-progress#propertiesattributes)
21#[derive(Debug, Properties, PartialEq, Clone)]
22pub struct CircularProgressProps {
23    #[prop_or_default]
24    pub indeterminate: bool,
25    #[prop_or_default]
26    pub progress: f32,
27    #[prop_or_default]
28    pub density: u32,
29    #[prop_or_default]
30    pub closed: bool,
31}
32
33component!(
34    MatCircularProgress,
35    CircularProgressProps,
36    |props: &CircularProgressProps| {
37        html! {
38             <mwc-circular-progress
39                 indeterminate={bool_to_option(props.indeterminate)}
40                 progress={to_option_string(props.progress)}
41                 density={to_option_string(props.density)}
42                 closed={bool_to_option(props.closed)}
43             ></mwc-circular-progress>
44        }
45    },
46    CircularProgress,
47    "circular-progress"
48);