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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
use *;
use crate::;
use component_doc;
use card_layout_styles;
/// Groups related content on an Orbital [`Material`] surface.
///
/// # Usage
///
/// Stack parts in document order:
/// 1. [`CardHeader`] — title, description, and optional header action
/// 2. [`CardMedia`] or [`CardPreview`] — hero image or preview region
/// 3. [`CardContent`] — body copy
/// 4. [`CardButtonArea`] — optional whole-card primary action region
/// 5. [`CardFooter`] — independent secondary actions
///
/// Insert [`CardSectionBorder`] between stacked slots when a flush horizontal rule is needed inside the card. Keep spacing on the neighboring slots; the border itself is a zero-padding rule.
///
/// **CardButtonArea vs CardFooter:** Wrap the hero and body in [`CardButtonArea`] when the **entire card** navigates or opens details — one primary click target. Keep footer actions in [`CardFooter`] **outside** the button area so secondary commands (Reply, Share, Cancel) do not share the card-level click handler.
///
/// # Examples
///
/// ## Default (body only)
/// Basic card with body content on a solid surface at resting elevation.
/// <!-- default -->
/// <!-- preview -->
/// ```rust
/// use crate::{Card, CardContent};
/// use turf::inline_style_sheet_values;
/// view! {
/// <div data-testid="card-preview" style="max-width: 360px;">
/// {
/// let (style_sheet, class_names) = inline_style_sheet_values! {
/// .PaddedContent {
/// --orbital-card-content-padding: 16px;
/// }
/// };
/// view! {
/// <style>{style_sheet}</style>
/// <Card>
/// <CardContent class=class_names.padded_content>
/// "Card body content"
/// </CardContent>
/// </Card>
/// }
/// }
/// </div>
/// }
/// ```
///
/// ## Full compound
/// Header, image hero, body, and footer actions in one card.
/// <!-- preview -->
/// ```rust
/// use crate::{
/// Button, ButtonAppearance, Card, CardContent, CardFooter, CardHeader,
/// CardHeaderAction, CardHeaderDescription, CardMedia, Subtitle1,
/// };
/// view! {
/// <div data-testid="card-compound-preview" style="max-width: 360px;">
/// <Card>
/// <CardHeader>
/// <Subtitle1>"Team workspace"</Subtitle1>
/// <CardHeaderDescription slot>
/// <span>"Shared files and tasks"</span>
/// </CardHeaderDescription>
/// <CardHeaderAction slot>
/// <Button appearance=ButtonAppearance::Transparent icon=icondata::AiMoreOutlined />
/// </CardHeaderAction>
/// </CardHeader>
/// <CardMedia
/// src="https://picsum.photos/seed/orbital-card/360/140"
/// alt="Sample card illustration"
/// height=140
/// />
/// <CardContent>"Card body copy."</CardContent>
/// <CardFooter>
/// <Button>"Reply"</Button>
/// <Button appearance=ButtonAppearance::Secondary>"Share"</Button>
/// </CardFooter>
/// </Card>
/// </div>
/// }
/// ```
///
/// ## With header
/// Title header and body content regions.
/// <!-- preview -->
/// ```rust
/// use crate::{Card, CardContent, CardHeader, Subtitle1};
/// view! {
/// <div data-testid="card-with-header" style="max-width: 360px;">
/// <Card>
/// <CardHeader>
/// <Subtitle1>"Overview"</Subtitle1>
/// </CardHeader>
/// <CardContent>"Metrics and summary content."</CardContent>
/// </Card>
/// </div>
/// }
/// ```
///
/// ## Media card
/// Photo hero with body copy and footer actions.
/// <!-- preview -->
/// ```rust
/// use crate::{Button, ButtonAppearance, Card, CardContent, CardFooter, CardMedia};
/// view! {
/// <div data-testid="card-media-preview" style="max-width: 360px;">
/// <Card>
/// <CardMedia
/// src="https://picsum.photos/seed/orbital-card/360/140"
/// alt="Sample card illustration"
/// height=140
/// />
/// <CardContent>"Lizards are a widespread group of squamate reptiles."</CardContent>
/// <CardFooter>
/// <Button>"Share"</Button>
/// <Button appearance=ButtonAppearance::Secondary>"Learn More"</Button>
/// </CardFooter>
/// </Card>
/// </div>
/// }
/// ```
///
/// ## Interactive media card
/// Primary click region wraps media and body; footer actions stay outside.
/// <!-- preview -->
/// ```rust
/// use leptos::prelude::*;
/// use crate::{Button, Card, CardButtonArea, CardContent, CardFooter, CardMedia};
/// let clicked = RwSignal::new(false);
/// view! {
/// <div data-testid="card-button-area-preview" style="max-width: 360px;">
/// <Card>
/// <CardButtonArea on_click=Callback::new(move |_| {
/// clicked.set(true);
/// #[cfg(target_arch = "wasm32")]
/// if let Some(window) = web_sys::window() {
/// let _ = window.alert_with_message("Card clicked!");
/// }
/// })>
/// <CardMedia
/// src="https://picsum.photos/seed/orbital-card/360/140"
/// alt="Sample card illustration"
/// height=140
/// />
/// <CardContent>
/// {move || if clicked.get() { "Card clicked!" } else { "Tap the card body to open details." }}
/// </CardContent>
/// </CardButtonArea>
/// <CardFooter>
/// <Button on:click=|ev| { ev.stop_propagation(); }>"Share"</Button>
/// </CardFooter>
/// </Card>
/// </div>
/// }
/// ```
///
/// ## Custom hero
/// Arbitrary preview content above the card body.
/// <!-- preview -->
/// ```rust
/// use crate::{Card, CardContent, CardPreview};
/// view! {
/// <div data-testid="card-custom-hero-preview" style="max-width: 360px;">
/// <Card>
/// <CardPreview>
/// <div style="height: 120px; background: var(--orb-color-surface-subtle); display: flex; align-items: center; justify-content: center;">
/// "Custom hero"
/// </div>
/// </CardPreview>
/// <CardContent>"Body below custom hero."</CardContent>
/// </Card>
/// </div>
/// }
/// ```
///
/// ## Raised elevation
/// Emphasized card surface using raised elevation.
/// <!-- preview -->
/// ```rust
/// use crate::{Card, CardContent, MaterialElevation};
/// use turf::inline_style_sheet_values;
/// view! {
/// <div data-testid="card-raised" style="max-width: 360px;">
/// {
/// let (style_sheet, class_names) = inline_style_sheet_values! {
/// .PaddedContent {
/// --orbital-card-content-padding: 16px;
/// }
/// };
/// view! {
/// <style>{style_sheet}</style>
/// <Card elevation=MaterialElevation::Raised>
/// <CardContent class=class_names.padded_content>
/// "Hero card content"
/// </CardContent>
/// </Card>
/// }
/// }
/// </div>
/// }
/// ```
///
/// ## Outlined
/// Flat bordered card surface with no shadow.
/// <!-- preview -->
/// ```rust
/// use crate::{Card, CardContent, MaterialElevation, MaterialVariant};
/// use turf::inline_style_sheet_values;
/// view! {
/// <div data-testid="card-outlined" style="max-width: 360px;">
/// {
/// let (style_sheet, class_names) = inline_style_sheet_values! {
/// .PaddedContent {
/// --orbital-card-content-padding: 16px;
/// }
/// };
/// view! {
/// <style>{style_sheet}</style>
/// <Card variant=MaterialVariant::Outlined elevation=MaterialElevation::Flat>
/// <CardContent class=class_names.padded_content>
/// "Outlined card content"
/// </CardContent>
/// </Card>
/// }
/// }
/// </div>
/// }
/// ```