mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-07 20:39:04 +03:00
Add story for ApplicationMenu
(#13948)
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
This commit is contained in:
parent
ea9ba6863d
commit
1a0242eff7
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -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(),
|
||||
|
3
crates/title_bar/src/stories.rs
Normal file
3
crates/title_bar/src/stories.rs
Normal file
@ -0,0 +1,3 @@
|
||||
mod application_menu;
|
||||
|
||||
pub use application_menu::*;
|
21
crates/title_bar/src/stories/application_menu.rs
Normal file
21
crates/title_bar/src/stories/application_menu.rs
Normal file
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user