Remove unneeded constructors for stories

This commit is contained in:
Marshall Bowers 2023-10-26 16:46:49 +02:00
parent 65045b9c52
commit 61694bba6a
33 changed files with 62 additions and 227 deletions

View File

@ -10,10 +10,6 @@ use crate::story::Story;
pub struct ZIndexStory;
impl ZIndexStory {
pub fn new() -> Self {
Self
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
Story::container(cx)
.child(Story::title(cx, "z-index"))

View File

@ -27,31 +27,16 @@ pub enum ElementStory {
impl ElementStory {
pub fn story(&self, cx: &mut WindowContext) -> AnyView {
match self {
Self::Avatar => {
view(cx.entity(|cx| ()), |_, _| ui::AvatarStory::new().render()).into_any()
}
Self::Button => {
view(cx.entity(|cx| ()), |_, _| ui::ButtonStory::new().render()).into_any()
}
Self::Details => view(cx.entity(|cx| ()), |_, _| {
ui::DetailsStory::new().render()
})
.into_any(),
Self::Avatar => view(cx.entity(|cx| ()), |_, _| ui::AvatarStory.render()).into_any(),
Self::Button => view(cx.entity(|cx| ()), |_, _| ui::ButtonStory.render()).into_any(),
Self::Details => view(cx.entity(|cx| ()), |_, _| ui::DetailsStory.render()).into_any(),
Self::Focus => FocusStory::view(cx).into_any(),
Self::Icon => {
view(cx.entity(|cx| ()), |_, _| ui::IconStory::new().render()).into_any()
}
Self::Input => {
view(cx.entity(|cx| ()), |_, _| ui::InputStory::new().render()).into_any()
}
Self::Label => {
view(cx.entity(|cx| ()), |_, _| ui::LabelStory::new().render()).into_any()
}
Self::Icon => view(cx.entity(|cx| ()), |_, _| ui::IconStory.render()).into_any(),
Self::Input => view(cx.entity(|cx| ()), |_, _| ui::InputStory.render()).into_any(),
Self::Label => view(cx.entity(|cx| ()), |_, _| ui::LabelStory.render()).into_any(),
Self::Scroll => ScrollStory::view(cx).into_any(),
Self::Text => TextStory::view(cx).into_any(),
Self::ZIndex => {
view(cx.entity(|cx| ()), |_, _| ZIndexStory::new().render()).into_any()
}
Self::ZIndex => view(cx.entity(|cx| ()), |_, _| ZIndexStory.render()).into_any(),
}
}
}
@ -90,96 +75,67 @@ pub enum ComponentStory {
impl ComponentStory {
pub fn story(&self, cx: &mut WindowContext) -> AnyView {
match self {
Self::AssistantPanel => view(cx.entity(|cx| ()), |_, _| {
ui::AssistantPanelStory::new().render()
})
.into_any(),
Self::Buffer => {
view(cx.entity(|cx| ()), |_, _| ui::BufferStory::new().render()).into_any()
Self::AssistantPanel => {
view(cx.entity(|cx| ()), |_, _| ui::AssistantPanelStory.render()).into_any()
}
Self::Buffer => view(cx.entity(|cx| ()), |_, _| ui::BufferStory.render()).into_any(),
Self::Breadcrumb => {
view(cx.entity(|cx| ()), |_, _| ui::BreadcrumbStory.render()).into_any()
}
Self::ChatPanel => {
view(cx.entity(|cx| ()), |_, _| ui::ChatPanelStory.render()).into_any()
}
Self::CollabPanel => {
view(cx.entity(|cx| ()), |_, _| ui::CollabPanelStory.render()).into_any()
}
Self::CommandPalette => {
view(cx.entity(|cx| ()), |_, _| ui::CommandPaletteStory.render()).into_any()
}
Self::ContextMenu => {
view(cx.entity(|cx| ()), |_, _| ui::ContextMenuStory.render()).into_any()
}
Self::Facepile => {
view(cx.entity(|cx| ()), |_, _| ui::FacepileStory.render()).into_any()
}
Self::Keybinding => {
view(cx.entity(|cx| ()), |_, _| ui::KeybindingStory.render()).into_any()
}
Self::Breadcrumb => view(cx.entity(|cx| ()), |_, _| {
ui::BreadcrumbStory::new().render()
})
.into_any(),
Self::ChatPanel => view(cx.entity(|cx| ()), |_, _| {
ui::ChatPanelStory::new().render()
})
.into_any(),
Self::CollabPanel => view(cx.entity(|cx| ()), |_, _| {
ui::CollabPanelStory::new().render()
})
.into_any(),
Self::CommandPalette => view(cx.entity(|cx| ()), |_, _| {
ui::CommandPaletteStory::new().render()
})
.into_any(),
Self::ContextMenu => view(cx.entity(|cx| ()), |_, _| {
ui::ContextMenuStory::new().render()
})
.into_any(),
Self::Facepile => view(cx.entity(|cx| ()), |_, _| {
ui::FacepileStory::new().render()
})
.into_any(),
Self::Keybinding => view(cx.entity(|cx| ()), |_, _| {
ui::KeybindingStory::new().render()
})
.into_any(),
Self::LanguageSelector => view(cx.entity(|cx| ()), |_, _| {
ui::LanguageSelectorStory::new().render()
})
.into_any(),
Self::MultiBuffer => view(cx.entity(|cx| ()), |_, _| {
ui::MultiBufferStory::new().render()
ui::LanguageSelectorStory.render()
})
.into_any(),
Self::MultiBuffer => {
view(cx.entity(|cx| ()), |_, _| ui::MultiBufferStory.render()).into_any()
}
Self::NotificationsPanel => view(cx.entity(|cx| ()), |_, _| {
ui::NotificationsPanelStory::new().render()
ui::NotificationsPanelStory.render()
})
.into_any(),
Self::Palette => view(cx.entity(|cx| ()), |_, _| {
ui::PaletteStory::new().render()
})
.into_any(),
Self::Panel => {
view(cx.entity(|cx| ()), |_, _| ui::PanelStory::new().render()).into_any()
Self::Palette => view(cx.entity(|cx| ()), |_, _| ui::PaletteStory.render()).into_any(),
Self::Panel => view(cx.entity(|cx| ()), |_, _| ui::PanelStory.render()).into_any(),
Self::ProjectPanel => {
view(cx.entity(|cx| ()), |_, _| ui::ProjectPanelStory.render()).into_any()
}
Self::ProjectPanel => view(cx.entity(|cx| ()), |_, _| {
ui::ProjectPanelStory::new().render()
})
.into_any(),
Self::RecentProjects => view(cx.entity(|cx| ()), |_, _| {
ui::RecentProjectsStory::new().render()
})
.into_any(),
Self::Tab => view(cx.entity(|cx| ()), |_, _| ui::TabStory::new().render()).into_any(),
Self::TabBar => {
view(cx.entity(|cx| ()), |_, _| ui::TabBarStory::new().render()).into_any()
Self::RecentProjects => {
view(cx.entity(|cx| ()), |_, _| ui::RecentProjectsStory.render()).into_any()
}
Self::Tab => view(cx.entity(|cx| ()), |_, _| ui::TabStory.render()).into_any(),
Self::TabBar => view(cx.entity(|cx| ()), |_, _| ui::TabBarStory.render()).into_any(),
Self::Terminal => {
view(cx.entity(|cx| ()), |_, _| ui::TerminalStory.render()).into_any()
}
Self::ThemeSelector => {
view(cx.entity(|cx| ()), |_, _| ui::ThemeSelectorStory.render()).into_any()
}
Self::Terminal => view(cx.entity(|cx| ()), |_, _| {
ui::TerminalStory::new().render()
})
.into_any(),
Self::ThemeSelector => view(cx.entity(|cx| ()), |_, _| {
ui::ThemeSelectorStory::new().render()
})
.into_any(),
Self::TitleBar => ui::TitleBarStory::view(cx).into_any(),
Self::Toast => {
view(cx.entity(|cx| ()), |_, _| ui::ToastStory::new().render()).into_any()
Self::Toast => view(cx.entity(|cx| ()), |_, _| ui::ToastStory.render()).into_any(),
Self::Toolbar => view(cx.entity(|cx| ()), |_, _| ui::ToolbarStory.render()).into_any(),
Self::TrafficLights => {
view(cx.entity(|cx| ()), |_, _| ui::TrafficLightsStory.render()).into_any()
}
Self::Copilot => {
view(cx.entity(|cx| ()), |_, _| ui::CopilotModalStory.render()).into_any()
}
Self::Toolbar => view(cx.entity(|cx| ()), |_, _| {
ui::ToolbarStory::new().render()
})
.into_any(),
Self::TrafficLights => view(cx.entity(|cx| ()), |_, _| {
ui::TrafficLightsStory::new().render()
})
.into_any(),
Self::Copilot => view(cx.entity(|cx| ()), |_, _| {
ui::CopilotModalStory::new().render()
})
.into_any(),
Self::Workspace => ui::WorkspaceStory::view(cx).into_any(),
}
}

View File

@ -81,13 +81,9 @@ mod stories {
use super::*;
#[derive(Component)]
pub struct AssistantPanelStory {}
pub struct AssistantPanelStory;
impl AssistantPanelStory {
pub fn new() -> Self {
Self {}
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
Story::container(cx)
.child(Story::title_for::<_, AssistantPanel>(cx))

View File

@ -83,10 +83,6 @@ mod stories {
pub struct BreadcrumbStory;
impl BreadcrumbStory {
pub fn new() -> Self {
Self
}
fn render<V: 'static>(
self,
view_state: &mut V,

View File

@ -246,10 +246,6 @@ mod stories {
pub struct BufferStory;
impl BufferStory {
pub fn new() -> Self {
Self
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);

View File

@ -117,10 +117,6 @@ mod stories {
pub struct ChatPanelStory;
impl ChatPanelStory {
pub fn new() -> Self {
Self
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
Story::container(cx)
.child(Story::title_for::<_, ChatPanel>(cx))

View File

@ -97,10 +97,6 @@ mod stories {
pub struct CollabPanelStory;
impl CollabPanelStory {
pub fn new() -> Self {
Self
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
Story::container(cx)
.child(Story::title_for::<_, CollabPanel>(cx))

View File

@ -35,10 +35,6 @@ mod stories {
pub struct CommandPaletteStory;
impl CommandPaletteStory {
pub fn new() -> Self {
Self
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
Story::container(cx)
.child(Story::title_for::<_, CommandPalette>(cx))

View File

@ -76,10 +76,6 @@ mod stories {
pub struct ContextMenuStory;
impl ContextMenuStory {
pub fn new() -> Self {
Self
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
Story::container(cx)
.child(Story::title_for::<_, ContextMenu>(cx))

View File

@ -33,10 +33,6 @@ mod stories {
pub struct CopilotModalStory;
impl CopilotModalStory {
pub fn new() -> Self {
Self
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
Story::container(cx)
.child(Story::title_for::<_, CopilotModal>(cx))

View File

@ -39,10 +39,6 @@ mod stories {
pub struct FacepileStory;
impl FacepileStory {
pub fn new() -> Self {
Self
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let players = static_players();

View File

@ -57,7 +57,10 @@ impl<V: 'static> IconButton<V> {
self
}
pub fn on_click(mut self, handler: impl 'static + Fn(&mut V, &mut ViewContext<V>) + Send + Sync) -> Self {
pub fn on_click(
mut self,
handler: impl 'static + Fn(&mut V, &mut ViewContext<V>) + Send + Sync,
) -> Self {
self.handlers.click = Some(Arc::new(handler));
self
}

View File

@ -168,10 +168,6 @@ mod stories {
pub struct KeybindingStory;
impl KeybindingStory {
pub fn new() -> Self {
Self
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let all_modifier_permutations = ModifierKey::iter().permutations(2);

View File

@ -46,10 +46,6 @@ mod stories {
pub struct LanguageSelectorStory;
impl LanguageSelectorStory {
pub fn new() -> Self {
Self
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
Story::container(cx)
.child(Story::title_for::<_, LanguageSelector>(cx))

View File

@ -48,10 +48,6 @@ mod stories {
pub struct MultiBufferStory;
impl MultiBufferStory {
pub fn new() -> Self {
Self
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);

View File

@ -56,10 +56,6 @@ mod stories {
pub struct NotificationsPanelStory;
impl NotificationsPanelStory {
pub fn new() -> Self {
Self
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
Story::container(cx)
.child(Story::title_for::<_, NotificationsPanel>(cx))

View File

@ -160,10 +160,6 @@ mod stories {
pub struct PaletteStory;
impl PaletteStory {
pub fn new() -> Self {
Self
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
Story::container(cx)
.child(Story::title_for::<_, Palette>(cx))

View File

@ -136,10 +136,6 @@ mod stories {
pub struct PanelStory;
impl PanelStory {
pub fn new() -> Self {
Self
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
Story::container(cx)
.child(Story::title_for::<_, Panel<V>>(cx))

View File

@ -65,10 +65,6 @@ mod stories {
pub struct ProjectPanelStory;
impl ProjectPanelStory {
pub fn new() -> Self {
Self
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
Story::container(cx)
.child(Story::title_for::<_, ProjectPanel>(cx))

View File

@ -42,10 +42,6 @@ mod stories {
pub struct RecentProjectsStory;
impl RecentProjectsStory {
pub fn new() -> Self {
Self
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
Story::container(cx)
.child(Story::title_for::<_, RecentProjects>(cx))

View File

@ -176,10 +176,6 @@ mod stories {
pub struct TabStory;
impl TabStory {
pub fn new() -> Self {
Self
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let git_statuses = GitStatus::iter();
let fs_statuses = FileSystemStatus::iter();

View File

@ -100,10 +100,6 @@ mod stories {
pub struct TabBarStory;
impl TabBarStory {
pub fn new() -> Self {
Self
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
Story::container(cx)
.child(Story::title_for::<_, TabBar>(cx))

View File

@ -91,10 +91,6 @@ mod stories {
pub struct TerminalStory;
impl TerminalStory {
pub fn new() -> Self {
Self
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
Story::container(cx)
.child(Story::title_for::<_, Terminal>(cx))

View File

@ -47,10 +47,6 @@ mod stories {
pub struct ThemeSelectorStory;
impl ThemeSelectorStory {
pub fn new() -> Self {
Self
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
Story::container(cx)
.child(Story::title_for::<_, ThemeSelector>(cx))

View File

@ -80,10 +80,6 @@ mod stories {
pub struct ToastStory;
impl ToastStory {
pub fn new() -> Self {
Self
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
Story::container(cx)
.child(Story::title_for::<_, Toast<V>>(cx))

View File

@ -83,10 +83,6 @@ mod stories {
pub struct ToolbarStory;
impl ToolbarStory {
pub fn new() -> Self {
Self
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);

View File

@ -85,10 +85,6 @@ mod stories {
pub struct TrafficLightsStory;
impl TrafficLightsStory {
pub fn new() -> Self {
Self
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
Story::container(cx)
.child(Story::title_for::<_, TrafficLights>(cx))

View File

@ -51,10 +51,6 @@ mod stories {
pub struct AvatarStory;
impl AvatarStory {
pub fn new() -> Self {
Self
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
Story::container(cx)
.child(Story::title_for::<_, Avatar>(cx))

View File

@ -230,10 +230,6 @@ mod stories {
pub struct ButtonStory;
impl ButtonStory {
pub fn new() -> Self {
Self
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let states = InteractionState::iter();

View File

@ -54,10 +54,6 @@ mod stories {
pub struct DetailsStory;
impl DetailsStory {
pub fn new() -> Self {
Self
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
Story::container(cx)
.child(Story::title_for::<_, Details<V>>(cx))

View File

@ -202,10 +202,6 @@ mod stories {
pub struct IconStory;
impl IconStory {
pub fn new() -> Self {
Self
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let icons = Icon::iter();

View File

@ -120,10 +120,6 @@ mod stories {
pub struct InputStory;
impl InputStory {
pub fn new() -> Self {
Self
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
Story::container(cx)
.child(Story::title_for::<_, Input>(cx))

View File

@ -209,10 +209,6 @@ mod stories {
pub struct LabelStory;
impl LabelStory {
pub fn new() -> Self {
Self
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
Story::container(cx)
.child(Story::title_for::<_, Label>(cx))