diff --git a/crates/client/src/gui/chat.rs b/crates/client/src/gui/chat.rs index e1450fb..92a76bb 100644 --- a/crates/client/src/gui/chat.rs +++ b/crates/client/src/gui/chat.rs @@ -126,7 +126,6 @@ pub enum ReportTarget { pub enum CardMenu { Main, More, - Accounts, Status, } diff --git a/crates/client/src/gui/profile.rs b/crates/client/src/gui/profile.rs index 903d827..75c9d14 100644 --- a/crates/client/src/gui/profile.rs +++ b/crates/client/src/gui/profile.rs @@ -242,13 +242,7 @@ impl Card { .flex() .flex_col() .gap(px(space::XS)) - .children(self_rows( - &self.others, - self.card_menu, - entity, - &popover, - palette, - )) + .children(main_self_rows(entity, &popover, palette)) .into_any_element() } else { let mut rows = self.social_rows(entity, &popover, palette); @@ -395,7 +389,12 @@ impl Card { .truncate(), ) .when(is_self, |name| { - name.child(account_toggle(self.card_menu, entity, palette)) + name.child(account_menu( + self.others.clone(), + entity, + &popover, + palette, + )) }), ) .map(|names| { @@ -585,21 +584,6 @@ impl Card { } } -fn self_rows( - others: &[(Id, String)], - card_menu: CardMenu, - entity: &Entity, - popover: &Entity, - palette: Palette, -) -> Vec { - match card_menu { - CardMenu::Accounts => accounts_rows(others, entity, popover, palette), - CardMenu::Main | CardMenu::More | CardMenu::Status => { - main_self_rows(entity, popover, palette) - } - } -} - fn main_self_rows( entity: &Entity, popover: &Entity, @@ -673,36 +657,34 @@ fn accounts_rows( ] } -fn account_toggle( - card_menu: CardMenu, +fn account_menu( + others: Vec<(Id, String)>, entity: &Entity, + card: &Entity, palette: Palette, -) -> impl IntoElement { - let open = card_menu == CardMenu::Accounts; - clickable( - "profile_accounts", - palette, - card_menu_action( - entity, - if open { - CardMenu::Main - } else { - CardMenu::Accounts - }, - ), - ) - .tip(w().profile.accounts) - .rounded(px(radius::SM)) - .flex_shrink_0() - .child( - Icon::new(if open { - IconName::ChevronUp - } else { - IconName::ChevronDown +) -> Popover { + let entity = entity.clone(); + let card = card.clone(); + Popover::new("account_menu") + .anchor(Anchor::TopLeft) + .appearance(false) + .trigger(Trigger::new( + clickable("profile_accounts", palette, |_, _| {}) + .tip(w().profile.accounts) + .rounded(px(radius::SM)) + .flex_shrink_0() + .child( + Icon::new(IconName::ChevronDown) + .size(px(size::ICON_SM)) + .text_color(palette.muted), + ), + )) + .content(move |_, _, _| { + super::parts::popover(palette.tokens) + .w(px(size::POPOVER)) + .p(px(space::XS)) + .children(accounts_rows(&others, &entity, &card, palette)) }) - .size(px(size::ICON_SM)) - .text_color(palette.muted), - ) } fn edit_status(entity: &Entity, status: &str, palette: Palette) -> impl IntoElement {