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