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