From 9f2e3bab9b0c8b5c60a6674ea06f2ab89763c374 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Tue, 21 Nov 2023 12:26:10 -0500 Subject: [PATCH] Allow popover to take an aside Co-Authored-By: Marshall Bowers <1486634+maxdeviant@users.noreply.github.com> --- crates/ui2/src/components/popover.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/crates/ui2/src/components/popover.rs b/crates/ui2/src/components/popover.rs index 74478e40512cc6da5753caa6fb39a097f713cd20..a919cc541753b3f7d4109ea673bf7b55f3c8c500 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>, + aside: Option, } 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 {