1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
use super::*;
/// A modal demo page showcasing different modal variations.
///
/// # Returns
///
/// - `VirtualNode` - The modal demo page virtual DOM tree.
#[component]
pub(crate) fn page_modal(node: VirtualNode<PageModalProps>) -> VirtualNode {
let PageModalProps: PageModalProps = node.try_get_props().unwrap_or_default();
let state: UseModal = use_modal();
html! {
div {
class: c_page_container()
euv_header {
icon: "💬"
title: "Modal Dialog"
subtitle: "Overlay dialogs with different content patterns: basic text, confirmation, form input, and nested stacking with back-gesture support."
}
euv_card {
title: "Basic Modal"
p {
class: c_demo_text()
"A simple modal with static text content. Click the close button or the overlay backdrop to dismiss."
}
div {
class: c_button_controls()
euv_button {
variant: EuvButtonVariant::Primary
label: "Open"
onclick: modal_on_open_basic(state)
}
}
}
euv_card {
title: "Confirm Modal"
p {
class: c_demo_text()
"A modal that requires the user to confirm or cancel an action. The result is displayed below the button."
}
div {
class: c_button_controls()
euv_button {
variant: EuvButtonVariant::Primary
label: "Open"
onclick: modal_on_open_confirm(state)
}
}
if { !state.get_confirm_result().get().is_empty() } {
euv_alert {
variant: AlertVariant::Success
state.get_confirm_result()
}
}
}
euv_card {
title: "Form Modal"
p {
class: c_demo_text()
"A modal containing validated form inputs. Submission is blocked until all validation rules pass."
}
div {
class: c_button_controls()
euv_button {
variant: EuvButtonVariant::Primary
label: "Open"
onclick: modal_on_open_form(state)
}
}
if { !state.get_modal_submitted().get().is_empty() } {
euv_alert {
variant: AlertVariant::Success
state.get_modal_submitted()
}
}
}
euv_card {
title: "Nested Modals"
p {
class: c_demo_text()
"Three stacked modal layers. The system back gesture closes them one at a time, newest first."
}
div {
class: c_button_controls()
euv_button {
variant: EuvButtonVariant::Primary
label: "Open"
onclick: modal_on_open_nested_1(state)
}
}
}
if { state.get_show_basic().get() } {
euv_modal {
title: "Basic Modal"
onclick: modal_dismiss_handler(state.get_show_basic())
p {
class: c_demo_text()
"This is a basic modal dialog. Click the close button or the overlay to dismiss."
}
p {
class: c_demo_text_muted()
"Modals are useful for displaying focused content that requires user attention."
}
}
}
if { state.get_show_confirm().get() } {
euv_modal {
title: "Confirm Action"
onclick: modal_dismiss_handler(state.get_show_confirm())
p {
class: c_demo_text()
"Are you sure you want to proceed with this action?"
}
div {
class: c_modal_actions()
euv_button {
variant: EuvButtonVariant::Primary
label: "Confirm"
onclick: modal_on_confirm(state)
}
euv_button {
variant: EuvButtonVariant::Primary
label: "Cancel"
onclick: modal_on_cancel_confirm(state)
}
}
}
}
if { state.get_show_form().get() } {
euv_modal {
title: "Quick Sign Up"
onclick: modal_dismiss_handler(state.get_show_form())
euv_field {
id: MODAL_NAME_ID
name: MODAL_NAME_NAME
label: "Name"
input_type: MODAL_TEXT_TYPE
placeholder: MODAL_NAME_PLACEHOLDER
autocomplete: MODAL_AUTOCOMPLETE_NAME
value: state.get_modal_name()
error: Some(state.get_name_error())
oninput: modal_on_input_name(state)
}
euv_field {
id: MODAL_EMAIL_ID
name: MODAL_EMAIL_NAME
label: "Email"
input_type: MODAL_EMAIL_TYPE
placeholder: MODAL_EMAIL_PLACEHOLDER
autocomplete: MODAL_AUTOCOMPLETE_EMAIL
value: state.get_modal_email()
error: Some(state.get_email_error())
oninput: modal_on_input_email(state)
}
if { !state.get_modal_error().get().is_empty() } {
euv_alert {
variant: AlertVariant::Error
state.get_modal_error()
}
}
div {
class: c_modal_actions()
euv_button {
variant: EuvButtonVariant::Primary
label: "Submit"
onclick: modal_on_form_submit(state)
}
euv_button {
variant: EuvButtonVariant::Primary
label: "Cancel"
onclick: modal_on_cancel_form(state)
}
}
}
}
if { state.get_show_nested_1().get() } {
euv_modal {
title: "Nested Modal · Layer 1"
onclick: modal_dismiss_handler(state.get_show_nested_1())
p {
class: c_demo_text()
"This is the first layer. Open another modal on top of it."
}
p {
class: c_demo_text_muted()
"Use the system back gesture to close the topmost layer first."
}
div {
class: c_modal_actions()
euv_button {
variant: EuvButtonVariant::Primary
label: "Open Layer 2"
onclick: modal_on_open_nested_2(state)
}
}
}
}
if { state.get_show_nested_2().get() } {
euv_modal {
title: "Nested Modal · Layer 2"
onclick: modal_dismiss_handler(state.get_show_nested_2())
p {
class: c_demo_text()
"This is the second layer, stacked over layer 1."
}
div {
class: c_modal_actions()
euv_button {
variant: EuvButtonVariant::Primary
label: "Open Layer 3"
onclick: modal_on_open_nested_3(state)
}
}
}
}
if { state.get_show_nested_3().get() } {
euv_modal {
title: "Nested Modal · Layer 3"
onclick: modal_dismiss_handler(state.get_show_nested_3())
p {
class: c_demo_text()
"This is the third and innermost layer."
}
p {
class: c_demo_text_muted()
"Press back three times: layer 3, then 2, then 1 close in order before leaving the page."
}
}
}
}
}
}