material_yew/
fab.rs

1use crate::bool_to_option;
2use wasm_bindgen::prelude::*;
3use yew::prelude::*;
4use yew::virtual_dom::AttrValue;
5
6#[wasm_bindgen(module = "/build/mwc-fab.js")]
7extern "C" {
8    #[derive(Debug)]
9    type Fab;
10
11    #[wasm_bindgen(getter, static_method_of = Fab)]
12    fn _dummy_loader() -> JsValue;
13}
14
15loader_hack!(Fab);
16
17/// Props for [`MatFab`]
18///
19/// [MWC Documentation for properties](https://github.com/material-components/material-components-web-components/tree/v0.27.0/packages/fab#propertiesattributes)
20#[derive(Debug, Properties, PartialEq, Clone)]
21pub struct FabProps {
22    #[prop_or_default]
23    pub icon: Option<AttrValue>,
24    #[prop_or_default]
25    pub label: Option<AttrValue>,
26    #[prop_or_default]
27    pub mini: bool,
28    #[prop_or_default]
29    pub reduced_touch_target: bool,
30    #[prop_or_default]
31    pub extended: bool,
32    #[prop_or_default]
33    pub show_icon_at_end: bool,
34    #[prop_or_default]
35    pub children: Children,
36}
37
38component!(
39    MatFab,
40    FabProps,
41    |props: &FabProps| {
42        html! {
43             <mwc-fab
44                 label={props.label.clone()}
45                 icon={props.icon.clone()}
46                 mini={bool_to_option(props.mini)}
47                 reducedTouchTarget={bool_to_option(props.reduced_touch_target)}
48                 extended={bool_to_option(props.extended)}
49                 showIconAtEnd={bool_to_option(props.show_icon_at_end)}
50             >{props.children.clone()}</mwc-fab>
51        }
52    },
53    Fab,
54    "fab"
55);