WIP
This commit is contained in:
parent
b4a5701e12
commit
92d2048aa4
4 changed files with 65 additions and 4 deletions
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
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue