Add .visible_on_hover helper method (#3639)

This PR adds a `.visible_on_hover` helper method that can be used to
make an element only visible on hover.

I noticed we were repeating this similar stanza in a bunch of different
spots:

```rs
some_element
    .invisible()
    .group_hover("", |style| style.visible())
``` 

so it seemed like a nice thing to factor out into a reusable utility.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2023-12-13 19:12:20 -05:00 committed by GitHub
parent d59de96921
commit 137e4e9251
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 37 additions and 37 deletions

View file

@ -21,10 +21,7 @@ use settings::{Settings, SettingsStore};
use std::sync::Arc;
use theme::ActiveTheme as _;
use time::{OffsetDateTime, UtcOffset};
use ui::{
h_stack, prelude::WindowContext, v_stack, Avatar, Button, ButtonCommon as _, Clickable, Icon,
IconButton, Label, Tooltip,
};
use ui::{prelude::*, Avatar, Button, Icon, IconButton, Label, Tooltip};
use util::{ResultExt, TryFutureExt};
use workspace::{
dock::{DockPosition, Panel, PanelEvent},
@ -382,12 +379,11 @@ impl ChatPanel {
.child(text.element("body".into(), cx))
.child(
div()
.invisible()
.absolute()
.top_1()
.right_2()
.w_8()
.group_hover("", |this| this.visible())
.visible_on_hover("")
.child(render_remove(message_id_to_remove, cx)),
)
.into_any()