1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use super::*;
use crate::prelude::*;
use yew::{
    prelude::*,
    virtual_dom::{VChild, VComp},
};

#[derive(PartialEq, Clone)]
pub struct MenuChildVariant {
    props: MenuChild,
}

impl<CHILD> From<VChild<CHILD>> for MenuChildVariant
where
    CHILD: BaseComponent,
    CHILD::Properties: Into<MenuChild> + Clone,
{
    fn from(vchild: VChild<CHILD>) -> Self {
        Self {
            props: (*vchild.props).clone().into(),
        }
    }
}

impl From<MenuChildVariant> for Html {
    fn from(value: MenuChildVariant) -> Self {
        match value.props {
            MenuChild::Action(props) => VComp::new::<MenuAction>(props, None).into(),
            MenuChild::Link(props) => VComp::new::<MenuLink>(props, None).into(),
            MenuChild::Group(props) => VComp::new::<MenuGroup>(props, None).into(),
            MenuChild::Loading(props) => VComp::new::<MenuLoading>(props, None).into(),
            MenuChild::Divider(props) => VComp::new::<ListDivider>(props, None).into(),
            MenuChild::Raw(props) => VComp::new::<Raw>(props, None).into(),
        }
    }
}