From 54fff2ff5b2f9fdbe1b99c0c2566e15dcb6cfcb9 Mon Sep 17 00:00:00 2001 From: Parker Loflin Date: Fri, 20 Nov 2026 22:22:28 +0000 Subject: [PATCH] component: Remove no-op grow and vertical options (#67220) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary `ComponentExampleGroup::grow()` and `vertical()` set fields that `render` never reads, so all 28 calls did nothing. Removes the fields, the builders and the calls. Also removes the unused `sorted_previews` and `empty_example`. **Most of the diff is rustfmt reflowing `GitPanel`'s preview. With whitespace hidden, it's +28/−77.** ## Testing - `./script/clippy` - To check by hand, open the component preview: the affected examples should render unchanged. ## Self-review - [x] I've reviewed my diff for quality, security, reliability, and performance. - [x] UI changes follow the [checklist](https://zed.dev/docs/development/ui-checklist). - [x] Tests cover the new or changed behavior. Release Notes: - N/A --- .../src/conversation_view/elicitation.rs | 3 - crates/agent_ui/src/ui/session_notice.rs | 2 - crates/component/src/component.rs | 6 - crates/component/src/component_layout.rs | 18 - .../src/components/extension_card.rs | 2 +- crates/git_ui/src/git_panel.rs | 320 +++++++++--------- crates/notifications/src/status_toast.rs | 3 +- crates/onboarding/src/theme_preview.rs | 37 +- .../ui/src/components/ai/ai_setting_item.rs | 2 +- crates/ui/src/components/ai/thread_item.rs | 4 +- crates/ui/src/components/banner.rs | 4 +- .../ui/src/components/button/button_link.rs | 11 +- .../ui/src/components/button/copy_button.rs | 2 +- crates/ui/src/components/callout.rs | 4 +- crates/ui/src/components/chip.rs | 2 +- .../components/collab/collab_notification.rs | 7 +- crates/ui/src/components/diff_stat.rs | 4 +- .../ui/src/components/label/spinner_label.rs | 2 +- .../src/components/list/list_bullet_item.rs | 2 +- .../notification/announcement_toast.rs | 2 +- crates/ui/src/styles/animation.rs | 6 +- 21 files changed, 197 insertions(+), 246 deletions(-) diff --git a/crates/agent_ui/src/conversation_view/elicitation.rs b/crates/agent_ui/src/conversation_view/elicitation.rs index f7fa2cdf11c..87a544f51b0 100644 --- a/crates/agent_ui/src/conversation_view/elicitation.rs +++ b/crates/agent_ui/src/conversation_view/elicitation.rs @@ -1430,7 +1430,6 @@ impl Component for ElicitationCardPreview { .width(px(640.)), ], ) - .vertical() .into_any_element(), example_group_with_title( "URL Requests", @@ -1442,7 +1441,6 @@ impl Component for ElicitationCardPreview { .width(px(640.)), ], ) - .vertical() .into_any_element(), example_group_with_title( "Terminal States", @@ -1459,7 +1457,6 @@ impl Component for ElicitationCardPreview { .width(px(640.)), ], ) - .vertical() .into_any_element(), ]) .into_any_element() diff --git a/crates/agent_ui/src/ui/session_notice.rs b/crates/agent_ui/src/ui/session_notice.rs index 8489a2e2a39..8e03511b963 100644 --- a/crates/agent_ui/src/ui/session_notice.rs +++ b/crates/agent_ui/src/ui/session_notice.rs @@ -151,7 +151,6 @@ impl Component for SessionNoticePreview { .width(px(640.)), ], ) - .vertical() .into_any_element(), example_group_with_title( "Layout", @@ -199,7 +198,6 @@ impl Component for SessionNoticePreview { .width(px(320.)), ], ) - .vertical() .into_any_element(), ]) .into_any_element() diff --git a/crates/component/src/component.rs b/crates/component/src/component.rs index abceb848dfe..1f0b116f208 100644 --- a/crates/component/src/component.rs +++ b/crates/component/src/component.rs @@ -73,12 +73,6 @@ impl ComponentRegistry { self.components.values() } - pub fn sorted_previews(&self) -> Vec { - let mut previews: Vec<_> = self.previews().cloned().collect(); - previews.sort_by_key(|a| a.name()); - previews - } - pub fn components(&self) -> Vec<&ComponentMetadata> { self.components.values().collect() } diff --git a/crates/component/src/component_layout.rs b/crates/component/src/component_layout.rs index a840d520a62..15a69111b3a 100644 --- a/crates/component/src/component_layout.rs +++ b/crates/component/src/component_layout.rs @@ -95,8 +95,6 @@ pub struct ComponentExampleGroup { pub title: Option, pub examples: Vec, pub width: Option, - pub grow: bool, - pub vertical: bool, } impl RenderOnce for ComponentExampleGroup { @@ -155,8 +153,6 @@ impl ComponentExampleGroup { title: None, examples, width: None, - grow: false, - vertical: false, } } pub fn with_title(title: impl Into, examples: Vec) -> Self { @@ -164,22 +160,12 @@ impl ComponentExampleGroup { title: Some(title.into()), examples, width: None, - grow: false, - vertical: false, } } pub fn width(mut self, width: Pixels) -> Self { self.width = Some(width); self } - pub fn grow(mut self) -> Self { - self.grow = true; - self - } - pub fn vertical(mut self) -> Self { - self.vertical = true; - self - } } pub fn single_example( @@ -189,10 +175,6 @@ pub fn single_example( ComponentExample::new(variant_name, example) } -pub fn empty_example(variant_name: impl Into) -> ComponentExample { - ComponentExample::new(variant_name, div().w_full().text_center().items_center().text_xs().opacity(0.4).child("This space is intentionally left blank. It indicates a case that should render nothing.").into_any_element()) -} - pub fn example_group(examples: Vec) -> ComponentExampleGroup { ComponentExampleGroup::new(examples) } diff --git a/crates/extensions_ui/src/components/extension_card.rs b/crates/extensions_ui/src/components/extension_card.rs index 9adcaf0532f..c458512a560 100644 --- a/crates/extensions_ui/src/components/extension_card.rs +++ b/crates/extensions_ui/src/components/extension_card.rs @@ -586,7 +586,7 @@ impl Component for ExtensionCard { div() .w_128() - .child(example_group(examples).vertical()) + .child(example_group(examples)) .into_any_element() } } diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 1d764d6a2ec..89743677b56 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -10604,170 +10604,162 @@ impl Component for PanelRepoFooter { .gap_6() .w_full() .flex_none() - .children(vec![ - example_group_with_title( - "Action Button States", - vec![ - single_example( - "No Branch", - div() - .w(example_width) - .overflow_hidden() - .child(PanelRepoFooter::new_preview(active_repository(1), None)) - .into_any_element(), - ), - single_example( - "Remote status unknown", - div() - .w(example_width) - .overflow_hidden() - .child(PanelRepoFooter::new_preview( - active_repository(2), - Some(branch(unknown_upstream)), - )) - .into_any_element(), - ), - single_example( - "No Remote Upstream", - div() - .w(example_width) - .overflow_hidden() - .child(PanelRepoFooter::new_preview( - active_repository(3), - Some(branch(no_remote_upstream)), - )) - .into_any_element(), - ), - single_example( - "Not Ahead or Behind", - div() - .w(example_width) - .overflow_hidden() - .child(PanelRepoFooter::new_preview( - active_repository(4), - Some(branch(not_ahead_or_behind_upstream)), - )) - .into_any_element(), - ), - single_example( - "Behind remote", - div() - .w(example_width) - .overflow_hidden() - .child(PanelRepoFooter::new_preview( - active_repository(5), - Some(branch(behind_upstream)), - )) - .into_any_element(), - ), - single_example( - "Ahead of remote", - div() - .w(example_width) - .overflow_hidden() - .child(PanelRepoFooter::new_preview( - active_repository(6), - Some(branch(ahead_of_upstream)), - )) - .into_any_element(), - ), - single_example( - "Ahead and behind remote", - div() - .w(example_width) - .overflow_hidden() - .child(PanelRepoFooter::new_preview( - active_repository(7), - Some(branch(ahead_and_behind_upstream)), - )) - .into_any_element(), - ), - ], - ) - .grow() - .vertical(), - ]) - .children(vec![ - example_group_with_title( - "Labels", - vec![ - single_example( - "Short Branch & Repo", - div() - .w(example_width) - .overflow_hidden() - .child(PanelRepoFooter::new_preview( - SharedString::from("zed"), - Some(custom("main", behind_upstream)), - )) - .into_any_element(), - ), - single_example( - "Long Branch", - div() - .w(example_width) - .overflow_hidden() - .child(PanelRepoFooter::new_preview( - SharedString::from("zed"), - Some(custom( - "redesign-and-update-git-ui-list-entry-style", - behind_upstream, - )), - )) - .into_any_element(), - ), - single_example( - "Long Repo", - div() - .w(example_width) - .overflow_hidden() - .child(PanelRepoFooter::new_preview( - SharedString::from("zed-industries-community-examples"), - Some(custom("gpui", ahead_of_upstream)), - )) - .into_any_element(), - ), - single_example( - "Long Repo & Branch", - div() - .w(example_width) - .overflow_hidden() - .child(PanelRepoFooter::new_preview( - SharedString::from("zed-industries-community-examples"), - Some(custom( - "redesign-and-update-git-ui-list-entry-style", - behind_upstream, - )), - )) - .into_any_element(), - ), - single_example( - "Uppercase Repo", - div() - .w(example_width) - .overflow_hidden() - .child(PanelRepoFooter::new_preview( - SharedString::from("LICENSES"), - Some(custom("main", ahead_of_upstream)), - )) - .into_any_element(), - ), - single_example( - "Uppercase Branch", - div() - .w(example_width) - .overflow_hidden() - .child(PanelRepoFooter::new_preview( - SharedString::from("zed"), - Some(custom("update-README", behind_upstream)), - )) - .into_any_element(), - ), - ], - ) - .grow() - .vertical(), - ]) + .children(vec![example_group_with_title( + "Action Button States", + vec![ + single_example( + "No Branch", + div() + .w(example_width) + .overflow_hidden() + .child(PanelRepoFooter::new_preview(active_repository(1), None)) + .into_any_element(), + ), + single_example( + "Remote status unknown", + div() + .w(example_width) + .overflow_hidden() + .child(PanelRepoFooter::new_preview( + active_repository(2), + Some(branch(unknown_upstream)), + )) + .into_any_element(), + ), + single_example( + "No Remote Upstream", + div() + .w(example_width) + .overflow_hidden() + .child(PanelRepoFooter::new_preview( + active_repository(3), + Some(branch(no_remote_upstream)), + )) + .into_any_element(), + ), + single_example( + "Not Ahead or Behind", + div() + .w(example_width) + .overflow_hidden() + .child(PanelRepoFooter::new_preview( + active_repository(4), + Some(branch(not_ahead_or_behind_upstream)), + )) + .into_any_element(), + ), + single_example( + "Behind remote", + div() + .w(example_width) + .overflow_hidden() + .child(PanelRepoFooter::new_preview( + active_repository(5), + Some(branch(behind_upstream)), + )) + .into_any_element(), + ), + single_example( + "Ahead of remote", + div() + .w(example_width) + .overflow_hidden() + .child(PanelRepoFooter::new_preview( + active_repository(6), + Some(branch(ahead_of_upstream)), + )) + .into_any_element(), + ), + single_example( + "Ahead and behind remote", + div() + .w(example_width) + .overflow_hidden() + .child(PanelRepoFooter::new_preview( + active_repository(7), + Some(branch(ahead_and_behind_upstream)), + )) + .into_any_element(), + ), + ], + )]) + .children(vec![example_group_with_title( + "Labels", + vec![ + single_example( + "Short Branch & Repo", + div() + .w(example_width) + .overflow_hidden() + .child(PanelRepoFooter::new_preview( + SharedString::from("zed"), + Some(custom("main", behind_upstream)), + )) + .into_any_element(), + ), + single_example( + "Long Branch", + div() + .w(example_width) + .overflow_hidden() + .child(PanelRepoFooter::new_preview( + SharedString::from("zed"), + Some(custom( + "redesign-and-update-git-ui-list-entry-style", + behind_upstream, + )), + )) + .into_any_element(), + ), + single_example( + "Long Repo", + div() + .w(example_width) + .overflow_hidden() + .child(PanelRepoFooter::new_preview( + SharedString::from("zed-industries-community-examples"), + Some(custom("gpui", ahead_of_upstream)), + )) + .into_any_element(), + ), + single_example( + "Long Repo & Branch", + div() + .w(example_width) + .overflow_hidden() + .child(PanelRepoFooter::new_preview( + SharedString::from("zed-industries-community-examples"), + Some(custom( + "redesign-and-update-git-ui-list-entry-style", + behind_upstream, + )), + )) + .into_any_element(), + ), + single_example( + "Uppercase Repo", + div() + .w(example_width) + .overflow_hidden() + .child(PanelRepoFooter::new_preview( + SharedString::from("LICENSES"), + Some(custom("main", ahead_of_upstream)), + )) + .into_any_element(), + ), + single_example( + "Uppercase Branch", + div() + .w(example_width) + .overflow_hidden() + .child(PanelRepoFooter::new_preview( + SharedString::from("zed"), + Some(custom("update-README", behind_upstream)), + )) + .into_any_element(), + ), + ], + )]) .into_any_element() } } diff --git a/crates/notifications/src/status_toast.rs b/crates/notifications/src/status_toast.rs index e07cb99df59..21d2de96697 100644 --- a/crates/notifications/src/status_toast.rs +++ b/crates/notifications/src/status_toast.rs @@ -244,8 +244,7 @@ impl Component for StatusToast { single_example("Warning", div().child(warning_example).into_any_element()), single_example("Create PR", div().child(pr_example).into_any_element()), ], - ) - .vertical(), + ), ]) .into_any_element() } diff --git a/crates/onboarding/src/theme_preview.rs b/crates/onboarding/src/theme_preview.rs index 534272ecda8..87d718c252a 100644 --- a/crates/onboarding/src/theme_preview.rs +++ b/crates/onboarding/src/theme_preview.rs @@ -354,26 +354,23 @@ impl Component for ThemePreviewTile { vec![] } }) - .child( - example_group(vec![single_example( - "Default Themes", - h_flex() - .gap_4() - .children( - themes_to_preview - .into_iter() - .map(|theme| { - div() - .w(px(200.)) - .h(px(140.)) - .child(ThemePreviewTile::new(theme, 0.42)) - }) - .collect::>(), - ) - .into_any_element(), - )]) - .grow(), - ) + .child(example_group(vec![single_example( + "Default Themes", + h_flex() + .gap_4() + .children( + themes_to_preview + .into_iter() + .map(|theme| { + div() + .w(px(200.)) + .h(px(140.)) + .child(ThemePreviewTile::new(theme, 0.42)) + }) + .collect::>(), + ) + .into_any_element(), + )])) .into_any_element() } } diff --git a/crates/ui/src/components/ai/ai_setting_item.rs b/crates/ui/src/components/ai/ai_setting_item.rs index f2b9abdd015..c1fb3627dbb 100644 --- a/crates/ui/src/components/ai/ai_setting_item.rs +++ b/crates/ui/src/components/ai/ai_setting_item.rs @@ -409,6 +409,6 @@ impl Component for AiSettingItem { ), ]; - example_group(examples).vertical().into_any_element() + example_group(examples).into_any_element() } } diff --git a/crates/ui/src/components/ai/thread_item.rs b/crates/ui/src/components/ai/thread_item.rs index 7cdb1557f19..9a70b32f7a9 100644 --- a/crates/ui/src/components/ai/thread_item.rs +++ b/crates/ui/src/components/ai/thread_item.rs @@ -980,9 +980,7 @@ impl Component for ThreadItem { ), ]; - example_group(thread_item_examples) - .vertical() - .into_any_element() + example_group(thread_item_examples).into_any_element() } } diff --git a/crates/ui/src/components/banner.rs b/crates/ui/src/components/banner.rs index 4568959a373..87e1874058b 100644 --- a/crates/ui/src/components/banner.rs +++ b/crates/ui/src/components/banner.rs @@ -184,8 +184,6 @@ impl Component for Banner { ), ]; - example_group(severity_examples) - .vertical() - .into_any_element() + example_group(severity_examples).into_any_element() } } diff --git a/crates/ui/src/components/button/button_link.rs b/crates/ui/src/components/button/button_link.rs index 841df96f555..e1b7de0861e 100644 --- a/crates/ui/src/components/button/button_link.rs +++ b/crates/ui/src/components/button/button_link.rs @@ -88,13 +88,10 @@ impl Component for ButtonLink { fn preview(_window: &mut Window, _cx: &mut App) -> AnyElement { v_flex() .gap_6() - .child( - example_group(vec![single_example( - "Simple", - ButtonLink::new("zed.dev", "https://zed.dev").into_any_element(), - )]) - .vertical(), - ) + .child(example_group(vec![single_example( + "Simple", + ButtonLink::new("zed.dev", "https://zed.dev").into_any_element(), + )])) .into_any_element() } } diff --git a/crates/ui/src/components/button/copy_button.rs b/crates/ui/src/components/button/copy_button.rs index 924d34e7c2f..4033aef4c95 100644 --- a/crates/ui/src/components/button/copy_button.rs +++ b/crates/ui/src/components/button/copy_button.rs @@ -195,6 +195,6 @@ impl Component for CopyButton { ), ]; - example_group(examples).vertical().into_any_element() + example_group(examples).into_any_element() } } diff --git a/crates/ui/src/components/callout.rs b/crates/ui/src/components/callout.rs index 46bbb58a1d1..f2db6223b41 100644 --- a/crates/ui/src/components/callout.rs +++ b/crates/ui/src/components/callout.rs @@ -365,8 +365,8 @@ impl Component for Callout { v_flex() .gap_4() - .child(example_group(basic_examples).vertical()) - .child(example_group_with_title("Severity", severity_examples).vertical()) + .child(example_group(basic_examples)) + .child(example_group_with_title("Severity", severity_examples)) .into_any_element() } } diff --git a/crates/ui/src/components/chip.rs b/crates/ui/src/components/chip.rs index 2609f2fc97b..1fc08410921 100644 --- a/crates/ui/src/components/chip.rs +++ b/crates/ui/src/components/chip.rs @@ -167,6 +167,6 @@ impl Component for Chip { ), ]; - example_group(chip_examples).vertical().into_any_element() + example_group(chip_examples).into_any_element() } } diff --git a/crates/ui/src/components/collab/collab_notification.rs b/crates/ui/src/components/collab/collab_notification.rs index 382749da37d..5cea7ac71b9 100644 --- a/crates/ui/src/components/collab/collab_notification.rs +++ b/crates/ui/src/components/collab/collab_notification.rs @@ -180,8 +180,11 @@ impl Component for CollabNotification { v_flex() .gap_6() - .child(example_group_with_title("Calls & Projects", call_examples).vertical()) - .child(example_group_with_title("Contact & Channel Toasts", toast_examples).vertical()) + .child(example_group_with_title("Calls & Projects", call_examples)) + .child(example_group_with_title( + "Contact & Channel Toasts", + toast_examples, + )) .into_any_element() } } diff --git a/crates/ui/src/components/diff_stat.rs b/crates/ui/src/components/diff_stat.rs index 20a0b38aa5c..338d4628743 100644 --- a/crates/ui/src/components/diff_stat.rs +++ b/crates/ui/src/components/diff_stat.rs @@ -86,8 +86,6 @@ impl Component for DiffStat { .into_any_element(), )]; - example_group(diff_stat_example) - .vertical() - .into_any_element() + example_group(diff_stat_example).into_any_element() } } diff --git a/crates/ui/src/components/label/spinner_label.rs b/crates/ui/src/components/label/spinner_label.rs index 583debde9cb..7ea179a12e1 100644 --- a/crates/ui/src/components/label/spinner_label.rs +++ b/crates/ui/src/components/label/spinner_label.rs @@ -205,6 +205,6 @@ impl Component for SpinnerLabel { single_example("Sand Variant", SpinnerLabel::sand().into_any_element()), ]; - example_group(examples).vertical().into_any_element() + example_group(examples).into_any_element() } } diff --git a/crates/ui/src/components/list/list_bullet_item.rs b/crates/ui/src/components/list/list_bullet_item.rs index 8fed3158756..f4c0daa053f 100644 --- a/crates/ui/src/components/list/list_bullet_item.rs +++ b/crates/ui/src/components/list/list_bullet_item.rs @@ -107,7 +107,7 @@ impl Component for ListBulletItem { v_flex() .gap_6() - .child(example_group(basic_examples).vertical()) + .child(example_group(basic_examples)) .into_any_element() } } diff --git a/crates/ui/src/components/notification/announcement_toast.rs b/crates/ui/src/components/notification/announcement_toast.rs index d47d264843c..4ce6879aa92 100644 --- a/crates/ui/src/components/notification/announcement_toast.rs +++ b/crates/ui/src/components/notification/announcement_toast.rs @@ -190,7 +190,7 @@ impl Component for AnnouncementToast { v_flex() .gap_6() - .child(example_group(examples).vertical()) + .child(example_group(examples)) .into_any_element() } } diff --git a/crates/ui/src/styles/animation.rs b/crates/ui/src/styles/animation.rs index ea08b74ca9a..e67138414eb 100644 --- a/crates/ui/src/styles/animation.rs +++ b/crates/ui/src/styles/animation.rs @@ -197,8 +197,7 @@ impl Component for Animation { .into_any_element(), ), ], - ) - .grow(), + ), example_group_with_title( "Fade and Animate In", vec![ @@ -267,8 +266,7 @@ impl Component for Animation { .into_any_element(), ), ], - ) - .grow(), + ), ]) .into_any_element() }