Compare commits
4 Commits
81ece5842c
...
v1.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
75c0cf2fc3
|
|||
|
2c6026f976
|
|||
|
676c7adfc1
|
|||
|
824e062cfd
|
@@ -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`, `sm`, `md`, `lg`, `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 >}}`.
|
||||||
|
|
||||||
|
|||||||
@@ -33,51 +33,55 @@
|
|||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
<figure {{ with .Get "class" }}class="{{.}}"{{ end }}>
|
<figure {{ with .Get "class" }}class="{{.}}"{{ end }}>
|
||||||
{{ if (.Get "link") -}}
|
<div class="snap-wrapper">
|
||||||
<a href="{{ .Get "link" }}"
|
{{ if (.Get "link") -}}
|
||||||
{{- with .Get "target" }} target="{{ . }}"{{ end -}}
|
<a href="{{ .Get "link" }}"
|
||||||
{{- with .Get "rel" }} rel="{{ . }}"{{ end -}}
|
{{- with .Get "target" }} target="{{ . }}"{{ end -}}
|
||||||
>
|
{{- with .Get "rel" }} rel="{{ . }}"{{ end -}}
|
||||||
{{ else -}}
|
>
|
||||||
<a href="#{{ $id }}">
|
{{ else -}}
|
||||||
{{- end -}}
|
{{ if not (eq (.Get "lightbox") "none") }}<a href="#{{ $id }}">{{ end }}
|
||||||
<!-- THUMBNAIL -->
|
{{- end -}}
|
||||||
<img src="{{ $thumb | relURL }}" class="snap-thumb"
|
<!-- THUMBNAIL -->
|
||||||
{{- with .Get "alt" }} alt="{{ . }}"{{ end -}}
|
<img src="{{ $thumb | relURL }}" class="snap-thumb"
|
||||||
{{- with .Get "title" }} title="{{ . }}"{{ end -}}
|
{{- with .Get "alt" }} alt="{{ . }}"{{ end -}}
|
||||||
{{- with .Get "height" }} height="{{ . }}"{{ end -}}
|
{{- with .Get "title" }} title="{{ . }}"{{ end -}}
|
||||||
{{- with .Get "width" }} width="{{ . }}"{{ end -}}
|
{{- with .Get "height" }} height="{{ . }}"{{ end -}}
|
||||||
/>
|
{{- with .Get "width" }} width="{{ . }}"{{ end -}}
|
||||||
{{- if or (.Get "caption") (.Get "attr")}}
|
/>
|
||||||
<figcaption>
|
{{- if or (.Get "caption") (.Get "attr")}}
|
||||||
{{- .Get "caption" | markdownify -}}
|
<figcaption>
|
||||||
{{- with .Get "attr" }} {{ . | markdownify}}{{ end -}}
|
{{- .Get "caption" | markdownify -}}
|
||||||
</figcaption>
|
{{- with .Get "attr" }} {{ . | markdownify}}{{ end -}}
|
||||||
{{- end }}
|
</figcaption>
|
||||||
</a>
|
|
||||||
<!-- FULL IMAGE; HIDDEN -->
|
|
||||||
<div class="snap-lightbox" id="{{ $id }}">
|
|
||||||
<a href="#_" class="snap-lightbox-close"></a>
|
|
||||||
<div class="snap-lightbox-inner">
|
|
||||||
<img src="{{ .Get "src" }}" {{ with .Get "alt" }}alt="{{ . }}"{{ end }} />
|
|
||||||
<p>
|
|
||||||
{{- if or (.Get "caption") (.Get "attr") -}}
|
|
||||||
{{- .Get "caption" | markdownify -}}
|
|
||||||
{{- with .Get "attrlink" }} <a href="{{ . }}">{{- end -}}
|
|
||||||
{{- with .Get "attr" }} {{ . | markdownify}}{{ end -}}
|
|
||||||
{{- with .Get "attrlink" }}</a>{{- end -}}
|
|
||||||
{{- end }}
|
{{- end }}
|
||||||
</p>
|
</a>
|
||||||
</div>
|
<!-- FULL IMAGE; HIDDEN -->
|
||||||
<a href="#_" class="snap-lightbox-close-button"><i class="snap-lightbox-x"></i></a>
|
{{- if not (eq (.Get "lightbox") "none") -}}
|
||||||
{{- if .Parent -}}
|
<div class="snap-lightbox" id="{{ $id }}">
|
||||||
{{- if not (eq $figid 1) -}}
|
<a href="#_" class="snap-lightbox-close"></a>
|
||||||
<a href="#{{ $previd }}" class="snap-lightbox-prev"><i class="snap-lightbox-arrow"></i></a>
|
<div class="snap-lightbox-inner">
|
||||||
{{- else -}}
|
<img src="{{ .Get "src" }}" {{ with .Get "alt" }}alt="{{ . }}"{{ end }} />
|
||||||
<span class="snap-lightbox-prev"><i class="snap-lightbox-arrow"></i></span>
|
<p>
|
||||||
{{- end -}}
|
{{- if or (.Get "caption") (.Get "attr") -}}
|
||||||
<!-- TODO: Somehow try to identify whether this is the last element in the gallery -->
|
{{- .Get "caption" | markdownify -}}
|
||||||
<a href="#{{ $nextid }}" class="snap-lightbox-next"><i class="snap-lightbox-arrow"></i></a>
|
{{- with .Get "attrlink" }} <a href="{{ . }}">{{- end -}}
|
||||||
{{- 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 }}
|
||||||
|
</div>
|
||||||
|
{{- end -}}
|
||||||
</div>
|
</div>
|
||||||
</figure>
|
</figure>
|
||||||
|
|||||||
@@ -7,10 +7,15 @@
|
|||||||
|
|
||||||
figure {
|
figure {
|
||||||
max-width: 90%;
|
max-width: 90%;
|
||||||
margin: 30px auto 40px;
|
margin: 10px auto;
|
||||||
display: block;
|
display: block;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* make box with box-shadow only as large as image */
|
||||||
|
.snap-wrapper {
|
||||||
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19);
|
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19);
|
||||||
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
figure a:hover {
|
figure a:hover {
|
||||||
@@ -22,12 +27,16 @@ figure img {
|
|||||||
max-height: 100%;
|
max-height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
figure.small img {
|
figure.sm {
|
||||||
max-height: 150px;
|
max-width: 30%;
|
||||||
}
|
}
|
||||||
|
|
||||||
figure.medium img {
|
figure.md {
|
||||||
max-height: 225px;
|
max-width: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
figure.lg {
|
||||||
|
max-width: 70%;
|
||||||
}
|
}
|
||||||
|
|
||||||
figure.pull-right {
|
figure.pull-right {
|
||||||
@@ -51,6 +60,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;
|
||||||
@@ -59,6 +73,11 @@ figure figcaption {
|
|||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* avoid sick effects of inline-block on gallery elements */
|
||||||
|
.snap-gallery .snap-wrapper {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
.snap-gallery figure {
|
.snap-gallery figure {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 30%;
|
width: 30%;
|
||||||
|
|||||||
Reference in New Issue
Block a user