typst/tests/typ/layout/stack.typ
Laurenz 5f4dde0a6b Remove inline alignment from stack
The current inline alignment is very broken and leads to lots of subtle weirdness. Getting rid of it simplifies the stack's interface a lot. At a later point either:
- inline alignment will be added back in a better way, or
- all nodes will be able to expand or align themselves, meaning that the stack's children take care of their alignment
2021-10-23 20:22:47 +02:00

40 lines
824 B
Typst

// Test stack layouts.
---
// Test stacks with different directions.
#let widths = (
30pt, 20pt, 40pt, 15pt,
30pt, 50%, 20pt, 100%,
)
#let shaded = {
let v = 0
let next() = { v += 0.1; rgb(v, v, v) }
w => rect(width: w, height: 10pt, fill: next())
}
#let items = for w in widths { (shaded(w),) }
#align(right)
#page(width: 50pt, margins: 0pt)
#stack(dir: btt, ..items)
#pagebreak()
---
// Test spacing.
#page(width: 50pt, margins: 0pt)
#par(spacing: 5pt)
#let x = square(size: 10pt, fill: eastern)
#stack(dir: rtl, spacing: 5pt, x, x, x)
#stack(dir: ltr, x, 20%, x, 20%, x)
#stack(dir: ltr, spacing: 5pt, x, x, 7pt, 3pt, x)
---
// Test overflow.
#page(width: 50pt, height: 30pt, margins: 0pt)
#box(stack(
rect(width: 40pt, height: 20pt, fill: conifer),
rect(width: 30pt, height: 13pt, fill: forest),
))