Feat: Live search accessibility, no-results message and View all styling

This commit is contained in:
elvira committed 2026-10-23 20:59:23 +03:00
1 parent d1d27a9ebd
commit 9217960de0
4 files changed
+118 -33

No files matched your search

@@ -7,7 +7,7 @@
--}}
@if ($products->isEmpty())
<p class="text-neutral-500">{{ __('storefront.shop.no_products') }}</p>
<p class="text-neutral-500">{{ __('storefront.search.no_results', ['query' => $query]) }}</p>
@else
<div class="flex items-center justify-between gap-6 flex-wrap mb-7">
<x-shop.result-count :paginator="$products" />
+54 -28
View File
@@ -4,41 +4,67 @@
Up to six products (thumbnail, name with the matched words underlined,
price), then a link to the full results page. Empty below 3 characters.
ARIA: the overlay's input is a combobox controlling the listbox below. The
options stay out of the tab order (focus remains in the input); the
`nav-search` controller moves aria-selected / aria-activedescendant with
the arrow keys. The hidden summary is copied into the overlay's persistent
role="status" region, since a live region swapped in with the frame isn't
reliably announced.
Vars: $query (string), $products (Collection of ProductCard arrays),
$total (int), $searched (bool)
--}}
<turbo-frame id="search-suggestions">
@if ($searched)
<div class="max-h-[calc(100dvh-var(--search-overlay-h))] overflow-y-auto bg-white border-b border-black">
@forelse ($products as $product)
<a
href="{{ $product['href'] }}"
data-turbo-frame="_top"
class="flex items-center gap-5 border-b border-neutral-300 px-10 py-4 transition-colors hover:bg-neutral-100 focus-visible:bg-neutral-100 focus-visible:outline-none"
>
<span class="flex aspect-[251/335] w-16 shrink-0 items-center justify-center overflow-hidden border border-black bg-white">
@if ($product['image'])
<img src="{{ $product['image'] }}" alt="" loading="lazy" class="block h-auto w-full">
@endif
</span>
<span class="min-w-0 flex-1">{{ \App\Support\SearchHighlight::name((string) $product['name'], $query) }}</span>
@if ($product['price'] !== null)
<span class="shrink-0"><x-ui.price :amount="$product['price']" /></span>
@endif
</a>
@empty
<p class="px-10 py-6 text-neutral-500">{{ __('storefront.shop.no_products') }}</p>
@endforelse
<p hidden data-nav-search-target="summary">{{ trans_choice('storefront.search.results_count', $total, ['count' => $total]) }}</p>
@if ($total > 0)
<a
href="{{ route('search', ['q' => $query]) }}"
data-turbo-frame="_top"
class="flex items-center justify-between px-10 py-5 font-medium uppercase tracking-wide transition-colors hover:bg-neutral-100 focus-visible:bg-neutral-100 focus-visible:outline-none"
<div class="max-h-[calc(100dvh-var(--search-overlay-h))] overflow-y-auto bg-white border-b border-black">
@if ($products->isNotEmpty())
<div
id="search-suggestions-list"
role="listbox"
aria-labelledby="search-overlay-label"
data-nav-search-target="listbox"
>
{{ trans_choice('storefront.search.view_all', $total, ['count' => $total]) }}
<x-ui.icon name="arrow-right" :size="20" />
</a>
@foreach ($products as $product)
<a
id="search-option-{{ $loop->index }}"
href="{{ $product['href'] }}"
role="option"
aria-selected="false"
tabindex="-1"
data-turbo-frame="_top"
data-nav-search-target="option"
class="flex items-center gap-5 border-b border-neutral-300 px-10 py-2 transition-colors hover:bg-neutral-100 aria-selected:bg-neutral-100"
>
<span class="flex aspect-[251/335] w-14 shrink-0 items-center justify-center overflow-hidden border border-black bg-white">
@if ($product['image'])
<img src="{{ $product['image'] }}" alt="" loading="lazy" class="block h-auto w-full">
@endif
</span>
<span class="min-w-0 flex-1">{{ \App\Support\SearchHighlight::name((string) $product['name'], $query) }}</span>
@if ($product['price'] !== null)
<span class="shrink-0"><x-ui.price :amount="$product['price']" /></span>
@endif
</a>
@endforeach
<a
id="search-option-all"
href="{{ route('search', ['q' => $query]) }}"
role="option"
aria-selected="false"
tabindex="-1"
data-turbo-frame="_top"
data-nav-search-target="option"
class="flex items-center gap-3 bg-black px-10 py-4 text-[19px] font-bold italic uppercase text-white transition-colors hover:bg-neutral-800 aria-selected:bg-neutral-800"
>
{{ trans_choice('storefront.search.view_all', $total, ['count' => $total]) }}
<x-ui.icon name="arrow-right" :size="20" />
</a>
</div>
@else
<p class="px-10 py-6 text-neutral-500">{{ __('storefront.search.no_results', ['query' => $query]) }}</p>
@endif
</div>
@endif