HugoGranstrom / nimiSlides

A Reveal.js theme for nimib for making slideshow presentations in Nim
https://hugogranstrom.com/nimiSlides
MIT License
78 stars 5 forks source link

Aligning text #8

Closed HugoGranstrom closed 1 year ago

HugoGranstrom commented 1 year ago

Reveal.js by default likes to center everything but when for example making lists it can cause trouble if each list element is created separately as they aren't aligned horizontally. In that case, one could left-align them for example. So the idea is to introduce align which just wraps it's content in a div with align properties:

slide:
  align("left"):
    nbText: "First"
    nbText: "Second"

The top three elements are without any alignment and the bottom three are left-aligned. image

A simple implementation would be:

template align*(text: string, body: untyped) =
  nbRawOutput: """
<div style="text-align: $1;">
""" % text
  body
  nbRawOutput: "</div>"

It only aligns text but I think that is enough to support out of the box for now. In the future a convenient flexbox API (in nimib?) would allow for more customization of layout.