htmx_components/server/
transition.rs1use super::html_element::HtmlElement;
2use rscx::{component, html, props};
3use rscx_web_macros::*;
4
5#[html_element]
6pub struct TransitionProps {
7 #[builder(setter(into))]
8 enter: String,
9
10 #[builder(setter(into))]
11 enter_from: String,
12
13 #[builder(setter(into))]
14 enter_to: String,
15
16 #[builder(setter(into))]
17 leave: String,
18
19 #[builder(setter(into))]
20 leave_from: String,
21
22 #[builder(setter(into))]
23 leave_to: String,
24
25 #[builder(setter(into), default)]
26 children: String,
27
28 #[builder(setter(into), default=String::from("div"))]
29 tag: String,
30}
31
32#[component]
33pub fn Transition(props: TransitionProps) -> String {
34 html! {
35 <HtmlElement
36 tag=props.tag
37 class=format!("hidden {}", props.class)
38 component_name="Transition"
39 attrs=spread_attrs!(props | omit(class))
40 .set("data-yc-control", "transition".into())
41 .set("data-transition-enter", props.enter)
42 .set("data-transition-enter-start", props.enter_from)
43 .set("data-transition-enter-end", props.enter_to)
44 .set("data-transition-leave", props.leave)
45 .set("data-transition-leave-start", props.leave_from)
46 .set("data-transition-leave-end", props.leave_to)
47 >
48 {props.children}
49 </HtmlElement>
50 }
51}