diff --git a/Cargo.lock b/Cargo.lock index a874052051..650e49080a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10282,6 +10282,7 @@ dependencies = [ "story", "strum", "theme", + "title_bar", "ui", ] diff --git a/crates/storybook/Cargo.toml b/crates/storybook/Cargo.toml index 1d7a828dd7..3c42fe9e35 100644 --- a/crates/storybook/Cargo.toml +++ b/crates/storybook/Cargo.toml @@ -33,6 +33,7 @@ simplelog = "0.9" story.workspace = true strum = { version = "0.25.0", features = ["derive"] } theme.workspace = true +title_bar = { workspace = true, features = ["stories"] } ui = { workspace = true, features = ["stories"] } [dev-dependencies] diff --git a/crates/storybook/src/story_selector.rs b/crates/storybook/src/story_selector.rs index ce0ab26a1e..efbd605b59 100644 --- a/crates/storybook/src/story_selector.rs +++ b/crates/storybook/src/story_selector.rs @@ -12,6 +12,7 @@ use ui::prelude::*; #[derive(Debug, PartialEq, Eq, Clone, Copy, strum::Display, EnumString, EnumIter)] #[strum(serialize_all = "snake_case")] pub enum ComponentStory { + ApplicationMenu, AutoHeightEditor, Avatar, Button, @@ -35,7 +36,6 @@ pub enum ComponentStory { Tab, TabBar, Text, - // TitleBar, ToggleButton, ToolStrip, ViewportUnits, @@ -45,6 +45,7 @@ pub enum ComponentStory { impl ComponentStory { pub fn story(&self, cx: &mut WindowContext) -> AnyView { match self { + Self::ApplicationMenu => cx.new_view(|_| title_bar::ApplicationMenuStory).into(), Self::AutoHeightEditor => AutoHeightEditorStory::new(cx).into(), Self::Avatar => cx.new_view(|_| ui::AvatarStory).into(), Self::Button => cx.new_view(|_| ui::ButtonStory).into(), @@ -69,7 +70,6 @@ impl ComponentStory { Self::Text => TextStory::view(cx).into(), Self::Tab => cx.new_view(|_| ui::TabStory).into(), Self::TabBar => cx.new_view(|_| ui::TabBarStory).into(), - // Self::TitleBar => cx.new_view(|_| title_bar::TitleBarStory).into(), Self::ToggleButton => cx.new_view(|_| ui::ToggleButtonStory).into(), Self::ToolStrip => cx.new_view(|_| ui::ToolStripStory).into(), Self::ViewportUnits => cx.new_view(|_| crate::stories::ViewportUnitsStory).into(), diff --git a/crates/title_bar/src/stories.rs b/crates/title_bar/src/stories.rs new file mode 100644 index 0000000000..21ed2268db --- /dev/null +++ b/crates/title_bar/src/stories.rs @@ -0,0 +1,3 @@ +mod application_menu; + +pub use application_menu::*; diff --git a/crates/title_bar/src/stories/application_menu.rs b/crates/title_bar/src/stories/application_menu.rs new file mode 100644 index 0000000000..405b363763 --- /dev/null +++ b/crates/title_bar/src/stories/application_menu.rs @@ -0,0 +1,21 @@ +use gpui::Render; +use story::{StoryContainer, StoryItem, StorySection}; + +use ui::prelude::*; + +use crate::application_menu::ApplicationMenu; + +pub struct ApplicationMenuStory; + +impl Render for ApplicationMenuStory { + fn render(&mut self, _cx: &mut ViewContext) -> impl IntoElement { + StoryContainer::new( + "ApplicationMenu Story", + "crates/title_bar/src/stories/application_menu.rs", + ) + .child(StorySection::new().child(StoryItem::new( + "Application Menu", + h_flex().child(ApplicationMenu::new()), + ))) + } +} diff --git a/crates/title_bar/src/stories/title_bar.rs b/crates/title_bar/src/stories/title_bar.rs deleted file mode 100644 index 99209780d3..0000000000 --- a/crates/title_bar/src/stories/title_bar.rs +++ /dev/null @@ -1,56 +0,0 @@ -use gpui::{NoAction, Render}; -use story::{StoryContainer, StoryItem, StorySection}; - -use crate::{prelude::*, PlatformStyle, UiTitleBar}; - -pub struct TitleBarStory; - -impl Render for TitleBarStory { - fn render(&mut self, _cx: &mut ViewContext) -> impl IntoElement { - fn add_sample_children(titlebar: UiTitleBar) -> UiTitleBar { - titlebar - .child(div().size_2().bg(gpui::red())) - .child(div().size_2().bg(gpui::blue())) - .child(div().size_2().bg(gpui::green())) - } - - StoryContainer::new("TitleBar", "crates/ui/src/components/stories/title_bar.rs") - .child( - StorySection::new().child( - StoryItem::new( - "Default (macOS)", - UiTitleBar::new("macos", Box::new(NoAction)) - .platform_style(PlatformStyle::Mac) - .map(add_sample_children), - ) - .description("") - .usage(""), - ), - ) - .child( - StorySection::new().child( - StoryItem::new( - "Default (Linux)", - UiTitleBar::new("linux", Box::new(NoAction)) - .platform_style(PlatformStyle::Linux) - .map(add_sample_children), - ) - .description("") - .usage(""), - ), - ) - .child( - StorySection::new().child( - StoryItem::new( - "Default (Windows)", - UiTitleBar::new("windows", Box::new(NoAction)) - .platform_style(PlatformStyle::Windows) - .map(add_sample_children), - ) - .description("") - .usage(""), - ), - ) - .into_element() - } -} diff --git a/crates/title_bar/src/title_bar.rs b/crates/title_bar/src/title_bar.rs index f4a558081f..d351d77e12 100644 --- a/crates/title_bar/src/title_bar.rs +++ b/crates/title_bar/src/title_bar.rs @@ -4,6 +4,9 @@ mod collab; mod platforms; mod window_controls; +#[cfg(feature = "stories")] +mod stories; + use crate::application_menu::ApplicationMenu; use crate::platforms::{platform_linux, platform_mac, platform_windows}; use auto_update::AutoUpdateStatus; @@ -29,6 +32,9 @@ use util::ResultExt; use vcs_menu::{BranchList, OpenRecent as ToggleVcsMenu}; use workspace::{notifications::NotifyResultExt, Workspace}; +#[cfg(feature = "stories")] +pub use stories::*; + const MAX_PROJECT_NAME_LENGTH: usize = 40; const MAX_BRANCH_NAME_LENGTH: usize = 40;