material_yew/icon_button_toggle/
off_icon.rs1use yew::prelude::*;
2
3const SLOT: &str = "offIcon";
4
5#[derive(Properties, PartialEq, Clone)]
7pub struct OffIconButtonToggleProps {
8 pub children: Children,
9}
10
11pub struct MatOffIconButtonToggle {}
17
18impl Component for MatOffIconButtonToggle {
19 type Message = ();
20 type Properties = OffIconButtonToggleProps;
21
22 fn create(_: &Context<Self>) -> Self {
23 Self {}
24 }
25
26 fn view(&self, ctx: &Context<Self>) -> Html {
27 let props = ctx.props();
28 let children = props
29 .children
30 .iter()
31 .map(|child| {
32 match child {
33 Html::VTag(mut vtag) => {
34 vtag.add_attribute("slot", SLOT);
35 Html::VTag(vtag)
36 }
37 _ => {
38 html! {
39 <span slot={SLOT}>
40 {child}
41 </span>
42 }
43 }
44 }
45 })
46 .collect::<Html>();
47
48 html! {
49 {children}
50 }
51 }
52}