diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-02-28 15:50:48 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-02-28 23:54:34 +0100 |
| commit | 3ca5b238238e1128aa7bbfbd5db9e632045d8600 (patch) | |
| tree | 2471f4b340a15695b7f4d518c0b39fabaea676c4 /src/library/layout/container.rs | |
| parent | b63c21c91d99a1554a019dc275f955d3e6a34271 (diff) | |
Reorganize library
Diffstat (limited to 'src/library/layout/container.rs')
| -rw-r--r-- | src/library/layout/container.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/library/layout/container.rs b/src/library/layout/container.rs new file mode 100644 index 00000000..55579878 --- /dev/null +++ b/src/library/layout/container.rs @@ -0,0 +1,24 @@ +use crate::library::prelude::*; + +/// An inline-level container that sizes content and places it into a paragraph. +pub struct BoxNode; + +#[class] +impl BoxNode { + fn construct(_: &mut Context, args: &mut Args) -> TypResult<Template> { + let width = args.named("width")?; + let height = args.named("height")?; + let body: LayoutNode = args.find()?.unwrap_or_default(); + Ok(Template::inline(body.sized(Spec::new(width, height)))) + } +} + +/// A block-level container that places content into a separate flow. +pub struct BlockNode; + +#[class] +impl BlockNode { + fn construct(_: &mut Context, args: &mut Args) -> TypResult<Template> { + Ok(Template::Block(args.find()?.unwrap_or_default())) + } +} |
