Skip to content

Commit 66382ac

Browse files
authored
ui: Remove outdated/unused component stories (#43118)
This PR removes basically all of the component stories, with the exception of the context menu, which is a bit more intricate to set up. All of the component that won't have a story after this PR will have an entry in the Component Preview, which serves basically the same purpose. Release Notes: - N/A
1 parent ba59626 commit 66382ac

File tree

17 files changed

+352
-709
lines changed

17 files changed

+352
-709
lines changed

crates/storybook/src/story_selector.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,9 @@ pub enum ComponentStory {
1717
ContextMenu,
1818
Cursor,
1919
Focus,
20-
IconButton,
21-
Keybinding,
22-
List,
23-
ListHeader,
24-
ListItem,
2520
OverflowScroll,
2621
Picker,
2722
Scroll,
28-
Tab,
29-
TabBar,
3023
Text,
3124
ViewportUnits,
3225
WithRemSize,
@@ -46,16 +39,9 @@ impl ComponentStory {
4639
Self::ContextMenu => cx.new(|_| ui::ContextMenuStory).into(),
4740
Self::Cursor => cx.new(|_| crate::stories::CursorStory).into(),
4841
Self::Focus => FocusStory::model(window, cx).into(),
49-
Self::IconButton => cx.new(|_| ui::IconButtonStory).into(),
50-
Self::Keybinding => cx.new(|_| ui::KeybindingStory).into(),
51-
Self::List => cx.new(|_| ui::ListStory).into(),
52-
Self::ListHeader => cx.new(|_| ui::ListHeaderStory).into(),
53-
Self::ListItem => cx.new(|_| ui::ListItemStory).into(),
5442
Self::OverflowScroll => cx.new(|_| crate::stories::OverflowScrollStory).into(),
5543
Self::Picker => PickerStory::new(window, cx).into(),
5644
Self::Scroll => ScrollStory::model(cx).into(),
57-
Self::Tab => cx.new(|_| ui::TabStory).into(),
58-
Self::TabBar => cx.new(|_| ui::TabBarStory).into(),
5945
Self::Text => TextStory::model(cx).into(),
6046
Self::ViewportUnits => cx.new(|_| crate::stories::ViewportUnitsStory).into(),
6147
Self::WithRemSize => cx.new(|_| crate::stories::WithRemSizeStory).into(),

crates/ui/src/components/list/list.rs

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
use component::{Component, ComponentScope, example_group_with_title, single_example};
12
use gpui::AnyElement;
23
use smallvec::SmallVec;
34

4-
use crate::{Label, ListHeader, prelude::*, v_flex};
5+
use crate::{Label, ListHeader, ListItem, prelude::*};
56

67
pub enum EmptyMessage {
78
Text(SharedString),
89
Element(AnyElement),
910
}
1011

11-
#[derive(IntoElement)]
12+
#[derive(IntoElement, RegisterComponent)]
1213
pub struct List {
1314
/// Message to display when the list is empty
1415
/// Defaults to "No items"
@@ -92,3 +93,50 @@ impl RenderOnce for List {
9293
})
9394
}
9495
}
96+
97+
impl Component for List {
98+
fn scope() -> ComponentScope {
99+
ComponentScope::Layout
100+
}
101+
102+
fn description() -> Option<&'static str> {
103+
Some(
104+
"A container component for displaying a collection of list items with optional header and empty state.",
105+
)
106+
}
107+
108+
fn preview(_window: &mut Window, _cx: &mut App) -> Option<AnyElement> {
109+
Some(
110+
v_flex()
111+
.gap_6()
112+
.children(vec![example_group_with_title(
113+
"Basic Lists",
114+
vec![
115+
single_example(
116+
"Simple List",
117+
List::new()
118+
.child(ListItem::new("item1").child(Label::new("Item 1")))
119+
.child(ListItem::new("item2").child(Label::new("Item 2")))
120+
.child(ListItem::new("item3").child(Label::new("Item 3")))
121+
.into_any_element(),
122+
),
123+
single_example(
124+
"With Header",
125+
List::new()
126+
.header(ListHeader::new("Section Header"))
127+
.child(ListItem::new("item1").child(Label::new("Item 1")))
128+
.child(ListItem::new("item2").child(Label::new("Item 2")))
129+
.into_any_element(),
130+
),
131+
single_example(
132+
"Empty List",
133+
List::new()
134+
.empty_message("No items to display")
135+
.into_any_element(),
136+
),
137+
],
138+
)])
139+
.into_any_element(),
140+
)
141+
}
142+
}

crates/ui/src/components/list/list_bullet_item.rs

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use crate::{ListItem, prelude::*};
2+
use component::{Component, ComponentScope, example_group_with_title, single_example};
23
use gpui::{IntoElement, ParentElement, SharedString};
34

4-
#[derive(IntoElement)]
5+
#[derive(IntoElement, RegisterComponent)]
56
pub struct ListBulletItem {
67
label: SharedString,
78
}
@@ -38,3 +39,45 @@ impl RenderOnce for ListBulletItem {
3839
.into_any_element()
3940
}
4041
}
42+
43+
impl Component for ListBulletItem {
44+
fn scope() -> ComponentScope {
45+
ComponentScope::DataDisplay
46+
}
47+
48+
fn description() -> Option<&'static str> {
49+
Some("A list item with a bullet point indicator for unordered lists.")
50+
}
51+
52+
fn preview(_window: &mut Window, _cx: &mut App) -> Option<AnyElement> {
53+
Some(
54+
v_flex()
55+
.gap_6()
56+
.child(example_group_with_title(
57+
"Bullet Items",
58+
vec![
59+
single_example(
60+
"Simple",
61+
ListBulletItem::new("First bullet item").into_any_element(),
62+
),
63+
single_example(
64+
"Multiple Lines",
65+
v_flex()
66+
.child(ListBulletItem::new("First item"))
67+
.child(ListBulletItem::new("Second item"))
68+
.child(ListBulletItem::new("Third item"))
69+
.into_any_element(),
70+
),
71+
single_example(
72+
"Long Text",
73+
ListBulletItem::new(
74+
"A longer bullet item that demonstrates text wrapping behavior",
75+
)
76+
.into_any_element(),
77+
),
78+
],
79+
))
80+
.into_any_element(),
81+
)
82+
}
83+
}

crates/ui/src/components/list/list_header.rs

Lines changed: 80 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
use std::sync::Arc;
22

3-
use crate::{Disclosure, Label, h_flex, prelude::*};
3+
use crate::{Disclosure, prelude::*};
4+
use component::{Component, ComponentScope, example_group_with_title, single_example};
45
use gpui::{AnyElement, ClickEvent};
56
use settings::Settings;
67
use theme::ThemeSettings;
78

8-
#[derive(IntoElement)]
9+
#[derive(IntoElement, RegisterComponent)]
910
pub struct ListHeader {
1011
/// The label of the header.
1112
label: SharedString,
@@ -138,3 +139,80 @@ impl RenderOnce for ListHeader {
138139
)
139140
}
140141
}
142+
143+
impl Component for ListHeader {
144+
fn scope() -> ComponentScope {
145+
ComponentScope::DataDisplay
146+
}
147+
148+
fn description() -> Option<&'static str> {
149+
Some(
150+
"A header component for lists with support for icons, actions, and collapsible sections.",
151+
)
152+
}
153+
154+
fn preview(_window: &mut Window, _cx: &mut App) -> Option<AnyElement> {
155+
Some(
156+
v_flex()
157+
.gap_6()
158+
.children(vec![
159+
example_group_with_title(
160+
"Basic Headers",
161+
vec![
162+
single_example(
163+
"Simple",
164+
ListHeader::new("Section Header").into_any_element(),
165+
),
166+
single_example(
167+
"With Icon",
168+
ListHeader::new("Files")
169+
.start_slot(Icon::new(IconName::File))
170+
.into_any_element(),
171+
),
172+
single_example(
173+
"With End Slot",
174+
ListHeader::new("Recent")
175+
.end_slot(Label::new("5").color(Color::Muted))
176+
.into_any_element(),
177+
),
178+
],
179+
),
180+
example_group_with_title(
181+
"Collapsible Headers",
182+
vec![
183+
single_example(
184+
"Expanded",
185+
ListHeader::new("Expanded Section")
186+
.toggle(Some(true))
187+
.into_any_element(),
188+
),
189+
single_example(
190+
"Collapsed",
191+
ListHeader::new("Collapsed Section")
192+
.toggle(Some(false))
193+
.into_any_element(),
194+
),
195+
],
196+
),
197+
example_group_with_title(
198+
"States",
199+
vec![
200+
single_example(
201+
"Selected",
202+
ListHeader::new("Selected Header")
203+
.toggle_state(true)
204+
.into_any_element(),
205+
),
206+
single_example(
207+
"Inset",
208+
ListHeader::new("Inset Header")
209+
.inset(true)
210+
.into_any_element(),
211+
),
212+
],
213+
),
214+
])
215+
.into_any_element(),
216+
)
217+
}
218+
}

crates/ui/src/components/list/list_item.rs

Lines changed: 114 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::sync::Arc;
22

3+
use component::{Component, ComponentScope, example_group_with_title, single_example};
34
use gpui::{AnyElement, AnyView, ClickEvent, MouseButton, MouseDownEvent, Pixels, px};
45
use smallvec::SmallVec;
56

@@ -13,7 +14,7 @@ pub enum ListItemSpacing {
1314
Sparse,
1415
}
1516

16-
#[derive(IntoElement)]
17+
#[derive(IntoElement, RegisterComponent)]
1718
pub struct ListItem {
1819
id: ElementId,
1920
group_name: Option<SharedString>,
@@ -355,3 +356,115 @@ impl RenderOnce for ListItem {
355356
)
356357
}
357358
}
359+
360+
impl Component for ListItem {
361+
fn scope() -> ComponentScope {
362+
ComponentScope::DataDisplay
363+
}
364+
365+
fn description() -> Option<&'static str> {
366+
Some(
367+
"A flexible list item component with support for icons, actions, disclosure toggles, and hierarchical display.",
368+
)
369+
}
370+
371+
fn preview(_window: &mut Window, _cx: &mut App) -> Option<AnyElement> {
372+
Some(
373+
v_flex()
374+
.gap_6()
375+
.children(vec![
376+
example_group_with_title(
377+
"Basic List Items",
378+
vec![
379+
single_example(
380+
"Simple",
381+
ListItem::new("simple")
382+
.child(Label::new("Simple list item"))
383+
.into_any_element(),
384+
),
385+
single_example(
386+
"With Icon",
387+
ListItem::new("with_icon")
388+
.start_slot(Icon::new(IconName::File))
389+
.child(Label::new("List item with icon"))
390+
.into_any_element(),
391+
),
392+
single_example(
393+
"Selected",
394+
ListItem::new("selected")
395+
.toggle_state(true)
396+
.start_slot(Icon::new(IconName::Check))
397+
.child(Label::new("Selected item"))
398+
.into_any_element(),
399+
),
400+
],
401+
),
402+
example_group_with_title(
403+
"List Item Spacing",
404+
vec![
405+
single_example(
406+
"Dense",
407+
ListItem::new("dense")
408+
.spacing(ListItemSpacing::Dense)
409+
.child(Label::new("Dense spacing"))
410+
.into_any_element(),
411+
),
412+
single_example(
413+
"Extra Dense",
414+
ListItem::new("extra_dense")
415+
.spacing(ListItemSpacing::ExtraDense)
416+
.child(Label::new("Extra dense spacing"))
417+
.into_any_element(),
418+
),
419+
single_example(
420+
"Sparse",
421+
ListItem::new("sparse")
422+
.spacing(ListItemSpacing::Sparse)
423+
.child(Label::new("Sparse spacing"))
424+
.into_any_element(),
425+
),
426+
],
427+
),
428+
example_group_with_title(
429+
"With Slots",
430+
vec![
431+
single_example(
432+
"End Slot",
433+
ListItem::new("end_slot")
434+
.child(Label::new("Item with end slot"))
435+
.end_slot(Icon::new(IconName::ChevronRight))
436+
.into_any_element(),
437+
),
438+
single_example(
439+
"With Toggle",
440+
ListItem::new("with_toggle")
441+
.toggle(Some(true))
442+
.child(Label::new("Expandable item"))
443+
.into_any_element(),
444+
),
445+
],
446+
),
447+
example_group_with_title(
448+
"States",
449+
vec![
450+
single_example(
451+
"Disabled",
452+
ListItem::new("disabled")
453+
.disabled(true)
454+
.child(Label::new("Disabled item"))
455+
.into_any_element(),
456+
),
457+
single_example(
458+
"Non-selectable",
459+
ListItem::new("non_selectable")
460+
.selectable(false)
461+
.child(Label::new("Non-selectable item"))
462+
.into_any_element(),
463+
),
464+
],
465+
),
466+
])
467+
.into_any_element(),
468+
)
469+
}
470+
}

0 commit comments

Comments
 (0)