WIP
This commit is contained in:
parent
b4a5701e12
commit
92d2048aa4
4 changed files with 65 additions and 4 deletions
|
@ -37,7 +37,10 @@ use gpui::{
|
||||||
};
|
};
|
||||||
use project::Project;
|
use project::Project;
|
||||||
use theme::ActiveTheme;
|
use theme::ActiveTheme;
|
||||||
use ui::{h_stack, prelude::*, Avatar, Button, ButtonStyle2, IconButton, KeyBinding, Tooltip};
|
use ui::{
|
||||||
|
h_stack, prelude::*, v_stack, Avatar, Button, ButtonLike, ButtonStyle2, Icon, IconButton,
|
||||||
|
IconElement, KeyBinding, List, ListItem, PopoverMenu, Tooltip,
|
||||||
|
};
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
use workspace::{notifications::NotifyResultExt, Workspace};
|
use workspace::{notifications::NotifyResultExt, Workspace};
|
||||||
|
|
||||||
|
@ -288,10 +291,25 @@ impl Render for CollabTitlebarItem {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.map(|this| {
|
.child(h_stack().px_1p5().map(|this| {
|
||||||
if let Some(user) = current_user {
|
if let Some(user) = current_user {
|
||||||
this.when_some(user.avatar.clone(), |this, avatar| {
|
this.when_some(user.avatar.clone(), |this, avatar| {
|
||||||
this.child(ui::Avatar::data(avatar))
|
this.child(
|
||||||
|
PopoverMenu::new(
|
||||||
|
ButtonLike::new("user-menu")
|
||||||
|
.child(h_stack().gap_0p5().child(Avatar::data(avatar)).child(
|
||||||
|
IconElement::new(Icon::ChevronDown).color(Color::Muted),
|
||||||
|
))
|
||||||
|
.style(ButtonStyle2::Subtle)
|
||||||
|
.tooltip(move |cx| Tooltip::text("Toggle User Menu", cx))
|
||||||
|
.into_any_element(),
|
||||||
|
)
|
||||||
|
.children(vec![
|
||||||
|
ListItem::new("foo"),
|
||||||
|
ListItem::new("bar"),
|
||||||
|
ListItem::new("baz"),
|
||||||
|
]),
|
||||||
|
)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.child(Button::new("sign_in", "Sign in").on_click(move |_, cx| {
|
this.child(Button::new("sign_in", "Sign in").on_click(move |_, cx| {
|
||||||
|
@ -305,7 +323,7 @@ impl Render for CollabTitlebarItem {
|
||||||
.detach();
|
.detach();
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
})
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ mod keybinding;
|
||||||
mod label;
|
mod label;
|
||||||
mod list;
|
mod list;
|
||||||
mod popover;
|
mod popover;
|
||||||
|
mod popover_menu;
|
||||||
mod stack;
|
mod stack;
|
||||||
mod tooltip;
|
mod tooltip;
|
||||||
|
|
||||||
|
@ -26,6 +27,7 @@ pub use keybinding::*;
|
||||||
pub use label::*;
|
pub use label::*;
|
||||||
pub use list::*;
|
pub use list::*;
|
||||||
pub use popover::*;
|
pub use popover::*;
|
||||||
|
pub use popover_menu::*;
|
||||||
pub use stack::*;
|
pub use stack::*;
|
||||||
pub use tooltip::*;
|
pub use tooltip::*;
|
||||||
|
|
||||||
|
|
39
crates/ui2/src/components/popover_menu.rs
Normal file
39
crates/ui2/src/components/popover_menu.rs
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
use gpui::{
|
||||||
|
div, overlay, AnyElement, Div, Element, ElementId, IntoElement, ParentElement, RenderOnce,
|
||||||
|
Styled, WindowContext,
|
||||||
|
};
|
||||||
|
use smallvec::SmallVec;
|
||||||
|
|
||||||
|
use crate::{prelude::*, ElevationIndex, List, Popover};
|
||||||
|
|
||||||
|
#[derive(IntoElement)]
|
||||||
|
pub struct PopoverMenu {
|
||||||
|
trigger: AnyElement,
|
||||||
|
children: SmallVec<[AnyElement; 2]>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RenderOnce for PopoverMenu {
|
||||||
|
type Rendered = Div;
|
||||||
|
|
||||||
|
fn render(self, cx: &mut WindowContext) -> Self::Rendered {
|
||||||
|
div()
|
||||||
|
.relative()
|
||||||
|
.child(self.trigger)
|
||||||
|
.child(overlay().child(Popover::new().children(self.children)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PopoverMenu {
|
||||||
|
pub fn new(trigger: AnyElement) -> Self {
|
||||||
|
Self {
|
||||||
|
trigger,
|
||||||
|
children: SmallVec::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ParentElement for PopoverMenu {
|
||||||
|
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement; 2]> {
|
||||||
|
&mut self.children
|
||||||
|
}
|
||||||
|
}
|
|
@ -3711,6 +3711,8 @@ impl Render for Workspace {
|
||||||
.items_start()
|
.items_start()
|
||||||
.text_color(cx.theme().colors().text)
|
.text_color(cx.theme().colors().text)
|
||||||
.bg(cx.theme().colors().background)
|
.bg(cx.theme().colors().background)
|
||||||
|
.border()
|
||||||
|
.border_color(cx.theme().colors().border)
|
||||||
.children(self.titlebar_item.clone())
|
.children(self.titlebar_item.clone())
|
||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue