euv_ui/component/notification/view/struct.rs
1use super::*;
2
3/// One card in the [`euv_notification`] stack.
4///
5/// A notification carries a headline and a body line, plus an optional
6/// close button. The component is purely presentational: it renders the
7/// item it is given and reports the clicks, so the caller keeps
8/// ownership of the queue and of any auto-dismiss timing.
9#[derive(Clone, CustomDebug, Default)]
10pub struct EuvNotificationItem {
11 /// The notification headline, rendered in `c_euv_notification_title`.
12 pub title: &'static str,
13 /// The notification body, rendered in `c_euv_notification_text`.
14 pub text: &'static str,
15 /// The callback fired when the close button is clicked.
16 #[debug(skip)]
17 pub on_close: Option<Rc<dyn Fn()>>,
18 /// Whether the notification renders a close button.
19 ///
20 /// Defaults to `false`, but supplying an `on_close` callback implies a
21 /// dismissible notification, so the close button is rendered either way.
22 pub dismissible: bool,
23}
24
25/// Props for the [`euv_notification`] component.
26///
27/// The stack is always mounted, so a caller can push notifications into
28/// it without remounting the component.
29#[derive(Clone, CustomDebug, Default)]
30pub struct EuvNotificationProps {
31 /// The notifications rendered in the stack, top to bottom.
32 pub items: Vec<EuvNotificationItem>,
33}
34
35/// Props of the [`euv_toast`] component.
36///
37/// A toast is a short-lived card: it carries a title, a description, an
38/// optional action and an optional close button. The component is
39/// presentational — it renders what it is given and reports the clicks,
40/// so the caller keeps ownership of the queue and of the dismissal.
41#[derive(Clone, CustomDebug, Data, Default, New)]
42pub struct EuvToastProps {
43 /// The visual variant of the toast.
44 #[get(type(copy))]
45 pub variant: EuvToastVariant,
46 /// The headline of the toast.
47 #[get(type(copy))]
48 pub title: &'static str,
49 /// The body line of the toast.
50 #[get(type(copy))]
51 pub description: &'static str,
52 /// The label of the action button.
53 #[get(type(copy))]
54 pub action_label: &'static str,
55 /// Whether the toast renders a close button.
56 #[get(type(copy))]
57 pub dismissible: bool,
58 /// The callback fired when the action button is clicked.
59 #[debug(skip)]
60 pub on_action: Option<Rc<dyn Fn()>>,
61 /// The callback fired when the close button is clicked.
62 #[debug(skip)]
63 pub on_close: Option<Rc<dyn Fn()>>,
64}
65
66/// Props of the [`euv_toast_title`] component.
67#[derive(Clone, Copy, CustomDebug, Data, Default, New)]
68pub struct EuvToastTitleProps {
69 /// The headline text.
70 #[get(type(copy))]
71 pub text: &'static str,
72}
73
74/// Props of the [`euv_toast_description`] component.
75#[derive(Clone, Copy, CustomDebug, Data, Default, New)]
76pub struct EuvToastDescriptionProps {
77 /// The body text.
78 #[get(type(copy))]
79 pub text: &'static str,
80}
81
82/// Props of the [`euv_toast_action`] component.
83#[derive(Clone, CustomDebug, Data, Default, New)]
84pub struct EuvToastActionProps {
85 /// The label of the button.
86 #[get(type(copy))]
87 pub label: &'static str,
88 /// The callback fired when the button is clicked.
89 #[debug(skip)]
90 pub on_click: Option<Rc<dyn Fn()>>,
91}
92
93/// Props of the [`euv_toast_card`] component.
94///
95/// The card is the shell a toast is built from: the headline, the body
96/// line, the action and the close button are its children, so it takes no
97/// setting of its own.
98#[derive(Clone, CustomDebug, Default)]
99pub struct EuvToastCardProps {}
100
101/// Props of the [`euv_toast_provider`] component.
102///
103/// The provider owns the queue of the toasts and the timing of their
104/// dismissal, so it adds no setting of its own: the toasts it holds are
105/// its children.
106#[derive(Clone, CustomDebug, Default)]
107pub struct EuvToastProviderProps {}
108
109/// Props of the [`euv_toast_viewport]` component.
110///
111/// The viewport is the fixed box the toasts stack inside, and it takes no
112/// setting of its own.
113#[derive(Clone, CustomDebug, Default)]
114pub struct EuvToastViewportProps {}
115
116/// Props of the [`euv_toast_close`] component.
117///
118/// The button that dismisses one toast reports the click to the caller,
119/// which owns the queue and decides what dismissing means.
120#[derive(Clone, CustomDebug, Default)]
121pub struct EuvToastCloseProps {
122 /// The callback fired when the button is clicked.
123 #[debug(skip)]
124 pub on_click: Option<Rc<dyn Fn()>>,
125}