use crate::{element::Element, html_element::*};
pub fn setup_toast(el: HtmlElement, oob: bool) -> HtmlElement {
let el = el
.set_attr("x-data", "toast")
.set_attr("x-show", "show")
.set_attr("x-transition:enter", "transition ease-out duration-50")
.set_attr("x-transition:enter-start", "opacity-0")
.set_attr("x-transition:enter-end", "opacity-100")
.set_attr("x-transition:leave", "transition ease-in duration-1000")
.set_attr("x-transition:leave-start", "opacity-100")
.set_attr("x-transition:leave-end", "opacity-0");
if oob {
div().hx_swap_oob("afterbegin:#toast-container").add(el)
} else {
el
}
}
pub trait FhtmxToast {
fn setup_toast(self, oob: bool) -> HtmlElement;
}
impl FhtmxToast for HtmlElement {
fn setup_toast(self, oob: bool) -> HtmlElement {
setup_toast(self, oob)
}
}