Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Allow popover to take an aside

Nate Butler9f2e3bab9b0c
diff --git a/crates/ui2/src/components/popover.rs b/crates/ui2/src/components/popover.rs
index 74478e40512..a919cc54175 100644
--- a/crates/ui2/src/components/popover.rs
+++ b/crates/ui2/src/components/popover.rs
@@ -1,5 +1,6 @@
use gpui::{
- AnyElement, Component, Div, ElementId, ParentElement, RenderOnce, Styled, WindowContext,
+ AnyElement, Component, Div, Element, ElementId, ParentElement, RenderOnce, Styled,
+ WindowContext,
};
use smallvec::SmallVec;
@@ -8,7 +9,7 @@ use crate::{v_stack, StyledExt};
#[derive(RenderOnce)]
pub struct Popover {
children: SmallVec<[AnyElement; 2]>,
- aside: Option<SmallVec<[AnyElement; 2]>>,
+ aside: Option<AnyElement>,
}
impl Component for Popover {
@@ -30,7 +31,7 @@ impl Component for Popover {
.absolute()
.elevation_2(cx)
.p_1()
- .children(aside),
+ .child(aside),
)
})
}
@@ -43,6 +44,14 @@ impl Popover {
aside: None,
}
}
+
+ pub fn aside(mut self, aside: impl RenderOnce) -> Self
+ where
+ Self: Sized,
+ {
+ self.aside = Some(aside.render_once().into_any());
+ self
+ }
}
impl ParentElement for Popover {