Git panel polish (#23144)

- Clicking checkbox in the header stages or unstages all changes
- Adds tooltips to header checkbox
- Addis the ability for checkboxes to have tooltips
- Ensure an entry in the list is always selected
- Hide revert all button for now

Release Notes:

- N/A
This commit is contained in:
Nate Butler 2025-01-14 15:27:05 -05:00 committed by GitHub
parent d13d099675
commit a3e7444d77
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 75 additions and 29 deletions

View file

@ -1,4 +1,4 @@
use gpui::{div, hsla, prelude::*, ElementId, Hsla, IntoElement, Styled, WindowContext};
use gpui::{div, hsla, prelude::*, AnyView, ElementId, Hsla, IntoElement, Styled, WindowContext};
use std::sync::Arc;
use crate::utils::is_light;
@ -44,6 +44,7 @@ pub struct Checkbox {
on_click: Option<Box<dyn Fn(&ToggleState, &mut WindowContext) + 'static>>,
filled: bool,
style: ToggleStyle,
tooltip: Option<Box<dyn Fn(&mut WindowContext) -> AnyView>>,
}
impl Checkbox {
@ -56,6 +57,7 @@ impl Checkbox {
on_click: None,
filled: false,
style: ToggleStyle::default(),
tooltip: None,
}
}
@ -91,6 +93,12 @@ impl Checkbox {
self.style = ToggleStyle::ElevationBased(elevation);
self
}
/// Sets the tooltip for the checkbox.
pub fn tooltip(mut self, tooltip: impl Fn(&mut WindowContext) -> AnyView + 'static) -> Self {
self.tooltip = Some(Box::new(tooltip));
self
}
}
impl Checkbox {
@ -176,6 +184,9 @@ impl RenderOnce for Checkbox {
this.on_click(move |_, cx| on_click(&self.toggle_state.inverse(), cx))
},
)
.when_some(self.tooltip, |this, tooltip| {
this.tooltip(move |cx| tooltip(cx))
})
}
}