ui: Make Callout
constructors more flexible (#29895)
This PR updates the `Callout` constructors to be more flexible by accepting `impl Into<SharedString>`s. Release Notes: - N/A
This commit is contained in:
parent
a2fa10f35f
commit
3e2abbf53b
3 changed files with 23 additions and 22 deletions
|
@ -1093,10 +1093,10 @@ impl MessageEditor {
|
||||||
Some(
|
Some(
|
||||||
div()
|
div()
|
||||||
.child(ui::Callout::multi_line(
|
.child(ui::Callout::multi_line(
|
||||||
title.into(),
|
title,
|
||||||
message.into(),
|
message,
|
||||||
icon,
|
icon,
|
||||||
"Start New Thread".into(),
|
"Start New Thread",
|
||||||
Box::new(cx.listener(|this, _, window, cx| {
|
Box::new(cx.listener(|this, _, window, cx| {
|
||||||
let from_thread_id = Some(this.thread.read(cx).id().clone());
|
let from_thread_id = Some(this.thread.read(cx).id().clone());
|
||||||
window.dispatch_action(Box::new(NewThread { from_thread_id }), cx);
|
window.dispatch_action(Box::new(NewThread { from_thread_id }), cx);
|
||||||
|
|
|
@ -93,10 +93,10 @@ impl RenderOnce for UsageCallout {
|
||||||
};
|
};
|
||||||
|
|
||||||
Callout::multi_line(
|
Callout::multi_line(
|
||||||
title.into(),
|
title,
|
||||||
message.into(),
|
message,
|
||||||
icon,
|
icon,
|
||||||
button_text.into(),
|
button_text,
|
||||||
Box::new(move |_, _, cx| {
|
Box::new(move |_, _, cx| {
|
||||||
cx.open_url(url);
|
cx.open_url(url);
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use crate::prelude::*;
|
|
||||||
use gpui::ClickEvent;
|
use gpui::ClickEvent;
|
||||||
|
|
||||||
|
use crate::prelude::*;
|
||||||
|
|
||||||
#[derive(IntoElement, RegisterComponent)]
|
#[derive(IntoElement, RegisterComponent)]
|
||||||
pub struct Callout {
|
pub struct Callout {
|
||||||
title: SharedString,
|
title: SharedString,
|
||||||
|
@ -13,33 +14,33 @@ pub struct Callout {
|
||||||
|
|
||||||
impl Callout {
|
impl Callout {
|
||||||
pub fn single_line(
|
pub fn single_line(
|
||||||
title: SharedString,
|
title: impl Into<SharedString>,
|
||||||
icon: Icon,
|
icon: Icon,
|
||||||
cta_label: SharedString,
|
cta_label: impl Into<SharedString>,
|
||||||
cta_action: Box<dyn Fn(&ClickEvent, &mut Window, &mut App) + 'static>,
|
cta_action: Box<dyn Fn(&ClickEvent, &mut Window, &mut App) + 'static>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
title,
|
title: title.into(),
|
||||||
message: None,
|
message: None,
|
||||||
icon,
|
icon,
|
||||||
cta_label,
|
cta_label: cta_label.into(),
|
||||||
cta_action,
|
cta_action,
|
||||||
line_height: None,
|
line_height: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn multi_line(
|
pub fn multi_line(
|
||||||
title: SharedString,
|
title: impl Into<SharedString>,
|
||||||
message: SharedString,
|
message: impl Into<SharedString>,
|
||||||
icon: Icon,
|
icon: Icon,
|
||||||
cta_label: SharedString,
|
cta_label: impl Into<SharedString>,
|
||||||
cta_action: Box<dyn Fn(&ClickEvent, &mut Window, &mut App) + 'static>,
|
cta_action: Box<dyn Fn(&ClickEvent, &mut Window, &mut App) + 'static>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
title,
|
title: title.into(),
|
||||||
message: Some(message),
|
message: Some(message.into()),
|
||||||
icon,
|
icon,
|
||||||
cta_label,
|
cta_label: cta_label.into(),
|
||||||
cta_action,
|
cta_action,
|
||||||
line_height: None,
|
line_height: None,
|
||||||
}
|
}
|
||||||
|
@ -127,11 +128,11 @@ impl Component for Callout {
|
||||||
single_example(
|
single_example(
|
||||||
"Single Line",
|
"Single Line",
|
||||||
Callout::single_line(
|
Callout::single_line(
|
||||||
"Your settings contain deprecated values, please update them.".into(),
|
"Your settings contain deprecated values, please update them.",
|
||||||
Icon::new(IconName::Warning)
|
Icon::new(IconName::Warning)
|
||||||
.color(Color::Warning)
|
.color(Color::Warning)
|
||||||
.size(IconSize::Small),
|
.size(IconSize::Small),
|
||||||
"Backup & Update".into(),
|
"Backup & Update",
|
||||||
Box::new(|_, _, _| {}),
|
Box::new(|_, _, _| {}),
|
||||||
)
|
)
|
||||||
.into_any_element(),
|
.into_any_element(),
|
||||||
|
@ -140,12 +141,12 @@ impl Component for Callout {
|
||||||
single_example(
|
single_example(
|
||||||
"Multi Line",
|
"Multi Line",
|
||||||
Callout::multi_line(
|
Callout::multi_line(
|
||||||
"Thread reached the token limit".into(),
|
"Thread reached the token limit",
|
||||||
"Start a new thread from a summary to continue the conversation.".into(),
|
"Start a new thread from a summary to continue the conversation.",
|
||||||
Icon::new(IconName::X)
|
Icon::new(IconName::X)
|
||||||
.color(Color::Error)
|
.color(Color::Error)
|
||||||
.size(IconSize::Small),
|
.size(IconSize::Small),
|
||||||
"Start New Thread".into(),
|
"Start New Thread",
|
||||||
Box::new(|_, _, _| {}),
|
Box::new(|_, _, _| {}),
|
||||||
)
|
)
|
||||||
.into_any_element(),
|
.into_any_element(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue