From 3c05d57e6a0ceea4cebcf088d5d82a4fda2f08a6 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Wed, 29 Nov 2023 14:56:23 -0500 Subject: [PATCH 1/3] Style hover popover --- crates/editor2/src/hover_popover.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/editor2/src/hover_popover.rs b/crates/editor2/src/hover_popover.rs index f80168ed25..2f2e8ee937 100644 --- a/crates/editor2/src/hover_popover.rs +++ b/crates/editor2/src/hover_popover.rs @@ -15,7 +15,7 @@ use lsp::DiagnosticSeverity; use project::{HoverBlock, HoverBlockKind, InlayHintLabelPart, Project}; use settings::Settings; use std::{ops::Range, sync::Arc, time::Duration}; -use ui::Tooltip; +use ui::{StyledExt, Tooltip}; use util::TryFutureExt; use workspace::Workspace; @@ -476,8 +476,10 @@ impl InfoPopover { ) -> AnyElement { div() .id("info_popover") + .elevation_2(cx) + .text_ui() + .p_2() .overflow_y_scroll() - .bg(gpui::red()) .max_w(max_size.width) .max_h(max_size.height) // Prevent a mouse move on the popover from being propagated to the editor, From d8ed7c072192244420303e2fd593915d9daf867b Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Wed, 29 Nov 2023 15:29:33 -0500 Subject: [PATCH 2/3] Move `GraphicSlot` out of `components` module (#3444) This PR moves the `GraphicSlot` definition out of the `components` module, as it doesn't contain a component. Release Notes: - N/A --- crates/ui2/src/components.rs | 2 -- crates/ui2/src/{components => }/slot.rs | 4 +--- crates/ui2/src/ui2.rs | 2 ++ 3 files changed, 3 insertions(+), 5 deletions(-) rename crates/ui2/src/{components => }/slot.rs (89%) diff --git a/crates/ui2/src/components.rs b/crates/ui2/src/components.rs index 0f46e3a378..c5d06bf0dd 100644 --- a/crates/ui2/src/components.rs +++ b/crates/ui2/src/components.rs @@ -11,7 +11,6 @@ mod keybinding; mod label; mod list; mod popover; -mod slot; mod stack; mod tooltip; @@ -31,7 +30,6 @@ pub use keybinding::*; pub use label::*; pub use list::*; pub use popover::*; -pub use slot::*; pub use stack::*; pub use tooltip::*; diff --git a/crates/ui2/src/components/slot.rs b/crates/ui2/src/slot.rs similarity index 89% rename from crates/ui2/src/components/slot.rs rename to crates/ui2/src/slot.rs index 7c896bf85b..3438e34621 100644 --- a/crates/ui2/src/components/slot.rs +++ b/crates/ui2/src/slot.rs @@ -2,11 +2,9 @@ use gpui::{ImageSource, SharedString}; use crate::Icon; -#[derive(Debug, Clone)] /// A slot utility that provides a way to to pass either /// an icon or an image to a component. -/// -/// Can be filled with a [] +#[derive(Debug, Clone)] pub enum GraphicSlot { Icon(Icon), Avatar(ImageSource), diff --git a/crates/ui2/src/ui2.rs b/crates/ui2/src/ui2.rs index 997abe4bd6..d1da22149c 100644 --- a/crates/ui2/src/ui2.rs +++ b/crates/ui2/src/ui2.rs @@ -18,6 +18,7 @@ mod disableable; mod fixed; pub mod prelude; mod selectable; +mod slot; mod styled_ext; mod styles; mod toggleable; @@ -29,6 +30,7 @@ pub use disableable::*; pub use fixed::*; pub use prelude::*; pub use selectable::*; +pub use slot::*; pub use styled_ext::*; pub use styles::*; pub use toggleable::*; From df5de47a7866e94cbfff391dd086c31773a432f0 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Wed, 29 Nov 2023 16:13:41 -0500 Subject: [PATCH 3/3] Make `toggle` method accept `impl Into>` (#3446) This PR makes the `toggle` method on the various list components accept an `impl Into>` instead of just an `Option`. This allows a caller with just a `bool` avoid having to wrap the `Option` themselves. Release Notes: - N/A --- crates/collab_ui2/src/collab_panel.rs | 2 +- crates/ui2/src/components/disclosure.rs | 7 +++---- crates/ui2/src/components/list.rs | 4 ++-- crates/ui2/src/components/list/list_header.rs | 4 ++-- crates/ui2/src/components/list/list_item.rs | 4 ++-- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/crates/collab_ui2/src/collab_panel.rs b/crates/collab_ui2/src/collab_panel.rs index 62a4dffbfd..3f99fea315 100644 --- a/crates/collab_ui2/src/collab_panel.rs +++ b/crates/collab_ui2/src/collab_panel.rs @@ -2505,7 +2505,7 @@ impl CollabPanel { .when_some(button, |el, button| el.right_button(button)) .selected(is_selected) .when(can_collapse, |el| { - el.toggle(Some(is_collapsed)).on_toggle( + el.toggle(is_collapsed).on_toggle( cx.listener(move |this, _, cx| this.toggle_section_expanded(section, cx)), ) }); diff --git a/crates/ui2/src/components/disclosure.rs b/crates/ui2/src/components/disclosure.rs index b3736f36a0..103c3112df 100644 --- a/crates/ui2/src/components/disclosure.rs +++ b/crates/ui2/src/components/disclosure.rs @@ -34,10 +34,9 @@ impl RenderOnce for Disclosure { fn render(self, _cx: &mut WindowContext) -> Self::Rendered { IconButton::new( "toggle", - if self.is_open { - Icon::ChevronDown - } else { - Icon::ChevronRight + match self.is_open { + true => Icon::ChevronDown, + false => Icon::ChevronRight, }, ) .color(Color::Muted) diff --git a/crates/ui2/src/components/list.rs b/crates/ui2/src/components/list.rs index f5eb2eb44b..aafd045391 100644 --- a/crates/ui2/src/components/list.rs +++ b/crates/ui2/src/components/list.rs @@ -44,8 +44,8 @@ impl List { self } - pub fn toggle(mut self, toggle: Option) -> Self { - self.toggle = toggle; + pub fn toggle(mut self, toggle: impl Into>) -> Self { + self.toggle = toggle.into(); self } } diff --git a/crates/ui2/src/components/list/list_header.rs b/crates/ui2/src/components/list/list_header.rs index a205de6220..7eacaef920 100644 --- a/crates/ui2/src/components/list/list_header.rs +++ b/crates/ui2/src/components/list/list_header.rs @@ -36,8 +36,8 @@ impl ListHeader { } } - pub fn toggle(mut self, toggle: Option) -> Self { - self.toggle = toggle; + pub fn toggle(mut self, toggle: impl Into>) -> Self { + self.toggle = toggle.into(); self } diff --git a/crates/ui2/src/components/list/list_item.rs b/crates/ui2/src/components/list/list_item.rs index d8630289a7..34a9844eaf 100644 --- a/crates/ui2/src/components/list/list_item.rs +++ b/crates/ui2/src/components/list/list_item.rs @@ -70,8 +70,8 @@ impl ListItem { self } - pub fn toggle(mut self, toggle: Option) -> Self { - self.toggle = toggle; + pub fn toggle(mut self, toggle: impl Into>) -> Self { + self.toggle = toggle.into(); self }