mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-11 04:36:24 +00:00
Improve mention visibility by adding a background color (#7014)
When the chat if going fast, It's hard to see who is mentioning you, so this feature will make it more clear by the UI instead of needing to read all the messages. <img width="242" alt="Screenshot 2024-01-29 at 21 19 07" src="https://github.com/zed-industries/zed/assets/62463826/65ec307d-5027-4ead-9568-854fc746c822"> Release Notes: - Added background to messages that mention you.
This commit is contained in:
parent
e5c4c8522b
commit
30b9cef5ba
1 changed files with 70 additions and 58 deletions
|
@ -8,8 +8,9 @@ use db::kvp::KEY_VALUE_STORE;
|
||||||
use editor::Editor;
|
use editor::Editor;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, div, list, prelude::*, px, Action, AppContext, AsyncWindowContext, DismissEvent,
|
actions, div, list, prelude::*, px, Action, AppContext, AsyncWindowContext, DismissEvent,
|
||||||
ElementId, EventEmitter, FocusHandle, FocusableView, FontWeight, ListOffset, ListScrollEvent,
|
ElementId, EventEmitter, Fill, FocusHandle, FocusableView, FontWeight, ListOffset,
|
||||||
ListState, Model, Render, Subscription, Task, View, ViewContext, VisualContext, WeakView,
|
ListScrollEvent, ListState, Model, Render, Subscription, Task, View, ViewContext,
|
||||||
|
VisualContext, WeakView,
|
||||||
};
|
};
|
||||||
use language::LanguageRegistry;
|
use language::LanguageRegistry;
|
||||||
use menu::Confirm;
|
use menu::Confirm;
|
||||||
|
@ -335,67 +336,78 @@ impl ChatPanel {
|
||||||
};
|
};
|
||||||
let this = cx.view().clone();
|
let this = cx.view().clone();
|
||||||
|
|
||||||
v_flex()
|
let mentioning_you = message
|
||||||
.w_full()
|
.mentions
|
||||||
.relative()
|
.iter()
|
||||||
.overflow_hidden()
|
.any(|m| Some(m.1) == self.client.user_id());
|
||||||
.when(!is_continuation_from_previous, |this| {
|
|
||||||
this.pt_3().child(
|
v_flex().w_full().relative().child(
|
||||||
h_flex()
|
div()
|
||||||
.text_ui_sm()
|
.bg(if mentioning_you {
|
||||||
.child(
|
Fill::from(cx.theme().colors().background)
|
||||||
div().absolute().child(
|
} else {
|
||||||
|
Fill::default()
|
||||||
|
})
|
||||||
|
.rounded_md()
|
||||||
|
.overflow_hidden()
|
||||||
|
.px_1()
|
||||||
|
.py_0p5()
|
||||||
|
.when(!is_continuation_from_previous, |this| {
|
||||||
|
this.mt_1().child(
|
||||||
|
h_flex()
|
||||||
|
.text_ui_sm()
|
||||||
|
.child(div().absolute().child(
|
||||||
Avatar::new(message.sender.avatar_uri.clone()).size(rems(1.)),
|
Avatar::new(message.sender.avatar_uri.clone()).size(rems(1.)),
|
||||||
|
))
|
||||||
|
.child(
|
||||||
|
div()
|
||||||
|
.pl(cx.rem_size() + px(6.0))
|
||||||
|
.pr(px(8.0))
|
||||||
|
.font_weight(FontWeight::BOLD)
|
||||||
|
.child(Label::new(message.sender.github_login.clone())),
|
||||||
|
)
|
||||||
|
.child(
|
||||||
|
Label::new(format_timestamp(
|
||||||
|
OffsetDateTime::now_utc(),
|
||||||
|
message.timestamp,
|
||||||
|
self.local_timezone,
|
||||||
|
))
|
||||||
|
.size(LabelSize::Small)
|
||||||
|
.color(Color::Muted),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
})
|
||||||
|
.when(mentioning_you, |this| this.mt_1())
|
||||||
|
.child(
|
||||||
|
v_flex()
|
||||||
|
.w_full()
|
||||||
|
.text_ui_sm()
|
||||||
|
.id(element_id)
|
||||||
|
.group("")
|
||||||
|
.child(text.element("body".into(), cx))
|
||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
.pl(cx.rem_size() + px(6.0))
|
.absolute()
|
||||||
.pr(px(8.0))
|
.z_index(1)
|
||||||
.font_weight(FontWeight::BOLD)
|
.right_0()
|
||||||
.child(Label::new(message.sender.github_login.clone())),
|
.w_6()
|
||||||
)
|
.bg(cx.theme().colors().panel_background)
|
||||||
.child(
|
.when(!self.has_open_menu(message_id_to_remove), |el| {
|
||||||
Label::new(format_timestamp(
|
el.visible_on_hover("")
|
||||||
OffsetDateTime::now_utc(),
|
})
|
||||||
message.timestamp,
|
.children(message_id_to_remove.map(|message_id| {
|
||||||
self.local_timezone,
|
popover_menu(("menu", message_id))
|
||||||
))
|
.trigger(IconButton::new(
|
||||||
.size(LabelSize::Small)
|
("trigger", message_id),
|
||||||
.color(Color::Muted),
|
IconName::Ellipsis,
|
||||||
|
))
|
||||||
|
.menu(move |cx| {
|
||||||
|
Some(Self::render_message_menu(&this, message_id, cx))
|
||||||
|
})
|
||||||
|
})),
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
})
|
)
|
||||||
.when(is_continuation_from_previous, |this| this.pt_1())
|
|
||||||
.child(
|
|
||||||
v_flex()
|
|
||||||
.w_full()
|
|
||||||
.text_ui_sm()
|
|
||||||
.id(element_id)
|
|
||||||
.group("")
|
|
||||||
.child(text.element("body".into(), cx))
|
|
||||||
.child(
|
|
||||||
div()
|
|
||||||
.absolute()
|
|
||||||
.z_index(1)
|
|
||||||
.right_0()
|
|
||||||
.w_6()
|
|
||||||
.bg(cx.theme().colors().panel_background)
|
|
||||||
.when(!self.has_open_menu(message_id_to_remove), |el| {
|
|
||||||
el.visible_on_hover("")
|
|
||||||
})
|
|
||||||
.children(message_id_to_remove.map(|message_id| {
|
|
||||||
popover_menu(("menu", message_id))
|
|
||||||
.trigger(IconButton::new(
|
|
||||||
("trigger", message_id),
|
|
||||||
IconName::Ellipsis,
|
|
||||||
))
|
|
||||||
.menu(move |cx| {
|
|
||||||
Some(Self::render_message_menu(&this, message_id, cx))
|
|
||||||
})
|
|
||||||
})),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn has_open_menu(&self, message_id: Option<u64>) -> bool {
|
fn has_open_menu(&self, message_id: Option<u64>) -> bool {
|
||||||
|
|
Loading…
Reference in a new issue