Move UI out of storybook2 and into ui2

This commit is contained in:
Marshall Bowers 2023-10-06 17:07:59 -04:00
parent 1cf5cdbeca
commit bcad2f4e9e
26 changed files with 51 additions and 78 deletions

View file

@ -0,0 +1,18 @@
use gpui3::Element;
pub trait ElementExt<S: 'static + Send + Sync>: Element<State = S> {
/// Applies a given function `then` to the current element if `condition` is true.
/// This function is used to conditionally modify the element based on a given condition.
/// If `condition` is false, it just returns the current element as it is.
fn when(mut self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
where
Self: Sized,
{
if condition {
self = then(self);
}
self
}
}
impl<S: 'static + Send + Sync, E: Element<State = S>> ElementExt<S> for E {}