Fix figure centering

master
Will Faught 2 years ago
parent b83cbaf009
commit 919ccf58ec

@ -14,34 +14,35 @@
{{ $vertical := $params.vertical | default "center" }} {{ $vertical := $params.vertical | default "center" }}
{{ $width := $params.width }} {{ $width := $params.width }}
{{ $heightish := or $maxheight $height }} {{ $heights := slice }}
{{ $showcaption := $caption }} {{ $showcaption := $caption }}
{{ $sidemargin := "" }} {{ $sidemargin := "" }}
{{ $style := slice }}
{{ $table := false }} {{ $table := false }}
{{ $widthish := or $maxwidth $width }} {{ $widths := slice }}
{{ if and $caption (or $compact $float) }} {{ if and $caption (or $compact $float) }}
{{ $table = true }} {{ $table = true }}
{{ end }} {{ end }}
{{ if $height }} {{ if $height }}
{{ $style = $style | append (printf "height: %v" $height) }} {{ $heights = $heights | append (printf "height: %v" $height) }}
{{ end }} {{ end }}
{{ if $maxheight }} {{ if $maxheight }}
{{ $style = $style | append (printf "max-height: %v" $maxheight) }} {{ $heights = $heights | append (printf "max-height: %v" $maxheight) }}
{{ end }} {{ end }}
{{ $heights = delimit ($heights | sort) "; " }}
{{ if $maxwidth }} {{ if $maxwidth }}
{{ $style = $style | append (printf "max-width: %v" $maxwidth) }} {{ $widths = $widths | append (printf "max-width: %v" $maxwidth) }}
{{ end }} {{ end }}
{{ if $width }} {{ if $width }}
{{ $style = $style | append (printf "width: %v" $width) }} {{ $widths = $widths | append (printf "width: %v" $width) }}
{{ end }} {{ end }}
{{ $style = delimit ($style | sort) "; " }} {{ $widths = delimit ($widths | sort) "; " }}
{{ if $float }} {{ if $float }}
{{ if eq $float "start" }} {{ if eq $float "start" }}
@ -66,26 +67,12 @@
{{ end }} {{ end }}
{{ end }} {{ end }}
<figure class="{{ if $widthish }} d-flex {{ end }} {{ with $float }} float-{{ . }} {{ end }} {{ if $widthish }} justify-content-{{ $horizontal }} {{ end }} {{ if $compact }} mb-0 {{ end }} {{ if $float }} {{ $sidemargin }} {{ end }} paige-figure {{ if $numbered }} paige-figure-numbered {{ end }}" {{ if and $float $style }} style="{{ $style | safeCSS }}" {{ end }}> <div class="align-items-{{ $vertical }} d-flex {{ with $float }} float-{{ . }} {{ end }} justify-content-{{ $horizontal }} {{ if $compact }} mb-0 {{ else }} mb-3 {{ end }} {{ with $sidemargin }} {{ . }} {{ end }} overflow-auto paige-figure {{ if $numbered }} paige-figure-numbered {{ end }}" {{ with $heights }} style="{{ . | safeCSS }}" {{ end }}>
{{ if or $heightish $widthish (and (not $float) $style) }} <figure class="{{ if $table }} d-table {{ end }} mb-0" {{ with $widths }} style="{{ . | safeCSS }}" {{ end }}>
<div {{ if or $heightish $widthish }} class="{{ if $height }} d-flex flex-column justify-content-{{ $vertical }} {{ end }} overflow-auto" {{ end }} {{ if and (not $float) $style }} style="{{ $style | safeCSS }}" {{ end }}> <div class="d-flex justify-content-{{ $horizontal }} text-{{ $horizontal }}">{{ $content }}</div>
{{ end }}
{{ if $table }}
<div class="d-table">
{{ end }}
<div class="text-{{ $horizontal }}">{{ $content }}</div>
{{ if $showcaption }} {{ if $showcaption }}
<figcaption class="figure-caption {{ with $gap }} mt-{{ . }} {{ end }} text-{{ $horizontal }}" {{ if $table }} style="caption-side: bottom; display: table-caption" {{ end }}>{{ $caption }}</figcaption> <figcaption class="figure-caption {{ with $gap }} mt-{{ . }} {{ end }} text-{{ $horizontal }}" {{ if $table }} style="caption-side: bottom; display: table-caption" {{ end }}>{{ $caption }}</figcaption>
{{ end }} {{ end }}
</figure>
{{ if $table }} </div>
</div>
{{ end }}
{{ if or $heightish $widthish (and (not $float) $style) }}
</div>
{{ end }}
</figure>

Loading…
Cancel
Save