component: Remove no-op grow and vertical options (#67220)

## 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
This commit is contained in:
Parker Loflin
2026-11-20 22:22:28 +00:00
committed by GitHub
parent 3463950447
commit 54fff2ff5b
21 changed files with 197 additions and 246 deletions
@@ -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()
-2
View File
@@ -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()
-6
View File
@@ -73,12 +73,6 @@ impl ComponentRegistry {
self.components.values()
}
pub fn sorted_previews(&self) -> Vec<ComponentMetadata> {
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()
}
-18
View File
@@ -95,8 +95,6 @@ pub struct ComponentExampleGroup {
pub title: Option<SharedString>,
pub examples: Vec<ComponentExample>,
pub width: Option<Pixels>,
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<SharedString>, examples: Vec<ComponentExample>) -> 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<SharedString>) -> 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<ComponentExample>) -> ComponentExampleGroup {
ComponentExampleGroup::new(examples)
}
@@ -586,7 +586,7 @@ impl Component for ExtensionCard {
div()
.w_128()
.child(example_group(examples).vertical())
.child(example_group(examples))
.into_any_element()
}
}
+156 -164
View File
@@ -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()
}
}
+1 -2
View File
@@ -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()
}
+17 -20
View File
@@ -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::<Vec<_>>(),
)
.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::<Vec<_>>(),
)
.into_any_element(),
)]))
.into_any_element()
}
}
@@ -409,6 +409,6 @@ impl Component for AiSettingItem {
),
];
example_group(examples).vertical().into_any_element()
example_group(examples).into_any_element()
}
}
+1 -3
View File
@@ -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()
}
}
+1 -3
View File
@@ -184,8 +184,6 @@ impl Component for Banner {
),
];
example_group(severity_examples)
.vertical()
.into_any_element()
example_group(severity_examples).into_any_element()
}
}
@@ -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()
}
}
@@ -195,6 +195,6 @@ impl Component for CopyButton {
),
];
example_group(examples).vertical().into_any_element()
example_group(examples).into_any_element()
}
}
+2 -2
View File
@@ -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()
}
}
+1 -1
View File
@@ -167,6 +167,6 @@ impl Component for Chip {
),
];
example_group(chip_examples).vertical().into_any_element()
example_group(chip_examples).into_any_element()
}
}
@@ -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()
}
}
+1 -3
View File
@@ -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()
}
}
@@ -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()
}
}
@@ -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()
}
}
@@ -190,7 +190,7 @@ impl Component for AnnouncementToast {
v_flex()
.gap_6()
.child(example_group(examples).vertical())
.child(example_group(examples))
.into_any_element()
}
}
+2 -4
View File
@@ -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()
}