diff --git a/crates/gpui2/src/elements/pressable.rs b/crates/gpui2/src/elements/pressable.rs index 960342a5e6..7685167773 100644 --- a/crates/gpui2/src/elements/pressable.rs +++ b/crates/gpui2/src/elements/pressable.rs @@ -5,7 +5,7 @@ use crate::{ ViewContext, }; use anyhow::Result; -use gpui::{geometry::vector::Vector2F, platform::MouseButtonEvent, LayoutId}; +use gpui::{color::Color, geometry::vector::Vector2F, platform::MouseButtonEvent, LayoutId}; use refineable::{CascadeSlot, Refineable, RefinementCascade}; use smallvec::SmallVec; use std::{cell::Cell, rc::Rc}; @@ -73,10 +73,15 @@ impl + Styleable> Element for Pressable { if bounds.contains_point(event.position) { pressed.set(true); cx.repaint(); + } else { + cx.bubble_event(); } - } else if pressed.get() { - pressed.set(false); - cx.repaint(); + } else { + if pressed.get() { + pressed.set(false); + cx.repaint(); + } + cx.bubble_event(); } }); diff --git a/crates/storybook/src/components.rs b/crates/storybook/src/components.rs index 36ac1575f5..4860ef28f4 100644 --- a/crates/storybook/src/components.rs +++ b/crates/storybook/src/components.rs @@ -12,7 +12,6 @@ mod tool_divider; pub use avatar::avatar; pub use avatar::Avatar; pub use icon_button::icon_button; -pub use icon_button::IconButton; pub use tab::tab; pub use tab::Tab; pub use tool_divider::tool_divider; diff --git a/crates/storybook/src/components/icon_button.rs b/crates/storybook/src/components/icon_button.rs index 32ef1d0ce2..f82979ab7c 100644 --- a/crates/storybook/src/components/icon_button.rs +++ b/crates/storybook/src/components/icon_button.rs @@ -12,7 +12,7 @@ pub struct IconButton { state: InteractionState, } -pub fn icon_button(path: &'static str) -> IconButton { +pub fn icon_button(path: &'static str) -> IconButton { IconButton { path, variant: ButtonVariant::default(), diff --git a/crates/storybook/src/components/icon_button2 b/crates/storybook/src/components/icon_button2 deleted file mode 100644 index 9fe738d5ac..0000000000 --- a/crates/storybook/src/components/icon_button2 +++ /dev/null @@ -1,123 +0,0 @@ -// use crate::prelude::{ButtonVariant, UIState}; -// use crate::theme::theme; -// use gpui2::elements::svg; -// use gpui2::style::{StyleHelpers, Styleable}; -// use gpui2::{elements::div, IntoElement}; -// use gpui2::{Element, ParentElement, ViewContext}; - -// #[derive(Element)] -// pub(crate) struct IconButton { -// path: &'static str, -// variant: ButtonVariant, -// state: UIState, -// } - -// pub fn icon_button(path: &'static str) -> IconButton { -// IconButton { -// path, -// variant: ButtonVariant::Filled, -// state: UIState::Default, -// } -// } - -// impl IconButton { -// fn variant(mut self, variant: ButtonVariant) -> Self { -// self.variant = variant; - -// // Example of more interesting setter behavior -// // FilledButtons must be disabled -// if self.variant == ButtonVariant::Filled { -// self.state = UIState::Disabled; -// } - -// self -// } - -// fn state(mut self, state: UIState) -> Self { -// // Example of more interesting setter behavior: -// // GhostButtons Cannot be disabled -// // Debug asserts are compiled out when we make a new release. -// // Useful for making sure developers develop correctly without breaking -// // everything -// debug_assert!(self.variant != ButtonVariant::Ghost && state != UIState::Disabled); - -// self.state = state; -// self -// } - -// // const state = { -// // foo: "foo", -// // bar: "bar" -// // } as const -// // -// // type State = typeof state[keyof typeof something] -// // -// // type Button { -// // style: State -// // } -// // -// //