1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use crate::bool_to_option;
use wasm_bindgen::prelude::*;
use yew::prelude::*;
use yew::virtual_dom::AttrValue;

#[wasm_bindgen(module = "/build/mwc-fab.js")]
extern "C" {
    #[derive(Debug)]
    type Fab;

    #[wasm_bindgen(getter, static_method_of = Fab)]
    fn _dummy_loader() -> JsValue;
}

loader_hack!(Fab);

/// Props for [`MatFab`]
///
/// [MWC Documentation for properties](https://github.com/material-components/material-components-web-components/tree/v0.27.0/packages/fab#propertiesattributes)
#[derive(Debug, Properties, PartialEq, Clone)]
pub struct FabProps {
    #[prop_or_default]
    pub icon: Option<AttrValue>,
    #[prop_or_default]
    pub label: Option<AttrValue>,
    #[prop_or_default]
    pub mini: bool,
    #[prop_or_default]
    pub reduced_touch_target: bool,
    #[prop_or_default]
    pub extended: bool,
    #[prop_or_default]
    pub show_icon_at_end: bool,
    #[prop_or_default]
    pub children: Children,
}

component!(
    MatFab,
    FabProps,
    |props: &FabProps| {
        html! {
             <mwc-fab
                 label={props.label.clone()}
                 icon={props.icon.clone()}
                 mini={bool_to_option(props.mini)}
                 reducedTouchTarget={bool_to_option(props.reduced_touch_target)}
                 extended={bool_to_option(props.extended)}
                 showIconAtEnd={bool_to_option(props.show_icon_at_end)}
             >{props.children.clone()}</mwc-fab>
        }
    },
    Fab,
    "fab"
);