onboarding: Add explainer tooltips for the editing and AI section (#35619)

Includes the ability to add a tooltip for both the badge and switch
field components.

Release Notes:

- N/A
This commit is contained in:
Danilo Leal 2025-08-04 20:52:22 -03:00 committed by GitHub
parent afc4f50300
commit e1d0e3fc34
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 191 additions and 48 deletions

View file

@ -11,7 +11,7 @@ use project::DisableAiSettings;
use settings::{Settings, update_settings_file};
use ui::{
Badge, ButtonLike, Divider, Modal, ModalFooter, ModalHeader, Section, SwitchField, ToggleState,
prelude::*,
prelude::*, tooltip_container,
};
use util::ResultExt;
use workspace::ModalView;
@ -41,7 +41,11 @@ fn render_llm_provider_section(
}
fn render_privacy_card(disabled: bool, cx: &mut App) -> impl IntoElement {
let privacy_badge = || Badge::new("Privacy").icon(IconName::ShieldCheck);
let privacy_badge = || {
Badge::new("Privacy")
.icon(IconName::ShieldCheck)
.tooltip(move |_, cx| cx.new(|_| AiPrivacyTooltip::new()).into())
};
v_flex()
.relative()
@ -355,3 +359,37 @@ impl Render for AiConfigurationModal {
)
}
}
pub struct AiPrivacyTooltip {}
impl AiPrivacyTooltip {
pub fn new() -> Self {
Self {}
}
}
impl Render for AiPrivacyTooltip {
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
const DESCRIPTION: &'static str = "One of Zed's most important principles is transparency. This is why we are and value open-source so much. And it wouldn't be any different with AI.";
tooltip_container(window, cx, move |this, _, _| {
this.child(
h_flex()
.gap_1()
.child(
Icon::new(IconName::ShieldCheck)
.size(IconSize::Small)
.color(Color::Muted),
)
.child(Label::new("Privacy Principle")),
)
.child(
div().max_w_64().child(
Label::new(DESCRIPTION)
.size(LabelSize::Small)
.color(Color::Muted),
),
)
})
}
}