Move UI out of storybook2
and into ui2
This commit is contained in:
parent
1cf5cdbeca
commit
bcad2f4e9e
26 changed files with 51 additions and 78 deletions
18
crates/ui2/src/element_ext.rs
Normal file
18
crates/ui2/src/element_ext.rs
Normal 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 {}
|
Loading…
Add table
Add a link
Reference in a new issue