style(sliders): update carousel item indexing for accessibility

Improves aria-labels for carousel items by using loop iteration instead of index.
This commit is contained in:
Jérémy Munsch 2026-06-26 16:30:58 +02:00
parent 8ab2702129
commit e2ae396154
No known key found for this signature in database
GPG key ID: 2AAECDA6B7330F91
2 changed files with 10 additions and 10 deletions

View file

@ -5,9 +5,9 @@
aria-roledescription="carousel" aria-label="{{ __('Offers Slider') }}">
<div class="carousel-inner p-2">
@foreach ($starProductList as $index => $productWithPricing)
@foreach ($starProductList as $productWithPricing)
<div class="carousel-item @if ($loop->first) active @endif" role="group" aria-roledescription="slide"
aria-label="{{ $index + 1 }} {{ __('of') }} {{ count($starProductList) }}">
aria-label="{{ $loop->iteration }} {{ __('of') }} {{ count($starProductList) }}">
<div class="h-100 p-2">
<div class="card h-100 w-100 rounded-4 position-relative d-flex flex-column justify-content-between border-0 shadow-sm">
@ -116,10 +116,10 @@
@if (count($starProductList) > 1)
<div class="carousel-indicators d-lg-none bottom-n15px" role="group" aria-label="{{ __('Choose slide') }}">
@foreach ($starProductList as $index => $product)
@foreach ($starProductList as $product)
<button class="@if ($loop->first) active @endif" data-bs-target="#products-carousel"
data-bs-slide-to="{{ $index }}" type="button" aria-current="@if ($loop->first) true @endif"
aria-label="Slide {{ $index + 1 }}"></button>
data-bs-slide-to="{{ $loop->index }}" type="button" aria-current="@if ($loop->first) true @endif"
aria-label="Slide {{ $loop->iteration }}"></button>
@endforeach
</div>
@endif

View file

@ -2,10 +2,10 @@
aria-roledescription="carousel" aria-label="{{ __('Main Slider') }}">
<div class="carousel-indicators" role="group" aria-label="{{ __('Choose slide') }}">
@foreach ($slides as $index => $slide)
<button class="btn btn-sm btn-outline-dark @if ($loop->first) active @endif" data-bs-target="#hero-carousel"
data-bs-slide-to="{{ $index }}" type="button" aria-current="@if ($loop->first) true @endif"
aria-label="{{ __('Slide :number', ['number' => $index + 1]) }}">
@foreach ($slides as $slide)
<button class="@if ($loop->first) active @endif" data-bs-target="#hero-carousel"
data-bs-slide-to="{{ $loop->index }}" type="button" aria-current="@if ($loop->first) true @endif"
aria-label="{{ __('Slide :number', ['number' => $loop->iteration]) }}">
</button>
@endforeach
</div>
@ -13,7 +13,7 @@
<div class="carousel-inner h-100">
@foreach ($slides as $slide)
<div class="carousel-item h-100 @if ($loop->first) active @endif" role="group" aria-roledescription="slide"
aria-label="{{ $index + 1 }} {{ __('of') }} {{ count($slides) }}">
aria-label="{{ $loop->iteration }} {{ __('of') }} {{ count($slides) }}">
<a class="d-flex justify-content-center align-items-center text-decoration-none px-md-5 h-100 w-100 overflow-hidden px-3"
href="{{ $slide->link }}">