summaryrefslogtreecommitdiff
path: root/library/src/layout/container.rs
diff options
context:
space:
mode:
Diffstat (limited to 'library/src/layout/container.rs')
-rw-r--r--library/src/layout/container.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/library/src/layout/container.rs b/library/src/layout/container.rs
index d65b78b6..22a9e02e 100644
--- a/library/src/layout/container.rs
+++ b/library/src/layout/container.rs
@@ -1,3 +1,4 @@
+use super::VNode;
use crate::prelude::*;
/// An inline-level container that sizes content.
@@ -63,9 +64,22 @@ pub struct BlockNode(pub Content);
#[node(LayoutBlock)]
impl BlockNode {
+ /// The spacing between the previous and this block.
+ #[property(skip)]
+ pub const ABOVE: VNode = VNode::weak(Em::new(1.2).into());
+ /// The spacing between this and the following block.
+ #[property(skip)]
+ pub const BELOW: VNode = VNode::weak(Em::new(1.2).into());
+
fn construct(_: &mut Vm, args: &mut Args) -> SourceResult<Content> {
Ok(Self(args.eat()?.unwrap_or_default()).pack())
}
+
+ fn set(...) {
+ let spacing = args.named("spacing")?.map(VNode::weak);
+ styles.set_opt(Self::ABOVE, args.named("above")?.map(VNode::strong).or(spacing));
+ styles.set_opt(Self::BELOW, args.named("below")?.map(VNode::strong).or(spacing));
+ }
}
impl LayoutBlock for BlockNode {