onboarding: Add the AI page (#35351)

This PR starts the work on the AI onboarding page as well as the
configuration modal

Release Notes:

- N/A

---------

Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
Co-authored-by: Anthony <anthony@zed.dev>
This commit is contained in:
Finn Evers 2025-08-01 16:43:59 +02:00 committed by GitHub
parent e5c6a596a9
commit b01d1872cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 550 additions and 63 deletions

View file

@ -566,7 +566,7 @@ impl RenderOnce for Switch {
pub struct SwitchField {
id: ElementId,
label: SharedString,
description: SharedString,
description: Option<SharedString>,
toggle_state: ToggleState,
on_click: Arc<dyn Fn(&ToggleState, &mut Window, &mut App) + 'static>,
disabled: bool,
@ -577,14 +577,14 @@ impl SwitchField {
pub fn new(
id: impl Into<ElementId>,
label: impl Into<SharedString>,
description: impl Into<SharedString>,
description: Option<SharedString>,
toggle_state: impl Into<ToggleState>,
on_click: impl Fn(&ToggleState, &mut Window, &mut App) + 'static,
) -> Self {
Self {
id: id.into(),
label: label.into(),
description: description.into(),
description: description,
toggle_state: toggle_state.into(),
on_click: Arc::new(on_click),
disabled: false,
@ -592,6 +592,11 @@ impl SwitchField {
}
}
pub fn description(mut self, description: impl Into<SharedString>) -> Self {
self.description = Some(description.into());
self
}
pub fn disabled(mut self, disabled: bool) -> Self {
self.disabled = disabled;
self
@ -616,13 +621,15 @@ impl RenderOnce for SwitchField {
.gap_4()
.justify_between()
.flex_wrap()
.child(
v_flex()
.child(match &self.description {
Some(description) => v_flex()
.gap_0p5()
.max_w_5_6()
.child(Label::new(self.label))
.child(Label::new(self.description).color(Color::Muted)),
)
.child(Label::new(self.label.clone()))
.child(Label::new(description.clone()).color(Color::Muted))
.into_any_element(),
None => Label::new(self.label.clone()).into_any_element(),
})
.child(
Switch::new(
SharedString::from(format!("{}-switch", self.id)),
@ -671,7 +678,7 @@ impl Component for SwitchField {
SwitchField::new(
"switch_field_unselected",
"Enable notifications",
"Receive notifications when new messages arrive.",
Some("Receive notifications when new messages arrive.".into()),
ToggleState::Unselected,
|_, _, _| {},
)
@ -682,7 +689,7 @@ impl Component for SwitchField {
SwitchField::new(
"switch_field_selected",
"Enable notifications",
"Receive notifications when new messages arrive.",
Some("Receive notifications when new messages arrive.".into()),
ToggleState::Selected,
|_, _, _| {},
)
@ -698,7 +705,7 @@ impl Component for SwitchField {
SwitchField::new(
"switch_field_default",
"Default color",
"This uses the default switch color.",
Some("This uses the default switch color.".into()),
ToggleState::Selected,
|_, _, _| {},
)
@ -709,7 +716,7 @@ impl Component for SwitchField {
SwitchField::new(
"switch_field_accent",
"Accent color",
"This uses the accent color scheme.",
Some("This uses the accent color scheme.".into()),
ToggleState::Selected,
|_, _, _| {},
)
@ -725,7 +732,7 @@ impl Component for SwitchField {
SwitchField::new(
"switch_field_disabled",
"Disabled field",
"This field is disabled and cannot be toggled.",
Some("This field is disabled and cannot be toggled.".into()),
ToggleState::Selected,
|_, _, _| {},
)
@ -733,6 +740,20 @@ impl Component for SwitchField {
.into_any_element(),
)],
),
example_group_with_title(
"No Description",
vec![single_example(
"No Description",
SwitchField::new(
"switch_field_disabled",
"Disabled field",
None,
ToggleState::Selected,
|_, _, _| {},
)
.into_any_element(),
)],
),
])
.into_any_element(),
)