use dioxus::prelude::*;
#[derive(Props, Clone, PartialEq)]
pub struct CarouselProps {
#[props(default)]
pub children: Element,
#[props(default = 0)]
pub initial_index: u32,
#[props(default = "300px".to_string())]
pub height: String,
#[props(default = "hover".to_string())]
pub trigger: String,
#[props(default = true)]
pub autoplay: bool,
#[props(default = 3000)]
pub interval: u32,
#[props(default = "outside".to_string())]
pub indicator_position: String,
#[props(default = "hover".to_string())]
pub arrow: String,
#[props(default = "default".to_string())]
pub carousel_type: String,
#[props(default)]
pub on_change: Option<EventHandler<u32>>,
#[props(default)]
pub class: Option<String>,
#[props(default)]
pub style: Option<String>,
}
#[component]
pub fn Carousel(props: CarouselProps) -> Element {
let mut class_names = vec!["el-carousel".to_string()];
if props.carousel_type == "card" { class_names.push("el-carousel--card".to_string()); }
if let Some(ref c) = props.class { class_names.push(c.clone()); }
rsx! {
div {
class: "{class_names.join(\" \")}",
style: "height: {props.height}; {props.style.clone().unwrap_or_default()}",
div {
class: "el-carousel__container",
style: "height: {props.height};",
{props.children}
}
div {
class: "el-carousel__indicators--{props.indicator_position}",
button {
class: "el-carousel__button",
}
}
}
}
}