add and document extra classes and parameters

This commit is contained in:
2020-03-09 14:12:41 +01:00
parent 824e062cfd
commit 676c7adfc1
3 changed files with 32 additions and 24 deletions

View File

@@ -41,7 +41,8 @@ Specifying your image files:
Optional parameters: Optional parameters:
- All the [features/parameters](https://gohugo.io/content-management/shortcodes/#figure) of Hugo's built-in `figure` shortcode work as normal, i.e. src, link, rel, title, caption, class, attr (attribution), attrlink, alt. width and height might lead to strange results when used inside `{{< gallery >}}`. - All the [features/parameters](https://gohugo.io/content-management/shortcodes/#figure) of Hugo's built-in `figure` shortcode work as normal, i.e. src, link, rel, title, caption, class, attr (attribution), attrlink, alt. width and height might lead to strange results when used inside `{{< gallery >}}`.
- `class` allows you to set any custom classes you want on the `<figure>` tag. - `class` allows you to set any custom classes you want on the `<figure>` tag. The values `no-border`, `small`, `medium`, `pull-left` and `pull-right` are made available by this project.
- `lightbox` allows you to control the lightbox. The value `none` will disable the lightbox completely.
Optional parameters work for standalone `{{< figure >}}` shortcodes and inside of `{{< gallery >}}`. However, they cannot be applied to `{{< snap-dir >}}`. Optional parameters work for standalone `{{< figure >}}` shortcodes and inside of `{{< gallery >}}`. However, they cannot be applied to `{{< snap-dir >}}`.

View File

@@ -40,7 +40,7 @@
{{- with .Get "rel" }} rel="{{ . }}"{{ end -}} {{- with .Get "rel" }} rel="{{ . }}"{{ end -}}
> >
{{ else -}} {{ else -}}
<a href="#{{ $id }}"> {{ if not (eq (.Get "lightbox") "none") }}<a href="#{{ $id }}">{{ end }}
{{- end -}} {{- end -}}
<!-- THUMBNAIL --> <!-- THUMBNAIL -->
<img src="{{ $thumb | relURL }}" class="snap-thumb" <img src="{{ $thumb | relURL }}" class="snap-thumb"
@@ -57,29 +57,31 @@
{{- end }} {{- end }}
</a> </a>
<!-- FULL IMAGE; HIDDEN --> <!-- FULL IMAGE; HIDDEN -->
<div class="snap-lightbox" id="{{ $id }}"> {{- if not (eq (.Get "lightbox") "none") -}}
<a href="#_" class="snap-lightbox-close"></a> <div class="snap-lightbox" id="{{ $id }}">
<div class="snap-lightbox-inner"> <a href="#_" class="snap-lightbox-close"></a>
<img src="{{ .Get "src" }}" {{ with .Get "alt" }}alt="{{ . }}"{{ end }} /> <div class="snap-lightbox-inner">
<p> <img src="{{ .Get "src" }}" {{ with .Get "alt" }}alt="{{ . }}"{{ end }} />
{{- if or (.Get "caption") (.Get "attr") -}} <p>
{{- .Get "caption" | markdownify -}} {{- if or (.Get "caption") (.Get "attr") -}}
{{- with .Get "attrlink" }} <a href="{{ . }}">{{- end -}} {{- .Get "caption" | markdownify -}}
{{- with .Get "attr" }} {{ . | markdownify}}{{ end -}} {{- with .Get "attrlink" }} <a href="{{ . }}">{{- end -}}
{{- with .Get "attrlink" }}</a>{{- end -}} {{- with .Get "attr" }} {{ . | markdownify}}{{ end -}}
{{- with .Get "attrlink" }}</a>{{- end -}}
{{- end }}
</p>
</div>
<a href="#_" class="snap-lightbox-close-button"><i class="snap-lightbox-x"></i></a>
{{- if .Parent -}}
{{- if not (eq $figid 1) -}}
<a href="#{{ $previd }}" class="snap-lightbox-prev"><i class="snap-lightbox-arrow"></i></a>
{{- else -}}
<span class="snap-lightbox-prev"><i class="snap-lightbox-arrow"></i></span>
{{- end -}}
<!-- TODO: Somehow try to identify whether this is the last element in the gallery -->
<a href="#{{ $nextid }}" class="snap-lightbox-next"><i class="snap-lightbox-arrow"></i></a>
{{- end }} {{- end }}
</p>
</div> </div>
<a href="#_" class="snap-lightbox-close-button"><i class="snap-lightbox-x"></i></a> {{- end -}}
{{- if .Parent -}}
{{- if not (eq $figid 1) -}}
<a href="#{{ $previd }}" class="snap-lightbox-prev"><i class="snap-lightbox-arrow"></i></a>
{{- else -}}
<span class="snap-lightbox-prev"><i class="snap-lightbox-arrow"></i></span>
{{- end -}}
<!-- TODO: Somehow try to identify whether this is the last element in the gallery -->
<a href="#{{ $nextid }}" class="snap-lightbox-next"><i class="snap-lightbox-arrow"></i></a>
{{- end }}
</div>
</div> </div>
</figure> </figure>

View File

@@ -56,6 +56,11 @@ figure figcaption {
color: #FFF; color: #FFF;
} }
/* Extra classes for figures */
figure.no-border .snap-wrapper {
box-shadow: none;
}
/** GALLERY MARKUP **/ /** GALLERY MARKUP **/
.snap-gallery { .snap-gallery {
margin: 10px; margin: 10px;