Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Slider block: only show controls/indicators if >1 slides are defined. #2949

Merged
merged 1 commit into from
Jun 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions modules/wowchemy/layouts/partials/blocks/slider.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
{{ $page := .wcPage }}
{{ $block := .wcBlock }}
{{ $hash_id := .wcIdentifier }}
{{ $slide_count := len $block.content.slides }}

<!-- Indicators -->
{{ if gt $slide_count 1 }}
<ol class="carousel-indicators">
{{ range $index, $item := $block.content.slides }}
<li data-target="#{{$hash_id}}" data-slide-to="{{$index}}" {{if eq $index 0}}class="active"{{end}}></li>
{{ end }}
</ol>
{{ end }}

<!-- Carousel slides wrapper -->
<div class="carousel-inner">
Expand Down Expand Up @@ -81,6 +84,7 @@ <h1 class="hero-title ">
</div>

<!-- Left and right controls -->
{{ if gt $slide_count 1 }}
<a class="carousel-control-prev" href="#{{$hash_id}}" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
<span class="sr-only">Previous</span>
Expand All @@ -89,3 +93,4 @@ <h1 class="hero-title ">
<span class="carousel-control-next-icon"></span>
<span class="sr-only">Next</span>
</a>
{{ end }}
5 changes: 5 additions & 0 deletions modules/wowchemy/layouts/partials/blocks/v1/slider.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
{{ $page := .wcPage }}
{{ $block := .wcBlock }}
{{ $hash_id := .wcIdentifier }}
{{ $slide_count := len $block.Params.content.slides }}

<!-- Indicators -->
{{ if gt $slide_count 1 }}
<ol class="carousel-indicators">
{{ range $index, $item := $block.Params.content.slides }}
<li data-target="#{{$hash_id}}" data-slide-to="{{$index}}" {{if eq $index 0}}class="active"{{end}}></li>
{{ end }}
</ol>
{{ end }}

<!-- Carousel slides wrapper -->
<div class="carousel-inner">
Expand Down Expand Up @@ -75,6 +78,7 @@ <h1 class="hero-title">
</div>

<!-- Left and right controls -->
{{ if gt $slide_count 1 }}
<a class="carousel-control-prev" href="#{{$hash_id}}" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
<span class="sr-only">Previous</span>
Expand All @@ -83,3 +87,4 @@ <h1 class="hero-title">
<span class="carousel-control-next-icon"></span>
<span class="sr-only">Next</span>
</a>
{{ end }}