Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
ui2: Reorganize components (#3228)
Marshall Bowers76db100d119c
diff --git a/crates/storybook2/src/stories/kitchen_sink.rs b/crates/storybook2/src/stories/kitchen_sink.rsindex cfa91417b6d..cf8277c4f45 100644--- a/crates/storybook2/src/stories/kitchen_sink.rs+++ b/crates/storybook2/src/stories/kitchen_sink.rs@@ -1,7 +1,4 @@-use crate::{- story::Story,- story_selector::{ComponentStory, ElementStory},-};+use crate::{story::Story, story_selector::ComponentStory};use gpui2::{Div, Render, StatefulInteraction, View, VisualContext};use strum::IntoEnumIterator;use ui::prelude::*;@@ -18,9 +15,6 @@ impl Render for KitchenSinkStory {type Element = Div<Self, StatefulInteraction<Self>>;fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {- let element_stories = ElementStory::iter()- .map(|selector| selector.story(cx))- .collect::<Vec<_>>();let component_stories = ComponentStory::iter().map(|selector| selector.story(cx)).collect::<Vec<_>>();@@ -29,8 +23,6 @@ impl Render for KitchenSinkStory {.id("kitchen-sink").overflow_y_scroll().child(Story::title(cx, "Kitchen Sink"))- .child(Story::label(cx, "Elements"))- .child(div().flex().flex_col().children(element_stories)).child(Story::label(cx, "Components")).child(div().flex().flex_col().children(component_stories))// Add a bit of space at the bottom of the kitchen sink so elementsdiff --git a/crates/storybook2/src/story_selector.rs b/crates/storybook2/src/story_selector.rsindex 968309bd8a0..a78705c7bbf 100644--- a/crates/storybook2/src/story_selector.rs+++ b/crates/storybook2/src/story_selector.rs@@ -7,55 +7,30 @@ use clap::builder::PossibleValue;use clap::ValueEnum;use gpui2::{AnyView, VisualContext};use strum::{EnumIter, EnumString, IntoEnumIterator};-use ui::{prelude::*, AvatarStory, ButtonStory, DetailsStory, IconStory, InputStory, LabelStory};--#[derive(Debug, PartialEq, Eq, Clone, Copy, strum::Display, EnumString, EnumIter)]-#[strum(serialize_all = "snake_case")]-pub enum ElementStory {- Avatar,- Button,- Colors,- Details,- Focus,- Icon,- Input,- Label,- Scroll,- Text,- ZIndex,-}--impl ElementStory {- pub fn story(&self, cx: &mut WindowContext) -> AnyView {- match self {- Self::Colors => cx.build_view(|_| ColorsStory).into(),- Self::Avatar => cx.build_view(|_| AvatarStory).into(),- Self::Button => cx.build_view(|_| ButtonStory).into(),- Self::Details => cx.build_view(|_| DetailsStory).into(),- Self::Focus => FocusStory::view(cx).into(),- Self::Icon => cx.build_view(|_| IconStory).into(),- Self::Input => cx.build_view(|_| InputStory).into(),- Self::Label => cx.build_view(|_| LabelStory).into(),- Self::Scroll => ScrollStory::view(cx).into(),- Self::Text => TextStory::view(cx).into(),- Self::ZIndex => cx.build_view(|_| ZIndexStory).into(),- }- }-}+use ui::prelude::*;+use ui::{AvatarStory, ButtonStory, DetailsStory, IconStory, InputStory, LabelStory};#[derive(Debug, PartialEq, Eq, Clone, Copy, strum::Display, EnumString, EnumIter)]#[strum(serialize_all = "snake_case")]pub enum ComponentStory {AssistantPanel,+ Avatar,Breadcrumb,Buffer,+ Button,ChatPanel,CollabPanel,+ Colors,CommandPalette,- Copilot,ContextMenu,+ Copilot,+ Details,Facepile,+ Focus,+ Icon,+ Input,Keybinding,+ Label,LanguageSelector,MultiBuffer,NotificationsPanel,@@ -63,29 +38,41 @@ pub enum ComponentStory {Panel,ProjectPanel,RecentProjects,+ Scroll,Tab,TabBar,Terminal,+ Text,ThemeSelector,TitleBar,Toast,Toolbar,TrafficLights,Workspace,+ ZIndex,}impl ComponentStory {pub fn story(&self, cx: &mut WindowContext) -> AnyView {match self {Self::AssistantPanel => cx.build_view(|_| ui::AssistantPanelStory).into(),- Self::Buffer => cx.build_view(|_| ui::BufferStory).into(),+ Self::Avatar => cx.build_view(|_| AvatarStory).into(),Self::Breadcrumb => cx.build_view(|_| ui::BreadcrumbStory).into(),+ Self::Buffer => cx.build_view(|_| ui::BufferStory).into(),+ Self::Button => cx.build_view(|_| ButtonStory).into(),Self::ChatPanel => cx.build_view(|_| ui::ChatPanelStory).into(),Self::CollabPanel => cx.build_view(|_| ui::CollabPanelStory).into(),+ Self::Colors => cx.build_view(|_| ColorsStory).into(),Self::CommandPalette => cx.build_view(|_| ui::CommandPaletteStory).into(),Self::ContextMenu => cx.build_view(|_| ui::ContextMenuStory).into(),+ Self::Copilot => cx.build_view(|_| ui::CopilotModalStory).into(),+ Self::Details => cx.build_view(|_| DetailsStory).into(),Self::Facepile => cx.build_view(|_| ui::FacepileStory).into(),+ Self::Focus => FocusStory::view(cx).into(),+ Self::Icon => cx.build_view(|_| IconStory).into(),+ Self::Input => cx.build_view(|_| InputStory).into(),Self::Keybinding => cx.build_view(|_| ui::KeybindingStory).into(),+ Self::Label => cx.build_view(|_| LabelStory).into(),Self::LanguageSelector => cx.build_view(|_| ui::LanguageSelectorStory).into(),Self::MultiBuffer => cx.build_view(|_| ui::MultiBufferStory).into(),Self::NotificationsPanel => cx.build_view(|cx| ui::NotificationsPanelStory).into(),@@ -93,23 +80,24 @@ impl ComponentStory {Self::Panel => cx.build_view(|cx| ui::PanelStory).into(),Self::ProjectPanel => cx.build_view(|_| ui::ProjectPanelStory).into(),Self::RecentProjects => cx.build_view(|_| ui::RecentProjectsStory).into(),+ Self::Scroll => ScrollStory::view(cx).into(),Self::Tab => cx.build_view(|_| ui::TabStory).into(),Self::TabBar => cx.build_view(|_| ui::TabBarStory).into(),Self::Terminal => cx.build_view(|_| ui::TerminalStory).into(),+ Self::Text => TextStory::view(cx).into(),Self::ThemeSelector => cx.build_view(|_| ui::ThemeSelectorStory).into(),+ Self::TitleBar => ui::TitleBarStory::view(cx).into(),Self::Toast => cx.build_view(|_| ui::ToastStory).into(),Self::Toolbar => cx.build_view(|_| ui::ToolbarStory).into(),Self::TrafficLights => cx.build_view(|_| ui::TrafficLightsStory).into(),- Self::Copilot => cx.build_view(|_| ui::CopilotModalStory).into(),- Self::TitleBar => ui::TitleBarStory::view(cx).into(),Self::Workspace => ui::WorkspaceStory::view(cx).into(),+ Self::ZIndex => cx.build_view(|_| ZIndexStory).into(),}}}#[derive(Debug, PartialEq, Eq, Clone, Copy)]pub enum StorySelector {- Element(ElementStory),Component(ComponentStory),KitchenSink,}@@ -126,13 +114,6 @@ impl FromStr for StorySelector {return Ok(Self::KitchenSink);}- if let Some((_, story)) = story.split_once("elements/") {- let element_story = ElementStory::from_str(story)- .with_context(|| format!("story not found for element '{story}'"))?;-- return Ok(Self::Element(element_story));- }-if let Some((_, story)) = story.split_once("components/") {let component_story = ComponentStory::from_str(story).with_context(|| format!("story not found for component '{story}'"))?;@@ -147,7 +128,6 @@ impl FromStr for StorySelector {impl StorySelector {pub fn story(&self, cx: &mut WindowContext) -> AnyView {match self {- Self::Element(element_story) => element_story.story(cx),Self::Component(component_story) => component_story.story(cx),Self::KitchenSink => KitchenSinkStory::view(cx).into(),}@@ -160,11 +140,9 @@ static ALL_STORY_SELECTORS: OnceLock<Vec<StorySelector>> = OnceLock::new();impl ValueEnum for StorySelector {fn value_variants<'a>() -> &'a [Self] {let stories = ALL_STORY_SELECTORS.get_or_init(|| {- let element_stories = ElementStory::iter().map(StorySelector::Element);let component_stories = ComponentStory::iter().map(StorySelector::Component);- element_stories- .chain(component_stories)+ component_stories.chain(std::iter::once(StorySelector::KitchenSink)).collect::<Vec<_>>()});@@ -174,7 +152,6 @@ impl ValueEnum for StorySelector {fn to_possible_value(&self) -> Option<clap::builder::PossibleValue> {let value = match self {- Self::Element(story) => format!("elements/{story}"),Self::Component(story) => format!("components/{story}"),Self::KitchenSink => "kitchen_sink".to_string(),};diff --git a/crates/ui2/src/components.rs b/crates/ui2/src/components.rsindex 7a9cac01ca7..f7674c2bd4d 100644--- a/crates/ui2/src/components.rs+++ b/crates/ui2/src/components.rs@@ -1,71 +1,45 @@-mod assistant_panel;-mod breadcrumb;-mod buffer;-mod buffer_search;-mod chat_panel;-mod collab_panel;-mod command_palette;+mod avatar;+mod button;mod context_menu;-mod copilot;-mod editor_pane;+mod details;mod facepile;+mod icon;mod icon_button;+mod indicator;+mod input;mod keybinding;-mod language_selector;+mod label;mod list;mod modal;-mod multi_buffer;mod notification_toast;-mod notifications_panel;mod palette;mod panel;-mod panes;+mod player;mod player_stack;-mod project_panel;-mod recent_projects;-mod status_bar;+mod stack;mod tab;-mod tab_bar;-mod terminal;-mod theme_selector;-mod title_bar;mod toast;-mod toolbar;-mod traffic_lights;-mod workspace;+mod tool_divider;-pub use assistant_panel::*;-pub use breadcrumb::*;-pub use buffer::*;-pub use buffer_search::*;-pub use chat_panel::*;-pub use collab_panel::*;-pub use command_palette::*;+pub use avatar::*;+pub use button::*;pub use context_menu::*;-pub use copilot::*;-pub use editor_pane::*;+pub use details::*;pub use facepile::*;+pub use icon::*;pub use icon_button::*;+pub use indicator::*;+pub use input::*;pub use keybinding::*;-pub use language_selector::*;+pub use label::*;pub use list::*;pub use modal::*;-pub use multi_buffer::*;pub use notification_toast::*;-pub use notifications_panel::*;pub use palette::*;pub use panel::*;-pub use panes::*;+pub use player::*;pub use player_stack::*;-pub use project_panel::*;-pub use recent_projects::*;-pub use status_bar::*;+pub use stack::*;pub use tab::*;-pub use tab_bar::*;-pub use terminal::*;-pub use theme_selector::*;-pub use title_bar::*;pub use toast::*;-pub use toolbar::*;-pub use traffic_lights::*;-pub use workspace::*;+pub use tool_divider::*;diff --git a/crates/ui2/src/elements/avatar.rs b/crates/ui2/src/components/avatar.rssimilarity index 100%rename from crates/ui2/src/elements/avatar.rsrename to crates/ui2/src/components/avatar.rsdiff --git a/crates/ui2/src/elements/button.rs b/crates/ui2/src/components/button.rssimilarity index 100%rename from crates/ui2/src/elements/button.rsrename to crates/ui2/src/components/button.rsdiff --git a/crates/ui2/src/elements/details.rs b/crates/ui2/src/components/details.rssimilarity index 100%rename from crates/ui2/src/elements/details.rsrename to crates/ui2/src/components/details.rsdiff --git a/crates/ui2/src/elements/icon.rs b/crates/ui2/src/components/icon.rssimilarity index 100%rename from crates/ui2/src/elements/icon.rsrename to crates/ui2/src/components/icon.rsdiff --git a/crates/ui2/src/elements/indicator.rs b/crates/ui2/src/components/indicator.rssimilarity index 100%rename from crates/ui2/src/elements/indicator.rsrename to crates/ui2/src/components/indicator.rsdiff --git a/crates/ui2/src/elements/input.rs b/crates/ui2/src/components/input.rssimilarity index 100%rename from crates/ui2/src/elements/input.rsrename to crates/ui2/src/components/input.rsdiff --git a/crates/ui2/src/elements/label.rs b/crates/ui2/src/components/label.rssimilarity index 100%rename from crates/ui2/src/elements/label.rsrename to crates/ui2/src/components/label.rsdiff --git a/crates/ui2/src/elements/player.rs b/crates/ui2/src/components/player.rssimilarity index 100%rename from crates/ui2/src/elements/player.rsrename to crates/ui2/src/components/player.rsdiff --git a/crates/ui2/src/elements/stack.rs b/crates/ui2/src/components/stack.rssimilarity index 100%rename from crates/ui2/src/elements/stack.rsrename to crates/ui2/src/components/stack.rsdiff --git a/crates/ui2/src/elements/tool_divider.rs b/crates/ui2/src/components/tool_divider.rssimilarity index 100%rename from crates/ui2/src/elements/tool_divider.rsrename to crates/ui2/src/components/tool_divider.rsdiff --git a/crates/ui2/src/elements.rs b/crates/ui2/src/elements.rsdeleted file mode 100644index dfff2761a76..00000000000--- a/crates/ui2/src/elements.rs+++ /dev/null@@ -1,21 +0,0 @@-mod avatar;-mod button;-mod details;-mod icon;-mod indicator;-mod input;-mod label;-mod player;-mod stack;-mod tool_divider;--pub use avatar::*;-pub use button::*;-pub use details::*;-pub use icon::*;-pub use indicator::*;-pub use input::*;-pub use label::*;-pub use player::*;-pub use stack::*;-pub use tool_divider::*;diff --git a/crates/ui2/src/lib.rs b/crates/ui2/src/lib.rsindex 5d0a57c6d90..0fd6eee0db4 100644--- a/crates/ui2/src/lib.rs+++ b/crates/ui2/src/lib.rs@@ -18,17 +18,17 @@#![allow(dead_code, unused_variables)]mod components;-mod elements;mod elevation;pub mod prelude;pub mod settings;mod static_data;+mod to_extract;pub mod utils;pub use components::*;-pub use elements::*;pub use prelude::*;pub use static_data::*;+pub use to_extract::*;// This needs to be fully qualified with `crate::` otherwise we get a panic// at:diff --git a/crates/ui2/src/to_extract.rs b/crates/ui2/src/to_extract.rsnew file mode 100644index 00000000000..e786dd0f7e0--- /dev/null+++ b/crates/ui2/src/to_extract.rs@@ -0,0 +1,47 @@+mod assistant_panel;+mod breadcrumb;+mod buffer;+mod buffer_search;+mod chat_panel;+mod collab_panel;+mod command_palette;+mod copilot;+mod editor_pane;+mod language_selector;+mod multi_buffer;+mod notifications_panel;+mod panes;+mod project_panel;+mod recent_projects;+mod status_bar;+mod tab_bar;+mod terminal;+mod theme_selector;+mod title_bar;+mod toolbar;+mod traffic_lights;+mod workspace;++pub use assistant_panel::*;+pub use breadcrumb::*;+pub use buffer::*;+pub use buffer_search::*;+pub use chat_panel::*;+pub use collab_panel::*;+pub use command_palette::*;+pub use copilot::*;+pub use editor_pane::*;+pub use language_selector::*;+pub use multi_buffer::*;+pub use notifications_panel::*;+pub use panes::*;+pub use project_panel::*;+pub use recent_projects::*;+pub use status_bar::*;+pub use tab_bar::*;+pub use terminal::*;+pub use theme_selector::*;+pub use title_bar::*;+pub use toolbar::*;+pub use traffic_lights::*;+pub use workspace::*;diff --git a/crates/ui2/src/components/assistant_panel.rs b/crates/ui2/src/to_extract/assistant_panel.rssimilarity index 100%rename from crates/ui2/src/components/assistant_panel.rsrename to crates/ui2/src/to_extract/assistant_panel.rsdiff --git a/crates/ui2/src/components/breadcrumb.rs b/crates/ui2/src/to_extract/breadcrumb.rssimilarity index 100%rename from crates/ui2/src/components/breadcrumb.rsrename to crates/ui2/src/to_extract/breadcrumb.rsdiff --git a/crates/ui2/src/components/buffer.rs b/crates/ui2/src/to_extract/buffer.rssimilarity index 100%rename from crates/ui2/src/components/buffer.rsrename to crates/ui2/src/to_extract/buffer.rsdiff --git a/crates/ui2/src/components/buffer_search.rs b/crates/ui2/src/to_extract/buffer_search.rssimilarity index 100%rename from crates/ui2/src/components/buffer_search.rsrename to crates/ui2/src/to_extract/buffer_search.rsdiff --git a/crates/ui2/src/components/chat_panel.rs b/crates/ui2/src/to_extract/chat_panel.rssimilarity index 100%rename from crates/ui2/src/components/chat_panel.rsrename to crates/ui2/src/to_extract/chat_panel.rsdiff --git a/crates/ui2/src/components/collab_panel.rs b/crates/ui2/src/to_extract/collab_panel.rssimilarity index 100%rename from crates/ui2/src/components/collab_panel.rsrename to crates/ui2/src/to_extract/collab_panel.rsdiff --git a/crates/ui2/src/components/command_palette.rs b/crates/ui2/src/to_extract/command_palette.rssimilarity index 100%rename from crates/ui2/src/components/command_palette.rsrename to crates/ui2/src/to_extract/command_palette.rsdiff --git a/crates/ui2/src/components/copilot.rs b/crates/ui2/src/to_extract/copilot.rssimilarity index 100%rename from crates/ui2/src/components/copilot.rsrename to crates/ui2/src/to_extract/copilot.rsdiff --git a/crates/ui2/src/components/editor_pane.rs b/crates/ui2/src/to_extract/editor_pane.rssimilarity index 100%rename from crates/ui2/src/components/editor_pane.rsrename to crates/ui2/src/to_extract/editor_pane.rsdiff --git a/crates/ui2/src/components/language_selector.rs b/crates/ui2/src/to_extract/language_selector.rssimilarity index 100%rename from crates/ui2/src/components/language_selector.rsrename to crates/ui2/src/to_extract/language_selector.rsdiff --git a/crates/ui2/src/components/multi_buffer.rs b/crates/ui2/src/to_extract/multi_buffer.rssimilarity index 100%rename from crates/ui2/src/components/multi_buffer.rsrename to crates/ui2/src/to_extract/multi_buffer.rsdiff --git a/crates/ui2/src/components/notifications_panel.rs b/crates/ui2/src/to_extract/notifications_panel.rssimilarity index 100%rename from crates/ui2/src/components/notifications_panel.rsrename to crates/ui2/src/to_extract/notifications_panel.rsdiff --git a/crates/ui2/src/components/panes.rs b/crates/ui2/src/to_extract/panes.rssimilarity index 100%rename from crates/ui2/src/components/panes.rsrename to crates/ui2/src/to_extract/panes.rsdiff --git a/crates/ui2/src/components/project_panel.rs b/crates/ui2/src/to_extract/project_panel.rssimilarity index 100%rename from crates/ui2/src/components/project_panel.rsrename to crates/ui2/src/to_extract/project_panel.rsdiff --git a/crates/ui2/src/components/recent_projects.rs b/crates/ui2/src/to_extract/recent_projects.rssimilarity index 100%rename from crates/ui2/src/components/recent_projects.rsrename to crates/ui2/src/to_extract/recent_projects.rsdiff --git a/crates/ui2/src/components/status_bar.rs b/crates/ui2/src/to_extract/status_bar.rssimilarity index 100%rename from crates/ui2/src/components/status_bar.rsrename to crates/ui2/src/to_extract/status_bar.rsdiff --git a/crates/ui2/src/components/tab_bar.rs b/crates/ui2/src/to_extract/tab_bar.rssimilarity index 100%rename from crates/ui2/src/components/tab_bar.rsrename to crates/ui2/src/to_extract/tab_bar.rsdiff --git a/crates/ui2/src/components/terminal.rs b/crates/ui2/src/to_extract/terminal.rssimilarity index 100%rename from crates/ui2/src/components/terminal.rsrename to crates/ui2/src/to_extract/terminal.rsdiff --git a/crates/ui2/src/components/theme_selector.rs b/crates/ui2/src/to_extract/theme_selector.rssimilarity index 100%rename from crates/ui2/src/components/theme_selector.rsrename to crates/ui2/src/to_extract/theme_selector.rsdiff --git a/crates/ui2/src/components/title_bar.rs b/crates/ui2/src/to_extract/title_bar.rssimilarity index 100%rename from crates/ui2/src/components/title_bar.rsrename to crates/ui2/src/to_extract/title_bar.rsdiff --git a/crates/ui2/src/components/toolbar.rs b/crates/ui2/src/to_extract/toolbar.rssimilarity index 100%rename from crates/ui2/src/components/toolbar.rsrename to crates/ui2/src/to_extract/toolbar.rsdiff --git a/crates/ui2/src/components/traffic_lights.rs b/crates/ui2/src/to_extract/traffic_lights.rssimilarity index 100%rename from crates/ui2/src/components/traffic_lights.rsrename to crates/ui2/src/to_extract/traffic_lights.rsdiff --git a/crates/ui2/src/components/workspace.rs b/crates/ui2/src/to_extract/workspace.rssimilarity index 100%rename from crates/ui2/src/components/workspace.rsrename to crates/ui2/src/to_extract/workspace.rs