46 lines
2.4 KiB
PHP
46 lines
2.4 KiB
PHP
{{--
|
|
Live search results under the search overlay — the answer to its
|
|
<turbo-frame id="search-suggestions"> (SearchController::suggestions()).
|
|
Up to six products (thumbnail, name with the matched words underlined,
|
|
price), then a link to the full results page. Empty below 3 characters.
|
|
|
|
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
|
|
|
|
@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"
|
|
>
|
|
{{ trans_choice('storefront.search.view_all', $total, ['count' => $total]) }}
|
|
<x-ui.icon name="arrow-right" :size="20" />
|
|
</a>
|
|
@endif
|
|
</div>
|
|
@endif
|
|
</turbo-frame>
|