diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-03-07 15:17:13 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-03-07 15:17:13 +0100 |
| commit | 25b5bd117529cd04bb789e1988eb3a3db8025a0e (patch) | |
| tree | 2fbb4650903123da047a1f1f11a0abda95286e12 /library/src/layout/hide.rs | |
| parent | 6ab7760822ccd24b4ef126d4737d41f1be15fe19 (diff) | |
Fully untyped model
Diffstat (limited to 'library/src/layout/hide.rs')
| -rw-r--r-- | library/src/layout/hide.rs | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/library/src/layout/hide.rs b/library/src/layout/hide.rs index 019dd2a6..5ba7dea4 100644 --- a/library/src/layout/hide.rs +++ b/library/src/layout/hide.rs @@ -1,6 +1,5 @@ use crate::prelude::*; -/// # Hide /// Hide content without affecting layout. /// /// The `hide` function allows you to hide content while the layout still 'sees' @@ -14,26 +13,18 @@ use crate::prelude::*; /// #hide[Hello] Joe /// ``` /// -/// ## Parameters -/// - body: `Content` (positional, required) -/// The content to hide. -/// -/// ## Category -/// layout -#[func] -#[capable(Show)] -#[derive(Debug, Hash)] -pub struct HideNode(pub Content); - -#[node] -impl HideNode { - fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> { - Ok(Self(args.expect("body")?).pack()) - } +/// Display: Hide +/// Category: layout +#[node(Show)] +pub struct HideNode { + /// The content to hide. + #[positional] + #[required] + pub body: Content, } impl Show for HideNode { fn show(&self, _: &mut Vt, _: &Content, _: StyleChain) -> SourceResult<Content> { - Ok(self.0.clone().styled(Meta::DATA, vec![Meta::Hidden])) + Ok(self.body().styled(MetaNode::DATA, vec![Meta::Hidden])) } } |
