From 072d2b061ab88cf347fcdc839366e978bfab1de6 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Sun, 9 Feb 2025 11:07:40 -0500 Subject: [PATCH] ui: Remove `ToolStrip` component (#24529) This PR removes the `ToolStrip` component. Pulling this change out of https://github.com/zed-industries/zed/pull/24456. Release Notes: - N/A --- crates/storybook/src/story_selector.rs | 2 - crates/ui/src/components.rs | 2 - crates/ui/src/components/stories.rs | 2 - .../ui/src/components/stories/tool_strip.rs | 33 ----------- crates/ui/src/components/tool_strip.rs | 58 ------------------- 5 files changed, 97 deletions(-) delete mode 100644 crates/ui/src/components/stories/tool_strip.rs delete mode 100644 crates/ui/src/components/tool_strip.rs diff --git a/crates/storybook/src/story_selector.rs b/crates/storybook/src/story_selector.rs index f9af57f8b5..6f844a65b5 100644 --- a/crates/storybook/src/story_selector.rs +++ b/crates/storybook/src/story_selector.rs @@ -36,7 +36,6 @@ pub enum ComponentStory { TabBar, Text, ToggleButton, - ToolStrip, ViewportUnits, WithRemSize, Vector, @@ -73,7 +72,6 @@ impl ComponentStory { Self::TabBar => cx.new(|_| ui::TabBarStory).into(), Self::Text => TextStory::model(cx).into(), Self::ToggleButton => cx.new(|_| ui::ToggleButtonStory).into(), - Self::ToolStrip => cx.new(|_| ui::ToolStripStory).into(), Self::ViewportUnits => cx.new(|_| crate::stories::ViewportUnitsStory).into(), Self::WithRemSize => cx.new(|_| crate::stories::WithRemSizeStory).into(), Self::Vector => cx.new(|_| ui::VectorStory).into(), diff --git a/crates/ui/src/components.rs b/crates/ui/src/components.rs index 94ace5632c..184d841bb1 100644 --- a/crates/ui/src/components.rs +++ b/crates/ui/src/components.rs @@ -29,7 +29,6 @@ mod tab; mod tab_bar; mod table; mod toggle; -mod tool_strip; mod tooltip; #[cfg(feature = "stories")] @@ -66,7 +65,6 @@ pub use tab::*; pub use tab_bar::*; pub use table::*; pub use toggle::*; -pub use tool_strip::*; pub use tooltip::*; #[cfg(feature = "stories")] diff --git a/crates/ui/src/components/stories.rs b/crates/ui/src/components/stories.rs index b55aa064f9..9161b14b47 100644 --- a/crates/ui/src/components/stories.rs +++ b/crates/ui/src/components/stories.rs @@ -15,7 +15,6 @@ mod list_item; mod tab; mod tab_bar; mod toggle_button; -mod tool_strip; pub use avatar::*; pub use button::*; @@ -31,4 +30,3 @@ pub use list_item::*; pub use tab::*; pub use tab_bar::*; pub use toggle_button::*; -pub use tool_strip::*; diff --git a/crates/ui/src/components/stories/tool_strip.rs b/crates/ui/src/components/stories/tool_strip.rs deleted file mode 100644 index 0a6a6b7ad0..0000000000 --- a/crates/ui/src/components/stories/tool_strip.rs +++ /dev/null @@ -1,33 +0,0 @@ -use gpui::Render; -use story::{Story, StoryItem, StorySection}; - -use crate::{prelude::*, ToolStrip, Tooltip}; - -pub struct ToolStripStory; - -impl Render for ToolStripStory { - fn render(&mut self, _window: &mut Window, _cx: &mut Context) -> impl IntoElement { - Story::container() - .child(Story::title_for::()) - .child( - StorySection::new().child(StoryItem::new( - "Vertical Tool Strip", - h_flex().child( - ToolStrip::vertical("tool_strip_example") - .tool( - IconButton::new("example_tool", IconName::AudioOn) - .tooltip(Tooltip::text("Example tool")), - ) - .tool( - IconButton::new("example_tool_2", IconName::MicMute) - .tooltip(Tooltip::text("Example tool 2")), - ) - .tool( - IconButton::new("example_tool_3", IconName::Screen) - .tooltip(Tooltip::text("Example tool 3")), - ), - ), - )), - ) - } -} diff --git a/crates/ui/src/components/tool_strip.rs b/crates/ui/src/components/tool_strip.rs deleted file mode 100644 index 00166c8d7e..0000000000 --- a/crates/ui/src/components/tool_strip.rs +++ /dev/null @@ -1,58 +0,0 @@ -#![allow(missing_docs)] - -use gpui::Axis; - -use crate::prelude::*; - -#[derive(IntoElement)] -pub struct ToolStrip { - id: ElementId, - tools: Vec, - axis: Axis, -} - -impl ToolStrip { - fn new(id: ElementId, axis: Axis) -> Self { - Self { - id, - tools: vec![], - axis, - } - } - - pub fn vertical(id: impl Into) -> Self { - Self::new(id.into(), Axis::Vertical) - } - - pub fn tools(mut self, tools: Vec) -> Self { - self.tools = tools; - self - } - - pub fn tool(mut self, tool: IconButton) -> Self { - self.tools.push(tool); - self - } -} - -impl RenderOnce for ToolStrip { - fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement { - let group = format!("tool_strip_{}", self.id.clone()); - - div() - .id(self.id.clone()) - .group(group) - .map(|element| match self.axis { - Axis::Vertical => element.v_flex(), - Axis::Horizontal => element.h_flex(), - }) - .flex_none() - .gap(DynamicSpacing::Base04.rems(cx)) - .p(DynamicSpacing::Base02.rems(cx)) - .border_1() - .border_color(cx.theme().colors().border) - .rounded(rems_from_px(6.0)) - .bg(cx.theme().colors().elevated_surface_background) - .children(self.tools) - } -}