info-werefox-cafe/void-fe/src/components/void_buttons.rs

53 lines
1.3 KiB
Rust
Raw Normal View History

use crate::utils::prop_structs::{ButtonProps, ContentChildren};
use dioxus::prelude::*;
#[cfg(target_family = "wasm")]
use dioxus_router::Link;
pub fn BackToHomePage(cx: Scope) -> Element {
#[cfg(any(target_family = "windows", target_family = "unix"))]
return cx.render(rsx!{
a {href: "/",
p {
"Back to the homepage"
}
}
});
#[cfg(target_family = "wasm")]
return cx.render(rsx!{
Link { to: "/",
p {
"Back to the homepage"
}
}
});
}
pub fn NavigationButton(cx: Scope<ButtonProps>) -> Element {
let title = cx.props.title.clone();
let title_ref = title.as_str();
let slug = cx.props.slug.clone();
let slug_ref = slug.as_str();
#[cfg(any(target_family = "windows", target_family = "unix"))]
return cx.render(rsx!{
a { href: "{slug_ref}",
"{title_ref}"
}
});
#[cfg(target_family = "wasm")]
return cx.render(rsx!{
Link { to: "{slug_ref}",
div {
dangerous_inner_html: "{title_ref}",
}
}
});
}
pub fn ButtonGroup<'a>(cx: Scope<'a, ContentChildren<'a>>) -> Element {
cx.render(rsx! {
div { class: "grid md:grid-flow-col grid-flow-row gap-y-4",
&cx.props.children
}
})
}