BlueGit

ict rusty-teams

Files

rusty-teams / crates / app / src / views / message_row.rs

message_row.rs

message_row.rs 23.2 KiB Download Raw
1use gpui_kit::assets::IconName;
2use gpui_kit::component::{Icon, h_flex, v_flex};
3use gpui_kit::prelude::FluentBuilder as _;
4use gpui_kit::*;
5use std::time::Duration;
6
7use super::adaptive_card::cards_view;
8use super::attachments::{FileActions, ImageActions, attachments_view, message_body};
9use super::avatar::{bot_avatar, person_avatar};
10use super::call_card::{CallActions, call_card_row};
11use super::jumbo_emoji::jumbo_row;
12use super::link_preview::{link_preview_card, meeting_join_chip};
13use super::message_actions::{MessageMenu, message_toolbar};
14use super::profile_card::opens_profile;
15use super::reaction_picker::PickHandler;
16use super::reaction_pills::{ReactionControls, reaction_pills};
17use super::reaction_proposal_pill::{ReactionPill, reaction_pill};
18use super::scheduled_toolbar::{ScheduledMenu, scheduled_toolbar};
19use super::toolbar_placement::{HoverChange, TimelineBounds, placed_toolbar};
20use super::translation_line::{TranslationActions, translation_line};
21use super::widgets::{icon, symbol};
22use crate::agents::{AgentRun, run_chip};
23use crate::card_state::BotIdentity;
24use crate::data::Directory;
25use crate::render::Block;
26use crate::restorable_deletes::{DELETED_TOMBSTONE, UNDO_DELETE_LABEL};
27use crate::rows::{Delivery, MessageRow, Receipt, ScheduledState, Skeleton, bubble_corners};
28use crate::sidebar_model::DELETED_PREVIEW;
29use crate::theme;
30use app_ui_kit::layout::ROW_PADDING;
31
32pub type RowAction = Option<Box<dyn Fn(&mut App)>>;
33pub type SharedRowAction = Option<std::rc::Rc<dyn Fn(&mut App)>>;
34
35pub const BUBBLE_TAGS: [&str; 12] = [
36 "message-bubble/0",
37 "message-bubble/1",
38 "message-bubble/2",
39 "message-bubble/3",
40 "message-bubble/4",
41 "message-bubble/5",
42 "message-bubble/6",
43 "message-bubble/7",
44 "message-bubble/8",
45 "message-bubble/9",
46 "message-bubble/10",
47 "message-bubble/11",
48];
49pub(super) const AVATAR_SIZE: f32 = 28.;
50pub(super) const AVATAR_GAP: f32 = 8.;
51const SERIES_START_GAP: f32 = 8.;
52pub(super) const BODY_SIZE: f32 = 13.5;
53const MAX_WIDTH_RATIO: f32 = 0.7;
54const NARROW_BUBBLE_WIDTH: f32 = 300.;
55const BUBBLE_PADDING_Y: f32 = 8.;
56const META_BOTTOM_INSET: f32 = 4.;
57const META_SIZE: f32 = 11.;
58const META_CHECK_SIZE: f32 = 15.;
59const SAVED_MARK_SIZE: f32 = 12.;
60const FORWARDED_SIZE: f32 = 11.;
61const FIGURE_SPACE_WIDTH: f32 = 7.4;
62const PULSE_PERIOD: Duration = Duration::from_millis(1600);
63const RECEIPT_FADE_PERIOD: Duration = Duration::from_millis(600);
64const SKELETON_LINE_HEIGHT: f32 = 20.;
65
66pub struct DeliveryActions {
67 pub retry: RowAction,
68 pub delete: RowAction,
69 pub send_now: RowAction,
70}
71
72pub struct RowActions {
73 pub bot: Option<BotIdentity>,
74 pub delivery: DeliveryActions,
75 pub reply: RowAction,
76 pub hovered: Option<HoverChange>,
77 pub menu: Option<MessageMenu>,
78 pub scheduled_menu: Option<ScheduledMenu>,
79 pub react: Option<PickHandler>,
80 pub reaction_controls: Option<ReactionControls>,
81 pub files: Option<FileActions>,
82 pub open_image: Option<ImageActions>,
83 pub highlighted: bool,
84 pub saved: bool,
85 pub pinned: bool,
86 pub translation: Option<TranslationActions>,
87 pub timeline: TimelineBounds,
88 pub agent_run: Option<AgentRun>,
89 pub call: CallActions,
90 pub reaction_proposal: Option<ReactionPill>,
91 pub undo_delete: SharedRowAction,
92}
93
94const TOOLBAR_RIGHT_INSET: f32 = 0.;
95
96fn separator_pill(label: &str, fill: Hsla, text_color: Hsla) -> Div {
97 h_flex()
98 .w_full()
99 .justify_center()
100 .mt(px(12.))
101 .mb(px(6.))
102 .child(
103 div()
104 .h(px(24.))
105 .px(px(8.))
106 .flex()
107 .items_center()
108 .rounded(px(12.))
109 .bg(fill)
110 .text_size(px(11.))
111 .text_color(text_color)
112 .child(label.to_owned()),
113 )
114}
115
116pub(super) fn day_separator(label: &str) -> Div {
117 separator_pill(label, theme::row_hover(), theme::text_muted())
118}
119
120pub(super) fn new_marker() -> Div {
121 separator_pill(
122 "New",
123 theme::mention_background(false),
124 theme::accent_text(),
125 )
126}
127
128pub(super) fn deleted_tombstone(index: usize, undo_delete: SharedRowAction) -> Div {
129 let line =
130 h_flex()
131 .gap(px(8.))
132 .items_baseline()
133 .text_size(px(13.))
134 .child(div().italic().text_color(theme::text_muted()).child(
135 if undo_delete.is_some() {
136 DELETED_TOMBSTONE
137 } else {
138 DELETED_PREVIEW
139 },
140 ));
141 match undo_delete {
142 Some(undo) => line.child(
143 div()
144 .id(ElementId::Name(format!("undo-delete-{index}").into()))
145 .cursor_pointer()
146 .font_weight(FontWeight::SEMIBOLD)
147 .text_color(theme::accent_text())
148 .hover(|link| link.underline())
149 .child(UNDO_DELETE_LABEL)
150 .on_click(move |_, _, cx| undo(cx)),
151 ),
152 None => line,
153 }
154}
155
156fn bubble_max_width(timeline: &TimelineBounds, reserved: f32) -> Length {
157 let Some(bounds) = timeline.get() else {
158 return relative(MAX_WIDTH_RATIO).into();
159 };
160 let row_width = (f32::from(bounds.size.width) - 2. * ROW_PADDING - reserved).max(0.);
161 px((row_width * MAX_WIDTH_RATIO).max(row_width.min(NARROW_BUBBLE_WIDTH))).into()
162}
163
164fn bubble(
165 row: &MessageRow,
166 index: usize,
167 own: bool,
168 directory: &Directory,
169 extras: BubbleExtras,
170 cx: &App,
171) -> Stateful<Div> {
172 let corners = bubble_corners(own, row.series);
173 let jumbo = row.jumbo.as_deref().filter(|_| {
174 !row.deleted && matches!(row.delivery, Delivery::Delivered | Delivery::Sending)
175 });
176 let mut element = div()
177 .id(ElementId::Name(format!("bubble-{index}").into()))
178 .when_some(extras.hover.clone(), |element, hover| {
179 element.on_hover(move |is_hovered, _, cx| hover(*is_hovered, cx))
180 })
181 .relative()
182 .max_w_full()
183 .when_some(BUBBLE_TAGS.get(index).copied(), |element, tag| {
184 element.debug_selector(|| tag.into())
185 })
186 .when(jumbo.is_none(), |element| {
187 element
188 .rounded_tl(px(corners.top_left))
189 .rounded_tr(px(corners.top_right))
190 .rounded_br(px(corners.bottom_right))
191 .rounded_bl(px(corners.bottom_left))
192 .px(px(12.))
193 .py(px(BUBBLE_PADDING_Y))
194 })
195 .text_size(px(BODY_SIZE))
196 .line_height(relative(1.45));
197 if row.deleted {
198 return element
199 .border_1()
200 .border_color(theme::border_strong())
201 .py(px(6.))
202 .child(deleted_tombstone(index, extras.undo_delete));
203 }
204 let failed = matches!(row.delivery, Delivery::Failed(_));
205 let scheduled = matches!(row.delivery, Delivery::Scheduled(_));
206 element = element
207 .when(!scheduled && jumbo.is_none(), |bubble| {
208 bubble.bg(if own && !failed {
209 theme::bubble_own()
210 } else {
211 theme::bubble_other()
212 })
213 })
214 .when(failed, |bubble| {
215 bubble.border_1().border_color(theme::red())
216 })
217 .when(scheduled, |bubble| {
218 bubble.border_1().border_color(
219 if row.delivery == Delivery::Scheduled(ScheduledState::DeliveryFailed) {
220 theme::red()
221 } else {
222 theme::accent()
223 },
224 )
225 });
226 let has_reactions = !row.reactions.is_empty();
227 let saved = extras.saved;
228 let mut content = v_flex().gap(px(6.));
229 if row.forwarded {
230 content = content.child(forwarded_header());
231 }
232 let attachments = attachments_view(
233 &row.blocks,
234 &row.images,
235 &row.local_images,
236 &row.files,
237 &format!("message-{index}"),
238 directory,
239 extras.files.as_ref(),
240 extras.open_image.as_ref(),
241 );
242 let cards = cards_view(&row.adaptive_cards, &row.conversation_id, &row.key, cx);
243 let trailing_content = attachments.is_some()
244 || row.meeting_link.is_some()
245 || row.link_preview.is_some()
246 || !cards.is_empty();
247 let padded_blocks = if has_reactions || trailing_content || jumbo.is_some() {
248 None
249 } else {
250 with_meta_room(&row.blocks, meta_room(row, own, saved))
251 };
252 let meta_inline = has_text(row) && padded_blocks.is_some();
253 if let Some(jumbo) = jumbo {
254 content = content.child(jumbo_row(&row.key, jumbo, own));
255 } else if has_text(row) {
256 content = content.children(message_body(
257 padded_blocks.as_deref().unwrap_or(&row.blocks),
258 &row.images,
259 &row.local_images,
260 &format!("message-{index}"),
261 own,
262 directory,
263 extras.open_image.as_ref(),
264 cx,
265 ));
266 }
267 content = content.children(attachments);
268 content = content.children(
269 row.meeting_link
270 .clone()
271 .map(|url| meeting_join_chip(format!("message-{index}-join"), url)),
272 );
273 content = content.children(row.link_preview.as_ref().map(|preview| {
274 link_preview_card(
275 preview,
276 format!("message-{index}-link"),
277 directory,
278 false,
279 None,
280 )
281 }));
282 content = content.children(cards);
283 if has_reactions {
284 content = content.child(
285 h_flex()
286 .gap(px(8.))
287 .items_end()
288 .child(
289 reaction_pills(
290 &row.reactions,
291 index,
292 own,
293 directory,
294 extras.react.clone(),
295 extras.controls.as_ref(),
296 )
297 .flex_auto(),
298 )
299 .child(
300 h_flex()
301 .flex_none()
302 .mb(px(META_BOTTOM_INSET - BUBBLE_PADDING_Y))
303 .child(bubble_meta(row, own, saved)),
304 ),
305 );
306 } else if !meta_inline {
307 content = content.child(h_flex().justify_end().child(bubble_meta(row, own, saved)));
308 }
309 element = element.child(content);
310 if meta_inline {
311 element = element.child(
312 div()
313 .absolute()
314 .right(px(8.))
315 .bottom(px(META_BOTTOM_INSET))
316 .child(bubble_meta(row, own, saved)),
317 );
318 }
319 if let Some(menu) = extras.menu {
320 element = element.child(placed_toolbar(
321 message_toolbar(menu, cx),
322 extras.timeline.clone(),
323 TOOLBAR_RIGHT_INSET,
324 ));
325 }
326 if let Some(menu) = extras.scheduled_menu {
327 element = element.child(placed_toolbar(
328 scheduled_toolbar(menu),
329 extras.timeline.clone(),
330 TOOLBAR_RIGHT_INSET,
331 ));
332 }
333 element
334}
335
336#[derive(Default)]
337struct BubbleExtras {
338 hover: Option<HoverChange>,
339 menu: Option<MessageMenu>,
340 scheduled_menu: Option<ScheduledMenu>,
341 react: Option<PickHandler>,
342 controls: Option<ReactionControls>,
343 files: Option<FileActions>,
344 open_image: Option<ImageActions>,
345 saved: bool,
346 translation: Option<TranslationActions>,
347 timeline: TimelineBounds,
348 agent_run: Option<AgentRun>,
349 reaction_proposal: Option<ReactionPill>,
350 undo_delete: SharedRowAction,
351}
352
353fn agent_chip(run: Option<AgentRun>) -> Option<Div> {
354 run.map(|run| div().py(px(2.)).child(run_chip(&run, theme::row_hover())))
355}
356
357pub(super) fn forwarded_header() -> Div {
358 h_flex()
359 .gap(px(4.))
360 .items_center()
361 .text_size(px(FORWARDED_SIZE))
362 .text_color(theme::text_muted())
363 .child(icon(IconName::Forward, FORWARDED_SIZE, theme::text_muted()))
364 .child("Forwarded")
365}
366
367fn bubble_meta(row: &MessageRow, own: bool, saved: bool) -> Div {
368 let tint = if own {
369 theme::own_meta()
370 } else {
371 theme::text_muted()
372 };
373 h_flex()
374 .gap(px(4.))
375 .items_center()
376 .text_size(px(META_SIZE))
377 .line_height(px(14.))
378 .italic()
379 .text_color(tint)
380 .when(row.edited, |meta| meta.child("Edited"))
381 .when(saved, |meta| {
382 meta.child(icon(
383 IconName::Bookmark,
384 SAVED_MARK_SIZE,
385 theme::accent_text(),
386 ))
387 })
388 .child(row.time.clone())
389 .when(own && row.delivery == Delivery::Sending, |meta| {
390 meta.child(symbol("schedule", META_CHECK_SIZE, tint))
391 })
392 .when(matches!(row.delivery, Delivery::Scheduled(_)), |meta| {
393 meta.child(symbol("schedule", META_SIZE + 3., tint))
394 })
395 .when(
396 own && row.delivery == Delivery::Delivered,
397 |meta| match row.receipt {
398 Receipt::Hidden => meta,
399 Receipt::Sent => meta.child(on_baseline(symbol("done", META_CHECK_SIZE, tint))),
400 Receipt::Read => meta.child(on_baseline(symbol(
401 "done_all",
402 META_CHECK_SIZE,
403 theme::own_read(),
404 ))),
405 Receipt::ReadLive => meta.child(receipt_fade_in(
406 &row.key,
407 on_baseline(symbol("done_all", META_CHECK_SIZE, theme::own_read())),
408 )),
409 },
410 )
411}
412
413fn on_baseline(check: Icon) -> Div {
414 div().relative().top(px(1.)).child(check)
415}
416
417fn pulse<E: IntoElement + Styled + 'static>(id: &'static str, element: E) -> AnimationElement<E> {
418 element.with_animation(
419 id,
420 Animation::new(PULSE_PERIOD)
421 .repeat_synced()
422 .with_easing(pulsating_between(0.35, 1.)),
423 |element, opacity| element.opacity(opacity),
424 )
425}
426
427fn receipt_fade_in(message_key: &str, check: Div) -> AnimationElement<Div> {
428 check.with_animation(
429 SharedString::from(format!("receipt-fade/{message_key}")),
430 Animation::new(RECEIPT_FADE_PERIOD).with_easing(ease_in_out),
431 |check, delta| check.opacity(0.25 + 0.75 * delta),
432 )
433}
434
435pub fn render_skeleton_row(skeleton: &Skeleton, index: usize) -> AnyElement {
436 let corners = bubble_corners(skeleton.own, Default::default());
437 let height = 14. + SKELETON_LINE_HEIGHT * f32::from(skeleton.lines);
438 let shape = div()
439 .w(relative(skeleton.width_ratio))
440 .h(px(height))
441 .rounded_tl(px(corners.top_left))
442 .rounded_tr(px(corners.top_right))
443 .rounded_br(px(corners.bottom_right))
444 .rounded_bl(px(corners.bottom_left))
445 .bg(if skeleton.own {
446 theme::bubble_own().opacity(0.55)
447 } else {
448 theme::bubble_other()
449 });
450 let line = h_flex()
451 .w_full()
452 .when(skeleton.own, |line| line.justify_end())
453 .when(!skeleton.own, |line| {
454 line.gap(px(AVATAR_GAP)).child(
455 div()
456 .size(px(AVATAR_SIZE))
457 .flex_none()
458 .rounded_full()
459 .bg(theme::bubble_other()),
460 )
461 })
462 .child(shape);
463 div()
464 .id(ElementId::Name(format!("row-{index}").into()))
465 .w_full()
466 .px(px(ROW_PADDING))
467 .pt(px(SERIES_START_GAP))
468 .child(pulse("skeleton", line))
469 .into_any_element()
470}
471
472fn meta_room(row: &MessageRow, own: bool, saved: bool) -> usize {
473 let mut width = 12. + row.time.chars().count() as f32 * 6.;
474 if saved {
475 width += SAVED_MARK_SIZE + 4.;
476 }
477 if row.edited {
478 width += 56.;
479 }
480 if own {
481 width += META_CHECK_SIZE + 4.;
482 }
483 (width / FIGURE_SPACE_WIDTH).ceil() as usize
484}
485
486fn with_meta_room(blocks: &[Block], room: usize) -> Option<Vec<Block>> {
487 let mut padded = blocks.to_vec();
488 let inline = padded.last_mut()?.last_inline_mut()?;
489 *inline = inline.with_trailing_room(room);
490 Some(padded)
491}
492
493pub(super) fn has_text(row: &MessageRow) -> bool {
494 !row.blocks.is_empty()
495 || (row.images.is_empty()
496 && row.local_images.is_empty()
497 && row.files.is_empty()
498 && row.adaptive_cards.is_empty())
499}
500
501fn delivery_link(
502 index: usize,
503 name: &str,
504 label: &'static str,
505 action: RowAction,
506) -> Stateful<Div> {
507 div()
508 .id(ElementId::Name(format!("{name}-{index}").into()))
509 .cursor_pointer()
510 .text_color(theme::red_tint())
511 .underline()
512 .child(label)
513 .when_some(action, |link, action| {
514 link.on_click(move |_, _, cx| action(cx))
515 })
516}
517
518pub(super) fn delivery_note(
519 row: &MessageRow,
520 delivery: DeliveryActions,
521 index: usize,
522) -> Option<AnyElement> {
523 let DeliveryActions {
524 retry,
525 delete,
526 send_now,
527 } = delivery;
528 let note = |text: &'static str| {
529 h_flex()
530 .gap(px(4.))
531 .text_size(px(11.))
532 .text_color(theme::red_soft())
533 .child(text)
534 };
535 match &row.delivery {
536 Delivery::Delivered | Delivery::Sending | Delivery::Scheduled(ScheduledState::Waiting) => {
537 None
538 }
539 Delivery::Failed(_) => Some(
540 note("Failed to send.")
541 .child(delivery_link(index, "retry", "Retry", retry))
542 .child(delivery_link(index, "delete", "Delete", delete))
543 .into_any_element(),
544 ),
545 Delivery::Scheduled(ScheduledState::DeliveryFailed) => Some(
546 note("Couldn't send at the scheduled time.")
547 .child(delivery_link(index, "send-now", "Send now", send_now))
548 .child(delivery_link(index, "delete", "Delete", delete))
549 .into_any_element(),
550 ),
551 Delivery::Scheduled(ScheduledState::ChangeFailed) => Some(
552 note("Couldn't change the scheduled message.")
553 .child(delivery_link(index, "retry", "Retry", retry))
554 .into_any_element(),
555 ),
556 }
557}
558
559fn others_row(
560 row: &MessageRow,
561 index: usize,
562 directory: &Directory,
563 bot: Option<&BotIdentity>,
564 delivery: DeliveryActions,
565 mut extras: BubbleExtras,
566 cx: &App,
567) -> Div {
568 let translation = extras.translation.take();
569 let agent_run = extras.agent_run.take();
570 let reaction_proposal = extras.reaction_proposal.take();
571 let first = !row.series.has_prev;
572 let author = bot.map_or_else(|| row.author.clone(), |bot| bot.name.clone());
573 let profile_user = row.sender_id.as_deref().filter(|_| bot.is_none());
574 let mut column = v_flex()
575 .gap(px(2.))
576 .flex_1()
577 .min_w_0()
578 .max_w(bubble_max_width(&extras.timeline, AVATAR_SIZE + AVATAR_GAP))
579 .items_start();
580 if first {
581 column = column.child(
582 h_flex().gap(px(8.)).items_baseline().pl(px(2.)).child(
583 opens_profile(
584 div().id(ElementId::Name(format!("author-{index}").into())),
585 profile_user,
586 )
587 .text_size(px(12.))
588 .font_weight(FontWeight::SEMIBOLD)
589 .text_color(theme::text_soft())
590 .child(author.clone()),
591 ),
592 );
593 }
594 column = column.child(bubble(row, index, false, directory, extras, cx));
595 column = column.children(agent_chip(agent_run));
596 column = column.children(reaction_proposal.map(|pill| reaction_pill(pill, &row.key)));
597 column = column.children(translation_line(row, index, translation.as_ref()));
598 if let Some(note) = delivery_note(row, delivery, index) {
599 column = column.child(note);
600 }
601 let lead = if let Some(bot) = bot.filter(|_| first) {
602 bot_avatar(bot, AVATAR_SIZE)
603 } else if first {
604 person_avatar(
605 directory,
606 row.sender_id.as_deref(),
607 &row.author,
608 AVATAR_SIZE,
609 )
610 } else {
611 div().size(px(AVATAR_SIZE)).into_any_element()
612 };
613 h_flex()
614 .w_full()
615 .gap(px(AVATAR_GAP))
616 .items_start()
617 .child(
618 opens_profile(
619 div().id(ElementId::Name(format!("author-avatar-{index}").into())),
620 profile_user.filter(|_| first),
621 )
622 .w(px(AVATAR_SIZE))
623 .flex_none()
624 .child(lead),
625 )
626 .child(column)
627}
628
629fn own_row(
630 row: &MessageRow,
631 index: usize,
632 directory: &Directory,
633 delivery: DeliveryActions,
634 mut extras: BubbleExtras,
635 cx: &App,
636) -> Div {
637 let translation = extras.translation.take();
638 let agent_run = extras.agent_run.take();
639 let reaction_proposal = extras.reaction_proposal.take();
640 let mut column = v_flex().w_full().items_end().gap(px(2.));
641 column = column.child(
642 h_flex().w_full().justify_end().child(
643 div()
644 .min_w_0()
645 .max_w(bubble_max_width(&extras.timeline, 0.))
646 .child(bubble(row, index, true, directory, extras, cx)),
647 ),
648 );
649 column = column.children(agent_chip(agent_run));
650 column = column.children(reaction_proposal.map(|pill| reaction_pill(pill, &row.key)));
651 column = column.children(translation_line(row, index, translation.as_ref()));
652 if let Some(note) = delivery_note(row, delivery, index) {
653 column = column.child(note);
654 }
655 column
656}
657
658pub fn render_message_row(
659 row: &MessageRow,
660 index: usize,
661 actions: RowActions,
662 directory: &Directory,
663 cx: &App,
664) -> AnyElement {
665 if let Some(call) = &row.call {
666 return call_card_row(row, call, index, directory, actions.call);
667 }
668 let RowActions {
669 bot,
670 delivery,
671 reply,
672 hovered,
673 menu,
674 scheduled_menu,
675 react,
676 reaction_controls,
677 files,
678 open_image,
679 highlighted,
680 saved,
681 translation,
682 timeline,
683 agent_run,
684 call: _,
685 pinned: _,
686 reaction_proposal,
687 undo_delete,
688 } = actions;
689 let extras = BubbleExtras {
690 hover: hovered,
691 menu,
692 scheduled_menu,
693 react,
694 controls: reaction_controls,
695 files,
696 open_image,
697 saved,
698 translation,
699 timeline,
700 agent_run,
701 reaction_proposal,
702 undo_delete,
703 };
704 let own = row.own;
705 let spacing = if row.series.has_prev {
706 px(2.)
707 } else {
708 px(SERIES_START_GAP)
709 };
710 let mut container = v_flex().w_full().px(px(ROW_PADDING));
711 if let Some(day) = &row.day_header {
712 container = container.child(day_separator(day));
713 }
714 if row.new_marker {
715 container = container.child(new_marker());
716 }
717 let body = if own {
718 own_row(row, index, directory, delivery, extras, cx)
719 } else {
720 others_row(row, index, directory, bot.as_ref(), delivery, extras, cx)
721 };
722 container
723 .child(
724 div()
725 .id(ElementId::Name(format!("row-{index}").into()))
726 .w_full()
727 .pt(spacing)
728 .when_some(reply, |element, reply| {
729 element.on_mouse_down(MouseButton::Right, move |_, _, cx| reply(cx))
730 })
731 .child(
732 div()
733 .w_full()
734 .rounded(px(10.))
735 .when(highlighted, |element| {
736 element.bg(theme::accent().opacity(0.2))
737 })
738 .child(body),
739 ),
740 )
741 .into_any_element()
742}