Files
3dealer/resources/views/components/header.blade.php
T
elviraandClaude Opus 5.5 4fc7880187 Markup: stable island targets for wishlist, account link and CSRF meta
- x-wishlist-button gets data-wishlist-product on its form root; the
  server-rendered aria-pressed stays for now.
- Both header account links (desktop and mobile menu) share
  [data-account-link].
- The CSRF meta tag gets id="csrf-token".

No visible change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 00:01:42 +02:00

211 lines
11 KiB
PHP

{{-- No bottom border on the mobile homepage, so the header runs straight into the hero. --}}
<header @class(['sticky top-0 z-50 h-20 bg-neutral-200 border-b border-black lg:h-26', 'max-lg:border-b-0' => request()->routeIs('home')])>
<div class="flex items-center gap-4 px-5 max-lg:h-full sm:px-8 lg:gap-14 lg:px-10">
{{-- Logo --}}
<a href="{{ url('/'.app()->getLocale()) }}" class="shrink-0 lg:py-4">
<img src="/images/logo.png" alt="{{ config('app.name') }}" class="h-14 w-auto lg:h-18">
</a>
{{-- Primary nav --}}
<nav class="hidden lg:flex items-center gap-6 h-full">
{{-- Products (CSS-only hover dropdown) --}}
<div class="group relative h-full flex items-center">
<a href="{{ route('products') }}" class="nav-link uppercase inline-flex items-center gap-1 relative font-display font-extrabold italic text-black no-underline py-8">
<span>{{ __('storefront.nav.products') }}</span>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="size-4 not-italic transition-transform group-hover:rotate-180">
<path fill-rule="evenodd" d="M5.22 8.22a.75.75 0 0 1 1.06 0L10 11.94l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.22 9.28a.75.75 0 0 1 0-1.06Z" clip-rule="evenodd" />
</svg>
</a>
<div class="nav-dropdown">
@foreach($categories ?? [] as $category)
<a href="{{ route('category.show', ['id' => $category['id']]) }}">
{{ $category['name'] }}
</a>
@endforeach
</div>
</div>
{{-- FAQ --}}
<a href="{{ route('faq') }}" class="nav-link uppercase inline-flex items-center gap-1 relative font-display font-extrabold italic text-black no-underline"><span>{{ __('storefront.nav.faq') }}</span></a>
{{-- Contact --}}
<a href="{{ route('contact') }}" class="nav-link uppercase inline-flex items-center gap-1 relative font-display font-extrabold italic text-black no-underline"><span>{{ __('storefront.nav.contact') }}</span></a>
</nav>
{{-- Right side actions — language, wishlist and account move into the mobile menu below `lg` --}}
<div class="ml-auto flex items-center gap-3 lg:gap-8">
{{-- Language switcher --}}
@foreach ($altLocales ?? [] as $altLocale)
<a href="{{ $altLocale['url'] }}" class="hidden lg:block uppercase font-display font-extrabold text-sm hover:opacity-70 transition-opacity" hreflang="{{ $altLocale['code'] }}" aria-label="{{ $altLocale['name'] }}">
{{ $altLocale['code'] }}
</a>
@endforeach
{{-- Wishlist — the account page, or the cookie-based guest page --}}
<a
href="{{ auth()->check() ? route('account.wishlist') : route('wishlist') }}"
class="hidden lg:flex items-center justify-center w-10 h-10 hover:opacity-70 transition-opacity"
aria-label="{{ __('storefront.account.nav_wishlist') }}"
@if (request()->routeIs('account.wishlist', 'wishlist')) aria-current="page" @endif
>
<x-ui.icon name="heart" :size="40" />
</a>
{{-- Account — the account page, or login for guests. [data-account-link]
is the island target shared with the mobile menu's link. --}}
<a
data-account-link
href="{{ auth()->check() ? route('account') : route('login') }}"
class="hidden lg:flex items-center justify-center w-10 h-10 hover:opacity-70 transition-opacity"
aria-label="{{ auth()->check() ? __('storefront.nav.account') : __('storefront.auth.login') }}"
>
<x-ui.icon name="user" :size="40" />
</a>
{{-- Cart — opens the checkout module's drawer, no separate cart page --}}
<button
type="button"
class="relative flex items-center justify-center w-10 h-10 hover:opacity-70 transition-opacity"
aria-label="{{ __('storefront.nav.cart') }}"
aria-haspopup="dialog"
data-controller="cart-count"
data-action="cart-count#open"
>
<x-ui.icon name="bag" :size="40" />
{{-- Island target: the count will come from the islands request
(Turbo Stream on #cart-badge). It's absolute inside the
fixed-size button, so showing it or going from 1 to 2 digits
never moves the header. Rule for every island: it may never
change the size of its container. --}}
<span
id="cart-badge"
data-cart-count-target="badge"
class="absolute -top-1 -right-2 text-sm font-bold leading-none"
hidden
>0</span>
</button>
{{-- Search --}}
<button
type="button"
popovertarget="search-overlay"
popovertargetaction="toggle"
class="flex items-center justify-center w-10 h-10 hover:opacity-70 transition-opacity"
aria-label="{{ __('storefront.shop.search_label') }}"
>
<x-ui.icon name="search" :size="40" />
</button>
</div>
{{-- Burger — toggles the #mobile-nav menu below `lg`; its three lines
morph into an X while the menu is open (.burger in app.css). --}}
<button
type="button"
popovertarget="mobile-nav"
class="burger flex h-10 w-10.5 shrink-0 flex-col items-center justify-center gap-1.75 lg:hidden"
aria-label="{{ __('storefront.nav.menu') }}"
aria-controls="mobile-nav"
>
<span class="block h-1 w-10.5 bg-black" aria-hidden="true"></span>
<span class="block h-1 w-10.5 bg-black" aria-hidden="true"></span>
<span class="block h-1 w-10.5 bg-black" aria-hidden="true"></span>
</button>
</div>
<x-search-overlay />
{{--
Mobile menu — a [popover] (top layer, Escape and click-away close for
free) that drops down from under the header, opened and closed by the
burger above. The header is a fixed h-20 below `lg` so the menu can sit
at top-20. The top-to-bottom wipe and the burger → X morph live in
app.css (.mobile-menu, .burger). Display stays on the inner wrapper,
never on the popover itself, so the UA's closed-state display:none holds.
--}}
<nav
id="mobile-nav"
popover
aria-label="{{ __('storefront.nav.menu') }}"
class="mobile-menu fixed inset-x-0 top-20 bottom-auto m-0 max-h-[calc(100dvh-5rem)] w-full max-w-none overflow-y-auto border-0 bg-neutral-200 p-0 text-black"
>
<div class="flex flex-col gap-8 px-5 py-6 sm:px-8">
<ul class="flex flex-col gap-5 font-display font-extrabold italic">
<li class="flex flex-col gap-4">
<a
href="{{ route('products') }}"
@class(['nav-link uppercase flex items-center justify-between gap-4', 'is-active' => request()->routeIs('products')])
@if (request()->routeIs('products')) aria-current="page" @endif
>
<span>{{ __('storefront.nav.products') }}</span>
<x-ui.icon name="arrow-right" :size="22" />
</a>
@if (count($categories ?? []))
<ul class="flex flex-col gap-3 border-l border-black pl-4 font-sans font-normal not-italic">
@foreach ($categories as $category)
<li>
<a href="{{ route('category.show', ['id' => $category['id']]) }}" class="underline-slide">{{ $category['name'] }}</a>
</li>
@endforeach
</ul>
@endif
</li>
<li>
<a
href="{{ route('faq') }}"
@class(['nav-link uppercase flex items-center justify-between gap-4', 'is-active' => request()->routeIs('faq')])
@if (request()->routeIs('faq')) aria-current="page" @endif
>
<span>{{ __('storefront.nav.faq') }}</span>
<x-ui.icon name="arrow-right" :size="22" />
</a>
</li>
<li>
<a
href="{{ route('contact') }}"
@class(['nav-link uppercase flex items-center justify-between gap-4', 'is-active' => request()->routeIs('contact')])
@if (request()->routeIs('contact')) aria-current="page" @endif
>
<span>{{ __('storefront.nav.contact') }}</span>
<x-ui.icon name="arrow-right" :size="22" />
</a>
</li>
</ul>
<ul class="flex flex-col gap-4 border-t border-black pt-6">
<li>
<a
href="{{ auth()->check() ? route('account.wishlist') : route('wishlist') }}"
class="inline-flex items-center gap-3 hover:opacity-70 transition-opacity"
@if (request()->routeIs('account.wishlist', 'wishlist')) aria-current="page" @endif
>
<x-ui.icon name="heart" :size="28" />
<span>{{ __('storefront.account.nav_wishlist') }}</span>
</a>
</li>
<li>
<a
data-account-link
href="{{ auth()->check() ? route('account') : route('login') }}"
class="inline-flex items-center gap-3 hover:opacity-70 transition-opacity"
>
<x-ui.icon name="user" :size="28" />
<span>{{ auth()->check() ? __('storefront.nav.account') : __('storefront.auth.login') }}</span>
</a>
</li>
@foreach ($altLocales ?? [] as $altLocale)
<li>
<a href="{{ $altLocale['url'] }}" hreflang="{{ $altLocale['code'] }}" lang="{{ $altLocale['code'] }}" class="underline-slide">{{ $altLocale['name'] }}</a>
</li>
@endforeach
</ul>
</div>
</nav>
</header>