euv_ui/component/carousel/view/struct.rs
1use super::*;
2
3/// One slide of the [`euv_carousel`].
4///
5/// Carries the headline of the slide and the supporting line under it.
6#[derive(Clone, Copy, CustomDebug, Data, Default, New)]
7pub struct EuvCarouselSlide {
8 /// The headline of the slide.
9 #[get(type(copy))]
10 pub title: &'static str,
11 /// The supporting line under the headline.
12 #[get(type(copy))]
13 pub desc: &'static str,
14}
15
16/// Props of the [`euv_carousel_content`] component.
17///
18/// The content is the viewport: it clips the track and lays the slides
19/// out along the orientation.
20#[derive(Clone, Copy, CustomDebug, Default)]
21pub struct EuvCarouselContentProps {
22 /// The direction the slides travel in.
23 pub orientation: EuvCarouselOrientation,
24}
25
26/// Props of the [`euv_carousel_item`] component.
27///
28/// The item is one slide of the track.
29#[derive(Clone, Copy, CustomDebug, Default)]
30pub struct EuvCarouselItemProps {
31 /// The direction the slides travel in.
32 pub orientation: EuvCarouselOrientation,
33}
34
35/// Props of the [`euv_carousel_next`] component.
36///
37/// The button steps the track forward.
38#[derive(Clone, CustomDebug, Default)]
39pub struct EuvCarouselNextProps {
40 /// The direction the slides travel in.
41 pub orientation: EuvCarouselOrientation,
42 /// The accessible name of the button.
43 pub label: &'static str,
44 /// Whether the button refuses to be pressed.
45 pub disabled: bool,
46 /// Optional callback fired when the button is pressed.
47 #[debug(skip)]
48 pub on_press: Option<Rc<dyn Fn()>>,
49}
50
51/// Props of the [`euv_carousel_previous`] component.
52///
53/// The button steps the track back.
54#[derive(Clone, CustomDebug, Default)]
55pub struct EuvCarouselPreviousProps {
56 /// The direction the slides travel in.
57 pub orientation: EuvCarouselOrientation,
58 /// The accessible name of the button.
59 pub label: &'static str,
60 /// Whether the button refuses to be pressed.
61 pub disabled: bool,
62 /// Optional callback fired when the button is pressed.
63 #[debug(skip)]
64 pub on_press: Option<Rc<dyn Fn()>>,
65}
66
67/// Props for the [`euv_carousel`] component.
68///
69/// Defines the strongly-typed interface for a slideshow: the slides it
70/// cycles through and the slide that is currently showing.
71#[derive(Clone, CustomDebug, Default)]
72pub struct EuvCarouselProps {
73 /// The slides, in display order.
74 pub slides: Vec<EuvCarouselSlide>,
75 /// The index of the slide that is currently showing.
76 pub active: Signal<u32>,
77 /// The callback fired when the shown slide changes.
78 #[debug(skip)]
79 pub on_change: Option<Rc<dyn Fn(u32)>>,
80}