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
//! Item component — media + content + actions list row. Sibling to EmptyState
//! and designed for list-row patterns (notifications, search results, file
//! rows). Mirrors shadcn's `Item` base primitive.
//!
//! Composition: wrap rows in [`group`], then compose each row from
//! [`media`] + [`content`] (with [`title`] / [`description`]) + [`actions`].
//! Use [`header`] / [`footer`] / [`separator`] for richer layouts.
use maud::{html, Markup};
/// Visual variant — frame style around the item.
#[derive(Clone, Debug, Default, PartialEq)]
pub enum Variant {
#[default]
Default,
Outline,
Muted,
}
impl Variant {
fn as_class(&self) -> &'static str {
match self {
Variant::Default => "default",
Variant::Outline => "outline",
Variant::Muted => "muted",
}
}
}
/// Density — controls padding + gap.
#[derive(Clone, Debug, Default, PartialEq)]
pub enum Size {
#[default]
Default,
Sm,
Xs,
}
impl Size {
fn as_class(&self) -> &'static str {
match self {
Size::Default => "default",
Size::Sm => "sm",
Size::Xs => "xs",
}
}
}
/// Media sub-variant — hints at whether the media slot hosts an icon, an
/// image, or generic content. Controls sizing inside `.mui-item__media`.
#[derive(Clone, Debug, Default, PartialEq)]
pub enum MediaVariant {
#[default]
Default,
Icon,
Image,
}
impl MediaVariant {
fn as_class(&self) -> &'static str {
match self {
MediaVariant::Default => "default",
MediaVariant::Icon => "icon",
MediaVariant::Image => "image",
}
}
}
/// Item rendering properties.
#[derive(Clone, Debug, Default)]
pub struct Props {
/// Optional DOM id (wire triggers / skip-links to this row).
pub id: Option<String>,
/// Visual variant — frame style.
pub variant: Variant,
/// Density.
pub size: Size,
/// Row contents — typically composed from `media`, `content`, `actions`.
pub children: Markup,
}
/// Render a single item row.
pub fn render(props: Props) -> Markup {
let variant_cls = format!("mui-item--{}", props.variant.as_class());
let size_cls = format!("mui-item--{}", props.size.as_class());
html! {
div class={"mui-item " (variant_cls) " " (size_cls)}
id=[props.id.as_deref()]
data-mui="item"
{
(props.children)
}
}
}
/// Wrap a list of items with consistent spacing.
pub fn group(children: Markup) -> Markup {
html! {
div class="mui-item-group" role="list" {
(children)
}
}
}
/// Media slot — icon, avatar, image, thumbnail.
pub fn media(variant: MediaVariant, children: Markup) -> Markup {
let variant_cls = format!("mui-item__media--{}", variant.as_class());
html! {
div class={"mui-item__media " (variant_cls)} {
(children)
}
}
}
/// Primary textual stack — usually holds [`title`] and [`description`].
pub fn content(children: Markup) -> Markup {
html! {
div class="mui-item__content" {
(children)
}
}
}
/// Item title — styled as a small heading.
pub fn title(children: Markup) -> Markup {
html! {
h3 class="mui-item__title" {
(children)
}
}
}
/// Item description — muted supporting text.
pub fn description(children: Markup) -> Markup {
html! {
p class="mui-item__description" {
(children)
}
}
}
/// Trailing actions slot — buttons, icons, timestamps.
pub fn actions(children: Markup) -> Markup {
html! {
div class="mui-item__actions" {
(children)
}
}
}
/// Optional header strip above the main row.
pub fn header(children: Markup) -> Markup {
html! {
div class="mui-item__header" {
(children)
}
}
}
/// Optional footer strip below the main row.
pub fn footer(children: Markup) -> Markup {
html! {
div class="mui-item__footer" {
(children)
}
}
}
/// Separator between grouped items.
pub fn separator() -> Markup {
html! {
hr class="mui-item__separator";
}
}
/// Showcase all item variants and common composition patterns.
pub fn showcase() -> Markup {
html! {
div.mui-showcase__grid {
section {
h2 { "Item group — three variants" }
p.mui-showcase__caption {
"Default with icon media, Outline with image media, Muted title-only (sm)."
}
(group(html! {
(render(Props {
variant: Variant::Default,
children: html! {
(media(MediaVariant::Icon, html! { "\u{1F4EC}" }))
(content(html! {
(title(html! { "New message from Jane" }))
(description(html! { "Hey — just a heads up that the design doc is ready for review." }))
}))
(actions(html! {
button class="mui-btn mui-btn--outline mui-btn--md" { "Reply" }
}))
},
..Default::default()
}))
(render(Props {
variant: Variant::Outline,
children: html! {
(media(MediaVariant::Image, html! {
div style="width:100%;height:100%;background:linear-gradient(135deg,#2563eb,#60a5fa);" {}
}))
(content(html! {
(title(html! { "Acme Corp launch brief" }))
(description(html! { "Shared folder \u{00b7} 12 files \u{00b7} updated 2h ago" }))
}))
(actions(html! {
button class="mui-btn mui-btn--outline mui-btn--md" { "Open" }
}))
},
..Default::default()
}))
(render(Props {
variant: Variant::Muted,
size: Size::Sm,
children: html! {
(content(html! {
(title(html! { "Drafts (3)" }))
}))
},
..Default::default()
}))
}))
}
section {
h2 { "With header / footer / separator" }
(group(html! {
(render(Props {
variant: Variant::Outline,
children: html! {
(header(html! {
span.mui-text-muted { "Today" }
}))
(media(MediaVariant::Icon, html! { "\u{1F514}" }))
(content(html! {
(title(html! { "Build finished" }))
(description(html! { "kapable-api \u{00b7} blue slot \u{00b7} 00:42 elapsed" }))
}))
(footer(html! {
span.mui-text-subtle { "deploy-daemon" }
}))
},
..Default::default()
}))
(separator())
(render(Props {
variant: Variant::Outline,
size: Size::Xs,
children: html! {
(media(MediaVariant::Icon, html! { "\u{2713}" }))
(content(html! {
(title(html! { "Tests passed" }))
}))
},
..Default::default()
}))
}))
}
}
}
}