material_dioxus/
icon.rs

1use dioxus::prelude::*;
2use wasm_bindgen::prelude::*;
3
4#[wasm_bindgen(module = "/build/mwc-icon.js")]
5extern "C" {
6    #[derive(Debug)]
7    type Icon;
8
9    #[wasm_bindgen(getter, static_method_of = Icon)]
10    fn _dummy_loader() -> JsValue;
11}
12
13loader_hack!(Icon);
14
15/// Props for [`MatIcon`]
16///
17/// [MWC Documentation for properties](https://github.com/material-components/material-components-web-components/tree/v0.27.0/packages/icon#propertiesattributes)
18#[derive(Props)]
19pub struct IconProps<'a> {
20    pub children: Element<'a>,
21
22    #[props(into, default)]
23    pub style: String,
24    #[props(into, default)]
25    pub class: String,
26    #[props(into)]
27    pub slot: Option<String>,
28}
29
30fn render<'a>(cx: Scope<'a, IconProps<'a>>) -> Element<'a> {
31    render! {
32        mwc-icon {
33            style: string_attr!(cx.props.style),
34            class: string_attr!(cx.props.class),
35            slot: optional_string_attr!(cx.props.slot),
36
37            &cx.props.children
38        }
39    }
40}
41
42component!('a, MatIcon, IconProps, render, Icon, "icon");