Consolidate figure designs

master
Will Faught 3 years ago
parent c8e955bd36
commit c578d235d2

@ -40,6 +40,42 @@ Don't believe everything you read on the Internet.
Code: Code:
```go-text-template
{{</* paige/figure caption="Abraham Lincoln" */>}}
Michael was having brunch with Sally Sitwell at a restaurant called Skip Church's Bistro. In addition to brunch, the restaurant was known for an item on the menu called the "Skip's Scramble", an omelet that contained everything on the menu. Do not order the Skip's Scramble. You might enjoy this. Oh. Em. Gee. That's amazing. It feels good to be back in a queen! I need a tea to give my dingle less tingle. Teamocil. Heyyyyyy Uncle Father Oscar.
{{</* /paige/figure */>}}
```
Result:
{{< paige/figure caption="Abraham Lincoln" >}}
Michael was having brunch with Sally Sitwell at a restaurant called Skip Church's Bistro. In addition to brunch, the restaurant was known for an item on the menu called the "Skip's Scramble", an omelet that contained everything on the menu. Do not order the Skip's Scramble. You might enjoy this. Oh. Em. Gee. That's amazing. It feels good to be back in a queen! I need a tea to give my dingle less tingle. Teamocil. Heyyyyyy Uncle Father Oscar.
{{< /paige/figure >}}
---
Code:
```go-text-template
{{</* paige/figure caption="Michael was having brunch with Sally Sitwell" float="end" */>}}
Michael was having brunch
{{</* /paige/figure */>}}
Michael was having brunch with Sally Sitwell at a restaurant called Skip Church's Bistro. In addition to brunch, the restaurant was known for an item on the menu called the "Skip's Scramble", an omelet that contained everything on the menu. Do not order the Skip's Scramble. You might enjoy this. Oh. Em. Gee. That's amazing. It feels good to be back in a queen! I need a tea to give my dingle less tingle. Teamocil. Heyyyyyy Uncle Father Oscar.
```
Result:
{{< paige/figure caption="Michael was having brunch with Sally Sitwell at a restaurant called Skip Church's Bistro." width="20%" height="15rem" float="end" >}}
Michael was having brunch with Sally Sitwell
{{< /paige/figure >}}
Michael was having brunch with Sally Sitwell at a restaurant called Skip Church's Bistro. In addition to brunch, the restaurant was known for an item on the menu called the "Skip's Scramble", an omelet that contained everything on the menu. Do not order the Skip's Scramble. You might enjoy this. Oh. Em. Gee. That's amazing. It feels good to be back in a queen! I need a tea to give my dingle less tingle. Teamocil. Heyyyyyy Uncle Father Oscar.
---
Code:
```go-text-template ```go-text-template
{{</* paige/figure caption="Abraham Lincoln" float="start" */>}} {{</* paige/figure caption="Abraham Lincoln" float="start" */>}}
Don't believe everything you read on the Internet. Don't believe everything you read on the Internet.
@ -62,24 +98,24 @@ Code:
```go-text-template ```go-text-template
{{</* paige/figure caption="Hickory Dickory Dock" */>}} {{</* paige/figure caption="Hickory Dickory Dock" */>}}
<pre style="font-family: inherit; font-size: 1rem"> <div style="white-space: pre">
Hickory dickory dock. Hickory dickory dock.
The mouse ran up the clock. The mouse ran up the clock.
The clock struck one, The clock struck one,
The mouse ran down, The mouse ran down,
Hickory dickory dock. Hickory dickory dock.
</pre> </div>
{{</* /paige/figure */>}} {{</* /paige/figure */>}}
``` ```
Result: Result:
{{< paige/figure caption="Hickory Dickory Dock" >}} {{< paige/figure caption="Hickory Dickory Dock" >}}
<pre style="font-family: inherit; font-size: 1rem"> <div style="white-space: pre">
Hickory dickory dock. Hickory dickory dock.
The mouse ran up the clock. The mouse ran up the clock.
The clock struck one, The clock struck one,
The mouse ran down, The mouse ran down,
Hickory dickory dock. Hickory dickory dock.
</pre> </div>
{{< /paige/figure >}} {{< /paige/figure >}}

@ -48,26 +48,28 @@
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ $margins := "" }} {{ $margin := "" }}
{{ if $float }} {{ if $float }}
{{ if eq $float "start" }} {{ if eq $float "start" }}
{{ $margins = "me-4" }} {{ $margin = "me-4" }}
{{ else if eq $float "end" }} {{ else if eq $float "end" }}
{{ $margins = "ms-4" }} {{ $margin = "ms-4" }}
{{ else }} {{ else }}
{{ errorf "invalid float: %q" $float }} {{ errorf "invalid float: %q" $float }}
{{ end }} {{ end }}
{{ end }} {{ end }}
<figure class="align-items-center d-flex flex-column {{ with $float }} float-{{ . }} {{ end }} {{ with $margins }} {{ . }} {{ end }} paige-figure"> <figure class="{{ with $float }} float-{{ . }} {{ $margin }} {{ end }} align-items-center d-flex flex-column justify-content-center paige-figure" {{ if $float }} {{ with $style }} style="{{ . | safeCSS }}" {{ end }} {{ end }}>
{{ with $style }} <div class="align-items-center d-flex flex-column justify-content-center {{ if and $float $height }} h-100 {{ end }}" {{ if not $float }} {{ with $style }} style="{{ . | safeCSS }}" {{ end }} {{ end }}>
<div class="align-items-center d-flex flex-column justify-content-center" style="{{ . | safeCSS }}"> {{ if $float }}
<div class="d-table">
{{ end }} {{ end }}
<div class="{{ if $caption }} mb-2 {{ end }} mw-100">{{ $content }}</div> <div {{ if $caption }} class="mb-2" {{ end }}>{{ $content }}</div>
{{ with $caption }} {{ with $caption }}
<figcaption class="figure-caption">{{ . }}</figcaption> <figcaption class="figure-caption text-center" {{ if $float }} style="caption-side: bottom; display: table-caption" {{ end }}>{{ . }}</figcaption>
{{ end }} {{ end }}
{{ if $style }} {{ if $float }}
</div> </div>
{{ end }} {{ end }}
</div>
</figure> </figure>

@ -7,6 +7,7 @@
{{ $maxwidth := .maxwidth }} {{ $maxwidth := .maxwidth }}
{{ $method := .method }} {{ $method := .method }}
{{ $options := .options }} {{ $options := .options }}
{{ $packed := .packed }}
{{ $page := .page }} {{ $page := .page }}
{{ $resource := .resource }} {{ $resource := .resource }}
{{ $src := .src }} {{ $src := .src }}
@ -14,14 +15,9 @@
{{ $title := .title }} {{ $title := .title }}
{{ $width := .width }} {{ $width := .width }}
{{ $class := "img-fluid" }}
{{ if $caption }}
{{ $class = "figure-img img-fluid" }}
{{ end }}
{{ $content := partial "paige/img.html" (dict {{ $content := partial "paige/img.html" (dict
"alt" $alt "alt" $alt
"class" $class "class" "img-fluid"
"method" $method "method" $method
"options" $options "options" $options
"page" $page "page" $page
@ -79,15 +75,8 @@
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ if $table }}
<figure class="d-table mb-0 paige-figure text-center">
{{ $content }}
{{ with $caption }}
<figcaption class="figure-caption" style="caption-side: bottom; display: table-caption">{{ . }}</figcaption>
{{ end }}
</figure>
{{ else if $float }}
{{ $margin := "" }} {{ $margin := "" }}
{{ if $float }}
{{ if eq $float "start" }} {{ if eq $float "start" }}
{{ $margin = "me-4" }} {{ $margin = "me-4" }}
{{ else if eq $float "end" }} {{ else if eq $float "end" }}
@ -95,25 +84,19 @@
{{ else }} {{ else }}
{{ errorf "invalid float: %q" $float }} {{ errorf "invalid float: %q" $float }}
{{ end }} {{ end }}
<figure class="d-table float-{{ $float }} {{ $margin }} paige-figure text-center" {{ with $style }} style="{{ . | safeCSS }}" {{ end }}>
{{ $content }}
{{ with $caption }}
<figcaption class="figure-caption" style="caption-side: bottom; display: table-caption">{{ . }}</figcaption>
{{ end }} {{ end }}
</figure>
{{ else }} <figure class="{{ if $float }} float-{{ $float }} {{ $margin }} {{ else if $packed }} mb-0 {{ end }} align-items-center d-flex flex-column justify-content-center paige-figure" {{ if $float }} {{ with $style }} style="{{ . | safeCSS }}" {{ end }} {{ end }}>
<figure class="paige-figure text-center"> <div class="align-items-center d-flex flex-column justify-content-center {{ if and $float $height }} h-100 {{ end }}" {{ if not $float }} {{ with $style }} style="{{ . | safeCSS }}" {{ end }} {{ end }}>
{{ with $style }} {{ if or $float $table }}
<div class="align-items-center d-flex flex-column"> <div class="d-table">
<div style="{{ . }}">
{{ end }} {{ end }}
{{ $content }} <div {{ if $caption }} class="mb-2" {{ end }}>{{ $content }}</div>
{{ with $caption }} {{ with $caption }}
<figcaption class="figure-caption">{{ . }}</figcaption> <figcaption class="figure-caption text-center" {{ if or $float $table }} style="caption-side: bottom; display: table-caption" {{ end }}>{{ . }}</figcaption>
{{ end }} {{ end }}
{{ if $style }} {{ if or $float $table }}
</div>
</div> </div>
{{ end }} {{ end }}
</div>
</figure> </figure>
{{ end }}

@ -25,6 +25,7 @@
"maxwidth" $maxwidth "maxwidth" $maxwidth
"method" $method "method" $method
"options" $options "options" $options
"packed" true
"page" .Page "page" .Page
"resource" $resource "resource" $resource
"src" $image "src" $image
@ -51,48 +52,49 @@
<figure> <figure>
{{ if eq $type "grid" }} {{ if eq $type "grid" }}
<div class="container-fluid {{ if $caption }} figure-img {{ end }} px-0"> <div class="container-fluid {{ if $caption }} mb-2 {{ end }} px-0">
<div class="align-items-{{ $align }} gx-3 gy-3 justify-content-{{ $justify }} row row-cols-1 row-cols-sm-2 row-cols-md-3 row-cols-lg-4 row-cols-xl-5 row-cols-xxl-6"> <div class="align-items-{{ $align }} gx-3 gy-3 justify-content-{{ $justify }} row row-cols-1 row-cols-sm-2 row-cols-md-3 row-cols-lg-4 row-cols-xl-5 row-cols-xxl-6">
{{ with $inner }} {{ with $inner }}
{{ . }} {{ . }}
{{ else }} {{ else }}
{{ range $resources }} {{ range $resources }}
{{ partial "paige/image-figure.html" (dict <div class="col">
{{ partial "paige/a.html" (dict
"content" (partial "paige/img.html" (dict
"class" "img-fluid"
"height" $height "height" $height
"link" .RelPermalink
"maxheight" $maxheight "maxheight" $maxheight
"maxwidth" $maxwidth "maxwidth" $maxwidth
"method" $method "method" $method
"options" $options "options" $options
"page" $.Page
"resource" . "resource" .
"table" true
"width" $width "width" $width
))
"href" .RelPermalink
) }} ) }}
</div>
{{ end }} {{ end }}
{{ end }} {{ end }}
</div> </div>
</div> </div>
{{ else if eq $type "rows" }} {{ else if eq $type "rows" }}
{{ if not (or $height $maxheight) }} <div class="align-items-{{ $align }} column-gap-3 d-flex flex-wrap justify-content-{{ $justify }} {{ if $caption }} mb-2 {{ end }} row-gap-3">
{{ $maxheight = $maxheight | default "10rem" }}
{{ end }}
<div class="align-items-{{ $align }} column-gap-3 d-flex {{ with $caption }} figure-img {{ end }} flex-wrap justify-content-{{ $justify }} row-gap-3">
{{ with $inner }} {{ with $inner }}
{{ . }} {{ . }}
{{ else }} {{ else }}
{{ range $resources }} {{ range $resources }}
{{ partial "paige/image-figure.html" (dict {{ partial "paige/a.html" (dict
"content" (partial "paige/img.html" (dict
"class" "img-fluid"
"height" $height "height" $height
"link" .RelPermalink
"maxheight" $maxheight "maxheight" $maxheight
"maxwidth" $maxwidth "maxwidth" $maxwidth
"method" $method "method" $method
"options" $options "options" $options
"page" $.Page
"resource" . "resource" .
"table" true
"width" $width "width" $width
))
"href" .RelPermalink
) }} ) }}
{{ end }} {{ end }}
{{ end }} {{ end }}

@ -51,29 +51,37 @@
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ $margins := "" }} {{ $margin := "" }}
{{ if $float }} {{ if $float }}
{{ if eq $float "start" }} {{ if eq $float "start" }}
{{ $margins = "me-4" }} {{ $margin = "me-4" }}
{{ else if eq $float "end" }} {{ else if eq $float "end" }}
{{ $margins = "ms-4" }} {{ $margin = "ms-4" }}
{{ else }} {{ else }}
{{ errorf "invalid float: %q" $float }} {{ errorf "invalid float: %q" $float }}
{{ end }} {{ end }}
{{ end }} {{ end }}
<figure class="align-items-center d-flex flex-column {{ with $float }} float-{{ . }} {{ end }} {{ with $margins }} {{ . }} {{ end }} paige-figure"> <figure class="{{ with $float }} float-{{ . }} {{ $margin }} {{ end }} align-items-center d-flex flex-column justify-content-center paige-figure" {{ if $float }} {{ with $style }} style="{{ . | safeCSS }}" {{ end }} {{ end }}>
{{ with $style }} <div class="align-items-center d-flex flex-column justify-content-center {{ if and $float $height }} h-100 {{ end }}" {{ if not $float }} {{ with $style }} style="{{ . | safeCSS }}" {{ end }} {{ end }}>
<div class="align-items-center d-flex flex-column justify-content-center" style="{{ . | safeCSS }}"> {{ if $float }}
<div class="d-table">
{{ end }}
{{ if $caption }}
<div class="mb-2">
{{ end }}
<blockquote class="blockquote {{ if not $cite }} mb-0 {{ end }} text-{{ $align }}">{{ $content }}</blockquote>
{{ if $caption }}
</div>
{{ end }} {{ end }}
<blockquote class="blockquote {{ if $caption }} mb-2 {{ else if not $cite }} mb-0 {{ end }} text-{{ $align }}">{{ $content }}</blockquote>
{{ with $caption }} {{ with $caption }}
<figcaption class="figure-caption">{{ . }}</figcaption> <figcaption class="figure-caption text-center" {{ if $float }} style="caption-side: bottom; display: table-caption" {{ end }}>{{ . }}</figcaption>
{{ end }} {{ end }}
{{ with $cite }} {{ with $cite }}
<figcaption class="blockquote-footer figure-caption mb-0 text-{{ $align }}">{{ . }}</figcaption> <figcaption class="blockquote-footer figure-caption mb-0 text-{{ $align }}">{{ . }}</figcaption>
{{ end }} {{ end }}
{{ if $style }} {{ if $float }}
</div> </div>
{{ end }} {{ end }}
</div>
</figure> </figure>

Loading…
Cancel
Save