Cargo.lock 🔗
@@ -10282,6 +10282,7 @@ dependencies = [
"story",
"strum",
"theme",
+ "title_bar",
"ui",
]
Marshall Bowers created
This PR adds a story for the `ApplicationMenu` so it can be viewed in
isolation.
<img width="664" alt="Screenshot 2024-07-08 at 4 45 24 PM"
src="https://github.com/zed-industries/zed/assets/1486634/dca3dd32-4845-4009-b781-b4bac9ba6049">
Release Notes:
- N/A
Cargo.lock | 1
crates/storybook/Cargo.toml | 1
crates/storybook/src/story_selector.rs | 4
crates/title_bar/src/stories.rs | 3
crates/title_bar/src/stories/application_menu.rs | 21 ++++++
crates/title_bar/src/stories/title_bar.rs | 56 ------------------
crates/title_bar/src/title_bar.rs | 6 +
7 files changed, 34 insertions(+), 58 deletions(-)
@@ -10282,6 +10282,7 @@ dependencies = [
"story",
"strum",
"theme",
+ "title_bar",
"ui",
]
@@ -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]
@@ -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(),
@@ -0,0 +1,3 @@
+mod application_menu;
+
+pub use application_menu::*;
@@ -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<Self>) -> 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()),
+ )))
+ }
+}
@@ -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<Self>) -> 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()
- }
-}
@@ -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;