[new shortcode] swiper

#232
This commit is contained in:
zzossig 2020-03-17 14:11:46 +09:00
parent 6c565cefa9
commit 4651968bfe
7 changed files with 94 additions and 2 deletions

13
assets/lib/swiper/swiper.min.css vendored Normal file

File diff suppressed because one or more lines are too long

14
assets/lib/swiper/swiper.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -30,3 +30,20 @@
@include justify-content(center); @include justify-content(center);
@include flex-direction(column); @include flex-direction(column);
} }
.swiper-slide {
@include flexbox();
@include flex-direction(column);
&[data-align='center'] {
@include align-items(center);
}
&[data-align='left'] {
@include align-items(flex-start);
}
&[data-align='right'] {
@include align-items(flex-end);
}
}

View File

@ -0,0 +1,47 @@
{{ $swiper_style := resources.Get "lib/swiper/swiper.min.css" | resources.Fingerprint }}
<link rel="stylesheet" href="{{ $swiper_style.RelPermalink }}">
{{ $swiper_script := resources.Get "lib/swiper/swiper.min.js" | resources.Fingerprint }}
<script defer src="{{ $swiper_script.RelPermalink }}"></script>
{{ $id := substr (md5 .Inner) 0 16 }}
{{ $enableNavigation := .Get "enableNavigation" }}
{{ $enablePagination := .Get "enablePagination" }}
<div id="{{ $id }}" class="swiper-container">
<div class="swiper-wrapper">
<!-- Slides -->
{{ .Inner }}
</div>
{{ if $enablePagination }}
<div class="swiper-pagination"></div>
{{ end }}
{{ if $enableNavigation }}
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
{{ end }}
</div>
<script>
'use strict';
document.addEventListener('DOMContentLoaded', function () {
{{ $options := .Params }}
var options = JSON.parse({{ $options | jsonify }});
var id = JSON.parse({{ $id | jsonify }});
var enableNavigation = JSON.parse({{ $enableNavigation | jsonify }});
var enablePagination = JSON.parse({{ $enablePagination | jsonify }});
var mySwiper = new Swiper('#' + id, {
...options,
pagination: {
el: enablePagination ? '.swiper-pagination' : null,
},
navigation: {
nextEl: enableNavigation ? '.swiper-button-next' : null,
prevEl: enableNavigation ? '.swiper-button-prev' : null,
},
});
});
</script>

View File

@ -0,0 +1 @@
<div class="swiper-slide" data-align="{{ .Get "align" | default "center" }}">{{ .Inner | markdownify }}</div>