material_yew/
icon_button.rs

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