fix(carousel): with templating generation

This commit is contained in:
Matthieu Bessat 2023-06-20 23:52:45 +02:00
parent bb0d92ead7
commit d96122050d
2 changed files with 28 additions and 58 deletions

View file

@ -227,67 +227,33 @@
</div> </div>
</section> </section>
{{ $slides_count := 6 }}
<section class="carousel-container"> <section class="carousel-container">
<div class="carousel" aria-label="Gallery"> <div class="carousel" aria-label="Gallery">
<ol class="carousel__viewport"> <ol class="carousel__viewport">
<li id="carousel__slide1" {{ range $index, $s := seq (sub $slides_count 0) }}
tabindex="0" <li id="carousel__slide{{ $index }}"
class="carousel__slide"> tabindex="0"
<div class="carousel__snapper"> class="carousel__slide">
<a href="#carousel__slide4" <div class="carousel__snapper">
class="carousel__prev">Diapositive précédente</a> <a href="#carousel__slide{{ partial "fullmod" (slice (sub $index 1) $slides_count) }}"
<a href="#carousel__slide2" class="carousel__prev">Diapositive précédente</a>
class="carousel__next">Diapositive suivante</a> <a href="#carousel__slide{{ partial "fullmod" (slice (add $index 1) $slides_count) }}"
</div> class="carousel__next">Diapositive suivante</a>
</li> </div>
<li id="carousel__slide2" </li>
tabindex="0" {{ end }}
class="carousel__slide">
<div class="carousel__snapper"></div>
<a href="#carousel__slide1"
class="carousel__prev">Diapositive précédente</a>
<a href="#carousel__slide3"
class="carousel__next">Diapositive suivante</a>
</li>
<li id="carousel__slide3"
tabindex="0"
class="carousel__slide">
<div class="carousel__snapper"></div>
<a href="#carousel__slide2"
class="carousel__prev">Diapositive précédente</a>
<a href="#carousel__slide4"
class="carousel__next">Diapositive suivante</a>
</li>
<li id="carousel__slide4"
tabindex="0"
class="carousel__slide">
<div class="carousel__snapper"></div>
<a href="#carousel__slide3"
class="carousel__prev">Diapositive précédente</a>
<a href="#carousel__slide1"
class="carousel__next">Diapositive suivante</a>
</li>
</ol>
<aside class="carousel__navigation">
<ol class="carousel__navigation-list">
<li class="carousel__navigation-item enabled">
<a href="#carousel__slide1"
class="carousel__navigation-button">1ère diapositive</a>
</li>
<li class="carousel__navigation-item">
<a href="#carousel__slide2"
class="carousel__navigation-button">2ème diapositive</a>
</li>
<li class="carousel__navigation-item">
<a href="#carousel__slide3"
class="carousel__navigation-button">3ème diapositive</a>
</li>
<li class="carousel__navigation-item">
<a href="#carousel__slide4"
class="carousel__navigation-button">4ème diapositive</a>
</li>
</ol> </ol>
</aside> <aside class="carousel__navigation">
<ol class="carousel__navigation-list">
{{ range $index, $s := seq (sub $slides_count 0) }}
<li class="carousel__navigation-item {{ if eq $index 0 }}enabled{{- end -}}">
<a href="#carousel__slide{{ $index }}"
class="carousel__navigation-button">{{ $index }}ème diapositive</a>
</li>
{{ end }}
</ol>
</aside>
</div> </div>
</section> </section>
</main> </main>

View file

@ -0,0 +1,4 @@
{{- $a := index . 0 -}}
{{- $b := index . 1 -}}
{{- $c := mod $a $b -}}
{{- if lt $c 0 -}}{{- add $c $b -}}{{- else -}}{{- $c -}}{{- end -}}