The Enum Component

Anything that implements mount(self) function can be a component, even enum, let's take a look at a simple example:

    use vertigo::{dom, DomNode};

    pub enum MenuItem {
        Blog,
        Shop,
        About,
    }

    impl MenuItem {
        pub fn into_component(self) -> Self {
            self
        }

        pub fn mount(&self) -> DomNode {
            let title = match self {
                Self::Blog => "Blog",
                Self::Shop => "Shop",
                Self::About => "About me",
            };

            dom! {
                <li>{title}</li>
            }
        }
    }

    dom! {
        <ul>
            <MenuItem::Blog />
            <MenuItem::Shop />
            <MenuItem::About />
        </ul>
    }

And more made-up but fancy one:

    use vertigo::{dom, DomNode};

    pub enum Page {
        NotFound,
        Ok { content: DomNode },
        Error { message: String },
    }

    impl Page {
        pub fn into_component(self) -> Self {
            self
        }

        pub fn mount(self) -> DomNode {
            match self {
                Self::NotFound => dom! { <main><p>"404 Not found"</p></main> },
                Self::Ok { content } => dom! { <main>{content}</main> },
                Self::Error { message } => dom! { <main>{message}</main> },
            }
        }
    }

    dom! {
        <ul>
            <Page::NotFound />
            <Page::Ok content={dom! { <p>"Hello!"</p> }} />
        </ul>
    }