How to create an adaptive vertical line that dynamically spans the height of its containing box/block

Here is the styling:

#let custom-line(stroke) = line(length: 100%, angle: 90deg, stroke: stroke)
#let custom-block = block.with(
  width: 8cm,
  height: 5.1cm,
  inset: (left: 2.5em, rest: 1em),
  radius: 1em,
  fill: blue.transparentize(70%),
)

#let block1(body) = custom-block({
  let line-blue = custom-line((cap: "round", thickness: 5pt, paint: blue))
  place(dx: -1.25em, line-blue)
  body
})

#let block2(body) = custom-block({
  let stroke = (cap: "round", thickness: 5pt, paint: red)
  let line-red-with-square = grid(
    rows: (1fr, auto, 1fr),
    row-gutter: 10pt,
    align: center,
    custom-line(stroke),
    square(size: 5pt, stroke: stroke, radius: 3pt),
    custom-line(stroke),
  )
  place(dx: -1.25em - 2.5pt, line-red-with-square)
  body
})

#set par(justify: true)

#block1[
  #lorem(52)
]

#block2[
  #lorem(52)
]

5 Likes