mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-06 18:46:49 +00:00
057b235c56
This PR implements the `VisibleOnHover` trait for `IconButton`s. I noticed that in a lot of places we were wrapping an `IconButton` in an extra `div` just so we could call `visible_on_hover` on it. By implementing the trait on `IconButton` directly it allows us to avoid the interstitial `div` entirely. Release Notes: - N/A
15 lines
545 B
Rust
15 lines
545 B
Rust
use gpui::{InteractiveElement, SharedString, Styled};
|
|
|
|
pub trait VisibleOnHover {
|
|
/// Sets the element to only be visible when the specified group is hovered.
|
|
///
|
|
/// Pass `""` as the `group_name` to use the global group.
|
|
fn visible_on_hover(self, group_name: impl Into<SharedString>) -> Self;
|
|
}
|
|
|
|
impl<E: InteractiveElement + Styled> VisibleOnHover for E {
|
|
fn visible_on_hover(self, group_name: impl Into<SharedString>) -> Self {
|
|
self.invisible()
|
|
.group_hover(group_name, |style| style.visible())
|
|
}
|
|
}
|