From 463c3ebfeab6149c3b38a6df1549c28683c82ef4 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Mon, 7 Jul 2025 12:11:19 +0800 Subject: [PATCH] chore: Remove unnecessary examples that have includes in gallery. (#1049) --- crates/story/examples/accordion.rs | 35 ---------------- crates/story/examples/alert.rs | 36 ----------------- crates/story/examples/button.rs | 40 ------------------- .../{html.html => fixtures/test.html} | 0 crates/story/examples/form.rs | 35 ---------------- crates/story/examples/html.rs | 4 +- crates/story/examples/input.rs | 35 ---------------- crates/story/examples/list.rs | 35 ---------------- crates/story/examples/markdown.rs | 2 +- crates/story/examples/modal.rs | 35 ---------------- crates/story/examples/popover.rs | 35 ---------------- crates/story/examples/scrollable.rs | 35 ---------------- crates/story/examples/sidebar.rs | 35 ---------------- crates/story/examples/switch.rs | 35 ---------------- crates/story/examples/table.rs | 35 ---------------- crates/story/examples/tabs.rs | 35 ---------------- crates/story/examples/text.rs | 40 ------------------- crates/story/examples/toggle.rs | 35 ---------------- crates/story/examples/tooltip.rs | 40 ------------------- 19 files changed, 3 insertions(+), 579 deletions(-) delete mode 100644 crates/story/examples/accordion.rs delete mode 100644 crates/story/examples/alert.rs delete mode 100644 crates/story/examples/button.rs rename crates/story/examples/{html.html => fixtures/test.html} (100%) delete mode 100644 crates/story/examples/form.rs delete mode 100644 crates/story/examples/input.rs delete mode 100644 crates/story/examples/list.rs delete mode 100644 crates/story/examples/modal.rs delete mode 100644 crates/story/examples/popover.rs delete mode 100644 crates/story/examples/scrollable.rs delete mode 100644 crates/story/examples/sidebar.rs delete mode 100644 crates/story/examples/switch.rs delete mode 100644 crates/story/examples/table.rs delete mode 100644 crates/story/examples/tabs.rs delete mode 100644 crates/story/examples/text.rs delete mode 100644 crates/story/examples/toggle.rs delete mode 100644 crates/story/examples/tooltip.rs diff --git a/crates/story/examples/accordion.rs b/crates/story/examples/accordion.rs deleted file mode 100644 index 5c3fdfd8..00000000 --- a/crates/story/examples/accordion.rs +++ /dev/null @@ -1,35 +0,0 @@ -use gpui::*; -use story::{AccordionStory, Assets}; - -pub struct Example { - root: Entity, -} - -impl Example { - pub fn new(window: &mut Window, cx: &mut Context) -> Self { - let root = AccordionStory::view(window, cx); - - Self { root } - } - - fn view(window: &mut Window, cx: &mut App) -> Entity { - cx.new(|cx| Self::new(window, cx)) - } -} - -impl Render for Example { - fn render(&mut self, _window: &mut Window, _cx: &mut Context) -> impl IntoElement { - div().p_4().size_full().child(self.root.clone()) - } -} - -fn main() { - let app = Application::new().with_assets(Assets); - - app.run(move |cx| { - story::init(cx); - cx.activate(true); - - story::create_new_window("Accordion Example", Example::view, cx); - }); -} diff --git a/crates/story/examples/alert.rs b/crates/story/examples/alert.rs deleted file mode 100644 index e89c916c..00000000 --- a/crates/story/examples/alert.rs +++ /dev/null @@ -1,36 +0,0 @@ -use gpui::*; - -use story::{AlertStory, Assets}; - -pub struct Example { - story: Entity, -} - -impl Example { - pub fn new(window: &mut Window, cx: &mut Context) -> Self { - Self { - story: AlertStory::view(window, cx), - } - } - - fn view(window: &mut Window, cx: &mut App) -> Entity { - cx.new(|cx| Self::new(window, cx)) - } -} - -impl Render for Example { - fn render(&mut self, _window: &mut Window, _: &mut Context) -> impl IntoElement { - self.story.clone() - } -} - -fn main() { - let app = Application::new().with_assets(Assets); - - app.run(move |cx| { - story::init(cx); - cx.activate(true); - - story::create_new_window("Alert Example", Example::view, cx); - }); -} diff --git a/crates/story/examples/button.rs b/crates/story/examples/button.rs deleted file mode 100644 index ebf311a0..00000000 --- a/crates/story/examples/button.rs +++ /dev/null @@ -1,40 +0,0 @@ -use gpui::*; -use story::{Assets, ButtonStory}; - -pub struct Example { - root: Entity, -} - -impl Example { - pub fn new(window: &mut Window, cx: &mut Context) -> Self { - let root = ButtonStory::view(window, cx); - - Self { root } - } - - fn view(window: &mut Window, cx: &mut App) -> Entity { - cx.new(|cx| Self::new(window, cx)) - } -} - -impl Render for Example { - fn render(&mut self, _window: &mut Window, _cx: &mut Context) -> impl IntoElement { - div() - .p_4() - .id("button_example") - .overflow_y_scroll() - .size_full() - .child(self.root.clone()) - } -} - -fn main() { - let app = Application::new().with_assets(Assets); - - app.run(move |cx| { - story::init(cx); - cx.activate(true); - - story::create_new_window("Button Example", Example::view, cx); - }); -} diff --git a/crates/story/examples/html.html b/crates/story/examples/fixtures/test.html similarity index 100% rename from crates/story/examples/html.html rename to crates/story/examples/fixtures/test.html diff --git a/crates/story/examples/form.rs b/crates/story/examples/form.rs deleted file mode 100644 index cb3eb272..00000000 --- a/crates/story/examples/form.rs +++ /dev/null @@ -1,35 +0,0 @@ -use gpui::*; -use story::{Assets, FormStory}; - -pub struct Example { - story: Entity, -} - -impl Example { - pub fn new(window: &mut Window, cx: &mut Context) -> Self { - let story = FormStory::view(window, cx); - - Self { story } - } - - fn view(window: &mut Window, cx: &mut App) -> Entity { - cx.new(|cx| Self::new(window, cx)) - } -} - -impl Render for Example { - fn render(&mut self, _window: &mut Window, _cx: &mut Context) -> impl IntoElement { - div().p_4().size_full().child(self.story.clone()) - } -} - -fn main() { - let app = Application::new().with_assets(Assets); - - app.run(move |cx| { - story::init(cx); - cx.activate(true); - - story::create_new_window("Form Example", Example::view, cx); - }); -} diff --git a/crates/story/examples/html.rs b/crates/story/examples/html.rs index 245a141d..ddc5502a 100644 --- a/crates/story/examples/html.rs +++ b/crates/story/examples/html.rs @@ -13,7 +13,7 @@ pub struct Example { _subscribe: Subscription, } -const EXAMPLE: &str = include_str!("./html.html"); +const EXAMPLE: &str = include_str!("./fixtures/test.html"); impl Example { pub fn new(window: &mut Window, cx: &mut Context) -> Self { @@ -87,6 +87,6 @@ fn main() { story::init(cx); cx.activate(true); - story::create_new_window("HTML Example", Example::view, cx); + story::create_new_window("HTML Render (native)", Example::view, cx); }); } diff --git a/crates/story/examples/input.rs b/crates/story/examples/input.rs deleted file mode 100644 index cb308c61..00000000 --- a/crates/story/examples/input.rs +++ /dev/null @@ -1,35 +0,0 @@ -use gpui::*; -use story::{Assets, InputStory}; - -pub struct Example { - root: Entity, -} - -impl Example { - pub fn new(window: &mut Window, cx: &mut Context) -> Self { - let root = InputStory::view(window, cx); - - Self { root } - } - - fn view(window: &mut Window, cx: &mut App) -> Entity { - cx.new(|cx| Self::new(window, cx)) - } -} - -impl Render for Example { - fn render(&mut self, _window: &mut Window, _cx: &mut Context) -> impl IntoElement { - div().p_4().size_full().child(self.root.clone()) - } -} - -fn main() { - let app = Application::new().with_assets(Assets); - - app.run(move |cx| { - story::init(cx); - cx.activate(true); - - story::create_new_window("Input Example", Example::view, cx); - }); -} diff --git a/crates/story/examples/list.rs b/crates/story/examples/list.rs deleted file mode 100644 index a9d16afa..00000000 --- a/crates/story/examples/list.rs +++ /dev/null @@ -1,35 +0,0 @@ -use gpui::*; -use story::{Assets, ListStory}; - -pub struct Example { - root: Entity, -} - -impl Example { - pub fn new(window: &mut Window, cx: &mut Context) -> Self { - let root = ListStory::view(window, cx); - - Self { root } - } - - fn view(window: &mut Window, cx: &mut App) -> Entity { - cx.new(|cx| Self::new(window, cx)) - } -} - -impl Render for Example { - fn render(&mut self, _window: &mut Window, _cx: &mut Context) -> impl IntoElement { - div().p_4().size_full().child(self.root.clone()) - } -} - -fn main() { - let app = Application::new().with_assets(Assets); - - app.run(move |cx| { - story::init(cx); - cx.activate(true); - - story::create_new_window("List Example", Example::view, cx); - }); -} diff --git a/crates/story/examples/markdown.rs b/crates/story/examples/markdown.rs index 4863acb0..4e5f96f1 100644 --- a/crates/story/examples/markdown.rs +++ b/crates/story/examples/markdown.rs @@ -101,6 +101,6 @@ fn main() { story::init(cx); cx.activate(true); - story::create_new_window("Markdown Example", Example::view, cx); + story::create_new_window("Markdown Editor", Example::view, cx); }); } diff --git a/crates/story/examples/modal.rs b/crates/story/examples/modal.rs deleted file mode 100644 index efa5ce97..00000000 --- a/crates/story/examples/modal.rs +++ /dev/null @@ -1,35 +0,0 @@ -use gpui::*; -use story::{Assets, ModalStory}; - -pub struct Example { - root: Entity, -} - -impl Example { - pub fn new(window: &mut Window, cx: &mut Context) -> Self { - let root = ModalStory::view(window, cx); - - Self { root } - } - - fn view(window: &mut Window, cx: &mut App) -> Entity { - cx.new(|cx| Self::new(window, cx)) - } -} - -impl Render for Example { - fn render(&mut self, _window: &mut Window, _cx: &mut Context) -> impl IntoElement { - div().p_4().size_full().child(self.root.clone()) - } -} - -fn main() { - let app = Application::new().with_assets(Assets); - - app.run(move |cx| { - story::init(cx); - cx.activate(true); - - story::create_new_window("Modal Example", Example::view, cx); - }); -} diff --git a/crates/story/examples/popover.rs b/crates/story/examples/popover.rs deleted file mode 100644 index 0c667ed7..00000000 --- a/crates/story/examples/popover.rs +++ /dev/null @@ -1,35 +0,0 @@ -use gpui::*; -use story::{Assets, PopoverStory}; - -pub struct Example { - story: Entity, -} - -impl Example { - pub fn new(window: &mut Window, cx: &mut Context) -> Self { - let story = PopoverStory::view(window, cx); - - Self { story } - } - - fn view(window: &mut Window, cx: &mut App) -> Entity { - cx.new(|cx| Self::new(window, cx)) - } -} - -impl Render for Example { - fn render(&mut self, _window: &mut Window, _cx: &mut Context) -> impl IntoElement { - div().p_4().size_full().child(self.story.clone()) - } -} - -fn main() { - let app = Application::new().with_assets(Assets); - - app.run(move |cx| { - story::init(cx); - cx.activate(true); - - story::create_new_window("Popover Example", Example::view, cx); - }); -} diff --git a/crates/story/examples/scrollable.rs b/crates/story/examples/scrollable.rs deleted file mode 100644 index 4457e86d..00000000 --- a/crates/story/examples/scrollable.rs +++ /dev/null @@ -1,35 +0,0 @@ -use gpui::*; -use story::{Assets, ScrollableStory}; - -pub struct Example { - story: Entity, -} - -impl Example { - pub fn new(window: &mut Window, cx: &mut Context) -> Self { - let story = ScrollableStory::view(window, cx); - - Self { story } - } - - fn view(window: &mut Window, cx: &mut App) -> Entity { - cx.new(|cx| Self::new(window, cx)) - } -} - -impl Render for Example { - fn render(&mut self, _window: &mut Window, _cx: &mut Context) -> impl IntoElement { - div().p_4().size_full().child(self.story.clone()) - } -} - -fn main() { - let app = Application::new().with_assets(Assets); - - app.run(move |cx| { - story::init(cx); - cx.activate(true); - - story::create_new_window("Scrollable Example", Example::view, cx); - }); -} diff --git a/crates/story/examples/sidebar.rs b/crates/story/examples/sidebar.rs deleted file mode 100644 index f373f315..00000000 --- a/crates/story/examples/sidebar.rs +++ /dev/null @@ -1,35 +0,0 @@ -use gpui::*; -use story::{Assets, SidebarStory}; - -pub struct Example { - root: Entity, -} - -impl Example { - pub fn new(window: &mut Window, cx: &mut Context) -> Self { - let root = SidebarStory::view(window, cx); - - Self { root } - } - - fn view(window: &mut Window, cx: &mut App) -> Entity { - cx.new(|cx| Self::new(window, cx)) - } -} - -impl Render for Example { - fn render(&mut self, _window: &mut Window, _cx: &mut Context) -> impl IntoElement { - div().mt(-px(1.)).size_full().child(self.root.clone()) - } -} - -fn main() { - let app = Application::new().with_assets(Assets); - - app.run(move |cx| { - story::init(cx); - cx.activate(true); - - story::create_new_window("Sidebar Example", Example::view, cx); - }); -} diff --git a/crates/story/examples/switch.rs b/crates/story/examples/switch.rs deleted file mode 100644 index f3587b89..00000000 --- a/crates/story/examples/switch.rs +++ /dev/null @@ -1,35 +0,0 @@ -use gpui::*; -use story::{Assets, SwitchStory}; - -pub struct Example { - story: Entity, -} - -impl Example { - pub fn new(window: &mut Window, cx: &mut Context) -> Self { - let story = SwitchStory::view(window, cx); - - Self { story } - } - - fn view(window: &mut Window, cx: &mut App) -> Entity { - cx.new(|cx| Self::new(window, cx)) - } -} - -impl Render for Example { - fn render(&mut self, _window: &mut Window, _cx: &mut Context) -> impl IntoElement { - div().p_4().size_full().child(self.story.clone()) - } -} - -fn main() { - let app = Application::new().with_assets(Assets); - - app.run(move |cx| { - story::init(cx); - cx.activate(true); - - story::create_new_window("Switch Example", Example::view, cx); - }); -} diff --git a/crates/story/examples/table.rs b/crates/story/examples/table.rs deleted file mode 100644 index e91e2d38..00000000 --- a/crates/story/examples/table.rs +++ /dev/null @@ -1,35 +0,0 @@ -use gpui::*; -use story::{Assets, TableStory}; - -pub struct Example { - table: Entity, -} - -impl Example { - pub fn new(window: &mut Window, cx: &mut Context) -> Self { - let table = TableStory::view(window, cx); - - Self { table } - } - - fn view(window: &mut Window, cx: &mut App) -> Entity { - cx.new(|cx| Self::new(window, cx)) - } -} - -impl Render for Example { - fn render(&mut self, _window: &mut Window, _cx: &mut Context) -> impl IntoElement { - div().p_4().size_full().child(self.table.clone()) - } -} - -fn main() { - let app = Application::new().with_assets(Assets); - - app.run(move |cx| { - story::init(cx); - cx.activate(true); - - story::create_new_window("Table Example", Example::view, cx); - }); -} diff --git a/crates/story/examples/tabs.rs b/crates/story/examples/tabs.rs deleted file mode 100644 index e07e224a..00000000 --- a/crates/story/examples/tabs.rs +++ /dev/null @@ -1,35 +0,0 @@ -use gpui::*; -use story::{Assets, TabsStory}; - -pub struct Example { - root: Entity, -} - -impl Example { - pub fn new(window: &mut Window, cx: &mut Context) -> Self { - let root = TabsStory::view(window, cx); - - Self { root } - } - - fn view(window: &mut Window, cx: &mut App) -> Entity { - cx.new(|cx| Self::new(window, cx)) - } -} - -impl Render for Example { - fn render(&mut self, _window: &mut Window, _cx: &mut Context) -> impl IntoElement { - div().p_4().size_full().child(self.root.clone()) - } -} - -fn main() { - let app = Application::new().with_assets(Assets); - - app.run(move |cx| { - story::init(cx); - cx.activate(true); - - story::create_new_window("Tabs Example", Example::view, cx); - }); -} diff --git a/crates/story/examples/text.rs b/crates/story/examples/text.rs deleted file mode 100644 index f7637542..00000000 --- a/crates/story/examples/text.rs +++ /dev/null @@ -1,40 +0,0 @@ -use gpui::*; -use story::{Assets, LabelStory}; - -pub struct Example { - root: Entity, -} - -impl Example { - pub fn new(window: &mut Window, cx: &mut Context) -> Self { - let root = LabelStory::view(window, cx); - - Self { root } - } - - fn view(window: &mut Window, cx: &mut App) -> Entity { - cx.new(|cx| Self::new(window, cx)) - } -} - -impl Render for Example { - fn render(&mut self, _window: &mut Window, _cx: &mut Context) -> impl IntoElement { - div() - .p_4() - .id("example") - .overflow_y_scroll() - .size_full() - .child(self.root.clone()) - } -} - -fn main() { - let app = Application::new().with_assets(Assets); - - app.run(move |cx| { - story::init(cx); - cx.activate(true); - - story::create_new_window("List Example", Example::view, cx); - }); -} diff --git a/crates/story/examples/toggle.rs b/crates/story/examples/toggle.rs deleted file mode 100644 index fd750b8d..00000000 --- a/crates/story/examples/toggle.rs +++ /dev/null @@ -1,35 +0,0 @@ -use gpui::*; -use story::{Assets, ToggleStory}; - -pub struct Example { - root: Entity, -} - -impl Example { - pub fn new(window: &mut Window, cx: &mut Context) -> Self { - let root = ToggleStory::view(window, cx); - - Self { root } - } - - fn view(window: &mut Window, cx: &mut App) -> Entity { - cx.new(|cx| Self::new(window, cx)) - } -} - -impl Render for Example { - fn render(&mut self, _window: &mut Window, _cx: &mut Context) -> impl IntoElement { - div().p_4().size_full().child(self.root.clone()) - } -} - -fn main() { - let app = Application::new().with_assets(Assets); - - app.run(move |cx| { - story::init(cx); - cx.activate(true); - - story::create_new_window("Toggle Example", Example::view, cx); - }); -} diff --git a/crates/story/examples/tooltip.rs b/crates/story/examples/tooltip.rs deleted file mode 100644 index 3f458ac7..00000000 --- a/crates/story/examples/tooltip.rs +++ /dev/null @@ -1,40 +0,0 @@ -use gpui::*; -use story::{Assets, TooltipStory}; - -pub struct Example { - root: Entity, -} - -impl Example { - pub fn new(window: &mut Window, cx: &mut Context) -> Self { - let root = TooltipStory::view(window, cx); - - Self { root } - } - - fn view(window: &mut Window, cx: &mut App) -> Entity { - cx.new(|cx| Self::new(window, cx)) - } -} - -impl Render for Example { - fn render(&mut self, _window: &mut Window, _cx: &mut Context) -> impl IntoElement { - div() - .p_4() - .id("example") - .overflow_y_scroll() - .size_full() - .child(self.root.clone()) - } -} - -fn main() { - let app = Application::new().with_assets(Assets); - - app.run(move |cx| { - story::init(cx); - cx.activate(true); - - story::create_new_window("Tooltip Example", Example::view, cx); - }); -}