Skip to content

Commit

Permalink
add column-gap parameter (#36)
Browse files Browse the repository at this point in the history
* add column-gap parameter

parameterized by em units so that a 1.0 gives a reasonably small value independent of screen size

* Update nimiSlides.nim

* Update nimiSlides.nim

* Update nimiSlides.nim

* Update nimiSlides.nim

* Update nimiSlides.nim

* Update nimiSlides.nim

fixed last bug

* Update nimiSlides.nim

fixed to match syntax of %-interpolation: float arg had to be stringified first
  • Loading branch information
quimt authored Feb 26, 2024
1 parent c9e80b9 commit f99f14a
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/nimiSlides.nim
Original file line number Diff line number Diff line change
Expand Up @@ -525,16 +525,28 @@ template align*(text: string, body: untyped) =
body
nbRawHtml: "</div>"

template columns*(body: untyped) =
nbRawHtml: """<div style="display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); overflow-wrap: break-word;">"""
#templates can't have default args and untyped args at the same time
#so we use overloading to get the same effect

template columns*(columnGap: float, body: untyped) =
#tempted to use fmt"", but strformat doesn't support template args in the format string
nbRawHtml: """<div style="display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); overflow-wrap: break-word; column-gap: $1 em;">
""" % $columnGap
body
nbRawHtml: "</div>"

template adaptiveColumns*(body: untyped) =
nbRawHtml: """<div style="display: grid; grid-auto-flow: column; overflow-wrap: break-word;">"""
template columns*(body: untyped) =
columns(1.0,body)

template adaptiveColumns*(columnGap: float, body: untyped) =
nbRawHtml: """<div style="display: grid; grid-auto-flow: column; overflow-wrap: break-word; column-gap: $1 em;">
""" % $columnGap
body
nbRawHtml: "</div>"

template adaptiveColumns*(body: untyped) =
adaptiveColumns(1.0,body)

template column*(bodyInner: untyped) =
## column should always be used inside a `columns` block
nbRawHtml: "<div>"
Expand Down

0 comments on commit f99f14a

Please sign in to comment.