From a46a562dc29c29702fac1c45773875b32c6c0376 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Tue, 9 Jul 2024 17:41:54 -0400 Subject: [PATCH] ui: Add margin style methods to `Label` and `LabelLike` (#14032) This PR adds margin style methods to the `Label` and `LabelLike` components. This allows for callers to provide a margin to these components without needing to introduce a wrapping `div` to do so. Release Notes: - N/A --- crates/collab_ui/src/collab_panel.rs | 3 +- crates/editor/src/editor.rs | 11 ++- crates/search/src/project_search.rs | 6 +- crates/title_bar/src/collab.rs | 3 +- .../ui/src/components/button/button_like.rs | 2 +- crates/ui/src/components/label/label.rs | 13 +++- crates/ui/src/components/label/label_like.rs | 17 ++++- crates/vcs_menu/src/lib.rs | 76 +++++++++++-------- 8 files changed, 81 insertions(+), 50 deletions(-) diff --git a/crates/collab_ui/src/collab_panel.rs b/crates/collab_ui/src/collab_panel.rs index 5d9b88377e..e4f03b14f2 100644 --- a/crates/collab_ui/src/collab_panel.rs +++ b/crates/collab_ui/src/collab_panel.rs @@ -2547,9 +2547,8 @@ impl CollabPanel { .take(FACEPILE_LIMIT) .chain(if extra_count > 0 { Some( - div() + Label::new(format!("+{extra_count}")) .ml_2() - .child(Label::new(format!("+{extra_count}"))) .into_any_element(), ) } else { diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index a02891e622..0718205e00 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -1129,11 +1129,10 @@ impl CompletionsMenu { None } else { Some( - h_flex().ml_4().child( - Label::new(text.clone()) - .size(LabelSize::Small) - .color(Color::Muted), - ), + Label::new(text.clone()) + .ml_4() + .size(LabelSize::Small) + .color(Color::Muted), ) } } else { @@ -1156,7 +1155,7 @@ impl CompletionsMenu { } })) .child(h_flex().overflow_hidden().child(completion_label)) - .end_slot::
(documentation_label), + .end_slot::